diff --git a/Buffs/Alcohol/BloodyMaryBuff.png b/Buffs/Alcohol/BloodyMaryBuff.png index 9f9d34bf27..46cf3a0b57 100644 Binary files a/Buffs/Alcohol/BloodyMaryBuff.png and b/Buffs/Alcohol/BloodyMaryBuff.png differ diff --git a/Buffs/Alcohol/CinnamonRollBuff.png b/Buffs/Alcohol/CinnamonRollBuff.png index dd3033fccc..8d9ff66e26 100644 Binary files a/Buffs/Alcohol/CinnamonRollBuff.png and b/Buffs/Alcohol/CinnamonRollBuff.png differ diff --git a/Buffs/Alcohol/FireballBuff.png b/Buffs/Alcohol/FireballBuff.png index f59f9e066e..8887354d3f 100644 Binary files a/Buffs/Alcohol/FireballBuff.png and b/Buffs/Alcohol/FireballBuff.png differ diff --git a/Buffs/Alcohol/MoscowMuleBuff.png b/Buffs/Alcohol/MoscowMuleBuff.png index 969367e33f..4ba5245776 100644 Binary files a/Buffs/Alcohol/MoscowMuleBuff.png and b/Buffs/Alcohol/MoscowMuleBuff.png differ diff --git a/Buffs/Alcohol/TequilaBuff.png b/Buffs/Alcohol/TequilaBuff.png index c005b88c92..a6c233e3d1 100644 Binary files a/Buffs/Alcohol/TequilaBuff.png and b/Buffs/Alcohol/TequilaBuff.png differ diff --git a/Buffs/Alcohol/TequilaSunriseBuff.png b/Buffs/Alcohol/TequilaSunriseBuff.png index 5f5a7a48ed..ef5bee8678 100644 Binary files a/Buffs/Alcohol/TequilaSunriseBuff.png and b/Buffs/Alcohol/TequilaSunriseBuff.png differ diff --git a/Buffs/Alcohol/Trippy.png b/Buffs/Alcohol/Trippy.png index 641781ec77..7efc1b9c5d 100644 Binary files a/Buffs/Alcohol/Trippy.png and b/Buffs/Alcohol/Trippy.png differ diff --git a/Buffs/Alcohol/VodkaBuff.png b/Buffs/Alcohol/VodkaBuff.png index 7a9e6b7150..485745f805 100644 Binary files a/Buffs/Alcohol/VodkaBuff.png and b/Buffs/Alcohol/VodkaBuff.png differ diff --git a/Buffs/DamageOverTime/ElementalMix.cs b/Buffs/DamageOverTime/ElementalMix.cs index 1113e7b68f..d206bffc57 100644 --- a/Buffs/DamageOverTime/ElementalMix.cs +++ b/Buffs/DamageOverTime/ElementalMix.cs @@ -46,11 +46,11 @@ namespace CalamityMod.Buffs.DamageOverTime GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(player.Calamity().RandomDebuffVisualSpot, speed, Main.rand.NextFloat(1.2f, 1.8f), effectcolor, Main.rand.Next(8, 14))); - int dustType = Main.rand.NextBool() ? 91 : 247; + int dustType = Main.rand.NextBool() ? 66 : 247; Dust dust = Dust.NewDustPerfect(player.Calamity().RandomDebuffVisualSpot, dustType); - dust.scale = (dustType == 91 ? 1.4f : 1.2f); - dust.velocity = (dustType == 247 ? Vector2.Zero : new Vector2(0, Main.rand.NextFloat(-1.5f, 4f)) - player.velocity / 2); - dust.noGravity = Main.rand.NextBool(4) && dustType == 91 ? false : true; + dust.scale = (dustType == 66 ? 1.4f : 1.2f); + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(4f, 8f)) - player.velocity / 2; + dust.noGravity = true; dust.alpha = Main.rand.Next(90, 150); dust.color = effectcolor; } @@ -71,12 +71,11 @@ namespace CalamityMod.Buffs.DamageOverTime GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(npcSize, speed, Main.rand.NextFloat(1.2f, 3.1f), effectcolor, Main.rand.Next(8, 14))); - int dustType = Main.rand.NextBool() ? 91 : 247; + int dustType = Main.rand.NextBool() ? 66 : 247; Dust dust = Dust.NewDustPerfect(npcSize, dustType); - dust.scale = (dustType == 91 ? 1.4f : 1.2f); - dust.velocity = (dustType == 247 ? Vector2.Zero : new Vector2(0, Main.rand.NextFloat(-1.5f, 4f)) - npc.velocity / 2); - dust.noGravity = Main.rand.NextBool(4) && dustType == 91 ? false : true; - dust.velocity = Vector2.Zero; + dust.scale = (dustType == 66 ? 1.4f : 1.2f); + dust.noGravity = true; + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(2f, 4f)) - npc.velocity / 2; dust.alpha = Main.rand.Next(90, 150); dust.color = effectcolor; } @@ -90,11 +89,11 @@ namespace CalamityMod.Buffs.DamageOverTime _ => Color.Violet, }; Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); - int dustType = Main.rand.NextBool() ? 91 : 247; + int dustType = Main.rand.NextBool() ? 66 : 247; Dust dust = Dust.NewDustPerfect(npcSize, dustType); - dust.scale = (dustType == 91 ? 0.9f : 1.4f); + dust.scale = (dustType == 66 ? 0.9f : 1.4f); dust.noGravity = true; - dust.velocity = Vector2.Zero; + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(2f, 4f)); dust.alpha = Main.rand.Next(35, 90); dust.color = effectcolor; } diff --git a/Buffs/DamageOverTime/MiracleBlight.cs b/Buffs/DamageOverTime/MiracleBlight.cs index f295731167..1fee9f02c9 100644 --- a/Buffs/DamageOverTime/MiracleBlight.cs +++ b/Buffs/DamageOverTime/MiracleBlight.cs @@ -36,37 +36,29 @@ namespace CalamityMod.Buffs.DamageOverTime var sparkColor = Main.rand.Next(4) switch { - 0 => Color.DarkRed, + 0 => Color.Red, 1 => Color.MediumTurquoise, 2 => Color.Orange, _ => Color.LawnGreen, }; - DirectionalPulseRing pulse = new DirectionalPulseRing(Player.Calamity().RandomDebuffVisualSpot, Vector2.Zero, sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.09f, 0.17f), 0f, 25); - GeneralParticleHandler.SpawnParticle(pulse); - float numberOfDusts = 3f; - float rotFactor = 360f / numberOfDusts; - if (Player.miscCounter % 4 == 0) + if (Main.rand.NextBool(2)) { - for (int i = 0; i < numberOfDusts; i++) - { - var DustType = Main.rand.Next(4) switch - { - 0 => 219, - 1 => 220, - 2 => 226, - _ => 222, - }; - float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(0.3f, 0).RotatedBy(rot * Main.rand.NextFloat(0.2f, 0.3f)); - Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f); - Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot + offset, DustType, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - velOffset *= 10; - dust.position = Player.Center - velOffset; - dust.scale = Main.rand.NextFloat(0.7f, 0.8f); - } + Dust dust = Dust.NewDustPerfect(Player.Calamity().RandomDebuffVisualSpot, 278, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.7f, 0.85f); + dust.color = sparkColor * 0.45f; + } + + float numberOfDusts = 1f; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f); + velOffset *= Main.rand.NextFloat(2, 13); + SquishyLightParticle exoEnergy = new(Player.Center + Player.velocity * 3 + velOffset * 1.5f, -velOffset * 0.25f, 0.3f, sparkColor, 8); + GeneralParticleHandler.SpawnParticle(exoEnergy); } } @@ -75,36 +67,31 @@ namespace CalamityMod.Buffs.DamageOverTime Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); var sparkColor = Main.rand.Next(4) switch { - 0 => Color.DarkRed, + 0 => Color.Red, 1 => Color.MediumTurquoise, 2 => Color.Orange, _ => Color.LawnGreen, }; - DirectionalPulseRing pulse = new DirectionalPulseRing(npcSize, Vector2.Zero, sparkColor, new Vector2(1, 1), 0, 0.18f + (0.0000007f * npc.width * npc.height), 0f, 25); - GeneralParticleHandler.SpawnParticle(pulse); - float numberOfDusts = 2f; - float rotFactor = 360f / numberOfDusts; if (Main.rand.NextBool(3)) + { + Dust dust = Dust.NewDustPerfect(npcSize, 278, CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.7f, 0.85f) + (0.0000007f * npc.width * npc.height); + dust.color = sparkColor * 0.45f; + } + + float numberOfDusts = 1f; + float rotFactor = 360f / numberOfDusts; + if (Main.rand.NextBool()) { for (int i = 0; i < numberOfDusts; i++) { - var DustType = Main.rand.Next(4) switch - { - 0 => 219, - 1 => 220, - 2 => 226, - _ => 222, - }; float rot = MathHelper.ToRadians(i * rotFactor); - Vector2 offset = new Vector2(0.3f, 0).RotatedBy(rot * Main.rand.NextFloat(0.2f, 0.3f)); Vector2 velOffset = CalamityUtils.RandomVelocity(100f, 70f, 150f, 0.04f); - Dust dust = Dust.NewDustPerfect(npc.Center + offset, DustType, new Vector2(velOffset.X, velOffset.Y)); - dust.noGravity = true; - dust.velocity = velOffset; - velOffset *= 10 + (0.0003f * npc.width * npc.height); - dust.position = npc.Center - velOffset; - dust.scale = Main.rand.NextFloat(0.7f, 0.8f); + velOffset *= Main.rand.NextFloat(1, 9) + (0.0002f * npc.width * npc.height); + SquishyLightParticle exoEnergy = new(npc.Center + npc.velocity * 3 + velOffset * 1.5f, -velOffset * 0.25f, 0.3f, sparkColor, 8); + GeneralParticleHandler.SpawnParticle(exoEnergy); } } } diff --git a/Buffs/Placeables/CirrusBlueCandleBuff.png b/Buffs/Placeables/CirrusBlueCandleBuff.png index 49bd55dfe6..a73721ff8f 100644 Binary files a/Buffs/Placeables/CirrusBlueCandleBuff.png and b/Buffs/Placeables/CirrusBlueCandleBuff.png differ diff --git a/Buffs/Placeables/CirrusPinkCandleBuff.png b/Buffs/Placeables/CirrusPinkCandleBuff.png index 93720eb840..c299a08857 100644 Binary files a/Buffs/Placeables/CirrusPinkCandleBuff.png and b/Buffs/Placeables/CirrusPinkCandleBuff.png differ diff --git a/Buffs/Placeables/CirrusPurpleCandleBuff.png b/Buffs/Placeables/CirrusPurpleCandleBuff.png index b0eccec1a3..3ff18f000a 100644 Binary files a/Buffs/Placeables/CirrusPurpleCandleBuff.png and b/Buffs/Placeables/CirrusPurpleCandleBuff.png differ diff --git a/Buffs/Placeables/CirrusYellowCandleBuff.png b/Buffs/Placeables/CirrusYellowCandleBuff.png index 691d19958d..2ac39e16dd 100644 Binary files a/Buffs/Placeables/CirrusYellowCandleBuff.png and b/Buffs/Placeables/CirrusYellowCandleBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a74d07a39a..9bc6e60bef 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -178,6 +178,12 @@ namespace CalamityMod.CalPlayer #region Timer and Counter public int gaelSwipes = 0; + public int dragoonDrizzlefishGelBoost = 1; + public int deadSunCounter = 6; + public int DragonsBreathAudioCooldown = 0; + public int DragonsBreathAudioCooldown2 = 0; + public int PhotoAudioCooldown = 0; + public int PhotoTimer = 90; public bool brittleStarBuffMode = false; public bool sBlasterDashActivated = false; public int saharaSlicersBolts = 0; @@ -2779,22 +2785,22 @@ namespace CalamityMod.CalPlayer brimflameFrenzy = true; Player.AddBuff(ModContent.BuffType(), 10 * 60, true); SoundEngine.PlaySound(BrimflameScowl.ActivationSound, Player.Center); - for (int num502 = 0; num502 < 36; num502++) + for (int i = 0; i < 36; i++) { - int dust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); - Main.dust[dust].velocity *= 3f; - Main.dust[dust].scale *= 1.15f; + int brimDust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); + Main.dust[brimDust].velocity *= 3f; + Main.dust[brimDust].scale *= 1.15f; } - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / (float)num226), default) + Player.Center; - Vector2 vector7 = vector6 - Player.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, (int)CalamityDusts.Brimstone, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotation = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Player.Center; + Vector2 dustVelocity = dustRotation - Player.Center; + int brimDust2 = Dust.NewDust(dustRotation + dustVelocity, 0, 0, (int)CalamityDusts.Brimstone, dustVelocity.X * 1.5f, dustVelocity.Y * 1.5f, 100, default, 1.4f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].noLight = true; + Main.dust[brimDust2].velocity = dustVelocity; } } } @@ -2873,22 +2879,22 @@ namespace CalamityMod.CalPlayer if (dsSetBonus) { SoundEngine.PlaySound(DemonshadeHelm.ActivationSound, Player.Center); - for (int num502 = 0; num502 < 36; num502++) + for (int i = 0; i < 36; i++) { - int dust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); - Main.dust[dust].velocity *= 3f; - Main.dust[dust].scale *= 1.15f; + int brimDust = Dust.NewDust(new Vector2(Player.position.X, Player.position.Y + 16f), Player.width, Player.height - 16, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1f); + Main.dust[brimDust].velocity *= 3f; + Main.dust[brimDust].scale *= 1.15f; } - int num226 = 36; - for (int num227 = 0; num227 < num226; num227++) + int dustAmt = 36; + for (int j = 0; j < dustAmt; j++) { - Vector2 vector6 = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; - vector6 = vector6.RotatedBy((double)((float)(num227 - (num226 / 2 - 1)) * MathHelper.TwoPi / (float)num226), default) + Player.Center; - Vector2 vector7 = vector6 - Player.Center; - int num228 = Dust.NewDust(vector6 + vector7, 0, 0, (int)CalamityDusts.Brimstone, vector7.X * 1.5f, vector7.Y * 1.5f, 100, default, 1.4f); - Main.dust[num228].noGravity = true; - Main.dust[num228].noLight = true; - Main.dust[num228].velocity = vector7; + Vector2 dustRotation = Vector2.Normalize(Player.velocity) * new Vector2((float)Player.width / 2f, (float)Player.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((double)((float)(j - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + Player.Center; + Vector2 dustVelocity = dustRotation - Player.Center; + int brimDust2 = Dust.NewDust(dustRotation + dustVelocity, 0, 0, (int)CalamityDusts.Brimstone, dustVelocity.X * 1.5f, dustVelocity.Y * 1.5f, 100, default, 1.4f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].noLight = true; + Main.dust[brimDust2].velocity = dustVelocity; } if (Player.whoAmI == Main.myPlayer) { @@ -3142,9 +3148,9 @@ namespace CalamityMod.CalPlayer public static Vector2? GetUnderworldPosition(Player player) { bool canSpawn = false; - int num = Main.maxTilesX / 2; - int num2 = 100; - int num3 = num2 / 2; + int halfWorldXTiles = Main.maxTilesX / 2; + int largerCheckRadius = 100; + int smallerCheckRadius = 50; int teleportStartY = Main.UnderworldLayer + 20; int teleportRangeY = 80; Player.RandomTeleportationAttemptSettings settings = new Player.RandomTeleportationAttemptSettings @@ -3158,12 +3164,12 @@ namespace CalamityMod.CalPlayer maximumFallDistanceFromOrignalPoint = 30 }; - Vector2 vector = player.CheckForGoodTeleportationSpot(ref canSpawn, num - num3, num2, teleportStartY, teleportRangeY, settings); + Vector2 vector = player.CheckForGoodTeleportationSpot(ref canSpawn, halfWorldXTiles - smallerCheckRadius, largerCheckRadius, teleportStartY, teleportRangeY, settings); if (!canSpawn) - vector = player.CheckForGoodTeleportationSpot(ref canSpawn, num - num2, num3, teleportStartY, teleportRangeY, settings); + vector = player.CheckForGoodTeleportationSpot(ref canSpawn, halfWorldXTiles - largerCheckRadius, smallerCheckRadius, teleportStartY, teleportRangeY, settings); if (!canSpawn) - vector = player.CheckForGoodTeleportationSpot(ref canSpawn, num + num3, num3, teleportStartY, teleportRangeY, settings); + vector = player.CheckForGoodTeleportationSpot(ref canSpawn, halfWorldXTiles + smallerCheckRadius, smallerCheckRadius, teleportStartY, teleportRangeY, settings); if (canSpawn) { @@ -3901,46 +3907,46 @@ namespace CalamityMod.CalPlayer { if (!CalamityLists.VeneratedLocketBanlist.Contains(item.type)) { - float num72 = item.shootSpeed; - Vector2 vector2 = Player.RotatedRelativePoint(Player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float veneratedCloneSpeed = item.shootSpeed; + Vector2 realPlayerPos = Player.RotatedRelativePoint(Player.MountedCenter, true); + float veneratedCloneXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float veneratedCloneYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (Player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + veneratedCloneYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float veneratedCloneDistance = (float)Math.Sqrt((double)(veneratedCloneXPos * veneratedCloneXPos + veneratedCloneYPos * veneratedCloneYPos)); + if ((float.IsNaN(veneratedCloneXPos) && float.IsNaN(veneratedCloneYPos)) || (veneratedCloneXPos == 0f && veneratedCloneYPos == 0f)) { - num78 = (float)Player.direction; - num79 = 0f; - num80 = num72; + veneratedCloneXPos = (float)Player.direction; + veneratedCloneYPos = 0f; + veneratedCloneDistance = veneratedCloneSpeed; } else { - num80 = num72 / num80; + veneratedCloneDistance = veneratedCloneSpeed / veneratedCloneDistance; } - vector2 = new Vector2(Player.position.X + (float)Player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)Player.direction) + ((float)Main.mouseX + Main.screenPosition.X - Player.position.X), Player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + Player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= 100f; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(Player.position.X + (float)Player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)Player.direction) + ((float)Main.mouseX + Main.screenPosition.X - Player.position.X), Player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + Player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= 100f; + veneratedCloneXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + veneratedCloneYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (veneratedCloneYPos < 0f) { - num79 *= -1f; + veneratedCloneYPos *= -1f; } - if (num79 < 20f) + if (veneratedCloneYPos < 20f) { - num79 = 20f; + veneratedCloneYPos = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int p = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.07), knockBack * 0.5f, Player.whoAmI); + veneratedCloneDistance = (float)Math.Sqrt((double)(veneratedCloneXPos * veneratedCloneXPos + veneratedCloneYPos * veneratedCloneYPos)); + veneratedCloneDistance = veneratedCloneSpeed / veneratedCloneDistance; + veneratedCloneXPos *= veneratedCloneDistance; + veneratedCloneYPos *= veneratedCloneDistance; + float speedX4 = veneratedCloneXPos + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = veneratedCloneYPos + (float)Main.rand.Next(-30, 31) * 0.02f; + int p = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, (int)(damage * 0.07), knockBack * 0.5f, Player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) { diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index cdd320628e..eaf39cd6f5 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -475,10 +475,8 @@ namespace CalamityMod.CalPlayer SpriteEffects spriteEffects = Player.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - float num25 = -4f; - float num24 = -8f; DrawData howDoIDrawThings = new DrawData(thingToDraw, - new Vector2((int)(drawPlayer.position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (9 * drawPlayer.direction)) + num25 * drawPlayer.direction, (int)(drawPlayer.position.Y - Main.screenPosition.Y + (drawPlayer.height / 2) + 2f * drawPlayer.gravDir + num24 * drawPlayer.gravDir)), + new Vector2((int)(drawPlayer.position.X - Main.screenPosition.X + (drawPlayer.width / 2) - (9 * drawPlayer.direction)) - 4f * drawPlayer.direction, (int)(drawPlayer.position.Y - Main.screenPosition.Y + (drawPlayer.height / 2) + 2f * drawPlayer.gravDir - 8f * drawPlayer.gravDir)), new Rectangle(0, 0, thingToDraw.Width, thingToDraw.Height), drawInfo.colorArmorBody, drawPlayer.bodyRotation, diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 2d0d95df72..6876d96acd 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -119,8 +119,8 @@ namespace CalamityMod.CalPlayer for (int j = 0; j < 100; j++) { - int num = Dust.NewDust(Player.position, Player.width, Player.height, 235, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; + int scarfDodgeDust = Dust.NewDust(Player.position, Player.width, Player.height, 235, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[scarfDodgeDust]; dust.position.X += Main.rand.Next(-20, 21); dust.position.Y += Main.rand.Next(-20, 21); dust.velocity *= 0.4f; @@ -233,8 +233,8 @@ namespace CalamityMod.CalPlayer for (int j = 0; j < 50; j++) { - int num = Dust.NewDust(Player.position, Player.width, Player.height, 173, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[num]; + int nebulousReviveDust = Dust.NewDust(Player.position, Player.width, Player.height, 173, 0f, 0f, 100, default, 2f); + Dust dust = Main.dust[nebulousReviveDust]; dust.position.X += Main.rand.Next(-20, 21); dust.position.Y += Main.rand.Next(-20, 21); dust.velocity *= 0.9f; @@ -2585,18 +2585,18 @@ namespace CalamityMod.CalPlayer { if (Player.inventory[i].stack > 0 && ((Player.inventory[i].type >= ItemID.LargeAmethyst && Player.inventory[i].type <= ItemID.LargeDiamond) || Player.inventory[i].type == ItemID.LargeAmber)) { - int num = Item.NewItem(source, (int)Player.position.X, (int)Player.position.Y, Player.width, Player.height, Player.inventory[i].type, 1, false, 0, false, false); - Main.item[num].netDefaults(Player.inventory[i].netID); - Main.item[num].Prefix((int)Player.inventory[i].prefix); - Main.item[num].stack = Player.inventory[i].stack; - Main.item[num].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f; - Main.item[num].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f; - Main.item[num].noGrabDelay = 100; - Main.item[num].favorited = false; - Main.item[num].newAndShiny = false; + int droppedLargeGem = Item.NewItem(source, (int)Player.position.X, (int)Player.position.Y, Player.width, Player.height, Player.inventory[i].type, 1, false, 0, false, false); + Main.item[droppedLargeGem].netDefaults(Player.inventory[i].netID); + Main.item[droppedLargeGem].Prefix((int)Player.inventory[i].prefix); + Main.item[droppedLargeGem].stack = Player.inventory[i].stack; + Main.item[droppedLargeGem].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f; + Main.item[droppedLargeGem].velocity.X = (float)Main.rand.Next(-20, 21) * 0.2f; + Main.item[droppedLargeGem].noGrabDelay = 100; + Main.item[droppedLargeGem].favorited = false; + Main.item[droppedLargeGem].newAndShiny = false; if (Main.netMode == NetmodeID.MultiplayerClient) { - NetMessage.SendData(MessageID.SyncItem, -1, -1, null, num, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncItem, -1, -1, null, droppedLargeGem, 0f, 0f, 0f, 0, 0, 0); } Player.inventory[i].SetDefaults(0, false); } diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 75d59db2ec..daf01e14a7 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -232,12 +232,14 @@ namespace CalamityMod.CalPlayer if (lAmbergris) { + if (Player.miscCounter % 3 == 2 && Player.dashDelay > 0) // Reduced dash cooldown by 33% + Player.dashDelay--; + if (Player.dashDelay == -1)// TODO: prevent working with special dashes, this was inconsitent with my old solution so I didn't keep it. not huge deal) { - Player.endurance += 0.05f; if (!HasIncreasedDashFirstFrame) { - Player.velocity.X *= 1.15f; + Player.velocity.X *= 1.2f; Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), 75, 20f, Player.whoAmI); HasIncreasedDashFirstFrame = true; } @@ -258,10 +260,10 @@ namespace CalamityMod.CalPlayer { float sparkscale = (Player.velocity.X * Player.direction * 0.07f); Vector2 SparkVelocity1 = Player.velocity.RotatedBy(Player.direction * 2, default) * 0.1f - Player.velocity / 2f; - SparkParticle spark = new SparkParticle(Player.Center + Player.velocity.RotatedBy(2f * Player.direction) * 1.5f, SparkVelocity1, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); + LineParticle spark = new LineParticle(Player.Center + Player.velocity.RotatedBy(2f * Player.direction) * 1.5f, SparkVelocity1, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); GeneralParticleHandler.SpawnParticle(spark); Vector2 SparkVelocity2 = Player.velocity.RotatedBy(Player.direction * -2, default) * 0.1f - Player.velocity / 2f; - SparkParticle spark2 = new SparkParticle(Player.Center + Player.velocity.RotatedBy(-2f * Player.direction) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); + LineParticle spark2 = new LineParticle(Player.Center + Player.velocity.RotatedBy(-2f * Player.direction) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkTurquoise : Color.DodgerBlue); GeneralParticleHandler.SpawnParticle(spark2); } if (Player.miscCounter % 4 == 0 && Player.velocity != Vector2.Zero) //every other frame spawn the hitbox @@ -275,7 +277,7 @@ namespace CalamityMod.CalPlayer { if (Player.dashDelay == -1)// TODO: prevent working with special dashes, this was inconsitent with my old solution so I didn't keep it. not huge deal) { - Player.endurance += 0.05f; + Player.endurance += 0.1f; if (!HasReducedDashFirstFrame) // Dash isn't reduced, this is used to determine the first frame of dashing { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact with { Volume = 0.4f , PitchVariance = 0.4f }, Player.Center); @@ -1183,7 +1185,7 @@ namespace CalamityMod.CalPlayer Vector2 dustLineEnd = Player.Center; Vector2 currentDustPos = default; Vector2 spinningpoint = new Vector2(0f, -3f).RotatedByRandom(MathHelper.Pi); - Vector2 value5 = new Vector2(2.1f, 2f); + Vector2 healerDustVel = new Vector2(2.1f, 2f); Color dustColor = Main.hslToRgb(Main.rgbToHsl(new Color(255, 200, Main.DiscoB)).X, 1f, 0.5f); dustColor.A = 255; for (int i = 0; i < maxHealDustIterations; i++) @@ -1191,18 +1193,18 @@ namespace CalamityMod.CalPlayer if (i % dustDivisor == 0) { currentDustPos = Vector2.Lerp(dustLineStart, dustLineEnd, i / (float)maxHealDustIterations); - int dust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); - Main.dust[dust].position = currentDustPos; - Main.dust[dust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * value5 * (0.8f + Main.rand.NextFloat() * 0.4f) + Player.velocity; - Main.dust[dust].noGravity = true; - Main.dust[dust].scale = 1f; - Main.dust[dust].fadeIn = Main.rand.NextFloat() * 2f; - Dust dust2 = Dust.CloneDust(dust); - Dust dust3 = dust2; - dust3.scale /= 2f; - dust3 = dust2; - dust3.fadeIn /= 2f; - dust2.color = new Color(255, 255, 255, 255); + int holyDust = Dust.NewDust(currentDustPos, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); + Main.dust[holyDust].position = currentDustPos; + Main.dust[holyDust].velocity = spinningpoint.RotatedBy(MathHelper.TwoPi * i / maxHealDustIterations) * healerDustVel * (0.8f + Main.rand.NextFloat() * 0.4f) + Player.velocity; + Main.dust[holyDust].noGravity = true; + Main.dust[holyDust].scale = 1f; + Main.dust[holyDust].fadeIn = Main.rand.NextFloat() * 2f; + Dust dustClone = Dust.CloneDust(holyDust); + Dust extraDust = dustClone; + extraDust.scale /= 2f; + extraDust = dustClone; + extraDust.fadeIn /= 2f; + dustClone.color = new Color(255, 255, 255, 255); } } } @@ -1310,6 +1312,12 @@ namespace CalamityMod.CalPlayer if (expiredCooldowns.Count > 0) SyncCooldownRemoval(Main.netMode == NetmodeID.Server, expiredCooldowns); + if (DragonsBreathAudioCooldown > 0) + DragonsBreathAudioCooldown--; + if (DragonsBreathAudioCooldown2 > 0) + DragonsBreathAudioCooldown2--; + if (PhotoAudioCooldown > 0) + PhotoAudioCooldown--; if (fullRageSoundCountdownTimer > 0) --fullRageSoundCountdownTimer; if (plagueTaintedSMGDroneCooldown > 0) diff --git a/CalamityLists.cs b/CalamityLists.cs index dbbe15a55a..88fd707329 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -713,7 +713,8 @@ namespace CalamityMod "Spirit Shield", "Briny_Coffee", "_Skeggy_", - "just akkolite" + "just akkolite", + "J.U.N.E.S", }; projectileDestroyExceptionList = new List() diff --git a/CalamityMod.cs b/CalamityMod.cs index f5340244a9..6a16cd4e08 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -49,7 +49,6 @@ using CalamityMod.NPCs.StormWeaver; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Schematics; @@ -345,7 +344,6 @@ namespace CalamityMod // However, render targets and certain other graphical objects can only be created on the main thread. Main.QueueMainThreadAction(() => { - FusableParticleManager.LoadParticleRenderSets(); Main.OnPreDraw += PrepareRenderTargets; }); @@ -376,7 +374,7 @@ namespace CalamityMod GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => - { + { float flightTimeInterpolant = player.wingTime / player.wingTimeMax; if (player.mount.Active) flightTimeInterpolant = 1f; @@ -449,7 +447,6 @@ namespace CalamityMod Main.QueueMainThreadAction(() => { - FusableParticleManager.UnloadParticleRenderSets(); Main.OnPreDraw -= PrepareRenderTargets; }); @@ -499,7 +496,6 @@ namespace CalamityMod public static void PrepareRenderTargets(GameTime gameTime) { - FusableParticleManager.PrepareFusableParticleTargets(); DeathAshParticle.PrepareRenderTargets(); FluidFieldManager.Update(); } @@ -517,7 +513,8 @@ namespace CalamityMod saveMethodInfo.Invoke(null, new object[] { cfg }); else Instance.Logger.Error("TML ConfigManager.Save reflection failed. Method signature has changed. Notify Calamity Devs if you see this in your log."); - } catch + } + catch { Instance.Logger.Error("An error occurred while manually saving Calamity mod configuration. This may be due to a complex mod conflict. It is safe to ignore this error."); } diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 83114d8232..62b0bfff95 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -1,5 +1,4 @@ using CalamityMod.Skies; -using Iced.Intel; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; @@ -124,14 +123,14 @@ namespace CalamityMod.Effects // Used by Devourer of Gods. Renders the portal that he escapes through at the end of phase 1. internal static Effect DoGPortalShader; - // Fusable particles. See the FusableParticleManager for comments on how this system works. - // These shaders are leveraged to render the results of the fusable particle simulation to the screen. + // Metaballs. See the MetaballManager class for comments on how this system works. + // These shaders are leveraged to render the results of the metaball simulation to the screen. // The "Base" shader draws the particles themselves. // The "Additive" shader actually FUSES the particles into their blobby mess. // // Backing textures vary. The primary use of this system is Gruesome Eminence. - internal static Effect BaseFusableParticleEdgeShader; - internal static Effect AdditiveFusableParticleEdgeShader; + internal static Effect MetaballEdgeShader; + internal static Effect AdditiveMetaballEdgeShader; // Used to render the results of Navier-Stokes fluid simulations. internal static Effect FluidShaders; @@ -178,7 +177,7 @@ namespace CalamityMod.Effects internal static Effect CircularGradientWithEdge; internal static Effect WavyOpacity; #endregion - + // // All below shaders were added by Amber // Authorship goes to Toasty @@ -187,7 +186,7 @@ namespace CalamityMod.Effects #region Amber's Shaders internal static Effect PrimitiveClearShader; #endregion - + // Shorthand to register a loaded shader in Terraria's graphics engine // All shaders registered this way are accessible under GameShaders.Misc // They will use the prefix described above @@ -340,11 +339,11 @@ namespace CalamityMod.Effects RegisterMiscShader(DoGPortalShader, "ScreenPass", "DoGPortal"); // These two shaders are often (but not always) used together. - BaseFusableParticleEdgeShader = LoadShader("ParticleFusion/BaseFusableParticleEdgeShader"); - RegisterMiscShader(BaseFusableParticleEdgeShader, "ParticlePass", "BaseFusableParticleEdge"); + MetaballEdgeShader = LoadShader("Metaballs/MetaballEdgeShader"); + RegisterMiscShader(MetaballEdgeShader, "ParticlePass", "MetaballEdge"); - AdditiveFusableParticleEdgeShader = LoadShader("ParticleFusion/AdditiveFusableParticleEdgeShader"); - RegisterMiscShader(AdditiveFusableParticleEdgeShader, "ParticlePass", "AdditiveFusableParticleEdge"); + AdditiveMetaballEdgeShader = LoadShader("Metaballs/AdditiveMetaballEdgeShader"); + RegisterMiscShader(AdditiveMetaballEdgeShader, "ParticlePass", "AdditiveMetaballEdge"); // This shader is not registered with the game but is invoked directly to render the results of fluid simulation. FluidShaders = LoadShader("FluidShaders"); diff --git a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx b/Effects/Metaballs/AdditiveMetaballEdgeShader.fx similarity index 76% rename from Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx rename to Effects/Metaballs/AdditiveMetaballEdgeShader.fx index b7c98d0961..039e453228 100644 --- a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.fx +++ b/Effects/Metaballs/AdditiveMetaballEdgeShader.fx @@ -12,25 +12,16 @@ float uDirection; float3 uLightSource; float2 uImageSize0; float2 uImageSize1; -float edgeBorderSize; -bool borderShouldBeSolid; -float3 edgeBorderColor; -float2 screenArea; -float2 renderTargetArea; -float2 screenMoveOffset; -float2 generalBackgroundOffset; -bool invertedScreen; -float2 upscaleFactor; float4 uShaderSpecificData; +float2 screenArea; +float2 layerOffset; +float2 singleFrameScreenOffset; + float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 { float2 originalCoords = coords; - if (invertedScreen) - coords.y = 1 - coords.y; - - // Account for screen movements. Not doing this causes the scene to move based on that. - coords += screenMoveOffset / renderTargetArea; + coords += layerOffset + singleFrameScreenOffset; float2 offset = 3 / screenArea; float4 color = tex2D(uImage0, coords); diff --git a/Effects/Metaballs/AdditiveMetaballEdgeShader.xnb b/Effects/Metaballs/AdditiveMetaballEdgeShader.xnb new file mode 100644 index 0000000000..504c6ffb0f Binary files /dev/null and b/Effects/Metaballs/AdditiveMetaballEdgeShader.xnb differ diff --git a/Effects/Metaballs/MetaballEdgeShader.fx b/Effects/Metaballs/MetaballEdgeShader.fx new file mode 100644 index 0000000000..3f04f11485 --- /dev/null +++ b/Effects/Metaballs/MetaballEdgeShader.fx @@ -0,0 +1,59 @@ +sampler metaballContents : register(s0); +sampler overlayTexture : register(s1); + +float2 screenSize; +float2 layerSize; +float2 layerOffset; +float4 edgeColor; +float2 singleFrameScreenOffset; + +// The usage of these two methods seemingly prevents imprecision problems for some reason. +float2 convertToScreenCoords(float2 coords) +{ + return coords * screenSize; +} + +float2 convertFromScreenCoords(float2 coords) +{ + return coords / screenSize; +} + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + // Calculate the base color. This is the calculated from the raw objects in the metaball render target. + float4 baseColor = tex2D(metaballContents, coords); + + // Used to negate the need for an inverted if (baseColor.a > 0) by ensuring all of the edge checks fail. + float alphaOffset = (1 - any(baseColor.a)); + + // Check if there are any empty pixels nearby. If there are, that means this pixel is at an edge, and should be colored accordingly. + float left = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(-2, 0))).a + alphaOffset; + float right = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(2, 0))).a + alphaOffset; + float top = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(0, -2))).a + alphaOffset; + float bottom = tex2D(metaballContents, convertFromScreenCoords(convertToScreenCoords(coords) + float2(0, 2))).a + alphaOffset; + + // Use step instead of branching in order to determine whether neighboring pixels are invisible. + float leftHasNoAlpha = step(left, 0); + float rightHasNoAlpha = step(right, 0); + float topHasNoAlpha = step(top, 0); + float bottomHasNoAlpha = step(bottom, 0); + + // Use addition instead of the OR boolean operator to get a 0-1 value for whether an edge is invisible. + // The equivalent for AND would be multiplication. + float conditionOpacityFactor = 1 - saturate(leftHasNoAlpha + rightHasNoAlpha + topHasNoAlpha + bottomHasNoAlpha); + + // Calculate layer colors. + float4 layerColor = tex2D(overlayTexture, (coords + layerOffset + singleFrameScreenOffset) * screenSize / layerSize); + float4 defaultColor = layerColor * tex2D(metaballContents, coords) * sampleColor; + + // Lastly, use the aforementioned condition to switch between the colors. If conditionOpacityFactor is 1, the default color is + // zeroed out and the edge is toggled, and vice versa. + return (defaultColor * conditionOpacityFactor) + (edgeColor * sampleColor * (1 - conditionOpacityFactor)); +} +technique Technique1 +{ + pass ParticlePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Metaballs/MetaballEdgeShader.xnb b/Effects/Metaballs/MetaballEdgeShader.xnb new file mode 100644 index 0000000000..6ee03aac55 Binary files /dev/null and b/Effects/Metaballs/MetaballEdgeShader.xnb differ diff --git a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb deleted file mode 100644 index ca8ec969be..0000000000 Binary files a/Effects/ParticleFusion/AdditiveFusableParticleEdgeShader.xnb and /dev/null differ diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx deleted file mode 100644 index e4155db9b9..0000000000 --- a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.fx +++ /dev/null @@ -1,78 +0,0 @@ -sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -float3 uColor; -float3 uSecondaryColor; -float uOpacity; -float uSaturation; -float uRotation; -float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; -float2 uImageSize0; -float2 uImageSize1; -float edgeBorderSize; -bool borderShouldBeSolid; -float3 edgeBorderColor; -float2 screenArea; -float2 renderTargetArea; -float2 screenMoveOffset; -float2 generalBackgroundOffset; -bool invertedScreen; -float2 upscaleFactor; -float4 uShaderSpecificData; - -float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 -{ - float2 originalCoords = coords; - if (invertedScreen) - coords.y = 1 - coords.y; - - // Account for screen movements. Not doing this causes the scene to move based on that. - coords += screenMoveOffset / renderTargetArea; - - float4 color = tex2D(uImage0, coords); - - // Determine how much downscaling is required to reasonably zoom in on things. - float downscaleFactor = float2(5, 5) / upscaleFactor / max(renderTargetArea.x, renderTargetArea.y) / 2; - float2 backgroundCoords = frac((renderTargetArea * (originalCoords + generalBackgroundOffset * upscaleFactor) + uWorldPosition) * downscaleFactor); - float4 backgroundColor = tex2D(uImage1, backgroundCoords); - - // Equivalent to edgeBorderSize pixels in both the X and Y direction. - float2 edgeOffset = float2(edgeBorderSize, edgeBorderSize) / renderTargetArea; - - // Check if the cardinal directions are not intersecting with any other active parts of the render target. - // If one of them isn't, that means that a border should be rendered. - float4 aboveColor = tex2D(uImage0, coords + float2(0, edgeOffset.y)); - float4 belowColor = tex2D(uImage0, coords - float2(0, edgeOffset.y)); - float4 leftColor = tex2D(uImage0, coords + float2(edgeOffset.x, 0)); - float4 rightColor = tex2D(uImage0, coords - float2(edgeOffset.x, 0)); - - // Invert color check thresholds based on whether the border should be solid when drawing. - float checkThreshold = 0.02; - if (!borderShouldBeSolid) - checkThreshold = 0.95; - - // If any cardinal color is sufficiently close to transparency choose an edge border color. - // Opacity multipliers ensure that this does not affect completely invisible areas of the render target. - if (aboveColor.r < checkThreshold || belowColor.r < checkThreshold || leftColor.r < checkThreshold || rightColor.r < checkThreshold) - { - float borderOpacity = color.a; - - // Use binary opacity if the border should be solid when drawing. - if (borderOpacity > 0 && borderShouldBeSolid) - borderOpacity = 1; - - return float4(edgeBorderColor, 1) * borderOpacity; - } - - return backgroundColor; -} -technique Technique1 -{ - pass ParticlePass - { - PixelShader = compile ps_2_0 PixelShaderFunction(); - } -} \ No newline at end of file diff --git a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb b/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb deleted file mode 100644 index c544bbed01..0000000000 Binary files a/Effects/ParticleFusion/BaseFusableParticleEdgeShader.xnb and /dev/null differ diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 286fb4bede..9b420d00f5 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -442,13 +442,6 @@ namespace CalamityMod.Events { CalamityUtils.KillAllHostileProjectiles(); HostileProjectileKillCounter = 3; - - // Mark Boss Rush as complete - DownedBossSystem.downedBossRush = true; - CalamityNetcode.SyncWorld(); - - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(Source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); } }; } @@ -744,7 +737,19 @@ namespace CalamityMod.Events HostileProjectileKillCounter = 3; if (BossDeathEffects.ContainsKey(npc.type)) + { BossDeathEffects[npc.type].Invoke(npc); + } + + if (npc.type == Bosses[Bosses.Count -1].EntityID) + { + // Mark Boss Rush as complete + DownedBossSystem.downedBossRush = true; + CalamityNetcode.SyncWorld(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(Source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + } } // Sync the stage and progress of Boss Rush whenever a relevant boss dies. diff --git a/ExtraTextures/BasicCircle.png b/ExtraTextures/BasicCircle.png new file mode 100644 index 0000000000..a9f476c6f7 Binary files /dev/null and b/ExtraTextures/BasicCircle.png differ diff --git a/Projectiles/Melee/Orbacle.png b/ExtraTextures/TinyGreyscaleCircle.png similarity index 100% rename from Projectiles/Melee/Orbacle.png rename to ExtraTextures/TinyGreyscaleCircle.png diff --git a/Gores/AstralWaterDroplet.cs b/Gores/AstralWaterDroplet.cs index 87a5e4f8e9..9eb6588b4d 100644 --- a/Gores/AstralWaterDroplet.cs +++ b/Gores/AstralWaterDroplet.cs @@ -28,52 +28,52 @@ namespace CalamityMod.Gores { gore.alpha = 100; } - int num = 4; + int goreFrameDelay = 4; gore.frameCounter++; if (gore.frame <= 4) { - int num2 = (int)(gore.position.X / 16f); - int num3 = (int)(gore.position.Y / 16f) - 1; - if (WorldGen.InWorld(num2, num3, 0) && !Main.tile[num2, num3].HasTile) + int goreXPos = (int)(gore.position.X / 16f); + int goreYPos = (int)(gore.position.Y / 16f) - 1; + if (WorldGen.InWorld(goreXPos, goreYPos, 0) && !Main.tile[goreXPos, goreYPos].HasTile) { gore.active = false; } if (gore.frame == 0) { - num = 24 + Main.rand.Next(256); + goreFrameDelay = 24 + Main.rand.Next(256); } if (gore.frame == 1) { - num = 24 + Main.rand.Next(256); + goreFrameDelay = 24 + Main.rand.Next(256); } if (gore.frame == 2) { - num = 24 + Main.rand.Next(256); + goreFrameDelay = 24 + Main.rand.Next(256); } if (gore.frame == 3) { - num = 24 + Main.rand.Next(96); + goreFrameDelay = 24 + Main.rand.Next(96); } if (gore.frame == 5) { - num = 16 + Main.rand.Next(64); + goreFrameDelay = 16 + Main.rand.Next(64); } - if ((int)gore.frameCounter >= num) + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; if (gore.frame == 5 && Main.netMode != NetmodeID.Server) { - int num4 = Gore.NewGore(new EntitySource_Misc("0"), gore.position, gore.velocity, gore.type, 1f); - Main.gore[num4].frame = 9; - Main.gore[num4].velocity *= 0f; + int astralWater = Gore.NewGore(new EntitySource_Misc("0"), gore.position, gore.velocity, gore.type, 1f); + Main.gore[astralWater].frame = 9; + Main.gore[astralWater].velocity *= 0f; } } } else if (gore.frame <= 6) { - num = 8; - if ((int)gore.frameCounter >= num) + goreFrameDelay = 8; + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; @@ -85,7 +85,7 @@ namespace CalamityMod.Gores } else if (gore.frame <= 9) { - num = 6; + goreFrameDelay = 6; gore.velocity.Y += 0.2f; if ((double)gore.velocity.Y < 0.5) { @@ -95,7 +95,7 @@ namespace CalamityMod.Gores { gore.velocity.Y = 12f; } - if ((int)gore.frameCounter >= num) + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; @@ -108,7 +108,7 @@ namespace CalamityMod.Gores else { gore.velocity.Y += 0.1f; - if ((int)gore.frameCounter >= num) + if ((int)gore.frameCounter >= goreFrameDelay) { gore.frameCounter = 0; gore.frame += 1; @@ -120,9 +120,9 @@ namespace CalamityMod.Gores } } - Vector2 value3 = gore.velocity; + Vector2 goreVelCheck = gore.velocity; gore.velocity = Collision.TileCollision(gore.position, gore.velocity, 16, 14, false, false, 1); - if (gore.velocity != value3) + if (gore.velocity != goreVelCheck) { if (gore.frame < 10) { @@ -146,12 +146,12 @@ namespace CalamityMod.Gores } ((WaterShaderData)Filters.Scene["WaterDistortion"].GetShader()).QueueRipple(gore.position + new Vector2(8f, 8f), 1f, RippleShape.Square, 0f); } - int num21 = (int)(gore.position.X + 8f) / 16; - int num22 = (int)(gore.position.Y + 14f) / 16; - if (Main.tile[num21, num22] != null && Main.tile[num21, num22].LiquidAmount > 0) + int goreTileX = (int)(gore.position.X + 8f) / 16; + int goreTileY = (int)(gore.position.Y + 14f) / 16; + if (Main.tile[goreTileX, goreTileY] != null && Main.tile[goreTileX, goreTileY].LiquidAmount > 0) { gore.velocity *= 0f; - gore.position.Y = (float)(num22 * 16 - (int)(Main.tile[num21, num22].LiquidAmount / 16)); + gore.position.Y = (float)(goreTileY * 16 - (int)(Main.tile[goreTileX, goreTileY].LiquidAmount / 16)); } } diff --git a/Graphics/Metaballs/BloodBoilerMetaball.cs b/Graphics/Metaballs/BloodBoilerMetaball.cs new file mode 100644 index 0000000000..d5d29fd0c8 --- /dev/null +++ b/Graphics/Metaballs/BloodBoilerMetaball.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class BloodBoilerMetaball : Metaball + { + public class BloodBoilerParticle + { + public Vector2 Center; + public float Size; + + public BloodBoilerParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => Color.DarkRed; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float pureRedIntensity = 0.15f; + float opacity = 0.5f; + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + foreach (BloodBoilerParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float pureRedInterpolant = Utils.GetLerpValue(25f, 60f, particle.Size, true) * pureRedIntensity; + Color drawColor = Color.Lerp(EdgeColor, Color.DarkRed, pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/BloodBoilerMetaball2.cs b/Graphics/Metaballs/BloodBoilerMetaball2.cs new file mode 100644 index 0000000000..873604126a --- /dev/null +++ b/Graphics/Metaballs/BloodBoilerMetaball2.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class BloodBoilerMetaball2 : Metaball + { + public class BloodBoilerParticle2 + { + public Vector2 Center; + public float Size; + + public BloodBoilerParticle2(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => Color.DarkRed; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float pureRedIntensity = 0.15f; + float opacity = 0.3f; + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + foreach (BloodBoilerParticle2 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float pureRedInterpolant = Utils.GetLerpValue(25f, 60f, particle.Size, true) * pureRedIntensity; + Color drawColor = Color.Lerp(EdgeColor, Color.DarkRed, pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/DragonsBreathMetaball.cs b/Graphics/Metaballs/DragonsBreathMetaball.cs new file mode 100644 index 0000000000..e041506bb2 --- /dev/null +++ b/Graphics/Metaballs/DragonsBreathMetaball.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class DragonsBreathFlameMetaball : DragonsBreathMetaball + { + // OrangeRed is FF4500 + // new Color(0xFF, 0x3A, 0x0A); + public override Color EdgeColor => Color.Orange; + + // Flame metaballs never turn white + public override void DrawInstances() => DrawInstancesInternal(0.03f, -1f); + } + public class DragonsBreathBeamMetaball : DragonsBreathMetaball + { + private static float whiteSizeThreshold = 72f; + + public override Color EdgeColor => Color.Orange; + + // Laser metaballs very suddenly turn white at a specific size + public override void DrawInstances() => DrawInstancesInternal(0.4f, whiteSizeThreshold); + } + + public abstract class DragonsBreathMetaball : Metaball + { + // Identical behavior to Blood Boiler particles + public class DragonsBreathParticle + { + public Vector2 Center; + public float Size; + + public DragonsBreathParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 5f) + Size = Size * 0.8f - 1f; + } + } + + public List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + internal void DrawInstancesInternal(float opacity, float whiteSizeThreshold) + { + float pureWhiteIntensity = 0.16f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (DragonsBreathParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + Color drawColor; + if (whiteSizeThreshold >= 0f) + { + float pureWhiteInterpolant = Utils.GetLerpValue(0.8f * whiteSizeThreshold, whiteSizeThreshold, particle.Size, true) * pureWhiteIntensity; + drawColor = Color.Lerp(EdgeColor, Color.DarkOrange, pureWhiteInterpolant) * opacity; + } + else + drawColor = Color.Lerp(EdgeColor, new Color(0xE0, 0x70, 0x10), Utils.GetLerpValue(60f, 100f, particle.Size, true) * 0.75f); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/DragonsBreathMetaball2.cs b/Graphics/Metaballs/DragonsBreathMetaball2.cs new file mode 100644 index 0000000000..c07f13e894 --- /dev/null +++ b/Graphics/Metaballs/DragonsBreathMetaball2.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class DragonsBreathFlameMetaball2 : DragonsBreathMetaball + { + // OrangeRed is FF4500 + // new Color(0xFF, 0x3A, 0x0A); + public override Color EdgeColor => Color.OrangeRed; + + // Flame metaballs never turn white + public override void DrawInstances() => DrawInstancesInternal(0.03f, -1f); + } + public class DragonsBreathBeamMetaball2 : DragonsBreathMetaball2 + { + private static float whiteSizeThreshold = 72f; + + public override Color EdgeColor => Color.OrangeRed * 1.2f; + + // Laser metaballs very suddenly turn white at a specific size + public override void DrawInstances() => DrawInstancesInternal(0.4f, whiteSizeThreshold); + } + + public abstract class DragonsBreathMetaball2 : Metaball + { + // Identical behavior to Blood Boiler particles + public class DragonsBreathParticle2 + { + public Vector2 Center; + public float Size; + + public DragonsBreathParticle2(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.91f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + public List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + internal void DrawInstancesInternal(float opacity, float whiteSizeThreshold) + { + float pureWhiteIntensity = 0.16f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (DragonsBreathParticle2 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + Color drawColor; + if (whiteSizeThreshold >= 0f) + { + float pureWhiteInterpolant = Utils.GetLerpValue(0.8f * whiteSizeThreshold, whiteSizeThreshold, particle.Size, true) * pureWhiteIntensity; + drawColor = Color.Lerp(EdgeColor, Color.White, pureWhiteInterpolant) * opacity; + } + else + drawColor = Color.Lerp(EdgeColor, Color.DarkOrange, Utils.GetLerpValue(60f, 100f, particle.Size, true) * 0.3f); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer1.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer1.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer1.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer1.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer2.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer2.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer2.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer2.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer3.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer3.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer3.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer3.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer4.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer4.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer4.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer4.png diff --git a/Particles/Metaballs/GruesomeEminence_Ghost_Layer5.png b/Graphics/Metaballs/GruesomeEminence_Ghost_Layer5.png similarity index 100% rename from Particles/Metaballs/GruesomeEminence_Ghost_Layer5.png rename to Graphics/Metaballs/GruesomeEminence_Ghost_Layer5.png diff --git a/Graphics/Metaballs/GruesomeMetaball.cs b/Graphics/Metaballs/GruesomeMetaball.cs new file mode 100644 index 0000000000..f1d273a344 --- /dev/null +++ b/Graphics/Metaballs/GruesomeMetaball.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class GruesomeMetaball : Metaball + { + public class GruesomeParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public GruesomeParticle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Size *= 0.94f; + Center += Velocity; + Velocity *= 0.96f; + } + } + + private static List> layerAssets; + + public static List Particles + { + get; + private set; + } = new(); + + // Check if there are any extraneous particles or if the Gruesome Eminence projectile is present when deciding if this particle should be drawn. + public override bool AnythingToDraw => Particles.Any() || CalamityUtils.AnyProjectiles(ModContent.ProjectileType()); + + public override IEnumerable Layers + { + get + { + for (int i = 0; i < layerAssets.Count; i++) + yield return layerAssets[i].Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => new(61, 6, 2); + + public override void Load() + { + if (Main.netMode == NetmodeID.Server) + return; + + // Load layer assets. + layerAssets = new(); + + for (int i = 1; i <= 5; i++) + layerAssets.Add(ModContent.Request($"CalamityMod/Graphics/Metaballs/GruesomeEminence_Ghost_Layer{i}", AssetRequestMode.ImmediateLoad)); + } + + public override void ClearInstances() => Particles.Clear(); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2.5f); + } + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size) => + Particles.Add(new(position, velocity, size)); + + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + switch (layerIndex) + { + // Background. + case 0: + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.03f; + + // Gaseous skulls. + case 1: + Vector2 offset = Vector2.One * (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.041f) * 2f; + offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.08f) * 0.97f); + return offset; + + // Spooky faces 1. + case 2: + offset = (Main.GlobalTimeWrappedHourly * 2.02f).ToRotationVector2() * 0.036f; + offset.Y += (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.161f) * 0.5f + 0.5f; + return offset; + + // Spooky faces 2. + case 3: + offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * -0.04f + (Main.GlobalTimeWrappedHourly * 1.89f).ToRotationVector2() * 0.03f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 466920161) * 0.025f; + return offset; + + // Spooky faces 3. + case 4: + offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f + (Main.GlobalTimeWrappedHourly * 1.77f).ToRotationVector2() * 0.04725f; + offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 577215664) * 0.05f; + return offset; + } + + return Vector2.Zero; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + // Draw all particles. + foreach (GruesomeParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, 0, 0f); + } + + // Draw gruesome eminence ghost heads. + foreach (Projectile eminence in CalamityUtils.AllProjectilesByID(ModContent.ProjectileType())) + eminence.ModProjectile().DrawHeadForMetaball(); + } + } +} diff --git a/Graphics/Metaballs/Metaball.cs b/Graphics/Metaballs/Metaball.cs new file mode 100644 index 0000000000..0ad632f8ae --- /dev/null +++ b/Graphics/Metaballs/Metaball.cs @@ -0,0 +1,151 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public abstract class Metaball : ModType + { + internal List LayerTargets = new(); + + /// + /// Required utility that is used to determine whether this metaball has anything to draw.

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

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

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

+ /// It is your responsibility to recreate layer targets later if you call this method manually. + ///
+ public void Dispose() + { + for (int i = 0; i < LayerTargets.Count; i++) + LayerTargets[i]?.Dispose(); + } + } +} diff --git a/Particles/Metaballs/FusableParticleBase.png b/Graphics/Metaballs/MetaballBase.png similarity index 100% rename from Particles/Metaballs/FusableParticleBase.png rename to Graphics/Metaballs/MetaballBase.png diff --git a/Graphics/Metaballs/MetaballDrawLayer.cs b/Graphics/Metaballs/MetaballDrawLayer.cs new file mode 100644 index 0000000000..d061aabe61 --- /dev/null +++ b/Graphics/Metaballs/MetaballDrawLayer.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Graphics.Metaballs +{ + public enum MetaballDrawLayer + { + BeforeNPCs, + BeforeProjectiles, + AfterProjectiles, + } +} diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs new file mode 100644 index 0000000000..832785925e --- /dev/null +++ b/Graphics/Metaballs/MetaballManager.cs @@ -0,0 +1,135 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class MetaballManager : ModSystem + { + internal static readonly List metaballs = new(); + + public override void OnModLoad() + { + // Prepare event subscribers. + RenderTargetManager.RenderTargetUpdateLoopEvent += PrepareMetaballTargets; + On_Main.DrawProjectiles += DrawMetaballsAfterProjectiles; + On_Main.DrawNPCs += DrawMetaballsBeforeNPCs; + } + + public override void OnModUnload() + { + // Clear all unmanaged metaball target resources on the GPU on mod unload. + Main.QueueMainThreadAction(() => + { + foreach (Metaball metaball in metaballs) + metaball?.Dispose(); + }); + } + + public override void OnWorldUnload() + { + foreach (Metaball metaball in metaballs) + metaball.ClearInstances(); + } + + private void PrepareMetaballTargets() + { + // Get a list of all metaballs currently in use. + var activeMetaballs = metaballs.Where(m => m.AnythingToDraw); + + // Don't bother wasting resources if metaballs are not in use at the moment. + if (!activeMetaballs.Any()) + return; + + // Prepare the sprite batch for drawing. Metaballs may restart the sprite batch via PrepareSpriteBatch if their implementation requires it. + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + + var gd = Main.instance.GraphicsDevice; + foreach (Metaball metaball in activeMetaballs) + { + // Update the metaball collection. + if (!Main.gamePaused) + metaball.Update(); + + // Prepare the sprite batch in accordance to the needs of the metaball instance. By default this does nothing, + metaball.PrepareSpriteBatch(Main.spriteBatch); + + // Draw the raw contents of the metaball to each of its render targets. + foreach (ManagedRenderTarget target in metaball.LayerTargets) + { + gd.SetRenderTarget(target); + gd.Clear(Color.Transparent); + metaball.DrawInstances(); + + // Flush metaball contents to its render target and reset the sprite batch for the next iteration. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + } + } + + // Return to the backbuffer and end the sprite batch. + gd.SetRenderTarget(null); + Main.spriteBatch.End(); + } + + private void DrawMetaballsAfterProjectiles(On_Main.orig_DrawProjectiles orig, Main self) + { + if (AnyActiveMetaballsAtLayer(MetaballDrawLayer.BeforeProjectiles)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + DrawMetaballs(MetaballDrawLayer.BeforeProjectiles); + Main.spriteBatch.End(); + } + + orig(self); + + if (AnyActiveMetaballsAtLayer(MetaballDrawLayer.AfterProjectiles)) + { + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + DrawMetaballs(MetaballDrawLayer.AfterProjectiles); + Main.spriteBatch.End(); + } + } + + private void DrawMetaballsBeforeNPCs(On_Main.orig_DrawNPCs orig, Main self, bool behindTiles) + { + if (!behindTiles && AnyActiveMetaballsAtLayer(MetaballDrawLayer.BeforeNPCs)) + { + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + DrawMetaballs(MetaballDrawLayer.BeforeNPCs); + Main.spriteBatch.ExitShaderRegion(); + } + orig(self, behindTiles); + } + + /// + /// Checks if a metaball of a given layering type is currently in use. This is used to minimize needless restarts when there is nothing to draw. + /// + /// The metaball layer type to check against. + internal static bool AnyActiveMetaballsAtLayer(MetaballDrawLayer layerType) => + metaballs.Any(m => m.AnythingToDraw && m.DrawContext == layerType); + + /// + /// Draws all metaballs of a given . Used for layer ordering reasons. + /// + /// The layer type to draw with. + public static void DrawMetaballs(MetaballDrawLayer layerType) + { + foreach (Metaball metaball in metaballs.Where(m => m.DrawContext == layerType && m.AnythingToDraw)) + { + for (int i = 0; i < metaball.LayerTargets.Count; i++) + { + // Prepare shaders for the given layer target. + metaball.PrepareShaderForTarget(i); + + // Draw the metaball's raw contents with the shader. + Main.spriteBatch.Draw(metaball.LayerTargets[i], Main.screenLastPosition - Main.screenPosition, Color.White); + } + } + } + } +} diff --git a/Graphics/Metaballs/MetaballMessy.png b/Graphics/Metaballs/MetaballMessy.png new file mode 100644 index 0000000000..cee0b3c12f Binary files /dev/null and b/Graphics/Metaballs/MetaballMessy.png differ diff --git a/Graphics/Metaballs/PaintMetaballs.cs b/Graphics/Metaballs/PaintMetaballs.cs new file mode 100644 index 0000000000..bfe0fc2cc7 --- /dev/null +++ b/Graphics/Metaballs/PaintMetaballs.cs @@ -0,0 +1,132 @@ +using CalamityMod.Effects; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class CyanPaint : PaintMetaball + { + public override Color EdgeColor => Color.Cyan * 0.7f; + } + + public class BluePaint : PaintMetaball + { + public override Color EdgeColor => Color.Blue * 0.7f; + } + + public class MagentaPaint : PaintMetaball + { + public override Color EdgeColor => Color.Magenta * 0.7f; + } + + public class LimePaint : PaintMetaball + { + public override Color EdgeColor => Color.Lime * 0.7f; + } + + public class YellowPaint : PaintMetaball + { + public override Color EdgeColor => Color.Yellow * 0.7f; + } + + public abstract class PaintMetaball : Metaball + { + public class PaintParticle + { + public float Size; + + public Vector2 Center; + + public PaintParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Size = MathHelper.Clamp(Size - 0.1f, 0f, 200f) * 0.997f; + if (Size < 20f) + Size = Size * 0.8f - 1f; + } + } + + // This list is personalized between the various subclasses. + public List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override void ClearInstances() => Particles.Clear(); + + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public void SpawnParticle(Vector2 position, float size) => + Particles.Add(new(position, size)); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 3f); + } + + public override void PrepareSpriteBatch(SpriteBatch spriteBatch) + { + // Draw with additive blending. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + // Draw all particles. + foreach (PaintParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Color paintColor = Color.Lerp(EdgeColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(50f, 100f, particle.Size, true) * 0.1f) * 1.2f; + + Main.spriteBatch.Draw(tex, drawPosition, null, paintColor, 0f, origin, scale, 0, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball.cs b/Graphics/Metaballs/PhotoMetaball.cs new file mode 100644 index 0000000000..528537a831 --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball.cs @@ -0,0 +1,122 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball : Metaball + { + public class PhotoParticle + { + public Vector2 Center; + public float Size; + public int Time = 0; + public float OrginSize; + + public PhotoParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time == 1) + OrginSize = Size; + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.8f, 0f, 1000f) * 0.96f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < OrginSize * 0.15f) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time = 0; + public override Color EdgeColor => sparkColor; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + if (Time % 10 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(EdgeColor, Color.White * 0.9f, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball2.cs b/Graphics/Metaballs/PhotoMetaball2.cs new file mode 100644 index 0000000000..98a189e8cf --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball2.cs @@ -0,0 +1,123 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball2 : Metaball + { + public class PhotoParticle2 + { + public Vector2 Center; + public float Size; + public int Time = 0; + public float OrginSize; + + public PhotoParticle2(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time == 1) + OrginSize = Size; + // Always slowly shrink the particles. + Size = MathHelper.Clamp(Size - 0.8f, 0f, 1000f) * 0.96f; + + // Once sufficiently small, the particles very rapidly shrink. + if (Size < OrginSize * 0.15f) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time; + public override Color EdgeColor => sparkColor * 5; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + if (Time % 8 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.DarkRed, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle2 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(Color.White, EdgeColor, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball3.cs b/Graphics/Metaballs/PhotoMetaball3.cs new file mode 100644 index 0000000000..95f2645dfc --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball3.cs @@ -0,0 +1,116 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball3 : Metaball + { + public class PhotoParticle3 + { + public Vector2 Center; + public float Size; + public int Time = 0; + + public PhotoParticle3(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time >= 6) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time = 0; + public override Color EdgeColor => sparkColor; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + + if (Time % 10 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle3 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(EdgeColor, Color.White * 0.9f, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/PhotoMetaball4.cs b/Graphics/Metaballs/PhotoMetaball4.cs new file mode 100644 index 0000000000..8aa4e991a5 --- /dev/null +++ b/Graphics/Metaballs/PhotoMetaball4.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class PhotoMetaball4 : Metaball + { + public class PhotoParticle4 + { + public Vector2 Center; + public float Size; + public int Time = 0; + + public PhotoParticle4(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + if (Time >= 6) + Size = 2; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public Color sparkColor; + public int Time; + public override Color EdgeColor => sparkColor * 5; + + public override void Update() + { + Time++; + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + + if (Time % 8 == 0) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + } + + } + + // Copied from Rancor Lava metaballs, since these need to be additive metaballs. + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => Particles.Add(new(position, size)); + + public override void DrawInstances() + { + float opacity = 1f; + Texture2D tex = ModContent.Request("CalamityMod/Graphics/Metaballs/MetaballMessy").Value; + + foreach (PhotoParticle4 particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + var origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + + float Interpolant = Utils.GetLerpValue(25f, 60f, particle.Size * 0.6f, true); + Color drawColor = Color.Lerp(Color.White, EdgeColor, Interpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + + Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/RancorLavaMetaball.cs b/Graphics/Metaballs/RancorLavaMetaball.cs new file mode 100644 index 0000000000..60882cf578 --- /dev/null +++ b/Graphics/Metaballs/RancorLavaMetaball.cs @@ -0,0 +1,121 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ModLoader; +using Terraria; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.Effects; +using System; + +namespace CalamityMod.Graphics.Metaballs +{ + // CONSIDER -- Dominic 01NOV2023 This really should not be a metaball. Some sort of separately drawn fire effect would be far more suitable, and overall less awkward. + // However, for consistency with the previous effect, I'll leave it as is. + public class RancorLavaMetaball : Metaball + { + public class LavaParticle + { + public int Time; + + public float Size; + + public Vector2 Center; + + public LavaParticle(Vector2 center, float size) + { + Center = center; + Size = size; + } + + public void Update() + { + Time++; + Size = MathHelper.Clamp(Size - 0.24f, 0f, 200f) * 0.9956f; + if (Size < 15f) + Size = Size * 0.95f - 0.9f; + } + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override IEnumerable Layers + { + get + { + yield return ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value; + } + } + + public override Color EdgeColor => new(255, 56, 3); + + public override void ClearInstances() => Particles.Clear(); + + public override void PrepareShaderForTarget(int layerIndex) + { + // Store the shader in an easy to use local variable. + var metaballShader = CalamityShaders.AdditiveMetaballEdgeShader; + + // Calculate the layer scroll offset. This is used to ensure that the texture contents of the given metaball have parallax, rather than being static over the screen + // regardless of world position. + Vector2 screenSize = new(Main.screenWidth, Main.screenHeight); + + // Supply shader parameter values. + metaballShader.Parameters["screenArea"]?.SetValue(screenSize); + metaballShader.Parameters["layerOffset"]?.SetValue(Vector2.Zero); + metaballShader.Parameters["singleFrameScreenOffset"]?.SetValue(Vector2.Zero); + + // Apply the metaball shader. + metaballShader.CurrentTechnique.Passes[0].Apply(); + } + + public static void SpawnParticle(Vector2 position, float size) => + Particles.Add(new(position, size)); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 3f); + } + + public override void PrepareSpriteBatch(SpriteBatch spriteBatch) + { + // Draw with additive blending. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.Default, Main.Rasterizer, null, Matrix.Identity); + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; + + // Draw all particles. + foreach (LavaParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Color lavaColor = EdgeColor * 1.2f; + + // Make the lava color vary slightly based on position, to make the effect less monotonous. + lavaColor.B = (byte)(lavaColor.B + (int)(MathF.Cos(particle.Center.Y * 0.015f + Main.GlobalTimeWrappedHourly * 0.1f) * 3f)); + + // Make the lava color bright for the first few frames of its existence. + float brightnessInterpolant = Utils.GetLerpValue(10f, 2f, particle.Time, true) * 0.67f; + lavaColor = Color.Lerp(lavaColor, Color.Wheat, brightnessInterpolant); + + Main.spriteBatch.Draw(tex, drawPosition, null, lavaColor, 0f, origin, scale, 0, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/StreamGougeLayer.png b/Graphics/Metaballs/StreamGougeLayer.png new file mode 100644 index 0000000000..826907fa0f Binary files /dev/null and b/Graphics/Metaballs/StreamGougeLayer.png differ diff --git a/Graphics/Metaballs/StreamGougeMetaball.cs b/Graphics/Metaballs/StreamGougeMetaball.cs new file mode 100644 index 0000000000..0099af636c --- /dev/null +++ b/Graphics/Metaballs/StreamGougeMetaball.cs @@ -0,0 +1,103 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Metaballs +{ + public class StreamGougeMetaball : Metaball + { + public class CosmicParticle + { + public float Size; + + public Vector2 Velocity; + + public Vector2 Center; + + public CosmicParticle(Vector2 center, Vector2 velocity, float size) + { + Center = center; + Velocity = velocity; + Size = size; + } + + public void Update() + { + Center += Velocity; + Velocity *= 0.96f; + Size *= 0.91f; + } + } + + public static Asset LayerAsset + { + get; + private set; + } + + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.AfterProjectiles; + + public override Color EdgeColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f); + + public override void Load() + { + if (Main.netMode == NetmodeID.Server) + return; + + // Load the layer asset wrapper. + LayerAsset = ModContent.Request($"CalamityMod/Graphics/Metaballs/StreamGougeLayer", AssetRequestMode.ImmediateLoad); + } + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static void SpawnParticle(Vector2 position, Vector2 velocity, float size) => + Particles.Add(new(position, velocity, size)); + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (CosmicParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/Graphics/Metaballs/VoidGeneratorMetaball.cs b/Graphics/Metaballs/VoidGeneratorMetaball.cs new file mode 100644 index 0000000000..69029411f3 --- /dev/null +++ b/Graphics/Metaballs/VoidGeneratorMetaball.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball; + +namespace CalamityMod.Graphics.Metaballs +{ + public class VoidGeneratorMetaball : Metaball + { + public static List Particles + { + get; + private set; + } = new(); + + public override bool AnythingToDraw => Particles.Any(); + + public override IEnumerable Layers + { + get + { + yield return LayerAsset.Value; + } + } + + public override MetaballDrawLayer DrawContext => MetaballDrawLayer.BeforeProjectiles; + + public override Color EdgeColor => Color.Lerp(Color.Purple, Color.Black, 0.75f); + + public override void Update() + { + // Update all particle instances. + // Once sufficiently small, they vanish. + for (int i = 0; i < Particles.Count; i++) + Particles[i].Update(); + Particles.RemoveAll(p => p.Size <= 2f); + } + + public static CosmicParticle SpawnParticle(Vector2 position, Vector2 velocity, float size) + { + CosmicParticle particle = new(position, velocity, size); + Particles.Add(particle); + + return particle; + } + + // Make the texture scroll. + public override Vector2 CalculateManualOffsetForLayer(int layerIndex) + { + return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f; + } + + public override void DrawInstances() + { + Texture2D tex = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; + + foreach (CosmicParticle particle in Particles) + { + Vector2 drawPosition = particle.Center - Main.screenPosition; + Vector2 origin = tex.Size() * 0.5f; + Vector2 scale = Vector2.One * particle.Size / tex.Size(); + Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); + } + } + } +} diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index e847402fc2..b8652d9518 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -16,7 +16,6 @@ using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Ravager; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; @@ -261,7 +260,7 @@ namespace CalamityMod.ILEditing self.dashTime = 15; return; } - + dashing = true; self.dashTime = 0; self.timeSinceLastDashStarted = 0; @@ -707,7 +706,6 @@ namespace CalamityMod.ILEditing private static void DrawFusableParticles(Terraria.On_Main.orig_SortDrawCacheWorms orig, Main self) { DeathAshParticle.DrawAll(); - FusableParticleManager.RenderAllFusableParticles(); if (Main.LocalPlayer.dye.Any(dyeItem => dyeItem.type == ModContent.ItemType())) Main.LocalPlayer.Calamity().ProfanedMoonlightAuroraDrawer?.Draw(Main.LocalPlayer.Center - Main.screenPosition, false, Main.GameViewMatrix.TransformationMatrix, Matrix.Identity); @@ -739,23 +737,23 @@ namespace CalamityMod.ILEditing Main.tileBatch.Draw(liquidTexture, position, liquidSize, colors, default(Vector2), 1f, SpriteEffects.None); return; } - + Texture2D slopeTexture = SelectLavaTexture(liquidType == 1 ? CustomLavaManagement.LavaSlopeTexture : TextureAssets.LiquidSlope[liquidType].Value, LiquidTileType.Slope); liquidSize.X += 18 * (slope - 1); switch (slope) { - case 1: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; - case 2: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; - case 3: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; - case 4: - Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); - break; + case 1: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; + case 2: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; + case 3: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; + case 4: + Main.tileBatch.Draw(slopeTexture, position, liquidSize, colors, Vector2.Zero, 1f, SpriteEffects.None); + break; } } @@ -797,7 +795,7 @@ namespace CalamityMod.ILEditing { initialColor = SelectLavaQuadColor(initialTexture, ref initialColor, liquidType == 1); - if (liquidType == ModContent.Find("CalamityMod/SunkenSeaWater").Slot || + if (liquidType == ModContent.Find("CalamityMod/SunkenSeaWater").Slot || liquidType == ModContent.Find("CalamityMod/SulphuricWater").Slot || liquidType == ModContent.Find("CalamityMod/SulphuricDepthsWater").Slot || liquidType == ModContent.Find("CalamityMod/UpperAbyssWater").Slot || @@ -923,7 +921,7 @@ namespace CalamityMod.ILEditing return; Tile above = CalamityUtils.ParanoidTileRetrieval(x, y - 1); - if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && + if (!Main.gamePaused && !above.HasTile && above.LiquidAmount <= 0 && Main.rand.NextBool(9) && Main.waterStyle == SulphuricWater.Type) { MediumMistParticle acidFoam = new(new(x * 16f + Main.rand.NextFloat(16f), y * 16f + 8f), -Vector2.UnitY.RotatedByRandom(0.67f) * Main.rand.NextFloat(1f, 2.4f), Color.LightSeaGreen, Color.White, 0.16f, 128f, 0.02f); diff --git a/Items/Accessories/CorruptFlask.png b/Items/Accessories/CorruptFlask.png index 373c8d6896..55856d02fb 100644 Binary files a/Items/Accessories/CorruptFlask.png and b/Items/Accessories/CorruptFlask.png differ diff --git a/Items/Accessories/CrimsonFlask.png b/Items/Accessories/CrimsonFlask.png index 9ab724f8a2..4e11feff1d 100644 Binary files a/Items/Accessories/CrimsonFlask.png and b/Items/Accessories/CrimsonFlask.png differ diff --git a/Items/Accessories/NebulousCore.cs b/Items/Accessories/NebulousCore.cs index 04f11cc140..1806d72212 100644 --- a/Items/Accessories/NebulousCore.cs +++ b/Items/Accessories/NebulousCore.cs @@ -22,9 +22,9 @@ namespace CalamityMod.Items.Accessories public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.35f * num, 0.05f * num, 0.35f * num); + float projLighting = Main.rand.Next(90, 111) * 0.01f; + projLighting *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.35f * projLighting, 0.05f * projLighting, 0.35f * projLighting); } public override void UpdateAccessory(Player player, bool hideVisual) @@ -36,61 +36,60 @@ namespace CalamityMod.Items.Accessories float knockBack = 3f; if (Main.rand.NextBool(15)) { - int num = 0; + int numProj = 0; for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].type == ModContent.ProjectileType()) { - num++; + numProj++; } } var source = player.GetSource_Accessory(Item); - if (Main.rand.Next(15) >= num && num < 10) + if (Main.rand.Next(15) >= numProj && numProj < 10) { - int num2 = 50; - int num3 = 24; - int num4 = 90; - for (int j = 0; j < num2; j++) + int spawnRadius = 24; + int backupSpawnRadius = 90; + for (int j = 0; j < 50; j++) { - int num5 = Main.rand.Next(200 - j * 2, 400 + j * 2); + int randomProjOffset = Main.rand.Next(200 - j * 2, 400 + j * 2); Vector2 center = player.Center; - center.X += (float)Main.rand.Next(-num5, num5 + 1); - center.Y += (float)Main.rand.Next(-num5, num5 + 1); - if (!Collision.SolidCollision(center, num3, num3) && !Collision.WetCollision(center, num3, num3)) + center.X += (float)Main.rand.Next(-randomProjOffset, randomProjOffset + 1); + center.Y += (float)Main.rand.Next(-randomProjOffset, randomProjOffset + 1); + if (!Collision.SolidCollision(center, spawnRadius, spawnRadius) && !Collision.WetCollision(center, spawnRadius, spawnRadius)) { - center.X += (float)(num3 / 2); - center.Y += (float)(num3 / 2); + center.X += (float)(spawnRadius / 2); + center.Y += (float)(spawnRadius / 2); if (Collision.CanHit(new Vector2(player.Center.X, player.position.Y), 1, 1, center, 1, 1) || Collision.CanHit(new Vector2(player.Center.X, player.position.Y - 50f), 1, 1, center, 1, 1)) { - int num6 = (int)center.X / 16; - int num7 = (int)center.Y / 16; - bool flag = false; - if (Main.rand.NextBool(3) && Main.tile[num6, num7] != null && Main.tile[num6, num7].WallType > 0) + int projTileX = (int)center.X / 16; + int projTileY = (int)center.Y / 16; + bool canSpawnProj = false; + if (Main.rand.NextBool(3) && Main.tile[projTileX, projTileY] != null && Main.tile[projTileX, projTileY].WallType > 0) { - flag = true; + canSpawnProj = true; } else { - center.X -= (float)(num4 / 2); - center.Y -= (float)(num4 / 2); - if (Collision.SolidCollision(center, num4, num4)) + center.X -= (float)(backupSpawnRadius / 2); + center.Y -= (float)(backupSpawnRadius / 2); + if (Collision.SolidCollision(center, backupSpawnRadius, backupSpawnRadius)) { - center.X += (float)(num4 / 2); - center.Y += (float)(num4 / 2); - flag = true; + center.X += (float)(backupSpawnRadius / 2); + center.Y += (float)(backupSpawnRadius / 2); + canSpawnProj = true; } } - if (flag) + if (canSpawnProj) { for (int k = 0; k < Main.maxProjectiles; k++) { if (Main.projectile[k].active && Main.projectile[k].owner == player.whoAmI && Main.projectile[k].type == ModContent.ProjectileType() && (center - Main.projectile[k].Center).Length() < 48f) { - flag = false; + canSpawnProj = false; break; } } - if (flag && Main.myPlayer == player.whoAmI) + if (canSpawnProj && Main.myPlayer == player.whoAmI) { Projectile.NewProjectile(source, center.X, center.Y, 0f, 0f, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); return; diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index b3dfb4b051..24f98f4393 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -43,9 +43,9 @@ namespace CalamityMod.Items.Accessories int myPlayer = Main.myPlayer; if (Main.player[myPlayer].team == player.team && player.team != 0) { - float num = player.position.X - Main.player[myPlayer].position.X; - float num2 = player.position.Y - Main.player[myPlayer].position.Y; - if ((float)Math.Sqrt(num * num + num2 * num2) < 800f) + float teamPlayerXDist = player.position.X - Main.player[myPlayer].position.X; + float teamPlayerYDist = player.position.Y - Main.player[myPlayer].position.Y; + if ((float)Math.Sqrt(teamPlayerXDist * teamPlayerXDist + teamPlayerYDist * teamPlayerYDist) < 800f) Main.player[myPlayer].AddBuff(BuffID.PaladinsShield, 20); } } diff --git a/Items/Accessories/ToxicHeart.cs b/Items/Accessories/ToxicHeart.cs index e926e8c9b0..3c74092b44 100644 --- a/Items/Accessories/ToxicHeart.cs +++ b/Items/Accessories/ToxicHeart.cs @@ -27,9 +27,8 @@ namespace CalamityMod.Items.Accessories player.buffImmune[ModContent.BuffType()] = true; int plagueCounter = 0; Lighting.AddLight((int)(player.Center.X / 16f), (int)(player.Center.Y / 16f), 0.05f, 1f, 0.1f); - int num = ModContent.BuffType(); - float num2 = 300f; - bool flag = plagueCounter % 60 == 0; + int plagueDebuff = ModContent.BuffType(); + bool shouldInflictPlague = plagueCounter % 60 == 0; int auraDamage = (int)player.GetBestClassDamage().ApplyTo(50); int random = Main.rand.Next(10); var source = player.GetSource_Accessory(Item); @@ -40,13 +39,13 @@ namespace CalamityMod.Items.Accessories for (int l = 0; l < Main.maxNPCs; l++) { NPC nPC = Main.npc[l]; - if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[num] && Vector2.Distance(player.Center, nPC.Center) <= num2) + if (nPC.IsAnEnemy() && !nPC.dontTakeDamage && !nPC.buffImmune[plagueDebuff] && Vector2.Distance(player.Center, nPC.Center) <= 300f) { - if (nPC.FindBuffIndex(num) == -1) + if (nPC.FindBuffIndex(plagueDebuff) == -1) { - nPC.AddBuff(num, 120, false); + nPC.AddBuff(plagueDebuff, 120, false); } - if (flag) + if (shouldInflictPlague) { if (player.whoAmI == Main.myPlayer) { diff --git a/Items/Accessories/Wings/AureateBooster.cs b/Items/Accessories/Wings/AureateBooster.cs index 9e2c91eebd..5e659207b6 100644 --- a/Items/Accessories/Wings/AureateBooster.cs +++ b/Items/Accessories/Wings/AureateBooster.cs @@ -38,12 +38,12 @@ namespace CalamityMod.Items.Accessories.Wings SoundEngine.PlaySound(SoundID.Item13, player.Center); player.rocketDelay2 = 60; } - int num66 = 2; + int dustAmt = 2; if (player.controlUp) { - num66 = 4; + dustAmt = 4; } - for (int num67 = 0; num67 < num66; num67++) + for (int i = 0; i < dustAmt; i++) { int type = 6; float scale = 1.75f; @@ -53,27 +53,27 @@ namespace CalamityMod.Items.Accessories.Wings { x = player.position.X + (float)(player.width / 2) - 26f; } - float num68 = player.position.Y + (float)player.height - 18f; - if (num67 == 1 || num67 == 3) + float dustYPos = player.position.Y + (float)player.height - 18f; + if (i == 1 || i == 3) { x = player.position.X + (float)(player.width / 2) + 8f; if (player.direction > 0) { x = player.position.X + (float)(player.width / 2) - 20f; } - num68 += 6f; + dustYPos += 6f; } - if (num67 > 1) + if (i > 1) { - num68 += player.velocity.Y; + dustYPos += player.velocity.Y; } - int num69 = Dust.NewDust(new Vector2(x, num68), 8, 8, type, 0f, 0f, alpha, default, scale); - Dust dust = Main.dust[num69]; + int boosterDust = Dust.NewDust(new Vector2(x, dustYPos), 8, 8, type, 0f, 0f, alpha, default, scale); + Dust dust = Main.dust[boosterDust]; dust.velocity.X *= 0.1f; - dust.velocity.Y = Main.dust[num69].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; + dust.velocity.Y = Main.dust[boosterDust].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; dust.noGravity = true; dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); - if (num66 == 4) + if (dustAmt == 4) { dust.velocity.Y += 6f; } diff --git a/Items/Accessories/Wings/DrewsWings.cs b/Items/Accessories/Wings/DrewsWings.cs index 279ab88e13..cb05b0c66b 100644 --- a/Items/Accessories/Wings/DrewsWings.cs +++ b/Items/Accessories/Wings/DrewsWings.cs @@ -31,19 +31,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/HadalMantle.cs b/Items/Accessories/Wings/HadalMantle.cs index aa76760ff8..a751b2333b 100644 --- a/Items/Accessories/Wings/HadalMantle.cs +++ b/Items/Accessories/Wings/HadalMantle.cs @@ -40,19 +40,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 6, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/MOAB.cs b/Items/Accessories/Wings/MOAB.cs index 37d6226b85..4fa0599fa1 100644 --- a/Items/Accessories/Wings/MOAB.cs +++ b/Items/Accessories/Wings/MOAB.cs @@ -69,10 +69,10 @@ namespace CalamityMod.Items.Accessories.Wings { yStart += player.velocity.Y; } - int num69 = Dust.NewDust(new Vector2(xStart, yStart), 8, 8, type, 0f, 0f, alpha, default, scale); - Dust dust = Main.dust[num69]; + int boosterDust = Dust.NewDust(new Vector2(xStart, yStart), 8, 8, type, 0f, 0f, alpha, default, scale); + Dust dust = Main.dust[boosterDust]; dust.velocity.X *= 0.1f; - dust.velocity.Y = Main.dust[num69].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; + dust.velocity.Y = Main.dust[boosterDust].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; dust.noGravity = true; dust.shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); if (dustAmt == 4) diff --git a/Items/Accessories/Wings/SilvaWings.cs b/Items/Accessories/Wings/SilvaWings.cs index de0edb4db6..0b24869c64 100644 --- a/Items/Accessories/Wings/SilvaWings.cs +++ b/Items/Accessories/Wings/SilvaWings.cs @@ -41,19 +41,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 157, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/SoulofCryogen.cs b/Items/Accessories/Wings/SoulofCryogen.cs index e1986d598f..718a2de574 100644 --- a/Items/Accessories/Wings/SoulofCryogen.cs +++ b/Items/Accessories/Wings/SoulofCryogen.cs @@ -33,9 +33,9 @@ namespace CalamityMod.Items.Accessories.Wings public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * num, 0.3f * num, 0.3f * num); + float lightOffset = (float)Main.rand.Next(90, 111) * 0.01f; + lightOffset *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * lightOffset, 0.3f * lightOffset, 0.3f * lightOffset); } public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) diff --git a/Items/Accessories/Wings/StarlightWings.cs b/Items/Accessories/Wings/StarlightWings.cs index e132c20b50..1f05487c5a 100644 --- a/Items/Accessories/Wings/StarlightWings.cs +++ b/Items/Accessories/Wings/StarlightWings.cs @@ -40,19 +40,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 173, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 173, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/TarragonWings.cs b/Items/Accessories/Wings/TarragonWings.cs index 6e44ccd393..b64b5c2d6e 100644 --- a/Items/Accessories/Wings/TarragonWings.cs +++ b/Items/Accessories/Wings/TarragonWings.cs @@ -43,19 +43,19 @@ namespace CalamityMod.Items.Accessories.Wings if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } player.noFallDmg = true; } diff --git a/Items/Accessories/Wings/TracersCelestial.cs b/Items/Accessories/Wings/TracersCelestial.cs index 4ed7748604..c40e9d5f4a 100644 --- a/Items/Accessories/Wings/TracersCelestial.cs +++ b/Items/Accessories/Wings/TracersCelestial.cs @@ -34,19 +34,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 107, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 107, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } CalamityPlayer modPlayer = player.Calamity(); player.accRunSpeed = 8f; diff --git a/Items/Accessories/Wings/TracersElysian.cs b/Items/Accessories/Wings/TracersElysian.cs index c09a119136..bf270f6390 100644 --- a/Items/Accessories/Wings/TracersElysian.cs +++ b/Items/Accessories/Wings/TracersElysian.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, Main.rand.NextBool() ? 206 : 173, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, Main.rand.NextBool() ? 206 : 173, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } CalamityPlayer modPlayer = player.Calamity(); player.accRunSpeed = 8.5f; diff --git a/Items/Accessories/Wings/TracersSeraph.cs b/Items/Accessories/Wings/TracersSeraph.cs index 6feb6dcf59..55063ce270 100644 --- a/Items/Accessories/Wings/TracersSeraph.cs +++ b/Items/Accessories/Wings/TracersSeraph.cs @@ -37,19 +37,19 @@ namespace CalamityMod.Items.Accessories.Wings { if (player.controlJump && player.wingTime > 0f && player.jump == 0 && player.velocity.Y != 0f && !hideVisual) { - int num59 = 4; + int dustXOffset = 4; if (player.direction == 1) { - num59 = -40; + dustXOffset = -40; } - int num60 = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)num59, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); - Main.dust[num60].noGravity = true; - Main.dust[num60].velocity *= 0.3f; + int flightDust = Dust.NewDust(new Vector2(player.position.X + (float)(player.width / 2) + (float)dustXOffset, player.position.Y + (float)(player.height / 2) - 15f), 30, 30, 91, 0f, 0f, 100, default, 2.4f); + Main.dust[flightDust].noGravity = true; + Main.dust[flightDust].velocity *= 0.3f; if (Main.rand.NextBool(10)) { - Main.dust[num60].fadeIn = 2f; + Main.dust[flightDust].fadeIn = 2f; } - Main.dust[num60].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); + Main.dust[flightDust].shader = GameShaders.Armor.GetSecondaryShader(player.cWings, player); } CalamityPlayer modPlayer = player.Calamity(); player.accRunSpeed = 9f; diff --git a/Items/Armor/DesertProwler/DesertProwlerSet.cs b/Items/Armor/DesertProwler/DesertProwlerSet.cs index c65a5bc236..36bb5313e7 100644 --- a/Items/Armor/DesertProwler/DesertProwlerSet.cs +++ b/Items/Armor/DesertProwler/DesertProwlerSet.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Armor.DesertProwler private void ActivateSetBonus(Terraria.On_Player.orig_KeyDoubleTap orig, Player player, int keyDir) { - if (keyDir == 0 && HasArmorSet(player) && !player.mount.Active) + if (keyDir == (Main.ReversedUpDownArmorSetBonuses ? 1 : 0) && HasArmorSet(player) && !player.mount.Active) { // The set bonus can only be activated if the player does not have the cooldown. if (!player.Calamity().cooldowns.TryGetValue(SandsmokeBomb.ID, out CooldownInstance cd)) @@ -166,7 +166,8 @@ namespace CalamityMod.Items.Armor.DesertProwler if (setBonusIndex != -1) { - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextValueFromModItem("AbilityBrief")); + string dir = Main.ReversedUpDownArmorSetBonuses ? "UP" : "DOWN"; + TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("AbilityBrief").Format(dir)); setBonus1.OverrideColor = Color.Lerp(new Color(255, 229, 156), new Color(233, 225, 198), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); tooltips.Insert(setBonusIndex + 1, setBonus1); diff --git a/Items/Armor/Wulfrum/WulfrumSet.cs b/Items/Armor/Wulfrum/WulfrumSet.cs index 4329df01e5..bcfb75ee28 100644 --- a/Items/Armor/Wulfrum/WulfrumSet.cs +++ b/Items/Armor/Wulfrum/WulfrumSet.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Items.Armor.Wulfrum private void ActivateSetBonus(Terraria.On_Player.orig_KeyDoubleTap orig, Player player, int keyDir) { - if (keyDir == 0 && HasArmorSet(player) && !player.mount.Active) + if (keyDir == (Main.ReversedUpDownArmorSetBonuses ? 1 : 0) && HasArmorSet(player) && !player.mount.Active) { //Only activate if no cooldown & available scrap. if (player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out CooldownInstance cd)) @@ -84,7 +84,7 @@ namespace CalamityMod.Items.Armor.Wulfrum else if (player.HasItem(ModContent.ItemType())) { player.ConsumeItem(ModContent.ItemType()); - //I Thiiiinnnk there's no need to add mp syncing packets sicne cooldowns get auto synced right. + //I Thiiiinnnk there's no need to add mp syncing packets since cooldowns get auto synced right. player.AddCooldown(WulfrumBastion.ID, BastionCooldown + BastionTime); //Though do i need to sync that or is the player inventory auto synced? DummyCannon.SetDefaults(ItemType()); @@ -228,7 +228,8 @@ namespace CalamityMod.Items.Armor.Wulfrum if (setBonusIndex != -1) { - TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextValueFromModItem("AbilityBrief")); + string dir = Main.ReversedUpDownArmorSetBonuses ? "UP" : "DOWN"; + TooltipLine setBonus1 = new TooltipLine(item.Mod, "CalamityMod:SetBonus1", CalamityUtils.GetTextFromModItem("AbilityBrief").Format(dir)); setBonus1.OverrideColor = Color.Lerp(new Color(194, 255, 67), new Color(112, 244, 244), 0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 3f)); tooltips.Insert(setBonusIndex + 1, setBonus1); diff --git a/Items/BaseItems/HeldOnlyItem.cs b/Items/BaseItems/HeldOnlyItem.cs index 5acf595f35..80ddb78e85 100644 --- a/Items/BaseItems/HeldOnlyItem.cs +++ b/Items/BaseItems/HeldOnlyItem.cs @@ -22,7 +22,6 @@ namespace CalamityMod.Items.BaseItems Terraria.UI.On_ItemSlot.LeftClick_ItemArray_int_int += LockMouseToSpecialItem; Terraria.UI.On_ItemSlot.Draw_SpriteBatch_ItemArray_int_int_Vector2_Color += DrawSpecial; } - private void DrawSpecial(Terraria.UI.On_ItemSlot.orig_Draw_SpriteBatch_ItemArray_int_int_Vector2_Color orig, SpriteBatch sb, Item[] inv, int context, int slot, Vector2 position, Color color) { if (inv[slot].ModItem is HeldOnlyItem && !(inv[slot].ModItem as HeldOnlyItem).VisibleInUI) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index cbce4e751d..201be331ff 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1597,7 +1597,7 @@ namespace CalamityMod.Items public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) { - bool flag = false; + bool hasEnoughAmmo = false; bool canShoot = false; for (int i = 54; i < Main.InventorySlotsTotal; i++) @@ -1605,12 +1605,12 @@ namespace CalamityMod.Items if (player.inventory[i].ammo == item.useAmmo && (player.inventory[i].stack >= ammoConsumed || !player.inventory[i].consumable)) { canShoot = true; - flag = true; + hasEnoughAmmo = true; break; } } - if (!flag) + if (!hasEnoughAmmo) { for (int j = 0; j < 54; j++) { @@ -1627,7 +1627,7 @@ namespace CalamityMod.Items public static void ConsumeAdditionalAmmo(Player player, Item item, int ammoConsumed) { Item itemAmmo = new Item(); - bool flag = false; + bool hasEnoughAmmo = false; bool dontConsumeAmmo = false; for (int i = 54; i < Main.InventorySlotsTotal; i++) @@ -1635,12 +1635,12 @@ namespace CalamityMod.Items if (player.inventory[i].ammo == item.useAmmo && (player.inventory[i].stack >= ammoConsumed || !player.inventory[i].consumable)) { itemAmmo = player.inventory[i]; - flag = true; + hasEnoughAmmo = true; break; } } - if (!flag) + if (!hasEnoughAmmo) { for (int j = 0; j < 54; j++) { diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index d2bb6cff2e..42f94f8953 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -93,7 +93,7 @@ namespace CalamityMod.Items { ItemID.DemonScythe, Do(AutoReuse, DamageExact(33)) }, { ItemID.DyeTradersScimitar, Do(AutoReuse, UseTurn, DamageExact(24)) }, // Exotic Scimitar { ItemID.ElectrosphereLauncher, Do(DamageRatio(1.1f)) }, - { ItemID.ElfMelter, Do(DamageExact(94), ShootSpeedDelta(+3f)) }, + { ItemID.ElfMelter, Do(DamageExact(62), ShootSpeedDelta(+5f)) }, { ItemID.EmeraldStaff, Do(DamageExact(27)) }, { ItemID.EmpressBlade, Do(AutoReuse, DamageExact(60), UseExact(20)) }, // Terraprisma { ItemID.EnchantedBoomerang, Do(DamageExact(24)) }, diff --git a/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs b/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs index bdbdcf864b..6b0a40d1e4 100644 --- a/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs +++ b/Items/Fishing/BrimstoneCragCatches/DragoonDrizzlefish.cs @@ -1,6 +1,10 @@ -using CalamityMod.Projectiles.Ranged; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -10,6 +14,9 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public class DragoonDrizzlefish : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Fishing"; + + public bool ballShot = true; + public int shotCounter = 0; public override void SetStaticDefaults() { Item.staff[Item.type] = true; //so it doesn't look weird af when holding it @@ -17,7 +24,7 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches public override void SetDefaults() { - Item.damage = 20; + Item.damage = 15; Item.DamageType = DamageClass.Ranged; Item.width = 42; Item.height = 38; @@ -25,31 +32,108 @@ namespace CalamityMod.Items.Fishing.BrimstoneCragCatches Item.useAnimation = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 2f; + Item.knockBack = 1.1f; Item.value = CalamityGlobalItem.Rarity3BuyPrice; Item.rare = ItemRarityID.Orange; Item.UseSound = SoundID.Item20; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; + Item.useAmmo = AmmoID.Gel; // for GFB + } + public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); + public override bool CanUseItem(Player player) + { + if (!Main.zenithWorld) + { + return true; + } + if (player.altFunctionUse == 2) + { + if (Main.zenithWorld) + { + CalamityGlobalItem.HasEnoughAmmo(player, Item, 5); + return true; + } + else + return false; + } + else + return true; } - //so it looks normal when holding - public override Vector2? HoldoutOrigin() => new Vector2(10, 10); + public override Vector2? HoldoutOrigin() => new Vector2(7, 7); + public override bool AltFunctionUse(Player player) => Main.zenithWorld ? true : false; + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.zenithWorld && player.altFunctionUse == 2 && player.Calamity().dragoonDrizzlefishGelBoost < 6) + return true; + else + return false; + } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - velocity = velocity.RotatedByRandom(MathHelper.ToRadians(10f)); - int shotType = ModContent.ProjectileType(); - if (Main.rand.NextBool()) + if (Main.zenithWorld && player.altFunctionUse == 2) { - shotType = ModContent.ProjectileType(); + //GFB stuff + if (player.Calamity().dragoonDrizzlefishGelBoost < 6) + { + player.Calamity().dragoonDrizzlefishGelBoost++; + SoundStyle roar = Sunskater.DeathSound; + SoundEngine.PlaySound(roar with { Pitch = 0.3f }, player.Center); + SoundEngine.PlaySound(SoundID.Item2 with { Pitch = 0.3f }, player.Center); + CombatText.NewText(player.Hitbox, Color.OrangeRed, ":)"); + for (int i = 0; i <= 11; i++) + { + Vector2 hVelocity = Main.rand.NextVector2Unit(); + hVelocity.X *= 0.66f; + hVelocity *= Main.rand.NextFloat(1f, 2f); + + int heart = Gore.NewGore(player.GetSource_FromThis(), player.Center + Main.rand.NextVector2Circular(14, 14), hVelocity, 331, Main.rand.NextFloat(0.2f, 1.3f)); + Main.gore[heart].sticky = false; + Main.gore[heart].velocity *= 0.4f; + Main.gore[heart].velocity.Y -= 0.7f; + } + } } else { - shotType = ModContent.ProjectileType(); + if (Main.zenithWorld) + { + if (Main.rand.NextBool(25) && player.Calamity().dragoonDrizzlefishGelBoost > 1) + { + SoundStyle roar = Sunskater.DeathSound; + SoundEngine.PlaySound(roar, player.Center); + player.Calamity().dragoonDrizzlefishGelBoost--; + } + if (player.Calamity().dragoonDrizzlefishGelBoost == 1 && Main.rand.NextBool(3)) + { + bool MADFISH = Main.rand.NextBool(4) ? true : false; + CombatText.NewText(player.Hitbox, Color.OrangeRed, MADFISH ? ">:(" : ":("); + SoundStyle roar = Sunskater.DeathSound; + SoundEngine.PlaySound(roar with { Pitch = -0.3f }, player.Center); + if (MADFISH) + player.AddBuff(ModContent.BuffType(), 240, true); + return false; + } + } + + velocity = velocity.RotatedByRandom(MathHelper.ToRadians(5.5f)); + int shotType = ModContent.ProjectileType(); + if (shotCounter < 3) + { + shotType = ModContent.ProjectileType(); + shotCounter++; + } + else + { + shotType = ModContent.ProjectileType(); + shotCounter = 0; + } + Projectile.NewProjectile(source, position, velocity, shotType, damage, knockback, player.whoAmI, 0f, Main.rand.Next(2)); } - Projectile.NewProjectile(source, position, velocity, shotType, damage, knockback, player.whoAmI, 0f, Main.rand.Next(2)); + return false; } } diff --git a/Items/Materials/AshesofCalamity.cs b/Items/Materials/AshesofCalamity.cs index ea39c61987..4edb13ab97 100644 --- a/Items/Materials/AshesofCalamity.cs +++ b/Items/Materials/AshesofCalamity.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.25f * num, 0.05f * num, 0.25f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.25f * brightness, 0.05f * brightness, 0.25f * brightness); } } } diff --git a/Items/Materials/BloodOrb.cs b/Items/Materials/BloodOrb.cs index a0619ff5dc..5360c10ad9 100644 --- a/Items/Materials/BloodOrb.cs +++ b/Items/Materials/BloodOrb.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.DataStructures; using Terraria.ModLoader; using Terraria.ID; @@ -10,12 +11,13 @@ namespace CalamityMod.Items.Materials public override void SetStaticDefaults() { Item.ResearchUnlockCount = 100; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(6, 4)); } public override void SetDefaults() { - Item.width = 18; - Item.height = 18; + Item.width = 16; + Item.height = 28; Item.maxStack = 9999; Item.value = Item.sellPrice(silver: 1, copper: 20); Item.rare = ItemRarityID.Blue; @@ -23,9 +25,9 @@ namespace CalamityMod.Items.Materials public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (Item.width / 2)) / 16f), (int)((Item.position.Y + (Item.height / 2)) / 16f), 0.75f * num, 0f, 0f); + float brightness = Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (Item.width / 2)) / 16f), (int)((Item.position.Y + (Item.height / 2)) / 16f), 0.75f * brightness, 0f, 0f); } public override void AddRecipes() diff --git a/Items/Materials/BloodOrb.png b/Items/Materials/BloodOrb.png index c1d024d4a7..f78d4d5b4c 100644 Binary files a/Items/Materials/BloodOrb.png and b/Items/Materials/BloodOrb.png differ diff --git a/Items/Materials/DarkPlasma.cs b/Items/Materials/DarkPlasma.cs index c162b90612..ca39e1fd37 100644 --- a/Items/Materials/DarkPlasma.cs +++ b/Items/Materials/DarkPlasma.cs @@ -28,9 +28,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * num, 0.45f * num, 0.7f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0f * brightness, 0.45f * brightness, 0.7f * brightness); } } } diff --git a/Items/Materials/DivineGeode.cs b/Items/Materials/DivineGeode.cs index a94403cae5..2f6acbc13d 100644 --- a/Items/Materials/DivineGeode.cs +++ b/Items/Materials/DivineGeode.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * num, 0.3f * num, 0f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * brightness, 0.3f * brightness, 0f * brightness); } } } diff --git a/Items/Materials/GalacticaSingularity.cs b/Items/Materials/GalacticaSingularity.cs index 52631ea105..5dc2bc2dd8 100644 --- a/Items/Materials/GalacticaSingularity.cs +++ b/Items/Materials/GalacticaSingularity.cs @@ -38,9 +38,9 @@ namespace CalamityMod.Items.Materials public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 1f * num, 0.3f * num, 0.3f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 1f * brightness, 0.3f * brightness, 0.3f * brightness); } } } diff --git a/Items/Materials/Polterplasm.cs b/Items/Materials/Polterplasm.cs index b976bece02..6a55c5c4f0 100644 --- a/Items/Materials/Polterplasm.cs +++ b/Items/Materials/Polterplasm.cs @@ -14,15 +14,15 @@ namespace CalamityMod.Items.Materials public override void SetStaticDefaults() { Item.ResearchUnlockCount = 25; - Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 5)); + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 6)); ItemID.Sets.AnimatesAsSoul[Type] = true; ItemID.Sets.SortingPriorityMaterials[Type] = 110; } public override void SetDefaults() { - Item.width = 12; - Item.height = 12; + Item.width = 24; + Item.height = 52; Item.maxStack = 9999; Item.value = Item.sellPrice(gold: 1); Item.rare = ItemRarityID.Purple; diff --git a/Items/Materials/Polterplasm.png b/Items/Materials/Polterplasm.png index e80d69386d..eacff5f4f7 100644 Binary files a/Items/Materials/Polterplasm.png and b/Items/Materials/Polterplasm.png differ diff --git a/Items/Materials/TwistingNether.cs b/Items/Materials/TwistingNether.cs index e293ea5378..e8b3336095 100644 --- a/Items/Materials/TwistingNether.cs +++ b/Items/Materials/TwistingNether.cs @@ -26,9 +26,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * num, 0.1f * num, 0.7f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * brightness, 0.1f * brightness, 0.7f * brightness); } } } diff --git a/Items/Materials/UnholyCore.cs b/Items/Materials/UnholyCore.cs index 34b8c96da5..4962d54429 100644 --- a/Items/Materials/UnholyCore.cs +++ b/Items/Materials/UnholyCore.cs @@ -16,8 +16,8 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - Item.width = 15; - Item.height = 12; + Item.width = 26; + Item.height = 46; Item.maxStack = 9999; Item.value = Item.sellPrice(silver: 80); Item.rare = ItemRarityID.Pink; diff --git a/Items/Materials/UnholyCore.png b/Items/Materials/UnholyCore.png index d13404b0e2..a69a956e27 100644 Binary files a/Items/Materials/UnholyCore.png and b/Items/Materials/UnholyCore.png differ diff --git a/Items/Materials/UnholyEssence.cs b/Items/Materials/UnholyEssence.cs index 1e1d21a7f2..217be5e725 100644 --- a/Items/Materials/UnholyEssence.cs +++ b/Items/Materials/UnholyEssence.cs @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Materials } public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * num, 0.3f * num, 0f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.45f * brightness, 0.3f * brightness, 0f * brightness); } } } diff --git a/Items/Materials/WulfrumMetalScrap.cs b/Items/Materials/WulfrumMetalScrap.cs index 0cd885b9fe..5752684df2 100644 --- a/Items/Materials/WulfrumMetalScrap.cs +++ b/Items/Materials/WulfrumMetalScrap.cs @@ -68,6 +68,7 @@ namespace CalamityMod.Items.Materials } public override void Load() => Terraria.On_Item.CanFillEmptyAmmoSlot += AvoidDefaultingToAmmoSlot; + private bool AvoidDefaultingToAmmoSlot(Terraria.On_Item.orig_CanFillEmptyAmmoSlot orig, Item self) { if (self.type == Type) diff --git a/Items/Materials/YharonSoulFragment.cs b/Items/Materials/YharonSoulFragment.cs index bf450c0800..f2b986749b 100644 --- a/Items/Materials/YharonSoulFragment.cs +++ b/Items/Materials/YharonSoulFragment.cs @@ -18,9 +18,9 @@ namespace CalamityMod.Items.Materials public override void Update(ref float gravity, ref float maxFallSpeed) { - float num = (float)Main.rand.Next(90, 111) * 0.01f; - num *= Main.essScale; - Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * num, 0.3f * num, 0.05f * num); + float brightness = (float)Main.rand.Next(90, 111) * 0.01f; + brightness *= Main.essScale; + Lighting.AddLight((int)((Item.position.X + (float)(Item.width / 2)) / 16f), (int)((Item.position.Y + (float)(Item.height / 2)) / 16f), 0.5f * brightness, 0.3f * brightness, 0.05f * brightness); } public override void SetDefaults() diff --git a/Items/Mounts/RimehoundMount.cs b/Items/Mounts/RimehoundMount.cs index f03f050846..6d7bc3e580 100644 --- a/Items/Mounts/RimehoundMount.cs +++ b/Items/Mounts/RimehoundMount.cs @@ -64,9 +64,9 @@ namespace CalamityMod.Items.Mounts public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity) { bool speed = Math.Abs(velocity.X) > mountedPlayer.mount.RunSpeed / 2f; - float num10 = (float)Math.Sign(mountedPlayer.velocity.X); - float num11 = 12f; - float num12 = 40f; + float direction = (float)Math.Sign(mountedPlayer.velocity.X); + float dustYOffset = 12f; + float dustXOffset = 40f; if (!speed) { mountedPlayer.basiliskCharge = 0f; @@ -92,19 +92,19 @@ namespace CalamityMod.Items.Mounts } if (mountedPlayer.cMount == 0) { - mountedPlayer.position += new Vector2(num10 * 24f, 0f); + mountedPlayer.position += new Vector2(direction * 24f, 0f); mountedPlayer.FloorVisuals(true); - mountedPlayer.position -= new Vector2(num10 * 24f, 0f); + mountedPlayer.position -= new Vector2(direction * 24f, 0f); } } - if (num10 == (float)mountedPlayer.direction) + if (direction == (float)mountedPlayer.direction) { for (int j = 0; j < (int)(3f * mountedPlayer.basiliskCharge); j++) { Dust dust = Main.dust[Dust.NewDust(mountedPlayer.BottomLeft, mountedPlayer.width, 6, 67, 0f, 0f, 0, default, 1f)]; - Vector2 value2 = mountedPlayer.Center + new Vector2(num10 * num12, num11); - dust.position = mountedPlayer.Center + new Vector2(num10 * (num12 - 2f), num11 - 6f + Main.rand.NextFloat() * 12f); - dust.velocity = (dust.position - value2).SafeNormalize(Vector2.Zero) * (3.5f + Main.rand.NextFloat() * 0.5f); + Vector2 dustVel = mountedPlayer.Center + new Vector2(direction * dustXOffset, dustYOffset); + dust.position = mountedPlayer.Center + new Vector2(direction * (dustXOffset - 2f), dustYOffset - 6f + Main.rand.NextFloat() * 12f); + dust.velocity = (dust.position - dustVel).SafeNormalize(Vector2.Zero) * (3.5f + Main.rand.NextFloat() * 0.5f); if (dust.velocity.Y < 0f) { Dust expr_808_cp_0_cp_0 = dust; diff --git a/Items/Placeables/Furniture/ResilientCandle.cs b/Items/Placeables/Furniture/ResilientCandle.cs index f490abe505..87c79ac75d 100644 --- a/Items/Placeables/Furniture/ResilientCandle.cs +++ b/Items/Placeables/Furniture/ResilientCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 34; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/ResilientCandle.png b/Items/Placeables/Furniture/ResilientCandle.png index d05ce51406..29c5480f8c 100644 Binary files a/Items/Placeables/Furniture/ResilientCandle.png and b/Items/Placeables/Furniture/ResilientCandle.png differ diff --git a/Items/Placeables/Furniture/SpitefulCandle.cs b/Items/Placeables/Furniture/SpitefulCandle.cs index 57568ede21..cef61b3d9b 100644 --- a/Items/Placeables/Furniture/SpitefulCandle.cs +++ b/Items/Placeables/Furniture/SpitefulCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 42; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/SpitefulCandle.png b/Items/Placeables/Furniture/SpitefulCandle.png index 2c512cef6c..48403fea34 100644 Binary files a/Items/Placeables/Furniture/SpitefulCandle.png and b/Items/Placeables/Furniture/SpitefulCandle.png differ diff --git a/Items/Placeables/Furniture/VigorousCandle.cs b/Items/Placeables/Furniture/VigorousCandle.cs index 83a994bcf7..f5457c0f4a 100644 --- a/Items/Placeables/Furniture/VigorousCandle.cs +++ b/Items/Placeables/Furniture/VigorousCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 38; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/VigorousCandle.png b/Items/Placeables/Furniture/VigorousCandle.png index fb18c15f40..ca1f8a3523 100644 Binary files a/Items/Placeables/Furniture/VigorousCandle.png and b/Items/Placeables/Furniture/VigorousCandle.png differ diff --git a/Items/Placeables/Furniture/WeightlessCandle.cs b/Items/Placeables/Furniture/WeightlessCandle.cs index 437f6f7bbc..76d6f8db0c 100644 --- a/Items/Placeables/Furniture/WeightlessCandle.cs +++ b/Items/Placeables/Furniture/WeightlessCandle.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Placeables.Furniture public new string LocalizationCategory => "Items.Placeables"; public override void SetDefaults() { - Item.width = 28; - Item.height = 40; + Item.width = 26; + Item.height = 36; Item.maxStack = 9999; Item.useTurn = true; Item.autoReuse = true; diff --git a/Items/Placeables/Furniture/WeightlessCandle.png b/Items/Placeables/Furniture/WeightlessCandle.png index c0168bcada..bf005cfb95 100644 Binary files a/Items/Placeables/Furniture/WeightlessCandle.png and b/Items/Placeables/Furniture/WeightlessCandle.png differ diff --git a/Items/Potions/Alcohol/BloodyMary.png b/Items/Potions/Alcohol/BloodyMary.png index 13c6fcf3ef..333f4ab986 100644 Binary files a/Items/Potions/Alcohol/BloodyMary.png and b/Items/Potions/Alcohol/BloodyMary.png differ diff --git a/Items/Potions/Alcohol/CinnamonRoll.png b/Items/Potions/Alcohol/CinnamonRoll.png index e6c6fb511c..66f03882a4 100644 Binary files a/Items/Potions/Alcohol/CinnamonRoll.png and b/Items/Potions/Alcohol/CinnamonRoll.png differ diff --git a/Items/Potions/Alcohol/Fireball.png b/Items/Potions/Alcohol/Fireball.png index 58a484de0e..48ba41816b 100644 Binary files a/Items/Potions/Alcohol/Fireball.png and b/Items/Potions/Alcohol/Fireball.png differ diff --git a/Items/Potions/Alcohol/MoscowMule.png b/Items/Potions/Alcohol/MoscowMule.png index 602654af71..9a3a129c08 100644 Binary files a/Items/Potions/Alcohol/MoscowMule.png and b/Items/Potions/Alcohol/MoscowMule.png differ diff --git a/Items/Potions/Alcohol/OddMushroom.cs b/Items/Potions/Alcohol/OddMushroom.cs index b90ad15881..6bb6eab159 100644 --- a/Items/Potions/Alcohol/OddMushroom.cs +++ b/Items/Potions/Alcohol/OddMushroom.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetDefaults() { - Item.width = 42; - Item.height = 48; + Item.width = 38; + Item.height = 50; Item.useTurn = true; Item.maxStack = 9999; Item.useAnimation = 17; diff --git a/Items/Potions/Alcohol/OddMushroom.png b/Items/Potions/Alcohol/OddMushroom.png index 81c156989f..947d323e19 100644 Binary files a/Items/Potions/Alcohol/OddMushroom.png and b/Items/Potions/Alcohol/OddMushroom.png differ diff --git a/Items/Potions/Alcohol/Tequila.png b/Items/Potions/Alcohol/Tequila.png index 6c5178cae7..8ef6726cd6 100644 Binary files a/Items/Potions/Alcohol/Tequila.png and b/Items/Potions/Alcohol/Tequila.png differ diff --git a/Items/Potions/Alcohol/TequilaSunrise.png b/Items/Potions/Alcohol/TequilaSunrise.png index e33013911e..30974d148a 100644 Binary files a/Items/Potions/Alcohol/TequilaSunrise.png and b/Items/Potions/Alcohol/TequilaSunrise.png differ diff --git a/Items/Potions/Alcohol/Vodka.png b/Items/Potions/Alcohol/Vodka.png index b64f3c0f1b..f1e7333959 100644 Binary files a/Items/Potions/Alcohol/Vodka.png and b/Items/Potions/Alcohol/Vodka.png differ diff --git a/Items/SummonItems/EyeofDesolation.cs b/Items/SummonItems/EyeofDesolation.cs index 96e352eb89..dab9ba5b48 100644 --- a/Items/SummonItems/EyeofDesolation.cs +++ b/Items/SummonItems/EyeofDesolation.cs @@ -67,31 +67,31 @@ namespace CalamityMod.Items.SummonItems safeBox.Height = 2500; spawnYAdd = 125; - int num52 = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; - int num53 = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; - int num54 = safeBox.Width / 2 / 16 + 1; - for (int num55 = num52 - num54; num55 <= num52 + num54; num55++) + int safeBoxTilesX = (int)(safeBox.X + (float)(safeBox.Width / 2)) / 16; + int safeBoxTilesY = (int)(safeBox.Y + (float)(safeBox.Height / 2)) / 16; + int safeBoxTilesWidth = safeBox.Width / 2 / 16 + 1; + for (int i = safeBoxTilesX - safeBoxTilesWidth; i <= safeBoxTilesX + safeBoxTilesWidth; i++) { - for (int num56 = num53 - num54; num56 <= num53 + num54; num56++) + for (int j = safeBoxTilesY - safeBoxTilesWidth; j <= safeBoxTilesY + safeBoxTilesWidth; j++) { - if (!WorldGen.InWorld(num55, num56, 2)) + if (!WorldGen.InWorld(i, j, 2)) continue; int xoffset = 0; int yoffset = 0; - if ((num55 == num52 - num54 || num55 == num52 + num54 || num56 == num53 - num54 || num56 == num53 + num54) && !Main.tile[num55 + xoffset, num56 + yoffset].HasTile) + if ((i == safeBoxTilesX - safeBoxTilesWidth || i == safeBoxTilesX + safeBoxTilesWidth || j == safeBoxTilesY - safeBoxTilesWidth || j == safeBoxTilesY + safeBoxTilesWidth) && !Main.tile[i + xoffset, j + yoffset].HasTile) { - Main.tile[num55 + xoffset, num56 + yoffset].TileType = (ushort)ModContent.TileType(); - Main.tile[num55 + xoffset, num56 + yoffset].Get().HasTile = true; + Main.tile[i + xoffset, j + yoffset].TileType = (ushort)ModContent.TileType(); + Main.tile[i + xoffset, j + yoffset].Get().HasTile = true; } if (Main.netMode == NetmodeID.Server) { - NetMessage.SendTileSquare(-1, num55 + xoffset, num56 + yoffset, 1, TileChangeType.None); + NetMessage.SendTileSquare(-1, i + xoffset, j + yoffset, 1, TileChangeType.None); } else { - WorldGen.SquareTileFrame(num55 + xoffset, num56 + yoffset, true); + WorldGen.SquareTileFrame(i + xoffset, j + yoffset, true); } } } diff --git a/Items/SummonItems/OldPowerCell.cs b/Items/SummonItems/OldPowerCell.cs index 119eb4cb92..8195e52b80 100644 --- a/Items/SummonItems/OldPowerCell.cs +++ b/Items/SummonItems/OldPowerCell.cs @@ -39,9 +39,9 @@ namespace CalamityMod.Items.SummonItems bool canSummon = false; if (player.Center.Y > Main.worldSurface * 16.0) { - int num = (int)player.Center.X / 16; - int num2 = (int)player.Center.Y / 16; - Tile tile = Framing.GetTileSafely(num, num2); + int playerTileX = (int)player.Center.X / 16; + int playerTileY = (int)player.Center.Y / 16; + Tile tile = Framing.GetTileSafely(playerTileX, playerTileY); if (tile.WallType == 87) canSummon = true; } diff --git a/Items/Tools/InfernaCutter.cs b/Items/Tools/InfernaCutter.cs index 15984d4cd9..227ccb8a6f 100644 --- a/Items/Tools/InfernaCutter.cs +++ b/Items/Tools/InfernaCutter.cs @@ -59,64 +59,64 @@ namespace CalamityMod.Items.Tools player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - float num339 = 0f; - float num340 = 0f; - float num341 = 0f; - float num342 = 0f; + float sparkYVel = 0f; + float sparkXVel = 0f; + float sparkYSpawn = 0f; + float sparkXSpawn = 0f; if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num339 = -7f; + sparkYVel = -7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num339 = -6f; - num340 = 2f; + sparkYVel = -6f; + sparkXVel = 2f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { - num339 = -4f; - num340 = 4f; + sparkYVel = -4f; + sparkXVel = 4f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num339 = -2f; - num340 = 6f; + sparkYVel = -2f; + sparkXVel = 6f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num340 = 7f; + sparkXVel = 7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 = 26f; + sparkXSpawn = 26f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num342 -= 4f; - num341 -= 20f; + sparkXSpawn -= 4f; + sparkYSpawn -= 20f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num341 += 6f; + sparkYSpawn += 6f; } if (player.direction == -1) { if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num342 -= 8f; + sparkXSpawn -= 8f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 -= 6f; + sparkXSpawn -= 6f; } } - num339 *= 1.5f; - num340 *= 1.5f; - num342 *= (float)player.direction; - num341 *= player.gravDir; + sparkYVel *= 1.5f; + sparkXVel *= 1.5f; + sparkXSpawn *= (float)player.direction; + sparkYSpawn *= player.gravDir; var source = player.GetSource_ItemUse(Item); int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage * 0.2f); - int spark = Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, (float)player.direction * num340, num339 * player.gravDir, ProjectileID.Spark, damage, 0f, player.whoAmI); + int spark = Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + sparkXSpawn, (float)(hitbox.Y + hitbox.Height / 2) + sparkYSpawn, (float)player.direction * sparkXVel, sparkYVel * player.gravDir, ProjectileID.Spark, damage, 0f, player.whoAmI); if (spark.WithinBounds(Main.maxProjectiles)) Main.projectile[spark].DamageType = DamageClass.Melee; } diff --git a/Items/Weapons/Magic/AlphaRay.cs b/Items/Weapons/Magic/AlphaRay.cs index 14350ef07e..b4e96df9b2 100644 --- a/Items/Weapons/Magic/AlphaRay.cs +++ b/Items/Weapons/Magic/AlphaRay.cs @@ -59,23 +59,23 @@ namespace CalamityMod.Items.Weapons.Magic } else { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 3; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 80f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + Vector2 laserSpawnPos = player.RotatedRelativePoint(player.MountedCenter, true); + float tenthPi = 0.314159274f; + int laserAmt = 3; + Vector2 laserVelocity = velocity; + laserVelocity.Normalize(); + laserVelocity *= 80f; + bool laserHitsTiles = Collision.CanHit(laserSpawnPos, 0, 0, laserSpawnPos + laserVelocity, 0, 0); + for (int i = 0; i < laserAmt; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float laserOffset = (float)i - ((float)laserAmt - 1f) / 2f; + Vector2 offsetSpawnPos = laserVelocity.RotatedBy((double)(tenthPi * laserOffset), default); + if (!laserHitsTiles) { - value9 -= vector7; + offsetSpawnPos -= laserVelocity; } - Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X * 1.5f, velocity.Y * 1.5f, type, (int)(damage * 0.8), knockback, player.whoAmI); - int laser = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X * 2f, velocity.Y * 2f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.4), knockback * 0.4f, player.whoAmI); + Projectile.NewProjectile(source, laserSpawnPos.X + offsetSpawnPos.X, laserSpawnPos.Y + offsetSpawnPos.Y, velocity.X * 1.5f, velocity.Y * 1.5f, type, (int)(damage * 0.8), knockback, player.whoAmI); + int laser = Projectile.NewProjectile(source, laserSpawnPos.X + offsetSpawnPos.X, laserSpawnPos.Y + offsetSpawnPos.Y, velocity.X * 2f, velocity.Y * 2f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.4), knockback * 0.4f, player.whoAmI); Main.projectile[laser].timeLeft = 120; Main.projectile[laser].tileCollide = false; } diff --git a/Items/Weapons/Magic/AsteroidStaff.cs b/Items/Weapons/Magic/AsteroidStaff.cs index bc438bcdaa..ae19993ce5 100644 --- a/Items/Weapons/Magic/AsteroidStaff.cs +++ b/Items/Weapons/Magic/AsteroidStaff.cs @@ -39,49 +39,49 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float meteorSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float meteorSpawnXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float meteorSpawnYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + meteorSpawnYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float meteorSpawnDist = (float)Math.Sqrt((double)(meteorSpawnXPos * meteorSpawnXPos + meteorSpawnYPos * meteorSpawnYPos)); + if ((float.IsNaN(meteorSpawnXPos) && float.IsNaN(meteorSpawnYPos)) || (meteorSpawnXPos == 0f && meteorSpawnYPos == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + meteorSpawnXPos = (float)player.direction; + meteorSpawnYPos = 0f; + meteorSpawnDist = meteorSpeed; } else { - num80 = num72 / num80; + meteorSpawnDist = meteorSpeed / meteorSpawnDist; } int asteroidAmt = 3; - for (int num113 = 0; num113 < asteroidAmt; num113++) + for (int i = 0; i < asteroidAmt; i++) { - vector2 = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + meteorSpawnXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + meteorSpawnYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (meteorSpawnYPos < 0f) { - num79 *= -1f; + meteorSpawnYPos *= -1f; } - if (num79 < 20f) + if (meteorSpawnYPos < 20f) { - num79 = 20f; + meteorSpawnYPos = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, type, damage, knockback, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + meteorSpawnDist = (float)Math.Sqrt((double)(meteorSpawnXPos * meteorSpawnXPos + meteorSpawnYPos * meteorSpawnYPos)); + meteorSpawnDist = meteorSpeed / meteorSpawnDist; + meteorSpawnXPos *= meteorSpawnDist; + meteorSpawnYPos *= meteorSpawnDist; + float meteorSpawnXOffset = meteorSpawnXPos; + float meteorSpawnYOffset = meteorSpawnYPos + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, meteorSpawnXOffset * 0.75f, meteorSpawnYOffset * 0.75f, type, damage, knockback, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); } return false; } diff --git a/Items/Weapons/Magic/AstralachneaStaff.cs b/Items/Weapons/Magic/AstralachneaStaff.cs index 1c1724dfee..0469e4db18 100644 --- a/Items/Weapons/Magic/AstralachneaStaff.cs +++ b/Items/Weapons/Magic/AstralachneaStaff.cs @@ -38,14 +38,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - int num73 = damage; - float num74 = knockback; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + int j = Main.myPlayer; + float fangSpeed = Item.shootSpeed; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); int spikeAmount = 4; if (Main.rand.NextBool(3)) { @@ -59,20 +57,20 @@ namespace CalamityMod.Items.Weapons.Magic { spikeAmount += 2; } - for (int num131 = 0; num131 < spikeAmount; num131++) + for (int i = 0; i < spikeAmount; i++) { - float num132 = num78; - float num133 = num79; - float num134 = 0.05f * (float)num131; - num132 += (float)Main.rand.Next(-400, 400) * num134; - num133 += (float)Main.rand.Next(-400, 400) * num134; - num80 = (float)Math.Sqrt((double)(num132 * num132 + num133 * num133)); - num80 = num72 / num80; - num132 *= num80; - num133 *= num80; - float x2 = vector2.X; - float y2 = vector2.Y; - Projectile.NewProjectile(source, x2, y2, num132, num133, ModContent.ProjectileType(), num73, num74, i, 0f, 0f); + float fangSpawnX = mouseXDist; + float fangSpawnY = mouseYDist; + float offsetDampener = 0.05f * (float)i; + fangSpawnX += (float)Main.rand.Next(-400, 400) * offsetDampener; + fangSpawnY += (float)Main.rand.Next(-400, 400) * offsetDampener; + float fangDistance = (float)Math.Sqrt((double)(fangSpawnX * fangSpawnX + fangSpawnY * fangSpawnY)); + fangDistance = fangSpeed / fangDistance; + fangSpawnX *= fangDistance; + fangSpawnY *= fangDistance; + float x2 = realPlayerPos.X; + float y2 = realPlayerPos.Y; + Projectile.NewProjectile(source, x2, y2, fangSpawnX, fangSpawnY, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/AuguroftheElements.cs b/Items/Weapons/Magic/AuguroftheElements.cs index 50bfc5e410..72f04b7502 100644 --- a/Items/Weapons/Magic/AuguroftheElements.cs +++ b/Items/Weapons/Magic/AuguroftheElements.cs @@ -35,27 +35,27 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - Vector2 value2 = new Vector2(num78, num79); - value2.Normalize(); - Vector2 value3 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value3.Normalize(); - value2 = value2 * 6f + value3; - value2.Normalize(); - value2 *= Item.shootSpeed; - float num91 = (float)Main.rand.Next(10, 50) * 0.001f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + Vector2 tentacleVelocity = new Vector2(mouseXDist, mouseYDist); + tentacleVelocity.Normalize(); + Vector2 tentacleRandVelocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + tentacleRandVelocity.Normalize(); + tentacleVelocity = tentacleVelocity * 6f + tentacleRandVelocity; + tentacleVelocity.Normalize(); + tentacleVelocity *= Item.shootSpeed; + float tentacleYDirection = (float)Main.rand.Next(10, 50) * 0.001f; if (Main.rand.NextBool()) { - num91 *= -1f; + tentacleYDirection *= -1f; } - float num92 = (float)Main.rand.Next(10, 50) * 0.001f; + float tentacleXDirection = (float)Main.rand.Next(10, 50) * 0.001f; if (Main.rand.NextBool()) { - num92 *= -1f; + tentacleXDirection *= -1f; } - Projectile.NewProjectile(source, vector2, value2, type, damage, knockback, player.whoAmI, num92, num91); + Projectile.NewProjectile(source, realPlayerPos, tentacleVelocity, type, damage, knockback, player.whoAmI, tentacleXDirection, tentacleYDirection); return false; } diff --git a/Items/Weapons/Magic/BloodBath.cs b/Items/Weapons/Magic/BloodBath.cs index 43c702f8c4..7f291993cd 100644 --- a/Items/Weapons/Magic/BloodBath.cs +++ b/Items/Weapons/Magic/BloodBath.cs @@ -40,57 +40,57 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float bloodSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYPos = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXPos * mouseXPos + mouseYPos * mouseYPos)); + if ((float.IsNaN(mouseXPos) && float.IsNaN(mouseYPos)) || (mouseXPos == 0f && mouseYPos == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXPos = (float)player.direction; + mouseYPos = 0f; + mouseDistance = bloodSpeed; } else { - num80 = num72 / num80; + mouseDistance = bloodSpeed / mouseDistance; } - int num107 = 2; + int bloodAmt = 2; if (Main.rand.NextBool(3)) { - num107++; + bloodAmt++; } if (Main.rand.NextBool(3)) { - num107++; + bloodAmt++; } - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < bloodAmt; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXPos = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYPos = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYPos < 0f) { - num79 *= -1f; + mouseYPos *= -1f; } - if (num79 < 20f) + if (mouseYPos < 20f) { - num79 = 20f; + mouseYPos = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXPos * mouseXPos + mouseYPos * mouseYPos)); + mouseDistance = bloodSpeed / mouseDistance; + mouseXPos *= mouseDistance; + mouseYPos *= mouseDistance; + float speedX4 = mouseXPos + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYPos + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/ClamorNoctus.cs b/Items/Weapons/Magic/ClamorNoctus.cs index ec774f15c5..fc307c109e 100644 --- a/Items/Weapons/Magic/ClamorNoctus.cs +++ b/Items/Weapons/Magic/ClamorNoctus.cs @@ -42,28 +42,28 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + int projAmt = 3; + for (int i = 0; i < projAmt; i++) { float damageMult = 1f; float kbMult = 1f; @@ -76,26 +76,26 @@ namespace CalamityMod.Items.Weapons.Magic damageMult = 25f; kbMult = 1.5f; } - vector2 = new Vector2(player.Center.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.Center.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.Center.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.Center.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/CosmicRainbow.cs b/Items/Weapons/Magic/CosmicRainbow.cs index 7a247f4a57..b12a27a960 100644 --- a/Items/Weapons/Magic/CosmicRainbow.cs +++ b/Items/Weapons/Magic/CosmicRainbow.cs @@ -34,66 +34,66 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 3; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 60f; - bool flag11 = Collision.CanHit(vector, 0, 0, vector + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + float tenthPi = 0.314159274f; + int directRainbowAmt = 3; + Vector2 directRainbowVel = velocity; + directRainbowVel.Normalize(); + directRainbowVel *= 60f; + bool rainbowHitsTiles = Collision.CanHit(vector, 0, 0, vector + directRainbowVel, 0, 0); + for (int i = 0; i < directRainbowAmt; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float rainbowOffset = (float)i - ((float)directRainbowAmt - 1f) / 2f; + Vector2 offsetSpawnPos = directRainbowVel.RotatedBy((double)(tenthPi * rainbowOffset), default); + if (!rainbowHitsTiles) { - value9 -= vector7; + offsetSpawnPos -= directRainbowVel; } - int rainbow = Projectile.NewProjectile(source, vector.X + value9.X, vector.Y + value9.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + int rainbow = Projectile.NewProjectile(source, vector.X + offsetSpawnPos.X, vector.Y + offsetSpawnPos.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); Main.projectile[rainbow].usesLocalNPCImmunity = true; Main.projectile[rainbow].localNPCHitCooldown = 10; } - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float skyRainbowSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = skyRainbowSpeed; } else { - num80 = num72 / num80; + mouseDistance = skyRainbowSpeed / mouseDistance; } - for (int num108 = 0; num108 < 2; num108++) + for (int j = 0; j < 2; j++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * j); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-15, 16) * 0.01f; - float speedY5 = num79 + (float)Main.rand.Next(-15, 16) * 0.01f; - int rainbow2 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = skyRainbowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-15, 16) * 0.01f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-15, 16) * 0.01f; + int rainbow2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); Main.projectile[rainbow2].usesLocalNPCImmunity = true; Main.projectile[rainbow2].localNPCHitCooldown = 10; } diff --git a/Items/Weapons/Magic/DeathhailStaff.cs b/Items/Weapons/Magic/DeathhailStaff.cs index 05d3b24171..16c43c5660 100644 --- a/Items/Weapons/Magic/DeathhailStaff.cs +++ b/Items/Weapons/Magic/DeathhailStaff.cs @@ -45,56 +45,53 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + int j = Main.myPlayer; + float beamSpeed = Item.shootSpeed; + float beamKnockback = knockback; + beamKnockback = player.GetWeaponKnockback(Item, beamKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = beamSpeed; } else { - num80 = num72 / num80; + mouseDistance = beamSpeed / mouseDistance; } int numLasers = 2; - for (int num108 = 0; num108 < numLasers; num108++) + for (int i = 0; i < numLasers; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(91) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(91) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-50, 51) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-50, 51) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, num73, num74, i, 0f, 0f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = beamSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-50, 51) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-50, 51) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, beamKnockback, i, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/DivineRetribution.cs b/Items/Weapons/Magic/DivineRetribution.cs index bbba73c6a0..3393d825bf 100644 --- a/Items/Weapons/Magic/DivineRetribution.cs +++ b/Items/Weapons/Magic/DivineRetribution.cs @@ -44,47 +44,47 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float spearSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; + mouseXDist = (float)player.direction; } else { - num80 = num72 / num80; + mouseDistance = spearSpeed / mouseDistance; } int numProjectiles = 5; for (int i = 0; i < numProjectiles; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 - vector2.Y += (float)(100 * i); //-= - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; //+ - - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; //+ - - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 + realPlayerPos.Y += (float)(100 * i); //-= + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; //+ - + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; //+ - + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX6 = num78 + (float)Main.rand.Next(-60, 61) * 0.02f; - float speedY7 = num79 + (float)Main.rand.Next(-60, 61) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = spearSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX6 = mouseXDist + (float)Main.rand.Next(-60, 61) * 0.02f; + float speedY7 = mouseYDist + (float)Main.rand.Next(-60, 61) * 0.02f; float ai1 = Main.rand.NextFloat() + 0.5f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); } return false; } diff --git a/Items/Weapons/Magic/EidolonStaff.cs b/Items/Weapons/Magic/EidolonStaff.cs index c76b80157c..b64847055f 100644 --- a/Items/Weapons/Magic/EidolonStaff.cs +++ b/Items/Weapons/Magic/EidolonStaff.cs @@ -41,35 +41,35 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num72 = Item.shootSpeed; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float projSpeed = Item.shootSpeed; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); int stardustAmt = 5; - float num132 = num78; - float num133 = num79; - num80 = (float)Math.Sqrt((double)(num132 * num132 + num133 * num133)); - num80 = num72 / num80; - num132 *= num80; - num133 *= num80; - float x2 = vector2.X; - float y2 = vector2.Y; - Projectile.NewProjectile(source, x2, y2, num132, num133, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + float mouseXCopy = mouseXDist; + float mouseYCopy = mouseYDist; + mouseDistance = (float)Math.Sqrt((double)(mouseXCopy * mouseXCopy + mouseYCopy * mouseYCopy)); + mouseDistance = projSpeed / mouseDistance; + mouseXCopy *= mouseDistance; + mouseYCopy *= mouseDistance; + float x2 = realPlayerPos.X; + float y2 = realPlayerPos.Y; + Projectile.NewProjectile(source, x2, y2, mouseXCopy, mouseYCopy, ModContent.ProjectileType(), damage, knockback, player.whoAmI); for (int i = 0; i < stardustAmt; i++) { - num132 = num78; - num133 = num79; - float num134 = 0.05f * (float)i; - num132 += (float)Main.rand.Next(-90, 91) * num134; - num133 += (float)Main.rand.Next(-90, 91) * num134; - num80 = (float)Math.Sqrt((double)(num132 * num132 + num133 * num133)); - num80 = num72 / num80; - num132 *= num80; - num133 *= num80; - x2 = vector2.X; - y2 = vector2.Y; - Projectile.NewProjectile(source, x2, y2, num132, num133, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + mouseXCopy = mouseXDist; + mouseYCopy = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + mouseXCopy += (float)Main.rand.Next(-90, 91) * randOffsetDampener; + mouseYCopy += (float)Main.rand.Next(-90, 91) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(mouseXCopy * mouseXCopy + mouseYCopy * mouseYCopy)); + mouseDistance = projSpeed / mouseDistance; + mouseXCopy *= mouseDistance; + mouseYCopy *= mouseDistance; + x2 = realPlayerPos.X; + y2 = realPlayerPos.Y; + Projectile.NewProjectile(source, x2, y2, mouseXCopy, mouseYCopy, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Magic/EldritchTome.cs b/Items/Weapons/Magic/EldritchTome.cs index a3d0c6b179..f22178553a 100644 --- a/Items/Weapons/Magic/EldritchTome.cs +++ b/Items/Weapons/Magic/EldritchTome.cs @@ -36,31 +36,30 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + float playerKnockback = knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - Vector2 value2 = new Vector2(num78, num79); - value2.Normalize(); - Vector2 value3 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value3.Normalize(); - value2 = value2 * 4f + value3; - value2.Normalize(); - value2 *= Item.shootSpeed; - float num91 = (float)Main.rand.Next(10, 80) * 0.001f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + Vector2 tentacleVelocity = new Vector2(mouseXDist, mouseYDist); + tentacleVelocity.Normalize(); + Vector2 tentacleRandVelocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + tentacleRandVelocity.Normalize(); + tentacleVelocity = tentacleVelocity * 4f + tentacleRandVelocity; + tentacleVelocity.Normalize(); + tentacleVelocity *= Item.shootSpeed; + float tentacleYDirection = (float)Main.rand.Next(10, 80) * 0.001f; if (Main.rand.NextBool()) { - num91 *= -1f; + tentacleYDirection *= -1f; } - float num92 = (float)Main.rand.Next(10, 80) * 0.001f; + float tentacleXDirection = (float)Main.rand.Next(10, 80) * 0.001f; if (Main.rand.NextBool()) { - num92 *= -1f; + tentacleXDirection *= -1f; } - Projectile.NewProjectile(source, vector2, value2, ModContent.ProjectileType(), num73, num74, i, num92, num91); + Projectile.NewProjectile(source, realPlayerPos, tentacleVelocity, ModContent.ProjectileType(), damage, playerKnockback, i, tentacleXDirection, tentacleYDirection); return false; } } diff --git a/Items/Weapons/Magic/FatesReveal.cs b/Items/Weapons/Magic/FatesReveal.cs index 138e10d3fa..07be0fb55d 100644 --- a/Items/Weapons/Magic/FatesReveal.cs +++ b/Items/Weapons/Magic/FatesReveal.cs @@ -46,33 +46,33 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = Item.shootSpeed; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = Item.shootSpeed; } else { - num80 = Item.shootSpeed / num80; + mouseDistance = Item.shootSpeed / mouseDistance; } - vector += new Vector2(num78, num79); + realPlayerPos += new Vector2(mouseXDist, mouseYDist); int numProjectiles = 5; for (int i = 0; i < numProjectiles; i++) { - vector.X += (float)Main.rand.Next(-100, 101); - vector.Y += (float)(Main.rand.Next(-25, 26) * i); - float spawnX = vector.X; - float spawnY = vector.Y; + realPlayerPos.X += (float)Main.rand.Next(-100, 101); + realPlayerPos.Y += (float)(Main.rand.Next(-25, 26) * i); + float spawnX = realPlayerPos.X; + float spawnY = realPlayerPos.Y; Projectile.NewProjectile(source, spawnX, spawnY, 0f, 0f, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); } return false; diff --git a/Items/Weapons/Magic/Genisis.cs b/Items/Weapons/Magic/Genisis.cs index fcc7207011..401e372148 100644 --- a/Items/Weapons/Magic/Genisis.cs +++ b/Items/Weapons/Magic/Genisis.cs @@ -36,10 +36,9 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 0f); - int num6 = 3; float SpeedX = velocity.X + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-20, 21) * 0.05f; - for (int index = 0; index < num6; ++index) + for (int index = 0; index < 3; ++index) { int projectile = Projectile.NewProjectile(source, position.X, position.Y, SpeedX * 1.05f, SpeedY * 1.05f, ProjectileID.LaserMachinegunLaser, (int)(damage * 0.65), knockback * 0.6f, player.whoAmI, 0f, 0f); Main.projectile[projectile].timeLeft = 120; diff --git a/Items/Weapons/Magic/HellwingStaff.cs b/Items/Weapons/Magic/HellwingStaff.cs index c15d2fbaf6..016d50affe 100644 --- a/Items/Weapons/Magic/HellwingStaff.cs +++ b/Items/Weapons/Magic/HellwingStaff.cs @@ -39,49 +39,48 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = velocity.Length(); - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y; + float projSpeed = velocity.Length(); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num130 = 4; - for (int num131 = 0; num131 < num130; num131++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num131); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-40, 41) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-40, 41) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/IceBarrage.cs b/Items/Weapons/Magic/IceBarrage.cs index bb6737bed0..59d80d7201 100644 --- a/Items/Weapons/Magic/IceBarrage.cs +++ b/Items/Weapons/Magic/IceBarrage.cs @@ -46,10 +46,10 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - vector2.X = Main.mouseX + Main.screenPosition.X; - vector2.Y = Main.mouseY + Main.screenPosition.Y; - Projectile.NewProjectile(source, vector2, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + realPlayerPos.X = Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = Main.mouseY + Main.screenPosition.Y; + Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, type, damage, knockback, player.whoAmI, 0f, 0f); CalamityGlobalItem.ConsumeAdditionalAmmo(player, Item, 2); diff --git a/Items/Weapons/Magic/IcicleStaff.cs b/Items/Weapons/Magic/IcicleStaff.cs index 9a9f8d0d2e..82a5db852d 100644 --- a/Items/Weapons/Magic/IcicleStaff.cs +++ b/Items/Weapons/Magic/IcicleStaff.cs @@ -21,8 +21,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.damage = 10; Item.DamageType = DamageClass.Magic; Item.mana = 6; - Item.width = 44; - Item.height = 44; + Item.width = 38; + Item.height = 42; Item.useTime = 7; Item.useAnimation = 14; Item.useStyle = ItemUseStyleID.Shoot; @@ -40,49 +40,48 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = velocity.Length(); - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + float icicleSpeed = velocity.Length(); + float playerKnockback = knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = icicleSpeed; } else { - num80 = num72 / num80; + mouseDistance = icicleSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), num73, num74, i, 0f, (float)Main.rand.Next(10)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = icicleSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, playerKnockback, i, 0f, (float)Main.rand.Next(10)); return false; } diff --git a/Items/Weapons/Magic/IcicleStaff.png b/Items/Weapons/Magic/IcicleStaff.png index 3d0dfd3b9a..0fbbbae95f 100644 Binary files a/Items/Weapons/Magic/IcicleStaff.png and b/Items/Weapons/Magic/IcicleStaff.png differ diff --git a/Items/Weapons/Magic/InfernalRift.cs b/Items/Weapons/Magic/InfernalRift.cs index 9131f0cc1c..0b024aef5b 100644 --- a/Items/Weapons/Magic/InfernalRift.cs +++ b/Items/Weapons/Magic/InfernalRift.cs @@ -44,29 +44,29 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num72 = Item.shootSpeed; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float projSpeed = Item.shootSpeed; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; float f = Main.rand.NextFloat() * MathHelper.TwoPi; - float value12 = 20f; - float value13 = 60f; - Vector2 vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - for (int num202 = 0; num202 < 50; num202++) + float lowerLerpValue = 20f; + float upperLerpValue = 60f; + Vector2 projSpawnOffset = realPlayerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerLerpValue, upperLerpValue, Main.rand.NextFloat()); + for (int i = 0; i < 50; i++) { - vector13 = vector2 + f.ToRotationVector2() * MathHelper.Lerp(value12, value13, Main.rand.NextFloat()); - if (Collision.CanHit(vector2, 0, 0, vector13 + (vector13 - vector2).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) + projSpawnOffset = realPlayerPos + f.ToRotationVector2() * MathHelper.Lerp(lowerLerpValue, upperLerpValue, Main.rand.NextFloat()); + if (Collision.CanHit(realPlayerPos, 0, 0, projSpawnOffset + (projSpawnOffset - realPlayerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) { break; } f = Main.rand.NextFloat() * MathHelper.TwoPi; } Vector2 mouseWorld = Main.MouseWorld; - Vector2 vector14 = mouseWorld - vector13; - Vector2 vector15 = new Vector2(num78, num79).SafeNormalize(Vector2.UnitY) * num72; - vector14 = vector14.SafeNormalize(vector15) * num72; - vector14 = Vector2.Lerp(vector14, vector15, 0.25f); - Projectile.NewProjectile(source, vector13, vector14, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 projSpawnPos = mouseWorld - projSpawnOffset; + Vector2 projVelocity = new Vector2(mouseXDist, mouseYDist).SafeNormalize(Vector2.UnitY) * projSpeed; + projSpawnPos = projSpawnPos.SafeNormalize(projVelocity) * projSpeed; + projSpawnPos = Vector2.Lerp(projSpawnPos, projVelocity, 0.25f); + Projectile.NewProjectile(source, projSpawnOffset, projSpawnPos, type, damage, knockback, player.whoAmI, 0f, 0f); return false; } diff --git a/Items/Weapons/Magic/Mistlestorm.cs b/Items/Weapons/Magic/Mistlestorm.cs index 306f5055be..e4675f7a01 100644 --- a/Items/Weapons/Magic/Mistlestorm.cs +++ b/Items/Weapons/Magic/Mistlestorm.cs @@ -39,17 +39,17 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num106 = 2 + Main.rand.Next(3); - for (int num107 = 0; num107 < num106; num107++) + int projAmt = 2 + Main.rand.Next(3); + for (int i = 0; i < projAmt; i++) { - float num110 = 0.025f * (float)num107; - velocity.X += (float)Main.rand.Next(-35, 36) * num110; - velocity.Y += (float)Main.rand.Next(-35, 36) * num110; - float num84 = velocity.Length(); - num84 = Item.shootSpeed / num84; - velocity.X *= num84; - velocity.Y *= num84; - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, (float)Main.rand.Next(0, 10 * (num107 + 1)), 0f); + float randVelocityDampener = 0.025f * (float)i; + velocity.X += (float)Main.rand.Next(-35, 36) * randVelocityDampener; + velocity.Y += (float)Main.rand.Next(-35, 36) * randVelocityDampener; + float projDistance = velocity.Length(); + projDistance = Item.shootSpeed / projDistance; + velocity.X *= projDistance; + velocity.Y *= projDistance; + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, (float)Main.rand.Next(0, 10 * (i + 1)), 0f); Projectile.NewProjectile(source, position, velocity, ProjectileID.Leaf, damage, knockback, player.whoAmI); } return false; diff --git a/Items/Weapons/Magic/PhoenixFlameBarrage.cs b/Items/Weapons/Magic/PhoenixFlameBarrage.cs index 130180ddb8..8f2a6f1573 100644 --- a/Items/Weapons/Magic/PhoenixFlameBarrage.cs +++ b/Items/Weapons/Magic/PhoenixFlameBarrage.cs @@ -40,58 +40,58 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; + float flameSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = flameSpeed; } else { - num80 = num72 / num80; + mouseDistance = flameSpeed / mouseDistance; } - int num107 = 30; + int flameAmt = 30; if (Main.rand.NextBool(3)) { - num107++; + flameAmt++; } if (Main.rand.NextBool(3)) { - num107++; + flameAmt++; } - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < flameAmt; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = flameSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/Serpentine.cs b/Items/Weapons/Magic/Serpentine.cs index 2b1ff6d602..5647e88358 100644 --- a/Items/Weapons/Magic/Serpentine.cs +++ b/Items/Weapons/Magic/Serpentine.cs @@ -34,31 +34,31 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int owner = player.whoAmI; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float velX = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float velY = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 projRotation = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); + Vector2 projSpawnPos = Main.MouseWorld - realPlayerPos; + float velX = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float velY = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - velY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + velY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } float dist = (float)Math.Sqrt((double)(velX * velX + velY * velY)); if ((float.IsNaN(velX) && float.IsNaN(velY)) || (velX == 0f && velY == 0f)) { velX = (float)player.direction; velY = 0f; - dist = num72; + dist = projSpeed; } else { - dist = num72 / dist; + dist = projSpeed / dist; } - float num77 = Vector2.Dot(value, vector3); - if (num77 > 0f) + float projDirection = Vector2.Dot(projRotation, projSpawnPos); + if (projDirection > 0f) { player.ChangeDir(1); } @@ -68,8 +68,8 @@ namespace CalamityMod.Items.Weapons.Magic } //velX = 0f; //velY = 0f; - //vector2.X = (float)Main.mouseX + Main.screenPosition.X; - //vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; + //realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + //realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; int curr = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, owner); int prev = curr; diff --git a/Items/Weapons/Magic/ShadecrystalTome.cs b/Items/Weapons/Magic/ShadecrystalTome.cs index a1eeec8c64..974d0ea9f7 100644 --- a/Items/Weapons/Magic/ShadecrystalTome.cs +++ b/Items/Weapons/Magic/ShadecrystalTome.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(1, 3); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(1, 3); + for (int index = 0; index < projAmt; ++index) { float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; diff --git a/Items/Weapons/Magic/SkyGlaze.cs b/Items/Weapons/Magic/SkyGlaze.cs index 28062701e3..73c4148597 100644 --- a/Items/Weapons/Magic/SkyGlaze.cs +++ b/Items/Weapons/Magic/SkyGlaze.cs @@ -38,49 +38,49 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float featherSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = featherSpeed; } else { - num80 = num72 / num80; + mouseDistance = featherSpeed / mouseDistance; } int featherAmt = 3; - for (int num108 = 0; num108 < featherAmt; num108++) + for (int i = 0; i < featherAmt; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = featherSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Magic/StarShower.cs b/Items/Weapons/Magic/StarShower.cs index 942cd99b4c..f18d8c054c 100644 --- a/Items/Weapons/Magic/StarShower.cs +++ b/Items/Weapons/Magic/StarShower.cs @@ -36,29 +36,29 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float starSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; + mouseXDist = (float)player.direction; + mouseYDist = 0f; } - float num208 = num78; - float num209 = num79; - num208 += (float)Main.rand.Next(-1, 2) * 0.5f; - num209 += (float)Main.rand.Next(-1, 2) * 0.5f; - vector2 += new Vector2(num208, num209); - for (int num108 = 0; num108 < 5; num108++) + float randXOffset = mouseXDist; + float randYOffset = mouseYDist; + randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + realPlayerPos += new Vector2(randXOffset, randYOffset); + for (int i = 0; i < 5; i++) { float speedX4 = 2f + (float)Main.rand.Next(-8, 5); float speedY5 = 15f + (float)Main.rand.Next(1, 6); - int star = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); + int star = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Magic/TomeofFates.cs b/Items/Weapons/Magic/TomeofFates.cs index ce91cbf567..d8c61b2b77 100644 --- a/Items/Weapons/Magic/TomeofFates.cs +++ b/Items/Weapons/Magic/TomeofFates.cs @@ -37,38 +37,37 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - int num73 = damage; - float num74 = knockback; - num74 = player.GetWeaponKnockback(Item, num74); + float playerKnockback = knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - Vector2 value2 = new Vector2(num78, num79); - value2.Normalize(); - Vector2 value3 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); - value3.Normalize(); - value2 = value2 * 4f + value3; - value2.Normalize(); - value2 *= Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + Vector2 tentacleVelocity = new Vector2(mouseXDist, mouseYDist); + tentacleVelocity.Normalize(); + Vector2 tentacleRandVelocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + tentacleRandVelocity.Normalize(); + tentacleVelocity = tentacleVelocity * 4f + tentacleRandVelocity; + tentacleVelocity.Normalize(); + tentacleVelocity *= Item.shootSpeed; int projChoice = Main.rand.Next(7); - float num91 = (float)Main.rand.Next(10, 160) * 0.001f; + float tentacleYDirection = (float)Main.rand.Next(10, 160) * 0.001f; if (Main.rand.NextBool()) { - num91 *= -1f; + tentacleYDirection *= -1f; } - float num92 = (float)Main.rand.Next(10, 160) * 0.001f; + float tentacleXDirection = (float)Main.rand.Next(10, 160) * 0.001f; if (Main.rand.NextBool()) { - num92 *= -1f; + tentacleXDirection *= -1f; } if (projChoice == 0) { - Projectile.NewProjectile(source, vector2.X, vector2.Y, value2.X, value2.Y, ModContent.ProjectileType(), (int)((double)num73 * 1.5f), num74, i, num92, num91); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, tentacleVelocity.X, tentacleVelocity.Y, ModContent.ProjectileType(), (int)((double)damage * 1.5f), playerKnockback, i, tentacleXDirection, tentacleYDirection); } else { - Projectile.NewProjectile(source, vector2.X, vector2.Y, value2.X, value2.Y, ModContent.ProjectileType(), num73, num74, i, num92, num91); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, tentacleVelocity.X, tentacleVelocity.Y, ModContent.ProjectileType(), damage, playerKnockback, i, tentacleXDirection, tentacleYDirection); } return false; } diff --git a/Items/Weapons/Magic/UndinesRetribution.cs b/Items/Weapons/Magic/UndinesRetribution.cs index 43834b2533..e075d8a142 100644 --- a/Items/Weapons/Magic/UndinesRetribution.cs +++ b/Items/Weapons/Magic/UndinesRetribution.cs @@ -40,46 +40,46 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float spearSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; + mouseXDist = (float)player.direction; } else { - num80 = num72 / num80; + mouseDistance = spearSpeed / mouseDistance; } - for (int num108 = 0; num108 < 3; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 - vector2.Y += (float)(100 * num108); //-= - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; //+ - - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; //+ - - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(51) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - /* - */ player.position.X), player.MountedCenter.Y + 600f); //- + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-50, 51); //200 + realPlayerPos.Y += (float)(100 * i); //-= + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; //+ - + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; //+ - + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX6 = num78 + (float)Main.rand.Next(-60, 61) * 0.02f; - float speedY7 = num79 + (float)Main.rand.Next(-60, 61) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = spearSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX6 = mouseXDist + (float)Main.rand.Next(-60, 61) * 0.02f; + float speedY7 = mouseYDist + (float)Main.rand.Next(-60, 61) * 0.02f; float ai1 = Main.rand.NextFloat() + 0.5f; - int bullet2 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); + int bullet2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX6, -speedY7, type, damage, knockback, player.whoAmI, 0.0f, ai1); } return false; } diff --git a/Items/Weapons/Magic/Vesuvius.cs b/Items/Weapons/Magic/Vesuvius.cs index 8bb0bb3ebe..ce81f4bfb9 100644 --- a/Items/Weapons/Magic/Vesuvius.cs +++ b/Items/Weapons/Magic/Vesuvius.cs @@ -68,49 +68,49 @@ namespace CalamityMod.Items.Weapons.Magic } else { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float meteorSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = meteorSpeed; } else { - num80 = num72 / num80; + mouseDistance = meteorSpeed / mouseDistance; } - for (int num113 = 0; num113 < 4; num113++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = meteorSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float meteorSpawnXOffset = mouseXDist; + float meteorSpawnYOffset = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; float ai0 = (float)Main.rand.Next(6); - Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, type, damage, knockback, player.whoAmI, ai0, 0.5f + (float)Main.rand.NextDouble() * 0.9f); //0.3 + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, meteorSpawnXOffset * 0.75f, meteorSpawnYOffset * 0.75f, type, damage, knockback, player.whoAmI, ai0, 0.5f + (float)Main.rand.NextDouble() * 0.9f); //0.3 } return false; } diff --git a/Items/Weapons/Magic/VividClarity.cs b/Items/Weapons/Magic/VividClarity.cs index aa4956a485..209bd54617 100644 --- a/Items/Weapons/Magic/VividClarity.cs +++ b/Items/Weapons/Magic/VividClarity.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Magic float sourceVariationLow = 20f; float sourceVariationHigh = 60f; Vector2 source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(sourceVariationLow, sourceVariationHigh, Main.rand.NextFloat()); - for (int num202 = 0; num202 < 50; num202++) + for (int i = 0; i < 50; i++) { source = playerPos + f.ToRotationVector2() * MathHelper.Lerp(sourceVariationLow, sourceVariationHigh, Main.rand.NextFloat()); if (Collision.CanHit(playerPos, 0, 0, source + (source - playerPos).SafeNormalize(Vector2.UnitX) * 8f, 0, 0)) diff --git a/Items/Weapons/Magic/WyvernsCall.cs b/Items/Weapons/Magic/WyvernsCall.cs index a761ac63b7..05717f3b85 100644 --- a/Items/Weapons/Magic/WyvernsCall.cs +++ b/Items/Weapons/Magic/WyvernsCall.cs @@ -38,28 +38,27 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { float damageMult = 1f; float kbMult = 1f; @@ -85,26 +84,26 @@ namespace CalamityMod.Items.Weapons.Magic damageMult = 1.2f; kbMult = 2f; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int feather = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-30, 31) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-30, 31) * 0.02f; + int feather = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, (int)(damage * damageMult), (int)(knockback * kbMult), player.whoAmI, 0f, (float)Main.rand.Next(15)); } return false; } diff --git a/Items/Weapons/Melee/Aftershock.cs b/Items/Weapons/Melee/Aftershock.cs index ae5f6cde92..52de9634c0 100644 --- a/Items/Weapons/Melee/Aftershock.cs +++ b/Items/Weapons/Melee/Aftershock.cs @@ -34,94 +34,94 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); target.AddBuff(ModContent.BuffType(), 300); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float rockSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = rockSpeed; } else { - num80 = num72 / num80; + mouseDistance = rockSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)100; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)100; + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-10, 11) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = rockSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-10, 11) * 0.02f; int rockDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); target.AddBuff(ModContent.BuffType(), 300); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float rockSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = rockSpeed; } else { - num80 = num72 / num80; + mouseDistance = rockSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)100; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)100; + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-10, 11) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = rockSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-10, 11) * 0.02f; int rockDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), rockDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); } public override void MeleeEffects(Player player, Rectangle hitbox) diff --git a/Items/Weapons/Melee/Avalanche.cs b/Items/Weapons/Melee/Avalanche.cs index 933b67c18d..679c49f80c 100644 --- a/Items/Weapons/Melee/Avalanche.cs +++ b/Items/Weapons/Melee/Avalanche.cs @@ -42,8 +42,8 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(source, target.Center, vector255, type, bombDamage, hit.Knockback, Main.myPlayer); + Vector2 projRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(source, target.Center, projRotation, type, bombDamage, hit.Knockback, Main.myPlayer); } } @@ -61,8 +61,8 @@ namespace CalamityMod.Items.Weapons.Melee Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX, -velocity); for (int k = 0; k < totalProjectiles; k++) { - Vector2 vector255 = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(source, target.Center, vector255, type, bombDamage, 0f, Main.myPlayer); + Vector2 projRotation = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(source, target.Center, projRotation, type, bombDamage, 0f, Main.myPlayer); } } @@ -70,8 +70,8 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(3)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 67, (float)(player.direction * 2), 0f, 150, default, 1.5f); - Main.dust[num250].velocity *= 0.2f; + int iceDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 67, (float)(player.direction * 2), 0f, 150, default, 1.5f); + Main.dust[iceDust].velocity *= 0.2f; } } } diff --git a/Items/Weapons/Melee/BansheeHook.cs b/Items/Weapons/Melee/BansheeHook.cs index c28f054d5e..9e3568bbbd 100644 --- a/Items/Weapons/Melee/BansheeHook.cs +++ b/Items/Weapons/Melee/BansheeHook.cs @@ -49,27 +49,27 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num82 = (float)Main.mouseX + Main.screenPosition.X - position.X; - float num83 = (float)Main.mouseY + Main.screenPosition.Y - position.Y; + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - position.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - position.Y; if (player.gravDir == -1f) { - num83 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - position.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - position.Y; } - float num84 = (float)Math.Sqrt((double)(num82 * num82 + num83 * num83)); - if ((float.IsNaN(num82) && float.IsNaN(num83)) || (num82 == 0f && num83 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num82 = (float)player.direction; - num83 = 0f; - num84 = Item.shootSpeed; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = Item.shootSpeed; } else { - num84 = Item.shootSpeed / num84; + mouseDistance = Item.shootSpeed / mouseDistance; } - num82 *= num84; - num83 *= num84; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; float ai4 = Main.rand.NextFloat() * Item.shootSpeed * 0.75f * (float)player.direction; - velocity = new Vector2(num82, num83); + velocity = new Vector2(mouseXDist, mouseYDist); Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, ai4, 0.0f); return false; } diff --git a/Items/Weapons/Melee/CelestialClaymore.cs b/Items/Weapons/Melee/CelestialClaymore.cs index e0f0631535..6e959d4e24 100644 --- a/Items/Weapons/Melee/CelestialClaymore.cs +++ b/Items/Weapons/Melee/CelestialClaymore.cs @@ -32,44 +32,43 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; switch (Main.rand.Next(3)) { case 0: @@ -84,7 +83,7 @@ namespace CalamityMod.Items.Weapons.Melee default: break; } - Projectile.NewProjectile(source, vector2.X, vector2.Y, 0f, 0f, type, (int)(damage * 0.8), knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, 0f, 0f, type, (int)(damage * 0.8), knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); } return false; } @@ -93,21 +92,21 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(4)) { - int num249 = Main.rand.Next(2); - if (num249 == 0) + int dustType = Main.rand.Next(2); + if (dustType == 0) { - num249 = 15; + dustType = 15; } - else if (num249 == 1) + else if (dustType == 1) { - num249 = 73; + dustType = 73; } else { - num249 = 244; + dustType = 244; } - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, num249, (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, dustType, (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[swingDust].velocity *= 0.2f; } } } diff --git a/Items/Weapons/Melee/CometQuasher.cs b/Items/Weapons/Melee/CometQuasher.cs index 74d7f09561..142394b369 100644 --- a/Items/Weapons/Melee/CometQuasher.cs +++ b/Items/Weapons/Melee/CometQuasher.cs @@ -36,48 +36,48 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { var source = player.GetSource_ItemUse(Item); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } - for (int num113 = 0; num113 < 2; num113++) + for (int i = 0; i < 2; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - int proj = Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float cometSpawnXOffset = mouseXDist; + float cometSpawnYOffset = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + int proj = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, cometSpawnXOffset * 0.75f, cometSpawnYOffset * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); Main.projectile[proj].Calamity().lineColor = Main.rand.Next(3); } } @@ -85,48 +85,48 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } - for (int num113 = 0; num113 < 2; num113++) + for (int i = 0; i < 2; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - int proj = Projectile.NewProjectile(source, vector2.X, vector2.Y, num114 * 0.75f, num115 * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float cometSpawnXOffset = mouseXDist; + float cometSpawnYOffset = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + int proj = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, cometSpawnXOffset * 0.75f, cometSpawnYOffset * 0.75f, ModContent.ProjectileType(), (int)(Item.damage * 0.5f), Item.knockBack, player.whoAmI, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f); Main.projectile[proj].Calamity().lineColor = Main.rand.Next(3); } } diff --git a/Items/Weapons/Melee/Devastation.cs b/Items/Weapons/Melee/Devastation.cs index 4b49d7298c..01d6dee779 100644 --- a/Items/Weapons/Melee/Devastation.cs +++ b/Items/Weapons/Melee/Devastation.cs @@ -54,51 +54,50 @@ namespace CalamityMod.Items.Weapons.Melee break; } Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, type, damage, knockback, Main.myPlayer); - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float projSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 4; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-40, 41) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-40, 41) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(5)); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(1)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-40, 41) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(5)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(3)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage / 2, knockback, player.whoAmI, 0f, (float)Main.rand.Next(1)); } return false; } diff --git a/Items/Weapons/Melee/DevilsDevastation.cs b/Items/Weapons/Melee/DevilsDevastation.cs index 81d91c3562..4243649280 100644 --- a/Items/Weapons/Melee/DevilsDevastation.cs +++ b/Items/Weapons/Melee/DevilsDevastation.cs @@ -119,39 +119,39 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.ShadowFlame, 450); target.AddBuff(BuffID.OnFire, 900); player.ApplyDamageToNPC(target, Item.damage * 4, 0f, 0, false); - float scalar1 = 1.7f; - float scalar2 = 0.8f; - float scalar3 = 2f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); for (int i = 0; i < 40; i++) { - int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, scalar1); + int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, firstDustScale); Dust dust = Main.dust[dustInt]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 4.5f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, scalar2); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * Main.rand.NextFloat() * target.width / 2f; dust.velocity.Y -= 3f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } for (int j = 0; j < 20; j++) { - int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, scalar3); + int dustInt = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, thirdDustScale); Dust dust = Main.dust[dustInt]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)target.velocity.ToRotation(), default) * target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } } diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index 9d741c2c96..773eabba6f 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -36,51 +36,50 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { var source = player.GetSource_ItemUse(Item); - float num72 = 25f; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float projSpeed = 25f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int projDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), projDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), projDamage, hit.Knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } if (target.Calamity().miscDefenseLoss < target.defense) @@ -97,50 +96,49 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); - float num72 = 25f; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + float projSpeed = 25f; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int earthDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), earthDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), earthDamage, Item.knockBack, player.whoAmI, 0f, (float)Main.rand.Next(10)); } if (player.moonLeech) diff --git a/Items/Weapons/Melee/EmpyreanKnives.cs b/Items/Weapons/Melee/EmpyreanKnives.cs index 5a4c74effc..49cea27978 100644 --- a/Items/Weapons/Melee/EmpyreanKnives.cs +++ b/Items/Weapons/Melee/EmpyreanKnives.cs @@ -36,60 +36,58 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float knifeSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = knifeSpeed; } else { - num80 = num72 / num80; + mouseDistance = knifeSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - int num146 = 4; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + int knifeAmt = 4; if (Main.rand.NextBool()) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(4)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(8)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(16)) { - num146++; + knifeAmt++; } - for (int num147 = 0; num147 < num146; num147++) + for (int i = 0; i < knifeAmt; i++) { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)num147; - num148 += (float)Main.rand.Next(-25, 26) * num150; - num149 += (float)Main.rand.Next(-25, 26) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - Projectile.NewProjectile(source, x4, y4, num148, num149, type, damage, knockback, player.whoAmI, 0f, 0f); + float knifeSpawnXPos = mouseXDist; + float knifeSpawnYPos = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + knifeSpawnXPos += (float)Main.rand.Next(-25, 26) * randOffsetDampener; + knifeSpawnYPos += (float)Main.rand.Next(-25, 26) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(knifeSpawnXPos * knifeSpawnXPos + knifeSpawnYPos * knifeSpawnYPos)); + mouseDistance = knifeSpeed / mouseDistance; + knifeSpawnXPos *= mouseDistance; + knifeSpawnYPos *= mouseDistance; + float x4 = realPlayerPos.X; + float y4 = realPlayerPos.Y; + Projectile.NewProjectile(source, x4, y4, knifeSpawnXPos, knifeSpawnYPos, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Melee/EntropicClaymore.cs b/Items/Weapons/Melee/EntropicClaymore.cs index 11ff310684..d9a820585d 100644 --- a/Items/Weapons/Melee/EntropicClaymore.cs +++ b/Items/Weapons/Melee/EntropicClaymore.cs @@ -38,8 +38,8 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(4, 6); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(4, 6); + for (int index = 0; index < projAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-20, 21) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-20, 21) * 0.05f; diff --git a/Items/Weapons/Melee/ExaltedOathblade.cs b/Items/Weapons/Melee/ExaltedOathblade.cs index 4750c5f0c4..935f03de6c 100644 --- a/Items/Weapons/Melee/ExaltedOathblade.cs +++ b/Items/Weapons/Melee/ExaltedOathblade.cs @@ -60,39 +60,39 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.ShadowFlame, 450); target.AddBuff(BuffID.OnFire, 900); player.ApplyDamageToNPC(target, player.GetWeaponDamage(player.ActiveItem()) * 2, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int num53 = 0; num53 < 40; num53++) + for (int i = 0; i < 40; i++) { - int num54 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 4.5f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(Math.PI) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 3f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } - for (int num55 = 0; num55 < 20; num55++) + for (int j = 0; j < 20; j++) { - int num56 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(target.position, target.width, target.height, 173, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(Math.PI).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } } diff --git a/Items/Weapons/Melee/ForbiddenOathblade.cs b/Items/Weapons/Melee/ForbiddenOathblade.cs index cae1a22330..83822db3c7 100644 --- a/Items/Weapons/Melee/ForbiddenOathblade.cs +++ b/Items/Weapons/Melee/ForbiddenOathblade.cs @@ -46,42 +46,42 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire, 720); int onHitDamage = player.CalcIntDamage(2 * Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int dustIncr; + for (int i = 0; i < 40; i = dustIncr + 1) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 4.5f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 3f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + dustIncr = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = dustIncr + 1) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 173, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 1.5f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + dustIncr = j; } } } diff --git a/Items/Weapons/Melee/GalactusBlade.cs b/Items/Weapons/Melee/GalactusBlade.cs index f462729e04..a2e0c6ceab 100644 --- a/Items/Weapons/Melee/GalactusBlade.cs +++ b/Items/Weapons/Melee/GalactusBlade.cs @@ -37,49 +37,48 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } - int num107 = 5; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 5; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-100, 101) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-100, 101) * 0.02f; - int projectile = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-100, 101) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-100, 101) * 0.02f; + int projectile = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } return false; } diff --git a/Items/Weapons/Melee/Greentide.cs b/Items/Weapons/Melee/Greentide.cs index 615f365490..056f573a04 100644 --- a/Items/Weapons/Melee/Greentide.cs +++ b/Items/Weapons/Melee/Greentide.cs @@ -32,107 +32,106 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { var source = player.GetSource_ItemUse(Item); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - float num74 = hit.Knockback; - num74 = player.GetWeaponKnockback(Item, num74); + int j = Main.myPlayer; + float projSpeed = Item.shootSpeed; + float playerKnockback = hit.Knockback; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - for (int num108 = 0; num108 < 3; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int greenWaterDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, num74, i, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, playerKnockback, i, 0f, (float)Main.rand.Next(10)); } } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { var source = player.GetSource_ItemUse(Item); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - float num74 = Item.knockBack; - num74 = player.GetWeaponKnockback(Item, num74); + int j = Main.myPlayer; + float projSpeed = Item.shootSpeed; + float playerKnockback = Item.knockBack; + playerKnockback = player.GetWeaponKnockback(Item, playerKnockback); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX - Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY - Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX - Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY - Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 4; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 4; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79 + (float)Main.rand.Next(-180, 181) * 0.02f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist + (float)Main.rand.Next(-180, 181) * 0.02f; int greenWaterDamage = player.CalcIntDamage(Item.damage); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, num74, i, 0f, (float)Main.rand.Next(10)); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), greenWaterDamage, playerKnockback, i, 0f, (float)Main.rand.Next(10)); } } diff --git a/Items/Weapons/Melee/Hellkite.cs b/Items/Weapons/Melee/Hellkite.cs index 14f1befc1b..9b0f324446 100644 --- a/Items/Weapons/Melee/Hellkite.cs +++ b/Items/Weapons/Melee/Hellkite.cs @@ -55,42 +55,42 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire3, 300); int onHitDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int increment; + for (int i = 0; i < 40; i = increment + 1) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + increment = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = increment + 1) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + increment = j; } } } diff --git a/Items/Weapons/Melee/IllustriousKnives.cs b/Items/Weapons/Melee/IllustriousKnives.cs index 5e2ee3cefd..6fe1669c29 100644 --- a/Items/Weapons/Melee/IllustriousKnives.cs +++ b/Items/Weapons/Melee/IllustriousKnives.cs @@ -40,60 +40,58 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float knifeSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = knifeSpeed; } else { - num80 = num72 / num80; + mouseDistance = knifeSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - int num146 = 4; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + int knifeAmt = 4; if (Main.rand.NextBool()) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(4)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(6)) { - num146++; + knifeAmt++; } if (Main.rand.NextBool(8)) { - num146++; + knifeAmt++; } - for (int num147 = 0; num147 < num146; num147++) + for (int i = 0; i < knifeAmt; i++) { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)num147; - num148 += (float)Main.rand.Next(-35, 36) * num150; - num149 += (float)Main.rand.Next(-35, 36) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - Projectile.NewProjectile(source, x4, y4, num148, num149, type, damage, knockback, player.whoAmI, 0f, 0f); + float knifeSpawnXPos = mouseXDist; + float knifeSpawnYPos = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + knifeSpawnXPos += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + knifeSpawnYPos += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(knifeSpawnXPos * knifeSpawnXPos + knifeSpawnYPos * knifeSpawnYPos)); + mouseDistance = knifeSpeed / mouseDistance; + knifeSpawnXPos *= mouseDistance; + knifeSpawnYPos *= mouseDistance; + float x4 = realPlayerPos.X; + float y4 = realPlayerPos.Y; + Projectile.NewProjectile(source, x4, y4, knifeSpawnXPos, knifeSpawnYPos, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Melee/IridescentExcalibur.cs b/Items/Weapons/Melee/IridescentExcalibur.cs index ed6fd22ea4..21c7469d36 100644 --- a/Items/Weapons/Melee/IridescentExcalibur.cs +++ b/Items/Weapons/Melee/IridescentExcalibur.cs @@ -133,8 +133,8 @@ namespace CalamityMod.Items.Weapons.Melee break; } - Dust dust24 = Main.dust[Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 267, 0f, 0f, alpha, color, 1.2f)]; - dust24.noGravity = true; + Dust swingDust = Main.dust[Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 267, 0f, 0f, alpha, color, 1.2f)]; + swingDust.noGravity = true; } } diff --git a/Items/Weapons/Melee/RedSun.cs b/Items/Weapons/Melee/RedSun.cs index 37d2bb4282..49e558c3ee 100644 --- a/Items/Weapons/Melee/RedSun.cs +++ b/Items/Weapons/Melee/RedSun.cs @@ -40,51 +40,48 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - Vector2 value = Vector2.UnitX.RotatedBy((double)player.fullRotation, default); - Vector2 vector3 = Main.MouseWorld - vector2; - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float flareSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = flareSpeed; } else { - num80 = num72 / num80; + mouseDistance = flareSpeed / mouseDistance; } - int num107 = 3; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 3; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), (int)((double)damage * 0.7), knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = flareSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), (int)((double)damage * 0.7), knockback, player.whoAmI, 0f, (float)Main.rand.Next(10)); } return false; } diff --git a/Items/Weapons/Melee/SoulHarvester.cs b/Items/Weapons/Melee/SoulHarvester.cs index 6039f8ddb1..92b7c7d045 100644 --- a/Items/Weapons/Melee/SoulHarvester.cs +++ b/Items/Weapons/Melee/SoulHarvester.cs @@ -47,23 +47,23 @@ namespace CalamityMod.Items.Weapons.Melee SoundEngine.PlaySound(SoundID.Item14, target.Center); int onHitDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } @@ -75,23 +75,23 @@ namespace CalamityMod.Items.Weapons.Melee if (target.statLife <= (target.statLifeMax * 0.15f)) { SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 89, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index cabf413e86..cd7fc08fbf 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -45,53 +45,52 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); SoundEngine.PlaySound(SoundID.Item88, player.Center); - int i = Main.myPlayer; - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + int j = Main.myPlayer; + float cometSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = cometSpeed; } else { - num80 = num72 / num80; + mouseDistance = cometSpeed / mouseDistance; } if (crit) damage /= 2; - int num112 = 2; - for (int num113 = 0; num113 < num112; num113++) + for (int i = 0; i < 2; i++) { - vector2 = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num113); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X + (float)Main.rand.Next(-40, 41) * 0.03f; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.Center.X + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X + (float)Main.rand.Next(-40, 41) * 0.03f; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float num114 = num78; - float num115 = num79 + (float)Main.rand.Next(-80, 81) * 0.02f; - int proj = Projectile.NewProjectile(source, vector2.X, vector2.Y, num114, num115, ProjectileID.LunarFlare, (int)(damage * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = cometSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX = mouseXDist; + float speedY = mouseYDist + (float)Main.rand.Next(-80, 81) * 0.02f; + int proj = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX, speedY, ProjectileID.LunarFlare, (int)(damage * 0.5), knockback, i, 0f, (float)Main.rand.Next(3)); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].DamageType = DamageClass.Melee; } diff --git a/Items/Weapons/Melee/StormRuler.cs b/Items/Weapons/Melee/StormRuler.cs index 81f51e2b91..7014194781 100644 --- a/Items/Weapons/Melee/StormRuler.cs +++ b/Items/Weapons/Melee/StormRuler.cs @@ -33,8 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[swingDust].velocity *= 0.2f; } } diff --git a/Items/Weapons/Melee/StormSaber.cs b/Items/Weapons/Melee/StormSaber.cs index 6a80e16a4c..b95302eb72 100644 --- a/Items/Weapons/Melee/StormSaber.cs +++ b/Items/Weapons/Melee/StormSaber.cs @@ -47,8 +47,8 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); - Main.dust[num250].velocity *= 0.2f; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 187, (float)(player.direction * 2), 0f, 150, default, 1.3f); + Main.dust[swingDust].velocity *= 0.2f; } } } diff --git a/Items/Weapons/Melee/Swordsplosion.cs b/Items/Weapons/Melee/Swordsplosion.cs index dec805925a..b0f1d4aa32 100644 --- a/Items/Weapons/Melee/Swordsplosion.cs +++ b/Items/Weapons/Melee/Swordsplosion.cs @@ -48,41 +48,40 @@ namespace CalamityMod.Items.Weapons.Melee type = ModContent.ProjectileType(); break; } - float num72 = Main.rand.Next(22, 30); - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y + vector2.Y; + float projSpeed = Main.rand.Next(22, 30); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - int num107 = 16; - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 16; i++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)-(float)player.direction + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f; - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-360, 361) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-360, 361) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 2f, 0f); + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)-(float)player.direction + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f; + realPlayerPos.Y -= (float)(100 * i); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = projSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-360, 361) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-360, 361) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 2f, 0f); } return false; } @@ -91,9 +90,9 @@ namespace CalamityMod.Items.Weapons.Melee { if (Main.rand.NextBool(5)) { - int num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); - Main.dust[num250].velocity *= 0.2f; - Main.dust[num250].noGravity = true; + int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f); + Main.dust[swingDust].velocity *= 0.2f; + Main.dust[swingDust].noGravity = true; } } } diff --git a/Items/Weapons/Melee/TheEnforcer.cs b/Items/Weapons/Melee/TheEnforcer.cs index c0826412bb..0805acfa6f 100644 --- a/Items/Weapons/Melee/TheEnforcer.cs +++ b/Items/Weapons/Melee/TheEnforcer.cs @@ -42,48 +42,47 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); SoundEngine.PlaySound(SoundID.Item73, player.Center); - int i = Main.myPlayer; - float num72 = 3f; + int j = Main.myPlayer; + float flameSpeed = 3f; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y + vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = player.direction; + mouseYDist = 0f; + mouseDistance = flameSpeed; } else { - num80 = num72 / num80; + mouseDistance = flameSpeed / mouseDistance; } - int num107 = 5; int essenceDamage = player.CalcIntDamage(0.25f * Item.damage); - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 5; i++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); - vector2.Y -= 100 * num108; - num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); + realPlayerPos.Y -= 100 * i; + mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - num80 = num72 / num80; - Projectile.NewProjectile(source, vector2, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); + mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + mouseDistance = flameSpeed / mouseDistance; + Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); } } @@ -91,48 +90,47 @@ namespace CalamityMod.Items.Weapons.Melee { var source = player.GetSource_ItemUse(Item); SoundEngine.PlaySound(SoundID.Item73, player.Center); - int i = Main.myPlayer; - float num72 = 3f; + int j = Main.myPlayer; + float flameSpeed = 3f; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X + vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y + vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X + realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight + Main.mouseY + realPlayerPos.Y; } - float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = player.direction; + mouseYDist = 0f; + mouseDistance = flameSpeed; } else { - num80 = num72 / num80; + mouseDistance = flameSpeed / mouseDistance; } - int num107 = 5; int essenceDamage = player.CalcIntDamage(0.25f * Item.damage); - for (int num108 = 0; num108 < num107; num108++) + for (int i = 0; i < 5; i++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); - vector2.Y -= 100 * num108; - num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(401) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-400, 401); + realPlayerPos.Y -= 100 * i; + mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - num80 = num72 / num80; - Projectile.NewProjectile(source, vector2, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); + mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + mouseDistance = flameSpeed / mouseDistance; + Projectile.NewProjectile(source, realPlayerPos, Vector2.Zero, ModContent.ProjectileType(), essenceDamage, 0f, i, 0f, Main.rand.Next(3)); } } diff --git a/Items/Weapons/Melee/TheMutilator.cs b/Items/Weapons/Melee/TheMutilator.cs index 57afc04611..da73273a8d 100644 --- a/Items/Weapons/Melee/TheMutilator.cs +++ b/Items/Weapons/Melee/TheMutilator.cs @@ -49,23 +49,23 @@ namespace CalamityMod.Items.Weapons.Melee target.position.Y += target.height / 2; target.position.X -= target.width / 2; target.position.Y -= target.height / 2; - for (int num621 = 0; num621 < 30; num621++) + for (int i = 0; i < 30; i++) { - int num622 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int bloodDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[bloodDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[bloodDust].scale = 0.5f; + Main.dust[bloodDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[bloodDust2].noGravity = true; + Main.dust[bloodDust2].velocity *= 5f; + bloodDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[bloodDust2].velocity *= 2f; } } } diff --git a/Items/Weapons/Melee/UltimusCleaver.cs b/Items/Weapons/Melee/UltimusCleaver.cs index 4d0845dc34..31df9995be 100644 --- a/Items/Weapons/Melee/UltimusCleaver.cs +++ b/Items/Weapons/Melee/UltimusCleaver.cs @@ -34,42 +34,42 @@ namespace CalamityMod.Items.Weapons.Melee target.AddBuff(BuffID.OnFire3, 360); int onHitDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (target.rotation - 1.57079637f).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 1.7f; + float secondDustScale = 0.8f; + float thirdDustScale = 2f; + Vector2 dustRotation = (target.rotation - 1.57079637f).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - int num3; - for (int num53 = 0; num53 < 40; num53 = num3 + 1) + int increment; + for (int i = 0; i < 40; i = increment + 1) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[swingDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + swingDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * (float)target.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); - num3 = num53; + dust.velocity += dustVelocity * Main.rand.NextFloat(); + increment = i; } - for (int num55 = 0; num55 < 20; num55 = num3 + 1) + for (int j = 0; j < 20; j = increment + 1) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int swingDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[swingDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)target.velocity.ToRotation(), default) * (float)target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - num3 = num55; + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); + increment = j; } } @@ -83,65 +83,65 @@ namespace CalamityMod.Items.Weapons.Melee player.itemAnimation == (int)(player.itemAnimationMax * 0.7) || player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - float num339 = 0f; - float num340 = 0f; - float num341 = 0f; - float num342 = 0f; + float sparkYVel = 0f; + float sparkXVel = 0f; + float sparkYSpawn = 0f; + float sparkXSpawn = 0f; if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num339 = -7f; + sparkYVel = -7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num339 = -6f; - num340 = 2f; + sparkYVel = -6f; + sparkXVel = 2f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.5)) { - num339 = -4f; - num340 = 4f; + sparkYVel = -4f; + sparkXVel = 4f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num339 = -2f; - num340 = 6f; + sparkYVel = -2f; + sparkXVel = 6f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num340 = 7f; + sparkXVel = 7f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 = 26f; + sparkXSpawn = 26f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.3)) { - num342 -= 4f; - num341 -= 20f; + sparkXSpawn -= 4f; + sparkYSpawn -= 20f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.1)) { - num341 += 6f; + sparkYSpawn += 6f; } if (player.direction == -1) { if (player.itemAnimation == (int)(player.itemAnimationMax * 0.9)) { - num342 -= 8f; + sparkXSpawn -= 8f; } if (player.itemAnimation == (int)(player.itemAnimationMax * 0.7)) { - num342 -= 6f; + sparkXSpawn -= 6f; } } - num339 *= 1.5f; - num340 *= 1.5f; - num342 *= (float)player.direction; - num341 *= player.gravDir; + sparkYVel *= 1.5f; + sparkXVel *= 1.5f; + sparkXSpawn *= (float)player.direction; + sparkYSpawn *= player.gravDir; var source = player.GetSource_ItemUse(Item); int damage = (int)player.GetTotalDamage().ApplyTo(Item.damage * 0.1f); - Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + num342, (float)(hitbox.Y + hitbox.Height / 2) + num341, - (float)player.direction * num340, num339 * player.gravDir, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, (float)(hitbox.X + hitbox.Width / 2) + sparkXSpawn, (float)(hitbox.Y + hitbox.Height / 2) + sparkYSpawn, + (float)player.direction * sparkXVel, sparkYVel * player.gravDir, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, 0f); } } } diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 37a443be04..80bdc77a98 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 source = player.RotatedRelativePoint(player.MountedCenter); - float num117 = MathHelper.Pi * 0.1f; + float tenthPi = MathHelper.Pi * 0.1f; int totalProjectiles = 6; velocity.Normalize(); @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Ranged bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0); for (int i = 0; i < totalProjectiles; i++) { - float num120 = i - (totalProjectiles - 1f) / 2f; - Vector2 offset = velocity.RotatedBy(num117 * num120); + float arrowOffset = i - (totalProjectiles - 1f) / 2f; + Vector2 offset = velocity.RotatedBy(tenthPi * arrowOffset); if (!canHit) offset -= velocity; diff --git a/Items/Weapons/Ranged/AquashardShotgun.cs b/Items/Weapons/Ranged/AquashardShotgun.cs index 45bf04d4c1..412e321103 100644 --- a/Items/Weapons/Ranged/AquashardShotgun.cs +++ b/Items/Weapons/Ranged/AquashardShotgun.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(2, 4); - for (int index = 0; index < num6; ++index) + int projAmt = Main.rand.Next(2, 4); + for (int index = 0; index < projAmt; ++index) { float SpeedX = velocity.X + Main.rand.Next(-40, 41) * 0.05f; float SpeedY = velocity.Y + Main.rand.Next(-40, 41) * 0.05f; diff --git a/Items/Weapons/Ranged/ArterialAssault.cs b/Items/Weapons/Ranged/ArterialAssault.cs index 0d6dab7648..ee342f4866 100644 --- a/Items/Weapons/Ranged/ArterialAssault.cs +++ b/Items/Weapons/Ranged/ArterialAssault.cs @@ -37,46 +37,46 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float arrowSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = arrowSpeed; } else { - num80 = num72 / num80; + mouseDistance = arrowSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (-(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f; - vector2.Y -= 100f; - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (-(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f; + realPlayerPos.Y -= 100f; + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78; - float speedY5 = num79; - int shotArrow = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = arrowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist; + float speedY5 = mouseYDist; + int shotArrow = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); Main.projectile[shotArrow].noDropItem = true; Main.projectile[shotArrow].tileCollide = false; Main.projectile[shotArrow].timeLeft = (int)(Main.projectile[shotArrow].timeLeft * Main.projectile[shotArrow].MaxUpdates * 0.75f); @@ -93,4 +93,4 @@ namespace CalamityMod.Items.Weapons.Ranged Register(); } } -} \ No newline at end of file +} diff --git a/Items/Weapons/Ranged/AuroraBlazer.cs b/Items/Weapons/Ranged/AuroraBlazer.cs index 00c45e3909..e5555c26b4 100644 --- a/Items/Weapons/Ranged/AuroraBlazer.cs +++ b/Items/Weapons/Ranged/AuroraBlazer.cs @@ -15,13 +15,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.damage = 49; Item.DamageType = DamageClass.Ranged; - Item.useTime = 18; - Item.useAnimation = 18; + Item.useTime = 5; + Item.useAnimation = 30; Item.knockBack = 2f; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 7.5f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.width = 68; Item.height = 36; @@ -32,21 +33,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.Lime; } - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - float SpeedX = velocity.X + Main.rand.NextFloat(-15f, 15f) * 0.05f; - float SpeedY = velocity.Y + Main.rand.NextFloat(-15f, 15f) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, Main.rand.Next(4, 11), 0f); - return false; - } - - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Ranged/AuroraBlazerGlow").Value); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request(Texture + "Glow").Value); public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 60; } } diff --git a/Items/Weapons/Ranged/BladedgeGreatbow.cs b/Items/Weapons/Ranged/BladedgeGreatbow.cs index 00d8ab463a..3db7c451d2 100644 --- a/Items/Weapons/Ranged/BladedgeGreatbow.cs +++ b/Items/Weapons/Ranged/BladedgeGreatbow.cs @@ -45,21 +45,21 @@ namespace CalamityMod.Items.Weapons.Ranged int index = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI); Main.projectile[index].noDropItem = true; } - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); float PiOver10 = MathHelper.Pi * 0.1f; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 10f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < 2; num119++) + Vector2 arrowVel = velocity; + arrowVel.Normalize(); + arrowVel *= 10f; + bool arrowHitsTiles = Collision.CanHit(realPlayerPos, 0, 0, realPlayerPos + arrowVel, 0, 0); + for (int i = 0; i < 2; i++) { - float num120 = (float)num119 - 1f / 2f; - Vector2 value9 = vector7.RotatedBy((double)(PiOver10 * num120), default); - if (!flag11) + float arrowOffset = (float)i - 1f / 2f; + Vector2 offsetSpawn = arrowVel.RotatedBy((double)(PiOver10 * arrowOffset), default); + if (!arrowHitsTiles) { - value9 -= vector7; + offsetSpawn -= arrowVel; } - int projectile = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, ProjectileID.Leaf, damage, 0f, player.whoAmI); + int projectile = Projectile.NewProjectile(source, realPlayerPos.X + offsetSpawn.X, realPlayerPos.Y + offsetSpawn.Y, velocity.X, velocity.Y, ProjectileID.Leaf, damage, 0f, player.whoAmI); if (projectile.WithinBounds(Main.maxProjectiles)) Main.projectile[projectile].DamageType = DamageClass.Ranged; } diff --git a/Items/Weapons/Ranged/BlightSpewer.cs b/Items/Weapons/Ranged/BlightSpewer.cs index ec4708815f..f6d3c59cc3 100644 --- a/Items/Weapons/Ranged/BlightSpewer.cs +++ b/Items/Weapons/Ranged/BlightSpewer.cs @@ -1,6 +1,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -10,26 +11,33 @@ namespace CalamityMod.Items.Weapons.Ranged public class BlightSpewer : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Nanomachines = new("CalamityMod/Sounds/Item/NanoSwarm") { PitchVariance = 0.45f, Volume = 0.4f }; public override void SetDefaults() { - Item.damage = 110; + Item.damage = 58; Item.DamageType = DamageClass.Ranged; Item.width = 76; Item.height = 36; - Item.useTime = 10; - Item.useAnimation = 30; + Item.useTime = 19; + Item.useAnimation = 19; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 2f; + Item.knockBack = 1.5f; Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity8BuyPrice; Item.rare = ItemRarityID.Yellow; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 7.5f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 7f; Item.useAmmo = AmmoID.Gel; } - + public override bool CanConsumeAmmo(Item ammo, Player player) + { + if (Main.rand.Next(0, 100) < 50) + return false; + return true; + } public override Vector2? HoldoutOffset() { return new Vector2(-10, 0); diff --git a/Items/Weapons/Ranged/BloodBoiler.cs b/Items/Weapons/Ranged/BloodBoiler.cs index 9348f54939..3a45180348 100644 --- a/Items/Weapons/Ranged/BloodBoiler.cs +++ b/Items/Weapons/Ranged/BloodBoiler.cs @@ -3,6 +3,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,21 +13,26 @@ namespace CalamityMod.Items.Weapons.Ranged public class BloodBoiler : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Heartbeat = new("CalamityMod/Sounds/Item/Heartbeat") { PitchVariance = 0.2f, Volume = 0.55f }; + + public bool shotReturn = false; public override void SetDefaults() { - Item.damage = 145; + Item.damage = 185; Item.DamageType = DamageClass.Ranged; Item.width = 60; Item.height = 30; Item.useTime = 5; - Item.useAnimation = 15; + Item.useAnimation = 20; Item.autoReuse = true; + Item.UseSound = Heartbeat; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4f; Item.value = CalamityGlobalItem.Rarity12BuyPrice; Item.rare = ModContent.RarityType(); - Item.shootSpeed = 12f; + Item.shootSpeed = 9.5f; Item.shoot = ModContent.ProjectileType(); } @@ -34,15 +40,18 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (Main.rand.NextFloat() > 0.75f) - --player.statLife; + shotReturn = !shotReturn; + if (Main.rand.NextFloat() > 0.60f) + player.statLife -= 1; if (player.statLife <= 0) { PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodBoiler" + Main.rand.Next(1, 2 + 1)).Format(player.name)); player.KillMe(pdr, 1000.0, 0, false); return false; } - return true; + Vector2 newVel = velocity.RotatedBy(shotReturn ? 0.03f : -0.03f); + Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI, 0, 0, shotReturn ? 5 : 0); + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/CleansingBlaze.cs b/Items/Weapons/Ranged/CleansingBlaze.cs index 19e4d8004b..49e048daed 100644 --- a/Items/Weapons/Ranged/CleansingBlaze.cs +++ b/Items/Weapons/Ranged/CleansingBlaze.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 130; + Item.damage = 240; Item.DamageType = DamageClass.Ranged; - Item.width = 64; - Item.height = 32; + Item.width = 108; + Item.height = 38; Item.useTime = 3; - Item.useAnimation = 12; + Item.useAnimation = 24; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4f; @@ -29,39 +29,26 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; + Item.shootSpeed = 11f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.rare = ModContent.RarityType(); } - public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) - { - Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Ranged/CleansingBlazeGlow").Value); - } + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) => Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request(Texture + "Glow").Value); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(2, 4); - for (int index = 0; index < num6; ++index) + Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 36f; + for (int i = 0; i < 3; i++) { - float SpeedX = velocity.X + (float)Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-15, 16) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); + Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI); } return false; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 90) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-20, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/CleansingBlaze.png b/Items/Weapons/Ranged/CleansingBlaze.png index e185d1db7e..bdf253d486 100644 Binary files a/Items/Weapons/Ranged/CleansingBlaze.png and b/Items/Weapons/Ranged/CleansingBlaze.png differ diff --git a/Items/Weapons/Ranged/CleansingBlazeGlow.png b/Items/Weapons/Ranged/CleansingBlazeGlow.png index a09f3d2248..3a8bdd621d 100644 Binary files a/Items/Weapons/Ranged/CleansingBlazeGlow.png and b/Items/Weapons/Ranged/CleansingBlazeGlow.png differ diff --git a/Items/Weapons/Ranged/ConferenceCall.cs b/Items/Weapons/Ranged/ConferenceCall.cs index 3359b6c12f..87052ebb5e 100644 --- a/Items/Weapons/Ranged/ConferenceCall.cs +++ b/Items/Weapons/Ranged/ConferenceCall.cs @@ -79,18 +79,18 @@ namespace CalamityMod.Items.Weapons.Ranged if (targetArrayIndex == 0) return false; - Vector2 vector2; + Vector2 targetPosition; int extraBulletDamage = (int)(damage * 0.8); for (int j = 0; j < targetArrayIndex; j++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * j; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * j; - Vector2 velocity2 = CalamityUtils.CalculatePredictiveAimToTarget(vector2, Main.npc[targets[j]], Item.shootSpeed); + Vector2 extraBulletVel = CalamityUtils.CalculatePredictiveAimToTarget(targetPosition, Main.npc[targets[j]], Item.shootSpeed); - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; @@ -104,13 +104,13 @@ namespace CalamityMod.Items.Weapons.Ranged { int randomTarget = Main.rand.Next(targetArrayIndex); - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * randomTarget; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * randomTarget; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * Item.shootSpeed; + Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; diff --git a/Items/Weapons/Ranged/ContinentalGreatbow.cs b/Items/Weapons/Ranged/ContinentalGreatbow.cs index ffeb621ef6..77f85f7128 100644 --- a/Items/Weapons/Ranged/ContinentalGreatbow.cs +++ b/Items/Weapons/Ranged/ContinentalGreatbow.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Items.Weapons.Ranged { type = ProjectileID.FireArrow; } - int num121 = Projectile.NewProjectile(spawnSource, source + offset, velocity, type, damage, knockback, player.whoAmI); - Main.projectile[num121].noDropItem = true; + int baseArrow = Projectile.NewProjectile(spawnSource, source + offset, velocity, type, damage, knockback, player.whoAmI); + Main.projectile[baseArrow].noDropItem = true; } for (int i = 0; i < 2; i++) { diff --git a/Items/Weapons/Ranged/DeadSunsWind.cs b/Items/Weapons/Ranged/DeadSunsWind.cs index b107626c62..08579dd809 100644 --- a/Items/Weapons/Ranged/DeadSunsWind.cs +++ b/Items/Weapons/Ranged/DeadSunsWind.cs @@ -2,6 +2,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -11,18 +12,21 @@ namespace CalamityMod.Items.Weapons.Ranged public class DeadSunsWind : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Shoot = new("CalamityMod/Sounds/Item/DeadSunShot") { PitchVariance = 0.35f, Volume = 0.4f }; + public static readonly SoundStyle Ricochet = new("CalamityMod/Sounds/Item/DeadSunRicochet") { Volume = 0.35f }; + public static readonly SoundStyle Explosion = new("CalamityMod/Sounds/Item/DeadSunExplosion") { Volume = 0.5f }; public override void SetDefaults() { - Item.damage = 80; + Item.damage = 182; Item.DamageType = DamageClass.Ranged; Item.width = 70; Item.height = 24; - Item.useTime = 6; - Item.useAnimation = 18; + Item.useTime = Item.useAnimation = 22; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; - Item.UseSound = SoundID.Item34; + Item.UseSound = Shoot; Item.value = CalamityGlobalItem.Rarity9BuyPrice; Item.rare = ItemRarityID.Cyan; Item.autoReuse = true; @@ -31,17 +35,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Gel; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 70) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/Deathwind.cs b/Items/Weapons/Ranged/Deathwind.cs index f53623d067..9b38ae885c 100644 --- a/Items/Weapons/Ranged/Deathwind.cs +++ b/Items/Weapons/Ranged/Deathwind.cs @@ -50,8 +50,8 @@ namespace CalamityMod.Items.Weapons.Ranged } else { - int num121 = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockback, player.whoAmI); - Main.projectile[num121].noDropItem = true; + int baseArrow = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockback, player.whoAmI); + Main.projectile[baseArrow].noDropItem = true; } } return false; diff --git a/Items/Weapons/Ranged/Disseminator.cs b/Items/Weapons/Ranged/Disseminator.cs index a90fb1e83c..9cf80321e1 100644 --- a/Items/Weapons/Ranged/Disseminator.cs +++ b/Items/Weapons/Ranged/Disseminator.cs @@ -79,29 +79,29 @@ namespace CalamityMod.Items.Weapons.Ranged if (targetArrayIndex == 0) return false; - Vector2 vector2; + Vector2 targetPosition; int extraBulletDamage = (int)(damage * 0.7); for (int j = 0; j < targetArrayIndex; j++) { - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * j; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * j; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * Item.shootSpeed; + Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[j]].Center - targetPosition) * Item.shootSpeed; - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y += 100 * j; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y += 100 * j; - velocity2 = Vector2.Normalize(Main.npc[targets[j]].Center - vector2) * Item.shootSpeed; + extraBulletVel = Vector2.Normalize(Main.npc[targets[j]].Center - targetPosition) * Item.shootSpeed; - proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; @@ -115,24 +115,24 @@ namespace CalamityMod.Items.Weapons.Ranged { int randomTarget = Main.rand.Next(targetArrayIndex); - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100 * randomTarget; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y -= 100 * randomTarget; - Vector2 velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * Item.shootSpeed; + Vector2 extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; - int proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + int proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y += 100 * randomTarget; + targetPosition = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y + 600f); + targetPosition.X = (targetPosition.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + targetPosition.Y += 100 * randomTarget; - velocity2 = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - vector2) * Item.shootSpeed; + extraBulletVel = Vector2.Normalize(Main.npc[targets[randomTarget]].Center - targetPosition) * Item.shootSpeed; - proj = Projectile.NewProjectile(source, vector2, velocity2, type, extraBulletDamage, knockback, player.whoAmI); + proj = Projectile.NewProjectile(source, targetPosition, extraBulletVel, type, extraBulletDamage, knockback, player.whoAmI); Main.projectile[proj].extraUpdates += 2; Main.projectile[proj].tileCollide = false; Main.projectile[proj].timeLeft /= 2; diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index 7998f6fe0d..e2877d9aca 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -1,6 +1,8 @@ -using CalamityMod.Projectiles.Ranged; +using System; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -12,154 +14,130 @@ namespace CalamityMod.Items.Weapons.Ranged public class DragonsBreath : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - public const int BetweenShotsPause = 15; - public const int PelletsPerShot = 6; - public const float FullAutoFireRateMult = 0.8f; - public const float FullAutoDamageMult = 0.8f; - // note this is extremely low because it's per pellet - public const float Spread = 0.018f; + + public static readonly SoundStyle FireballSound = new("CalamityMod/Sounds/Custom/Yharon/YharonFireball", 3) { PitchVariance = 0.3f, Volume = 0.75f }; + public static readonly SoundStyle WeldingBurn = new("CalamityMod/Sounds/Item/WeldingBurn") { Volume = 0.65f }; + public static readonly SoundStyle WeldingShoot = new("CalamityMod/Sounds/Item/WeldingShoot") { Volume = 0.45f }; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + public SlotId WeldSoundSlot; + + public int BetweenShotsPause = 14; + public float Counter = 2; + public float MaxFirerateShots = 20; + public float WeldingShots = 50; + public bool StrongShotMode = false; + public int DragonsBreathSetUseTime = 5; + public int DragonsBreathSetUseAnimation = 9; public override void SetDefaults() { - Item.damage = 162; + Item.damage = 493; Item.DamageType = DamageClass.Ranged; - Item.width = 124; - Item.height = 78; - Item.useTime = 9; - Item.useAnimation = 18; + Item.width = 94; + Item.height = 72; + Item.useTime = DragonsBreathSetUseTime; + Item.useAnimation = DragonsBreathSetUseAnimation; Item.reuseDelay = BetweenShotsPause; - Item.useLimitPerAnimation = 2; Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 6.5f; - // item.UseSound = SoundID.Item38; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 12f; - Item.useAmmo = AmmoID.Bullet; - Item.Calamity().canFirePointBlankShots = true; + Item.knockBack = 4.5f; + Item.UseSound = null; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 3.5f; + Item.useAmmo = AmmoID.Gel; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.Rarity15BuyPrice; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.66f; + public override bool CanConsumeAmmo(Item ammo, Player player) => !StrongShotMode && Main.rand.NextFloat() > 0.80f; - public override Vector2? HoldoutOffset() => new Vector2(-5, 5); - - public override bool AltFunctionUse(Player player) => true; - - public override bool CanUseItem(Player player) - { - Item.reuseDelay = player.altFunctionUse == 2 ? 0 : BetweenShotsPause; - return base.CanUseItem(player); - } - - public override float UseSpeedMultiplier(Player player) => player.altFunctionUse == 2 ? FullAutoFireRateMult : 1f; + public override Vector2? HoldoutOffset() => new Vector2(18, 10.5f); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - SoundEngine.PlaySound(SoundID.Item38, position); - bool doDust = false; - Vector2 vel = velocity; - int[] bulletIDs = new int[PelletsPerShot]; - float spreadFactor = 1f; - - // Right click full auto: Randomly intermix three regular bullets and three Dragon's Breath Rounds in a wider spread - if (player.altFunctionUse == 2) + if (!StrongShotMode) { - damage = (int)(damage * FullAutoDamageMult); + if (Counter == 2) + SoundEngine.PlaySound(FireballSound, player.Center); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(2.5f)); + Projectile.NewProjectile(source, position, newVel * Main.rand.NextFloat(1.2f, 0.8f), type, damage, knockback, player.whoAmI); + Counter--; + if (MaxFirerateShots > 0 && BetweenShotsPause == 4) + MaxFirerateShots--; - for (int i = 0; i < PelletsPerShot; ++i) - bulletIDs[i] = type; - int dragonsBreathAdded = 0; - while (dragonsBreathAdded < PelletsPerShot / 2) + if (Counter <= 0) { - int i = Main.rand.Next(PelletsPerShot); - if (bulletIDs[i] == Item.shoot) - continue; - bulletIDs[i] = Item.shoot; - ++dragonsBreathAdded; + if (BetweenShotsPause > 4) + { + BetweenShotsPause -= 1; + Item.reuseDelay = BetweenShotsPause; + } + Counter = 2; + } + if (BetweenShotsPause <= 4 && MaxFirerateShots == 0) + { + BetweenShotsPause = 0; + Item.reuseDelay = BetweenShotsPause; + StrongShotMode = true; + DragonsBreathSetUseTime = 2; + DragonsBreathSetUseAnimation = 2; + SoundEngine.PlaySound(ScorchedEarth.ShootSound, player.Center); } - - spreadFactor = 1.52f; } - // Left click first shot: Six regular bullets, low spread - else if (player.itemAnimation == player.itemAnimationMax - 1) + else if (StrongShotMode) { - for (int i = 0; i < PelletsPerShot; ++i) - bulletIDs[i] = type; - } - // Left click second shot: Six Dragon's Breath Rounds, very low spread. Extra sound and dust blast. - else - { - SoundEngine.PlaySound(SoundID.Item74, position); - for (int i = 0; i < PelletsPerShot; ++i) - bulletIDs[i] = Item.shoot; - - spreadFactor = 0.5f; - doDust = true; - } - - // Actually fire the chosen bullets. - float angleOffset = Spread * -0.5f * (PelletsPerShot - 1) * spreadFactor; - for (int i = 0; i < PelletsPerShot; ++i) - { - Vector2 rotatedVel = vel.RotatedBy(angleOffset); - Projectile.NewProjectile(source, position, rotatedVel, bulletIDs[i], damage, knockback, player.whoAmI); - angleOffset += Spread * spreadFactor; - - if (doDust) - SpawnDragonsBreathDust(position, rotatedVel); + if (SoundEngine.TryGetActiveSound(WeldSoundSlot, out var WeldSound) && WeldSound.IsPlaying) + WeldSound.Position = player.Center; + if (player.Calamity().DragonsBreathAudioCooldown2 == 0) + { + player.Calamity().DragonsBreathAudioCooldown2 = 30; + WeldSoundSlot = SoundEngine.PlaySound(WeldingShoot, player.Center); + } + Projectile.NewProjectile(source, position, velocity * 1.5f, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 1); + WeldingShots--; + if (WeldingShots <= 0) + { + Counter = 2; + BetweenShotsPause = 14; + Item.reuseDelay = BetweenShotsPause; + SoundEngine.PlaySound(SpeedBlaster.Empty, player.Center); + Projectile.NewProjectile(source, player.Center, new Vector2(5 * -player.direction, -5), ModContent.ProjectileType(), Main.zenithWorld ? 250000 : 1, knockback, player.whoAmI); + MaxFirerateShots = 20; + WeldingShots = 50; + WeldSound?.Stop(); + StrongShotMode = false; + DragonsBreathSetUseTime = 5; + DragonsBreathSetUseAnimation = 9; + } } return false; } - - private void SpawnDragonsBreathDust(Vector2 pos, Vector2 velocity) + public override void UseStyle(Player player, Rectangle heldItemFrame) { - pos += velocity.SafeNormalize(Vector2.Zero) * Item.width * Item.scale * 0.71f; - for (int i = 0; i < 30; ++i) - { - // Pick a random type of smoke (there's a little fire mixed in) - int dustID; - switch (Main.rand.Next(6)) - { - case 0: - dustID = 262; - break; - case 1: - case 2: - dustID = 54; - break; - default: - dustID = 53; - break; - } + player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; - // Choose a random speed and angle to belch out the smoke - float dustSpeed = Main.rand.NextFloat(3.0f, 13.0f); - float angleRandom = 0.06f; - Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(velocity.ToRotation()); - dustVel = dustVel.RotatedBy(-angleRandom); - dustVel = dustVel.RotatedByRandom(2.0f * angleRandom); + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 7f; + Vector2 itemSize = new Vector2(94, 72); + Vector2 itemOrigin = new Vector2(-17, 3); - // Sometimes make smoke fly upward instead of outward. - if (Main.rand.NextBool(4)) - dustVel = Vector2.Lerp(dustVel, -Vector2.UnitY * dustVel.Length(), Main.rand.NextFloat(0.6f, 0.85f)) * 0.6f; + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); - // Pick a size for the smoke particle - float scale = Main.rand.NextFloat(0.5f, 1.6f); + base.UseStyle(player, heldItemFrame); + } - // Actually spawn the smoke - int idx = Dust.NewDust(pos, 1, 1, dustID, dustVel.X, dustVel.Y, 0, default, scale); - Main.dust[idx].noGravity = true; - Main.dust[idx].position = pos; - } + public override void UseItemFrame(Player player) + { + player.direction = Math.Sign((player.Calamity().mouseWorld - player.Center).X); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + if (animProgress < 0.4f) + rotation += StrongShotMode && WeldingShots == 1 ? -0.25f * (float)Math.Pow((0.6f - animProgress) / 0.6f, 2) * player.direction : 0; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); } } } diff --git a/Items/Weapons/Ranged/DragonsBreath.png b/Items/Weapons/Ranged/DragonsBreath.png index afb0f0ec98..3ff2a5ca01 100644 Binary files a/Items/Weapons/Ranged/DragonsBreath.png and b/Items/Weapons/Ranged/DragonsBreath.png differ diff --git a/Items/Weapons/Ranged/Drataliornus.cs b/Items/Weapons/Ranged/Drataliornus.cs index f455891ab1..2fb5edea6c 100644 --- a/Items/Weapons/Ranged/Drataliornus.cs +++ b/Items/Weapons/Ranged/Drataliornus.cs @@ -75,15 +75,15 @@ namespace CalamityMod.Items.Weapons.Ranged const int numFlames = 5; int flameDamage = (int)(damage * RightClickDamageRatio); - const float num3 = 0.471238898f; + const float fifteenHundredthPi = 0.471238898f; Vector2 spinningpoint = velocity; spinningpoint.Normalize(); spinningpoint *= 36f; - for (int index1 = 0; index1 < numFlames; ++index1) + for (int i = 0; i < numFlames; ++i) { - float num8 = index1 - (numFlames - 1) / 2; - Vector2 vector2_5 = spinningpoint.RotatedBy(num3 * num8, new Vector2()); - Projectile.NewProjectile(source, position.X + vector2_5.X, position.Y + vector2_5.Y, velocity.X, velocity.Y, flameID, flameDamage, knockback, player.whoAmI, 1f, 0f); + float piArrowOffset = i - (numFlames - 1) / 2; + Vector2 offsetSpawn = spinningpoint.RotatedBy(fifteenHundredthPi * piArrowOffset, new Vector2()); + Projectile.NewProjectile(source, position.X + offsetSpawn.X, position.Y + offsetSpawn.Y, velocity.X, velocity.Y, flameID, flameDamage, knockback, player.whoAmI, 1f, 0f); } } else diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 07b4755e46..9fb00ce050 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -11,48 +11,50 @@ namespace CalamityMod.Items.Weapons.Ranged public class ElementalEruption : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public int FlareCounter = 0; + + public override void SetStaticDefaults() + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + } + public override void SetDefaults() { - Item.damage = 77; + Item.damage = 83; Item.DamageType = DamageClass.Ranged; Item.width = 64; Item.height = 34; - Item.useTime = 14; - Item.useAnimation = 14; + Item.useAnimation = Item.useTime = 6; Item.useStyle = ItemUseStyleID.Shoot; + Item.noUseGraphic = true; Item.noMelee = true; Item.knockBack = 3.5f; Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity11BuyPrice; Item.rare = ItemRarityID.Purple; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 10f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 9f; Item.useAmmo = AmmoID.Gel; + Item.channel = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int numFirestreams = Main.rand.Next(3, 5); - for (int index = 0; index < numFirestreams; ++index) - { - float SpeedX = velocity.X + Main.rand.Next(-20, 21) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-20, 21) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); - } + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > 0.9f; - public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). - AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(5). diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 78c4f01c40..0238256994 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Items.Weapons.Ranged if (player.altFunctionUse == 2) { velocity *= 2f; - int num6 = Main.rand.Next(4, 6); - for (int index = 0; index < num6; ++index) + int flareAmt = Main.rand.Next(4, 6); + for (int index = 0; index < flareAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-50, 51) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-50, 51) * 0.05f; @@ -70,8 +70,8 @@ namespace CalamityMod.Items.Weapons.Ranged } else { - int num6 = Main.rand.Next(1, 3); - for (int index = 0; index < num6; ++index) + int flareAmt = Main.rand.Next(1, 3); + for (int index = 0; index < flareAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; diff --git a/Items/Weapons/Ranged/FlarewingBow.cs b/Items/Weapons/Ranged/FlarewingBow.cs index 5cde932d3d..dbc0a5d0f3 100644 --- a/Items/Weapons/Ranged/FlarewingBow.cs +++ b/Items/Weapons/Ranged/FlarewingBow.cs @@ -35,29 +35,28 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 3; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 50f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + float tenthPi = 0.314159274f; + Vector2 arrowVel = velocity; + arrowVel.Normalize(); + arrowVel *= 50f; + bool arrowHitsTiles = Collision.CanHit(vector2, 0, 0, vector2 + arrowVel, 0, 0); + for (int i = 0; i < 3; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float piOffsetValue = (float)i - 1f; + Vector2 offsetSpawn = arrowVel.RotatedBy((double)(tenthPi * piOffsetValue), default); + if (!arrowHitsTiles) { - value9 -= vector7; + offsetSpawn -= arrowVel; } if (CalamityUtils.CheckWoodenAmmo(type, player)) { - int num123 = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - Main.projectile[num123].noDropItem = true; + int arrowSpawn = Projectile.NewProjectile(source, vector2.X + offsetSpawn.X, vector2.Y + offsetSpawn.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Main.projectile[arrowSpawn].noDropItem = true; } else { - int num123 = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); - Main.projectile[num123].noDropItem = true; + int arrowSpawn = Projectile.NewProjectile(source, vector2.X + offsetSpawn.X, vector2.Y + offsetSpawn.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + Main.projectile[arrowSpawn].noDropItem = true; } } return false; diff --git a/Items/Weapons/Ranged/GunkShot.cs b/Items/Weapons/Ranged/GunkShot.cs index 290e75df07..ee19d870a9 100644 --- a/Items/Weapons/Ranged/GunkShot.cs +++ b/Items/Weapons/Ranged/GunkShot.cs @@ -39,8 +39,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int num6 = Main.rand.Next(3, 5); - for (int index = 0; index < num6; ++index) + int bulletAmt = Main.rand.Next(3, 5); + for (int index = 0; index < bulletAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-25, 26) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-25, 26) * 0.05f; diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 974dbfc314..58080aa750 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -4,6 +4,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -12,22 +13,25 @@ namespace CalamityMod.Items.Weapons.Ranged public class HalleysInferno : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public static readonly SoundStyle Shoot = new("CalamityMod/Sounds/Item/HalleysInfernoShoot") { Volume = 0.6f }; + public static readonly SoundStyle Hit = new("CalamityMod/Sounds/Item/HalleysInfernoHit") { Volume = 0.5f }; public override void SetDefaults() { - Item.damage = 1125; - Item.knockBack = 5f; + Item.damage = 1205; + Item.knockBack = 5.5f; Item.DamageType = DamageClass.Ranged; - Item.useTime = Item.useAnimation = 30; + Item.useTime = Item.useAnimation = 39; Item.autoReuse = true; Item.useAmmo = AmmoID.Gel; - Item.shootSpeed = 14.6f; + Item.shootSpeed = 12f; Item.shoot = ModContent.ProjectileType(); Item.width = 84; Item.height = 34; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.UseSound = SoundID.Item34; + Item.UseSound = Shoot; Item.value = CalamityGlobalItem.Rarity13BuyPrice; Item.rare = ModContent.RarityType(); } diff --git a/Items/Weapons/Ranged/HavocsBreath.cs b/Items/Weapons/Ranged/HavocsBreath.cs index 7c5e9546fe..dd8addabd2 100644 --- a/Items/Weapons/Ranged/HavocsBreath.cs +++ b/Items/Weapons/Ranged/HavocsBreath.cs @@ -1,6 +1,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,12 +13,13 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 67; + Item.damage = 60; Item.DamageType = DamageClass.Ranged; Item.width = 50; Item.height = 18; - Item.useTime = 9; - Item.useAnimation = 30; + Item.useTime = 5; + Item.useAnimation = 35; + Item.reuseDelay = 20; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -28,13 +30,18 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8.5f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextBool(); + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - public override Vector2? HoldoutOffset() + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - return new Vector2(-10, 0); + for (int i = 0; i <= 2; i++) + { + Projectile.NewProjectile(source, position + velocity * 4f, velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.9f, 1.25f), type, damage , knockback, player.whoAmI); + } + return false; } } } diff --git a/Items/Weapons/Ranged/Hellborn.cs b/Items/Weapons/Ranged/Hellborn.cs index 3100f92ab5..941688b083 100644 --- a/Items/Weapons/Ranged/Hellborn.cs +++ b/Items/Weapons/Ranged/Hellborn.cs @@ -76,39 +76,39 @@ namespace CalamityMod.Items.Weapons.Ranged modifiers.SourceDamage *= ExplosionDamageMultiplier; int touchDamage = player.CalcIntDamage(Item.damage); player.ApplyDamageToNPC(target, touchDamage, 0f, 0, false); - float num50 = 3.4f; - float num51 = 1.6f; - float num52 = 4f; - Vector2 value3 = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * target.velocity.Length(); + float firstDustScale = 3.4f; + float secondDustScale = 1.6f; + float thirdDustScale = 4f; + Vector2 dustRotation = (target.rotation - MathHelper.PiOver2).ToRotationVector2(); + Vector2 dustVelocity = dustRotation * target.velocity.Length(); SoundEngine.PlaySound(SoundID.Item14, target.Center); - for (int num53 = 0; num53 < 80; num53++) + for (int i = 0; i < 80; i++) { - int num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; + int contactDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 200, default, firstDustScale); + Dust dust = Main.dust[contactDust]; dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - num54 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, num51); + dust.velocity += dustVelocity * Main.rand.NextFloat(); + contactDust = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 100, default, secondDustScale); dust.position = target.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * target.width / 2f; dust.velocity.Y -= 6f; dust.velocity *= 2f; dust.noGravity = true; dust.fadeIn = 1f; dust.color = Color.Crimson * 0.5f; - dust.velocity += value4 * Main.rand.NextFloat(); + dust.velocity += dustVelocity * Main.rand.NextFloat(); } - for (int num55 = 0; num55 < 40; num55++) + for (int j = 0; j < 40; j++) { - int num56 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; + int contactDust2 = Dust.NewDust(new Vector2(target.position.X, target.position.Y), target.width, target.height, 174, 0f, 0f, 0, default, thirdDustScale); + Dust dust = Main.dust[contactDust2]; dust.position = target.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy(target.velocity.ToRotation()) * target.width / 3f; dust.noGravity = true; dust.velocity.Y -= 6f; dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); + dust.velocity += dustVelocity * (0.6f + 0.6f * Main.rand.NextFloat()); } } diff --git a/Items/Weapons/Ranged/Infinity.cs b/Items/Weapons/Ranged/Infinity.cs index 1ad1076a95..0d806aa604 100644 --- a/Items/Weapons/Ranged/Infinity.cs +++ b/Items/Weapons/Ranged/Infinity.cs @@ -57,12 +57,12 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - //If you right click, shoots an helix of normal bullets - Vector2 num7 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 num8 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, num7.X, num7.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + //If you right click, shoots a helix of normal bullets + Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); + Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, type, damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, num8.X, num8.Y, type, damage, knockback, player.whoAmI, 0f, 0f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, type, damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot2].timeLeft = 180; //Code to constantly make the shooting go side to side to make the helix if (limit) @@ -86,11 +86,11 @@ namespace CalamityMod.Items.Weapons.Ranged else { //If left click, do the same as above but spawn Charged Blasts instead - Vector2 num7 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); - Vector2 num8 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); - int shot1 = Projectile.NewProjectile(source, position.X, position.Y, num7.X, num7.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + Vector2 helixVel1 = velocity.RotatedBy(MathHelper.ToRadians(rotation)); + Vector2 helixVel2 = velocity.RotatedBy(MathHelper.ToRadians(-rotation)); + int shot1 = Projectile.NewProjectile(source, position.X, position.Y, helixVel1.X, helixVel1.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot1].timeLeft = 180; - int shot2 = Projectile.NewProjectile(source, position.X, position.Y, num8.X, num8.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + int shot2 = Projectile.NewProjectile(source, position.X, position.Y, helixVel2.X, helixVel2.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); Main.projectile[shot2].timeLeft = 180; if (limit) { diff --git a/Items/Weapons/Ranged/Meowthrower.cs b/Items/Weapons/Ranged/Meowthrower.cs index a8b2a0b9ab..b26cda021c 100644 --- a/Items/Weapons/Ranged/Meowthrower.cs +++ b/Items/Weapons/Ranged/Meowthrower.cs @@ -10,7 +10,9 @@ namespace CalamityMod.Items.Weapons.Ranged public class Meowthrower : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; - private bool Fire2 = false; + + public int CatCounter = 0; + public override void SetDefaults() { Item.damage = 37; @@ -18,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.width = 74; Item.height = 24; Item.useTime = 8; - Item.useAnimation = 8; + Item.useAnimation = 32; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.25f; @@ -27,29 +29,32 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.LightRed; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 5.5f; + Item.shootSpeed = 8f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 85) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float SpeedX = velocity.X + (float)Main.rand.Next(-15, 16) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-15, 16) * 0.05f; - int projType = Fire2 ? ModContent.ProjectileType() : type; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, projType, damage, knockback, player.whoAmI, 0.0f, 0.0f); - Fire2 = !Fire2; + // Fires a homing cat... thing + CatCounter++; + if (CatCounter >= 4) + { + CatCounter = 0; + // They prefer to avoid the smokes + Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 38f; + Vector2 newVel = velocity.RotatedBy(MathHelper.ToRadians(Main.rand.NextFloat(6f, 15f) * Main.rand.NextBool().ToDirectionInt())) * 1.5f; + Projectile.NewProjectile(source, newPos, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + } + + // Fires two flames, blue and pink, slightly randomly spread + for (int i = 0; i < 2; i++) + { + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(6f)); + Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI, i); + } return false; } } diff --git a/Items/Weapons/Ranged/NettlevineGreatbow.cs b/Items/Weapons/Ranged/NettlevineGreatbow.cs index fd53d37d1b..186a929722 100644 --- a/Items/Weapons/Ranged/NettlevineGreatbow.cs +++ b/Items/Weapons/Ranged/NettlevineGreatbow.cs @@ -36,22 +36,21 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num117 = 0.314159274f; - int num118 = 4; - Vector2 vector7 = velocity; - vector7.Normalize(); - vector7 *= 40f; - bool flag11 = Collision.CanHit(vector2, 0, 0, vector2 + vector7, 0, 0); - for (int num119 = 0; num119 < num118; num119++) + float tenthPi = 0.314159274f; + Vector2 arrowVel = velocity; + arrowVel.Normalize(); + arrowVel *= 40f; + bool arrowHitsTiles = Collision.CanHit(vector2, 0, 0, vector2 + arrowVel, 0, 0); + for (int i = 0; i < 4; i++) { - float num120 = (float)num119 - ((float)num118 - 1f) / 2f; - Vector2 value9 = vector7.RotatedBy((double)(num117 * num120), default); - if (!flag11) + float piOffsetAmt = (float)i - 3f / 2f; + Vector2 offsetSpawn = arrowVel.RotatedBy((double)(tenthPi * piOffsetAmt), default); + if (!arrowHitsTiles) { - value9 -= vector7; + offsetSpawn -= arrowVel; } - int num121 = Projectile.NewProjectile(source, vector2.X + value9.X, vector2.Y + value9.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); - Main.projectile[num121].noDropItem = true; + int arrowSpawn = Projectile.NewProjectile(source, vector2.X + offsetSpawn.X, vector2.Y + offsetSpawn.Y, velocity.X, velocity.Y, type, damage, knockback, player.whoAmI); + Main.projectile[arrowSpawn].noDropItem = true; } for (int i = 0; i < 2; i++) { diff --git a/Items/Weapons/Ranged/OverloadedBlaster.cs b/Items/Weapons/Ranged/OverloadedBlaster.cs index 923c7eed5d..873af079aa 100644 --- a/Items/Weapons/Ranged/OverloadedBlaster.cs +++ b/Items/Weapons/Ranged/OverloadedBlaster.cs @@ -12,12 +12,11 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 16; + Item.damage = 19; Item.DamageType = DamageClass.Ranged; Item.width = 42; Item.height = 34; - Item.useTime = 16; - Item.useAnimation = 16; + Item.useAnimation = Item.useTime = 22; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -25,30 +24,22 @@ namespace CalamityMod.Items.Weapons.Ranged Item.rare = ItemRarityID.LightRed; Item.UseSound = SoundID.Item9; Item.autoReuse = true; - Item.shootSpeed = 6.5f; + Item.shootSpeed = 5f; Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Gel; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-4, -5); - } + public override Vector2? HoldoutOffset() => new Vector2(-4, -5); - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 33) - return false; - return true; - } + public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 25; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int index = 0; index < 5; ++index) + Vector2 newPos = position + velocity * 6f; + for (int i = 0; i < 3; i++) { - float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.8f, 1.2f); + Projectile.NewProjectile(source, newPos, newVel, type, damage, knockback, player.whoAmI); } return false; } diff --git a/Items/Weapons/Ranged/PearlGod.cs b/Items/Weapons/Ranged/PearlGod.cs index a165d38638..28688d5b84 100644 --- a/Items/Weapons/Ranged/PearlGod.cs +++ b/Items/Weapons/Ranged/PearlGod.cs @@ -70,14 +70,14 @@ namespace CalamityMod.Items.Weapons.Ranged for (int i = 0; i < totalLoops; i++) { - int proj = Projectile.NewProjectile(source, position, velocity.RotatedBy(-rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); - Main.projectile[proj].extraUpdates += spread; - int proj2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(+rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); - Main.projectile[proj2].extraUpdates += spread; + int bullet1 = Projectile.NewProjectile(source, position, velocity.RotatedBy(-rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); + Main.projectile[bullet1].extraUpdates += spread; + int bullet2 = Projectile.NewProjectile(source, position, velocity.RotatedBy(+rotation * (i + 1)), type, (int)(damage * 0.5), knockback * 0.5f, player.whoAmI); + Main.projectile[bullet2].extraUpdates += spread; } - int proj3 = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, spread); - Main.projectile[proj3].extraUpdates += spread; + int shockblast = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, spread); + Main.projectile[shockblast].extraUpdates += spread; spread++; } @@ -85,8 +85,8 @@ namespace CalamityMod.Items.Weapons.Ranged { for (int i = 0; i < 3; i++) { - int proj = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage * 2, knockback * 2f, player.whoAmI, 0f, 10f); - Main.projectile[proj].extraUpdates += 9; + int bigShockblast = Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage * 2, knockback * 2f, player.whoAmI, 0f, 10f); + Main.projectile[bigShockblast].extraUpdates += 9; } finalShot = false; diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index 8067539b54..3f54f61e48 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -3,7 +3,9 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Linq; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -12,30 +14,34 @@ namespace CalamityMod.Items.Weapons.Ranged { public class Photoviscerator : ModItem, ILocalizedModType { + public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/PhotoUseSound") { Volume = 0.55f }; + public static readonly SoundStyle HitSound = new("CalamityMod/Sounds/Item/PhotoHitSound") { Volume = 0.45f }; public new string LocalizationCategory => "Items.Weapons.Ranged"; - public const float AmmoNotConsumeChance = 0.9f; - private const float AltFireShootSpeed = 17f; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + // Left-click stats + public static float AmmoNotConsumeChance = 0.95f; + public static int LightBombCooldown = 10; + + // Right-click stats + public static float RightClickVelocityMult = 2.5f; + public static int RightClickCooldown = 20; public override void SetDefaults() { - Item.damage = 130; + Item.width = 208; + Item.height = 66; + + Item.damage = 118; Item.DamageType = DamageClass.Ranged; - Item.width = 84; - Item.height = 30; - Item.useTime = 2; - Item.useAnimation = 10; - Item.useStyle = ItemUseStyleID.Shoot; - Item.noMelee = true; + Item.useTime = Item.useAnimation = LightBombCooldown; + Item.shootSpeed = 6f; Item.knockBack = 2f; - Item.UseSound = SoundID.Item34; - Item.autoReuse = true; - Item.shootSpeed = 18f; + Item.shoot = ModContent.ProjectileType(); Item.useAmmo = AmmoID.Gel; + Item.useStyle = ItemUseStyleID.Shoot; + Item.channel = true; + Item.noMelee = true; + Item.noUseGraphic = true; Item.rare = ModContent.RarityType(); Item.value = CalamityGlobalItem.RarityVioletBuyPrice; @@ -43,69 +49,42 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - Item.shoot = ModContent.ProjectileType(); - Item.useTime = Item.useAnimation = 27; - } - else - { - Item.useTime = 2; - Item.useAnimation = 10; - Item.shoot = ModContent.ProjectileType(); - } - return base.CanUseItem(player); - } + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; - public override Vector2? HoldoutOffset() + public override void HoldItem(Player player) { - return new Vector2(-15, 0); + if (player.whoAmI != Main.myPlayer) + return; + + // Right-click channeling + player.Calamity().rightClickListener = true; + + if (player.Calamity().mouseRight && CanUseItem(player) && !Main.mapFullscreen && !Main.blockMouse) + { + // Only one out at a time + if (Main.projectile.Any(n => n.active && n.type == Item.shoot && n.owner == player.whoAmI)) + return; + Projectile.NewProjectile(Item.GetSource_FromThis(), player.Center, Vector2.Zero, Item.shoot, 0, 0f, player.whoAmI); + } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - // Alt fire: Shoot an Exo Flare Cluster. - if (player.altFunctionUse == 2) - { - int projID = ModContent.ProjectileType(); - - position += velocity.ToRotation().ToRotationVector2() * 80f; - Projectile.NewProjectile(source, position, velocity.SafeNormalize(Vector2.Zero) * AltFireShootSpeed, projID, damage, knockback, player.whoAmI); + // The holdout will initially double up when right clicking otherwise + if (player.altFunctionUse == 2f) return false; - } - - // Left click: Exo Fire, with a chance of Exo Light Bombs. - for (int i = 0; i < 2; i++) - { - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 0f); - } - if (player.itemAnimation == 2) - { - for (int i = 0; i < 2; i++) - { - - position += velocity.ToRotation().ToRotationVector2() * 64f; - int yDirection = (i == 0).ToDirectionInt(); - velocity = velocity.RotatedBy(0.2f * yDirection); - Projectile lightBomb = Projectile.NewProjectileDirect(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - - lightBomb.localAI[1] = yDirection; - lightBomb.netUpdate = true; - } - } + + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); return false; } - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.NextFloat() > AmmoNotConsumeChance; - public override void AddRecipes() { CreateRecipe(). AddIngredient(). - AddIngredient(). AddIngredient(). + AddIngredient(). AddIngredient(). AddTile(). Register(); diff --git a/Items/Weapons/Ranged/Photoviscerator.png b/Items/Weapons/Ranged/Photoviscerator.png index e48518e0e3..904aa35731 100644 Binary files a/Items/Weapons/Ranged/Photoviscerator.png and b/Items/Weapons/Ranged/Photoviscerator.png differ diff --git a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs index 05690d6d98..56c1ce7263 100644 --- a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs +++ b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs @@ -39,59 +39,59 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; + float arrowSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = player.direction; + mouseYDist = 0f; + mouseDistance = arrowSpeed; } else { - num80 = num72 / num80; + mouseDistance = arrowSpeed / mouseDistance; } - vector2 = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); - vector2.Y -= 100f; - num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + player.width * 0.5f + (Main.rand.Next(201) * -(float)player.direction) + (Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + Main.rand.Next(-200, 201); + realPlayerPos.Y -= 100f; + mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt(num78 * num78 + num79 * num79); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; + mouseDistance = (float)Math.Sqrt(mouseXDist * mouseXDist + mouseYDist * mouseYDist); + mouseDistance = arrowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; if (CalamityUtils.CheckWoodenAmmo(type, player)) { for (int i = 0; i < 7; i++) { - float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f; - float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, i); + float speedX4 = mouseXDist + Main.rand.Next(-120, 121) * 0.02f; + float speedY5 = mouseYDist + Main.rand.Next(-120, 121) * 0.02f; + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, i); } } else { for (int i = 0; i < 7; i++) { - float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f; - float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f; - int num121 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); + float speedX4 = mouseXDist + Main.rand.Next(-120, 121) * 0.02f; + float speedY5 = mouseYDist + Main.rand.Next(-120, 121) * 0.02f; + int num121 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI); Main.projectile[num121].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/PristineFury.cs b/Items/Weapons/Ranged/PristineFury.cs index c22a3032c0..5d7a5297f2 100644 --- a/Items/Weapons/Ranged/PristineFury.cs +++ b/Items/Weapons/Ranged/PristineFury.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Ranged; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Ranged; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -14,11 +15,12 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public int frameCounter = 0; public int frame = 0; - public static int BaseDamage = 77; + public static int BaseDamage = 70; + public bool Trail = true; public override void SetStaticDefaults() { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; } public override void SetDefaults() @@ -37,6 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 11f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; Item.value = CalamityGlobalItem.Rarity12BuyPrice; Item.rare = ModContent.RarityType(); @@ -46,59 +49,51 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool AltFunctionUse(Player player) => true; - public override bool CanUseItem(Player player) - { - if (player.altFunctionUse == 2) - { - Item.useTime = 5; - Item.useAnimation = 20; - } - else - { - Item.useTime = 3; - Item.useAnimation = 15; - } - return base.CanUseItem(player); - } + // Right click consumes ammo at the same rate but faster at spewing + public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 0.5f : 1f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.altFunctionUse == 2) { - int flameAmt = 3; - damage = (int)(damage * 1.2); - for (int index = 0; index < flameAmt; ++index) + for (int i = 0; i < 2; i++) { - float SpeedX = velocity.X + Main.rand.NextFloat(-1.25f, 1.25f); - float SpeedY = velocity.Y + Main.rand.NextFloat(-1.25f, 1.25f); - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 0.8f), knockback, player.whoAmI); + Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(5f)); + Projectile.NewProjectile(source, position, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); } } else { - damage = (int)(damage * 0.94); - Projectile.NewProjectile(source, position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, Trail ? 1 : 0); + Trail = !Trail; + for (int i = 0; i <= 2; i++) + { + Dust dust = Dust.NewDustPerfect(position + velocity * 3f + new Vector2(0, -3), 158, velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.35f) * Main.rand.NextFloat(0.5f, 2.5f), 0, default, Main.rand.NextFloat(1.6f, 2f)); + dust.noGravity = true; + } + CritSpark spark = new CritSpark(position + velocity * 3f + new Vector2(0, -3), velocity.RotatedBy(0.25f * player.direction).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.2f, 1.8f), Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed, Color.OrangeRed, 0.9f, 18, 2f, 1.9f); + GeneralParticleHandler.SpawnParticle(spark); } return false; } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PristineFury_Animated").Value; + Texture2D texture = ModContent.Request(Texture + "_Animated").Value; spriteBatch.Draw(texture, position, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 4), Color.White, 0f, origin, scale, SpriteEffects.None, 0); return false; } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PristineFury_Animated").Value; + Texture2D texture = ModContent.Request(Texture + "_Animated").Value; spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 4), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); return false; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Ranged/PristineFuryGlow").Value; + Texture2D texture = ModContent.Request(Texture + "Glow").Value; spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 4, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); } } diff --git a/Items/Weapons/Ranged/Shadethrower.cs b/Items/Weapons/Ranged/Shadethrower.cs index d2a11f603b..af4bccaec2 100644 --- a/Items/Weapons/Ranged/Shadethrower.cs +++ b/Items/Weapons/Ranged/Shadethrower.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.width = 76; Item.height = 30; Item.useTime = 10; - Item.useAnimation = 10; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; @@ -28,19 +28,10 @@ namespace CalamityMod.Items.Weapons.Ranged Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8f; Item.useAmmo = AmmoID.Gel; + Item.consumeAmmoOnFirstShotOnly = true; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 66) - return false; - return true; - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override void AddRecipes() { diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 712c328ddf..847b5e039c 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -11,14 +11,15 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public override void SetDefaults() { - Item.damage = 7; + Item.damage = 10; Item.knockBack = 1f; Item.DamageType = DamageClass.Ranged; Item.autoReuse = true; - Item.useTime = 10; - Item.useAnimation = 30; + Item.useTime = 12; + Item.useAnimation = 36; Item.useAmmo = AmmoID.Gel; - Item.shootSpeed = 5f; + Item.consumeAmmoOnFirstShotOnly = true; + Item.shootSpeed = 6f; Item.shoot = ModContent.ProjectileType(); Item.width = 52; @@ -32,8 +33,6 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-4, 0); - public override bool CanConsumeAmmo(Item ammo, Player player) => Main.rand.Next(100) >= 70; - public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index 72e2affe92..8fa8a9ba9a 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -55,38 +55,38 @@ namespace CalamityMod.Items.Weapons.Ranged int i = Main.myPlayer; float sSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; + mouseXDist = (float)player.direction; + mouseYDist = 0f; } else { - num80 = sSpeed / num80; + mouseDistance = sSpeed / mouseDistance; } - float num208 = num78; - float num209 = num79; - num208 += (float)Main.rand.Next(-1, 2) * 0.5f; - num209 += (float)Main.rand.Next(-1, 2) * 0.5f; - if (Collision.CanHitLine(player.Center, 0, 0, vector2 + new Vector2(num208, num209) * 2f, 0, 0)) + float randXOffset = mouseXDist; + float randYOffset = mouseYDist; + randXOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + randYOffset += (float)Main.rand.Next(-1, 2) * 0.5f; + if (Collision.CanHitLine(player.Center, 0, 0, realPlayerPos + new Vector2(randXOffset, randYOffset) * 2f, 0, 0)) { - vector2 += new Vector2(num208, num209); + realPlayerPos += new Vector2(randXOffset, randYOffset); } - Projectile.NewProjectile(source, position.X, position.Y - player.gravDir * 4f, num208, num209, type, damage, knockback, i, 0f, (float)Main.rand.Next(12) / 6f); - int num6 = Main.rand.Next(2, 4); - for (int index = 0; index < num6; ++index) + Projectile.NewProjectile(source, position.X, position.Y - player.gravDir * 4f, randXOffset, randYOffset, type, damage, knockback, i, 0f, (float)Main.rand.Next(12) / 6f); + int bulletAmt = Main.rand.Next(2, 4); + for (int index = 0; index < bulletAmt; ++index) { float SpeedX = velocity.X + (float)Main.rand.Next(-60, 61) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-60, 61) * 0.05f; - Projectile.NewProjectile(source, vector2.X, vector2.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0f, 0f); } return false; } diff --git a/Items/Weapons/Ranged/TerraFlameburster.cs b/Items/Weapons/Ranged/TerraFlameburster.cs index 301887cddb..34b7099f26 100644 --- a/Items/Weapons/Ranged/TerraFlameburster.cs +++ b/Items/Weapons/Ranged/TerraFlameburster.cs @@ -2,6 +2,7 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -10,36 +11,40 @@ namespace CalamityMod.Items.Weapons.Ranged public class TerraFlameburster : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public int FlareCounter = 0; + public int TerraUseTime = 8; + public override void SetDefaults() { - Item.damage = 55; + Item.damage = 58; Item.DamageType = DamageClass.Ranged; Item.width = 68; Item.height = 22; - Item.useTime = 3; - Item.useAnimation = 15; + Item.useTime = TerraUseTime; + Item.useAnimation = TerraUseTime; Item.useStyle = ItemUseStyleID.Shoot; + Item.noUseGraphic = true; Item.noMelee = true; Item.knockBack = 3.25f; - Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity9BuyPrice; Item.rare = ItemRarityID.Yellow; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 7.5f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Gel; + Item.channel = true; } - public override Vector2? HoldoutOffset() + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - return new Vector2(-10, 0); - } - - public override bool CanConsumeAmmo(Item ammo, Player player) - { - if (Main.rand.Next(0, 100) < 80) - return false; - return true; + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/TheStorm.cs b/Items/Weapons/Ranged/TheStorm.cs index 48073d36a5..a2b44e1444 100644 --- a/Items/Weapons/Ranged/TheStorm.cs +++ b/Items/Weapons/Ranged/TheStorm.cs @@ -12,12 +12,18 @@ namespace CalamityMod.Items.Weapons.Ranged public class TheStorm : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Ranged"; + + public override void SetStaticDefaults() + { + ItemID.Sets.AnimatesAsSoul[Type] = true; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(5, 9)); + } public override void SetDefaults() { Item.damage = 35; Item.DamageType = DamageClass.Ranged; - Item.width = 34; - Item.height = 50; + Item.width = 54; + Item.height = 90; Item.useTime = 7; Item.useAnimation = 14; Item.useStyle = ItemUseStyleID.Shoot; @@ -32,61 +38,66 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Arrow; } + public override Vector2? HoldoutOffset() + { + return new Vector2(-10, 0); + } + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = Main.rand.Next(25, 30); + float arrowSpeed = Main.rand.Next(25, 30); player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = arrowSpeed; } else { - num80 = num72 / num80; + mouseDistance = arrowSpeed / mouseDistance; } for (int j = 0; j < 3; j++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * j); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); + realPlayerPos.Y -= (float)(100 * j); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-120, 121) * 0.01f; - float speedY5 = num79 + (float)Main.rand.Next(-120, 121) * 0.01f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = arrowSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-120, 121) * 0.01f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-120, 121) * 0.01f; if (CalamityUtils.CheckWoodenAmmo(type, player)) { - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, knockback, i); - Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, knockback, i); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, knockback, i); + Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, knockback, i); } else { - int arrow1 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, type, damage, knockback, i); + int arrow1 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.9f, type, damage, knockback, i); Main.projectile[arrow1].noDropItem = true; - int arrow2 = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, type, damage, knockback, i); + int arrow2 = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5 * 0.8f, type, damage, knockback, i); Main.projectile[arrow2].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/TheStorm.png b/Items/Weapons/Ranged/TheStorm.png index 813babc1ff..9344fef25d 100644 Binary files a/Items/Weapons/Ranged/TheStorm.png and b/Items/Weapons/Ranged/TheStorm.png differ diff --git a/Items/Weapons/Ranged/Vortexpopper.cs b/Items/Weapons/Ranged/Vortexpopper.cs index c9599b7efb..a486f60a4a 100644 --- a/Items/Weapons/Ranged/Vortexpopper.cs +++ b/Items/Weapons/Ranged/Vortexpopper.cs @@ -37,65 +37,65 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float bulletSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = bulletSpeed; } else { - num80 = num72 / num80; + mouseDistance = bulletSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - Vector2 value6 = Vector2.Normalize(new Vector2(num78, num79)) * 40f * Item.scale; - if (Collision.CanHit(vector2, 0, 0, vector2 + value6, 0, 0)) + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + Vector2 bulletVel = Vector2.Normalize(new Vector2(mouseXDist, mouseYDist)) * 40f * Item.scale; + if (Collision.CanHit(realPlayerPos, 0, 0, realPlayerPos + bulletVel, 0, 0)) { } - float ai = new Vector2(num78, num79).ToRotation(); - float num96 = 2.09439516f; - for (int num98 = 0; num98 < 6; num98++) + float ai = new Vector2(mouseXDist, mouseYDist).ToRotation(); + float twoThirdsPi = 2.09439516f; + for (int i = 0; i < 6; i++) { - float scaleFactor2 = (float)Main.rand.NextDouble() * 0.2f + 0.05f; - Vector2 vector6 = new Vector2(num78, num79).RotatedBy((double)(num96 * (float)Main.rand.NextDouble() - num96 / 2f), default) * scaleFactor2; - int num99 = Projectile.NewProjectile(source, position.X, position.Y, vector6.X, vector6.Y, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); - Main.projectile[num99].localAI[0] = (float)type; - Main.projectile[num99].localAI[1] = 12f; + float randVelMult = (float)Main.rand.NextDouble() * 0.2f + 0.05f; + Vector2 bulletSpawnVelocity = new Vector2(mouseXDist, mouseYDist).RotatedBy((double)(twoThirdsPi * (float)Main.rand.NextDouble() - twoThirdsPi / 2f), default) * randVelMult; + int initialBullet = Projectile.NewProjectile(source, position.X, position.Y, bulletSpawnVelocity.X, bulletSpawnVelocity.Y, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); + Main.projectile[initialBullet].localAI[0] = (float)type; + Main.projectile[initialBullet].localAI[1] = 12f; } - for (int num108 = 0; num108 < 6; num108++) + for (int j = 0; j < 6; j++) { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-800, 801); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) + realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); + realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-800, 801); + realPlayerPos.Y -= (float)(100 * j); + mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; + if (mouseYDist < 0f) { - num79 *= -1f; + mouseYDist *= -1f; } - if (num79 < 20f) + if (mouseYDist < 20f) { - num79 = 20f; + mouseYDist = 20f; } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - int projectile = Projectile.NewProjectile(source, vector2.X, vector2.Y, speedX4, speedY5, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); - Main.projectile[projectile].localAI[0] = (float)type; - Main.projectile[projectile].localAI[1] = 12f; + mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + mouseDistance = bulletSpeed / mouseDistance; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + float speedX4 = mouseXDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + float speedY5 = mouseYDist + (float)Main.rand.Next(-1000, 1001) * 0.02f; + int extraBullet = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ProjectileID.Xenopopper, damage, knockback, player.whoAmI, ai, 0f); + Main.projectile[extraBullet].localAI[0] = (float)type; + Main.projectile[extraBullet].localAI[1] = 12f; } return false; } diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index 78c82ac42b..f0a52d7d84 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -39,42 +39,42 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - float num72 = Item.shootSpeed; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + float kunaiSpeed = Item.shootSpeed; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = kunaiSpeed; } else { - num80 = num72 / num80; + mouseDistance = kunaiSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; int projAmt = player.Calamity().StealthStrikeAvailable() ? 8 : 3; for (int i = 0; i < projAmt; i++) { - float num148 = num78; - float num149 = num79; - float num150 = 0.05f * (float)i; - num148 += (float)Main.rand.Next(-35, 36) * num150; - num149 += (float)Main.rand.Next(-35, 36) * num150; - num80 = (float)Math.Sqrt((double)(num148 * num148 + num149 * num149)); - num80 = num72 / num80; - num148 *= num80; - num149 *= num80; - float x4 = vector2.X; - float y4 = vector2.Y; - int stealth = Projectile.NewProjectile(source, x4, y4, num148, num149, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); + float randXOffset = mouseXDist; + float randYOffset = mouseYDist; + float randOffsetDampener = 0.05f * (float)i; + randXOffset += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + randYOffset += (float)Main.rand.Next(-35, 36) * randOffsetDampener; + mouseDistance = (float)Math.Sqrt((double)(randXOffset * randXOffset + randYOffset * randYOffset)); + mouseDistance = kunaiSpeed / mouseDistance; + randXOffset *= mouseDistance; + randYOffset *= mouseDistance; + float x4 = realPlayerPos.X; + float y4 = realPlayerPos.Y; + int stealth = Projectile.NewProjectile(source, x4, y4, randXOffset, randYOffset, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); if (stealth.WithinBounds(Main.maxProjectiles) && player.Calamity().StealthStrikeAvailable()) Main.projectile[stealth].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index cca4ae7b1f..a8e33bf71f 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -44,20 +44,20 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - realPlayerPos.Y; } - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = player.direction; - num79 = 0f; + mouseXDist = player.direction; + mouseYDist = 0f; } - vector2 += new Vector2(num78, num79); - int proj = Projectile.NewProjectile(source, vector2, new Vector2(0f,-0.5f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1f); + realPlayerPos += new Vector2(mouseXDist, mouseYDist); + int proj = Projectile.NewProjectile(source, realPlayerPos, new Vector2(0f,-0.5f), ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 1f); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().stealthStrike = true; return false; diff --git a/Items/Weapons/Summon/EnchantedConch.cs b/Items/Weapons/Summon/EnchantedConch.cs index 910403a22a..3e9c7b9671 100644 --- a/Items/Weapons/Summon/EnchantedConch.cs +++ b/Items/Weapons/Summon/EnchantedConch.cs @@ -34,30 +34,29 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; - int num73 = damage; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; + mouseXDist = (float)player.direction; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 = 0f; - num79 = 0f; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - int p = Projectile.NewProjectile(source, vector2.X, vector2.Y, num78, num79, ModContent.ProjectileType(), num73, knockback, i, 0f, 0f); + mouseXDist = 0f; + mouseYDist = 0f; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + int p = Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, mouseXDist, mouseYDist, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; return false; diff --git a/Items/Weapons/Summon/EntropysVigil.cs b/Items/Weapons/Summon/EntropysVigil.cs index 581fb72238..ec80ab9fe7 100644 --- a/Items/Weapons/Summon/EntropysVigil.cs +++ b/Items/Weapons/Summon/EntropysVigil.cs @@ -34,41 +34,41 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; spinningpoint = spinningpoint.RotatedBy(-3.1415927410125732, default); - p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; spinningpoint = spinningpoint.RotatedBy(-5.1415927410125732, default); - p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); + p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; return false; diff --git a/Items/Weapons/Summon/EtherealSubjugator.cs b/Items/Weapons/Summon/EtherealSubjugator.cs index 362c2b5eed..362b210822 100644 --- a/Items/Weapons/Summon/EtherealSubjugator.cs +++ b/Items/Weapons/Summon/EtherealSubjugator.cs @@ -42,33 +42,33 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 1f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 1f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; } diff --git a/Items/Weapons/Summon/HauntedScroll.cs b/Items/Weapons/Summon/HauntedScroll.cs index 5a5c76d627..65d293808f 100644 --- a/Items/Weapons/Summon/HauntedScroll.cs +++ b/Items/Weapons/Summon/HauntedScroll.cs @@ -10,12 +10,18 @@ namespace CalamityMod.Items.Weapons.Summon public class HauntedScroll : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Summon"; + public override void SetStaticDefaults() + { + ItemID.Sets.AnimatesAsSoul[Type] = true; + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(6, 6)); + } + public override void SetDefaults() { Item.damage = 25; Item.mana = 10; - Item.width = 52; - Item.height = 52; + Item.width = 36; + Item.height = 48; Item.useTime = Item.useAnimation = 24; Item.useStyle = ItemUseStyleID.HoldUp; Item.noMelee = true; diff --git a/Items/Weapons/Summon/HauntedScroll.png b/Items/Weapons/Summon/HauntedScroll.png index f6199e1553..8ddebbd5cc 100644 Binary files a/Items/Weapons/Summon/HauntedScroll.png and b/Items/Weapons/Summon/HauntedScroll.png differ diff --git a/Items/Weapons/Summon/ResurrectionButterfly.cs b/Items/Weapons/Summon/ResurrectionButterfly.cs index b7cc95f0d7..f4ef5c48dd 100644 --- a/Items/Weapons/Summon/ResurrectionButterfly.cs +++ b/Items/Weapons/Summon/ResurrectionButterfly.cs @@ -37,37 +37,37 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(1.5707963705062866, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; spinningpoint = spinningpoint.RotatedBy(-3.1415927410125732, default); - p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); + p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, ModContent.ProjectileType(), damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; return false; diff --git a/Items/Weapons/Summon/VileFeeder.cs b/Items/Weapons/Summon/VileFeeder.cs index c42b8e20d1..22cdd84e12 100644 --- a/Items/Weapons/Summon/VileFeeder.cs +++ b/Items/Weapons/Summon/VileFeeder.cs @@ -37,33 +37,33 @@ namespace CalamityMod.Items.Weapons.Summon if (player.altFunctionUse != 2) { int i = Main.myPlayer; - float num72 = Item.shootSpeed; + float projSpeed = Item.shootSpeed; player.itemTime = Item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; + Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true); + float mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X; + float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y; if (player.gravDir == -1f) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; + mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - realPlayerPos.Y; } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) + float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist)); + if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f)) { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; + mouseXDist = (float)player.direction; + mouseYDist = 0f; + mouseDistance = projSpeed; } else { - num80 = num72 / num80; + mouseDistance = projSpeed / mouseDistance; } - num78 *= num80; - num79 *= num80; - vector2.X = (float)Main.mouseX + Main.screenPosition.X; - vector2.Y = (float)Main.mouseY + Main.screenPosition.Y; - Vector2 spinningpoint = new Vector2(num78, num79); + mouseXDist *= mouseDistance; + mouseYDist *= mouseDistance; + realPlayerPos.X = (float)Main.mouseX + Main.screenPosition.X; + realPlayerPos.Y = (float)Main.mouseY + Main.screenPosition.Y; + Vector2 spinningpoint = new Vector2(mouseXDist, mouseYDist); spinningpoint = spinningpoint.RotatedBy(MathHelper.PiOver2, default); - int p = Projectile.NewProjectile(source, vector2.X + spinningpoint.X, vector2.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); + int p = Projectile.NewProjectile(source, realPlayerPos.X + spinningpoint.X, realPlayerPos.Y + spinningpoint.Y, spinningpoint.X, spinningpoint.Y, type, damage, knockback, i, 0f, 0f); if (Main.projectile.IndexInRange(p)) Main.projectile[p].originalDamage = Item.damage; } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 3700f213d5..9cb8c667c4 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1001,8 +1001,8 @@ LeviathanAmbergris: { DisplayName: Leviathan Ambergris Tooltip: ''' - 15% increased dash velocity - You gain 5% damage reduction while dashing + 20% increased dash velocity + Delay after dashing is reduced by 33% Your dashes are empowered by water, knocking back and damaging nearby enemies with viscous currents ''' } @@ -1547,7 +1547,8 @@ SlagsplitterPauldron: { DisplayName: Slagsplitter Pauldron Tooltip: ''' - You gain 5% damage reduction while dashing + You gain 10% damage reduction while dashing + Enemies you dash through are afflicted with Armor Crunch Your dashes are empowered by fire, shredding enemies near you with violent explosions ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson index cad61ccd6c..37fa7981d0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson @@ -59,7 +59,7 @@ DesertProwlerHat: { DisplayName: Desert Prowler Hat Tooltip: 4% increased ranged critical strike chance and 20% chance to not consume ammo SetBonus: Ranged attacks deal an extra {0} flat damage - AbilityBrief: Sandsmoke Bomb - Double tap DOWN to shroud yourself in a small cloud of sand + AbilityBrief: Sandsmoke Bomb - Double tap {0} to shroud yourself in a small cloud of sand AbilityDescription: ''' While the sand cloud is active, gain increased mobility but heavily reduced defense @@ -296,7 +296,7 @@ WulfrumHat: { Comes equipped with hair extensions ''' SetBonus: +1 max minion - AbilityBrief: Wulfrum Bastion - Double tap DOWN while dismounted to equip wulfrum power armor + AbilityBrief: Wulfrum Bastion - Double tap {0} while dismounted to equip wulfrum power armor AbilityDescription: ''' While the armor is active, you can only use the integrated fusion cannon, but your defensive stats are increased diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index 1ce0cc040c..13a8b24a11 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -83,12 +83,21 @@ CragBullhead: { DragoonDrizzlefish: { DisplayName: Dragoon Drizzlefish - Tooltip: + Tooltip: "[GFB]" + TooltipNormal: ''' - Fires an inaccurate spread of fireballs + Fires an assortment of hellfire and brimstone fireballs + Sometimes fires a larger splitting fireball The brimstone sac appears to contain fuel 'Revenge is a dish best served flaming hot' ''' + TooltipGFB: + ''' + Fires an assortment of hellfire and brimstone fireballs + Sometimes fires a larger splitting fireball + Right click to feed the little boy some tasty gel + 'He is a hungry boy' + ''' } Havocfish: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson index 7698133d95..b08c49fe33 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Lore.hjson @@ -407,7 +407,7 @@ LoreMechs: { These unwieldy beasts of steel were the experiments of Draedon, my former colleague and prodigious engineer. His intent was to fuel a war machine with soul energy, allowing it to fight with purpose and zeal. The creations were a success, perhaps too much of one as the souls continued to express their own free will. - Dreadon was displeased with the results. However these were my soldiers with their loyalty forged anew in iron. + Draedon was displeased with the results. However these were my soldiers with their loyalty forged anew in iron. I dismissed them from duty, yet they linger here still. Scouring the land for evidence of the divine. Unfortunately for you that puts you in their crosshairs. Give them a battle worth dying in. ''' @@ -430,7 +430,7 @@ LorePerforators: { DisplayName: The Perforators and Their Hive Lore: ''' - These creatures were unique. They wielded the slain Gods' power are purely as possible, veins flowing with spilt ichor. + These creatures were unique. They wielded the slain Gods' power as purely as possible, veins flowing with spilt ichor. All that exists in the Crimson is truly the divine turned inside out; their gore now glistens with perverse treachery for all to bear witness. The mire reeks of centuries of vile manipulation and callous domination of the hapless. Judgment has long passed and only extinction is left waiting. diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 2499aa2144..ef166a86a4 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -115,8 +115,8 @@ AuroraBlazer: { DisplayName: Aurora Blazer Tooltip: ''' - Spews astral flames that travel in a star-shaped patterns - 60% chance to save ammo + Spews a nebula stream which forms a star shaped pattern + Uses gel for ammo ''' } @@ -142,7 +142,12 @@ BladedgeGreatbow: { BlightSpewer: { DisplayName: Blight Spewer - Tooltip: "" + Tooltip: + ''' + Fires clouds of plague nanomachines that stick to tiles + Nanomachines aggressively lock onto nearby enemies + 40% chance to save ammo + ''' } BlissfulBombardier: { @@ -158,9 +163,8 @@ BloodBoiler: { DisplayName: Blood Boiler Tooltip: ''' - Fires a stream of lifestealing bloodfire + Fires twin streams of life stealing bloodfire that returns to you Uses your health as ammo - 25% chance to save ammo ''' } @@ -222,7 +226,11 @@ ClaretCannon: { CleansingBlaze: { DisplayName: Cleansing Blaze - Tooltip: 90% chance to save ammo + Tooltip: + ''' + Unleashes a torrent of flames which can pass through tiles + Uses gel for ammo + ''' } ClockGatlignum: { @@ -349,7 +357,13 @@ DarkechoGreatbow: { DeadSunsWind: { DisplayName: Dead Sun's Wind - Tooltip: 70% chance to save ammo + Tooltip: + ''' + Fires a concentrated blast of superheated cosmic plasma that explodes and can ricochet off blocks + Shots aggressively home in on enemies after being ricocheted + Consecutive hits cause larger explosions + Uses gel for ammo + ''' } Deathwind: { @@ -393,12 +407,11 @@ DragonsBreath: { DisplayName: Dragon's Breath Tooltip: ''' - Press to fire in two-shot bursts - The first shot is a spread of 6 normal bullets - The second shot is a tight spread of 6 Dragon's Breath rounds - Press to fire full auto and mix the bullets randomly, but deal 20% less damage - This weapon has no randomness to its spread pattern - 66% chance to save ammo + Fires dragon fireballs at an accelerating pace + Upon firing for long enough, you will begin using a cartridge of energy + While using a cartridge you will shoot a draconic beam of fire that doesn't consume ammo + Once a cartridge has been ejected you will return to the original fire rate + 80% chance to save ammo ''' } @@ -427,8 +440,9 @@ ElementalEruption: { DisplayName: Elemental Eruption Tooltip: ''' - Fires a spread of rainbow flames - 90% chance to save ammo + Charge and then spew rainbow flames and pairs of high-energy homing flares + Uses gel for ammo + 70% chance to save ammo ''' } @@ -549,8 +563,9 @@ HalleysInferno: { DisplayName: Halley's Inferno Tooltip: ''' - Fires a flaming blue comet + Fires a highly concentrated shot of lunar fire Press to zoom out + Uses gel for ammo 50% chance to save ammo 'Halley came sooner than expected' ''' @@ -563,7 +578,11 @@ HandheldTank: { HavocsBreath: { DisplayName: Havoc's Breath - Tooltip: 50% chance to save ammo + Tooltip: + ''' + Fires a cone of scorching brimstone fire + Uses gel for ammo + ''' } HeavenlyGale: { @@ -698,8 +717,9 @@ Meowthrower: { DisplayName: Meowthrower Tooltip: ''' - Fires blue and pink flames that emit meows on enemy hits - 85% chance to save ammo + Cooks your foes to purrfection with catty smoke + Occasionally launches homing feline entities + Uses gel for ammo ''' } @@ -814,8 +834,11 @@ OverloadedBlaster: { DisplayName: Overloaded Blaster Tooltip: ''' - Fires a large spread of bouncing slime - 33% chance to save ammo + Converts gel into a spread of energized slime pearls that overload when they come to a stop + Overloaded slime pearls deal double damage but no longer pierce + Slime pearls bounce off of walls at very high speed + Uses gel for ammo + 25% chance to save ammo ''' } @@ -860,7 +883,8 @@ Photoviscerator: { ''' Fires a stream of exo flames and light that explodes into homing sparks Press to fire homing flares which stick to enemies and incinerate them - 90% chance to save ammo + Uses gel for ammo + 95% chance to save ammo ''' } @@ -912,8 +936,9 @@ PristineFury: { DisplayName: Pristine Fury Tooltip: ''' - Fires an intense helix of flames that explode into a column of fire - Press to fire a short ranged cloud of lingering flames + Fires an intense helix of flames that explode into a column of smoke + Press to disperse intense clouds of profaned heat + Uses gel for ammo ''' } @@ -1019,7 +1044,11 @@ SepticSkewer: { Shadethrower: { DisplayName: Shadethrower - Tooltip: 66% chance to save ammo + Tooltip: + ''' + Spits clouds of shade which afflict enemies with brain rot + Uses gel for ammo + ''' } Shellshooter: { @@ -1066,7 +1095,11 @@ SomaPrime: { SparkSpreader: { DisplayName: Spark Spreader - Tooltip: 70% chance to save ammo + Tooltip: + ''' + Ignites your foe with flaming sparks + Uses gel for ammo + ''' } SpectralstormCannon: { @@ -1083,7 +1116,7 @@ SpeedBlaster: { Tooltip: ''' Rapidly fires phosphorescent paintball shots - to eject a powerful glob which propels you while moving + Press to eject a powerful glob which propels you while moving This ability has a cooldown of {0} seconds While under cooldown, you fire more rapidly with greater accuracy ''' @@ -1177,7 +1210,12 @@ TelluricGlare: { TerraFlameburster: { DisplayName: Terra Flameburster - Tooltip: 80% chance to save ammo + Tooltip: + ''' + Charge and then spew high-energy flames and pairs of homing flares + Uses gel for ammo + 50% chance to save ammo + ''' } TheBallista: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 68ecc465e2..d51517068f 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -23,6 +23,7 @@ BarinadeArrow.DisplayName: Fin Arrow BeeRPG.DisplayName: Bee RPG BigCoral.DisplayName: Big Coral BigNuke.DisplayName: Big Nuke +BlightFlames.DisplayName: Blight Flames BlissfulBombardierDustProjectile.DisplayName: Holy Flare Dust BloodBoilerFire.DisplayName: Blood Fire BloodClotFriendly.DisplayName: Blood Clot @@ -53,10 +54,10 @@ ContagionArrow.DisplayName: Contagion Arrow ContagionBall.DisplayName: Contagion Ball CorinthPrimeAirburst.DisplayName: Airburst CorinthPrimeAirburstGrenade.DisplayName: Corinth Prime Airburst Shot -CorossiveFlames.DisplayName: Plagued Flames CorrodedShell.DisplayName: Corroded Shell CosmicFire.DisplayName: Dead Sun's Fire DaemonsFlameArrow.DisplayName: Daemon's Arrow +DeadSunExplosion.DisplayName: Dead Sun's Explosion DragonsBreathRound.DisplayName: Dragon's Breath Round DrataliornusExoArrow.DisplayName: Drataliornus Arrow DrataliornusFlame.DisplayName: Drataliornus Arrow @@ -65,6 +66,7 @@ DrizzlefishFireball.DisplayName: Drizzlefish Fireball DrizzlefishFireSplit.DisplayName: Drizzlefish Flames DWArrow.DisplayName: Death's Arrow ElementalFire.DisplayName: Elemental Fire +ElementalFlare.DisplayName: Elemental Flare ElysianArrowProj.DisplayName: Elysian Arrow EmesisGore.DisplayName: Rotten Gore EnhancedNanoRoundProj.DisplayName: Enhanced Nano Round @@ -120,8 +122,8 @@ MagnomalyExplosion.DisplayName: Explosion MagnomalyRocket.DisplayName: Nuke MarksmanShot.DisplayName: Marksman Shot MechanicalBarracuda.DisplayName: Barracuda +MeowCreature.DisplayName: the creature :3 MeowFire.DisplayName: Purr Fire -MeowFire2.DisplayName: Purr Fire MiniatureFolly.DisplayName: Miniature Folly MiniRocket.DisplayName: Rocket MiniSharkron.DisplayName: Mini Sharkron @@ -216,7 +218,8 @@ TerraArrowMain.DisplayName: Terra Arrow TerraArrowSplit.DisplayName: Terra Arrow TerraBulletMain.DisplayName: Terra Bullet TerraBulletSplit.DisplayName: Terra Bullet -TerraFireGreen.DisplayName: Terra Fire +TerraFire.DisplayName: Terra Fire +TerraFlare.DisplayName: Terra Flare TheMaelstromExplosion.DisplayName: Reaper Explosion TheMaelstromShark.DisplayName: Reaper Shark ThePackMinissile.DisplayName: Pack Minissile @@ -240,3 +243,7 @@ Voidragon.DisplayName: Voidragon Blast VoidragonTentacle.DisplayName: Voidragon Tentacle WaterSpout.DisplayName: Spout WulfrumScrapBullet.DisplayName: High Speed Scrap +AuricBullet.DisplayName: Auric Bullet +P90Round.DisplayName: Armor-piercing Round +DragonsBreathFlames.DisplayName: Draconic Flames +DragonsBreathMag.DisplayName: Dragons Breath Cartridge diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index f15bb64992..e2e1e2b93d 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -8,7 +8,6 @@ using CalamityMod.ExtraJumps; using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.Systems; using CalamityMod.UI; using CalamityMod.UI.CalamitasEnchants; @@ -579,13 +578,13 @@ namespace CalamityMod public static float AddMaxStealth(Player p, float add) => p is null ? 0f : (p.Calamity().rogueStealthMax += add); public static bool CanStealthStrike(Player p) => p?.Calamity()?.StealthStrikeAvailable() ?? false; - + public static void SetStealthProjectile(Projectile projectile, bool enabled) { if (projectile != null) projectile.Calamity().stealthStrike = enabled; } - + public static bool GetStealthProjectile(Projectile projectile) => projectile?.Calamity()?.stealthStrike ?? false; #endregion @@ -924,7 +923,7 @@ namespace CalamityMod #endregion #region Summoner Cross Class Nerf Disabling - public static bool SetSummonerNerfDisabledByMinion(int type, bool disableNerf) + public static bool SetSummonerNerfDisabledByMinion(int type, bool disableNerf) { if (disableNerf && !CalamityLists.DisabledSummonerNerfMinions.Contains(type)) { @@ -958,11 +957,11 @@ namespace CalamityMod #endregion #region Debuff Display support - public static void RegisterDebuff(Texture2D texture, Predicate debuffCheck) + public static void RegisterDebuff(string texturePath, Predicate debuffCheck) { - if (!CalamityGlobalNPC.debuffTextureList.Contains((texture, debuffCheck))) + if (!CalamityGlobalNPC.moddedDebuffTextureList.Contains((texturePath, debuffCheck))) { - CalamityGlobalNPC.debuffTextureList.Add((texture, debuffCheck)); + CalamityGlobalNPC.moddedDebuffTextureList.Add((texturePath, debuffCheck)); } } #endregion @@ -1098,7 +1097,7 @@ namespace CalamityMod case "AddDifficultyToUI": if (args.Length < 2) return new ArgumentException("ERROR: Not enough arguements provided"); - + if (args[1] is not DifficultyMode mode) return new ArgumentException("ERROR: A class inheriting from 'DifficultyMode' must be provided."); AddCustomDifficulty(mode); @@ -1112,7 +1111,7 @@ namespace CalamityMod case "GetAbyssLightStrength": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) + if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int."); return GetLightStrength(castPlayer(args[1])); @@ -1153,7 +1152,7 @@ namespace CalamityMod case "GetWearingRogueArmor": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) + if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetRogueArmor\" must be a Player or an int."); return GetWearingRogueArmor(castPlayer(args[1])); @@ -1181,7 +1180,7 @@ namespace CalamityMod case "GetWearingPostMoonLordSummonerArmor": if (args.Length < 2) return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player)."); - if(!isValidPlayerArg(args[1])) + if (!isValidPlayerArg(args[1])) return new ArgumentException("ERROR: The argument to \"GetPostMoonLordSummonerArmor\" must be a Player or an int."); return GetWearingPostMLSummonerArmor(castPlayer(args[1])); @@ -1716,7 +1715,7 @@ namespace CalamityMod case "CanFirePointBlank": case "CanFirePointBlankShots": if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array).");; + return new ArgumentNullException("ERROR: Must specify an Item object (or int index of an Item in the Main.item array)."); ; if (!isValidItemArg(args[1])) return new ArgumentException("ERROR: The first argument to \"CanFirePointBlank\" must be an Item or an int."); return CanFirePointBlank(castItem(args[1])); @@ -1924,8 +1923,6 @@ namespace CalamityMod return new ArgumentNullException("ERROR: Must specify a Mod instance to load particles from."); GeneralParticleHandler.LoadModParticleInstances(args[1] as Mod); - FusableParticleManager.ExtraModsToLoadSetsFrom.Add(args[1] as Mod); - FusableParticleManager.LoadParticleRenderSets(); return null; case "RegisterModCooldowns": @@ -2003,11 +2000,11 @@ namespace CalamityMod case "DisplayDebuff": case "DebuffIcon": { - if (args.Length < 2 || args[1] is not Texture2D texture) - return new ArgumentException("ERROR: The first argument to \"RegisterDebuff\" must be the texture of a debuff as a Texture2D"); + if (args.Length < 2 || args[1] is not string texturePath) + return new ArgumentException("ERROR: The first argument to \"RegisterDebuff\" must be the texture path to the debuff sprite as a string"); if (args.Length != 3 || args[2] is not Predicate debuffCheck) return new ArgumentException("ERROR: The second argument to \"RegisterDebuff\" Must be a Predicate that checks if an NPC meets the conditions for the debuff."); - RegisterDebuff(texture, debuffCheck); + RegisterDebuff(texturePath, debuffCheck); return null; } diff --git a/NPCs/Abyss/BabyCannonballJellyfish.cs b/NPCs/Abyss/BabyCannonballJellyfish.cs index e63b7ff216..005e45e222 100644 --- a/NPCs/Abyss/BabyCannonballJellyfish.cs +++ b/NPCs/Abyss/BabyCannonballJellyfish.cs @@ -134,13 +134,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/BabyCannonballJellyfishGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/BabyCannonballJellyfishGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(new Color(67, 218, 166)); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/BabyCannonballJellyfishGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckDead() diff --git a/NPCs/Abyss/Bloatfish.cs b/NPCs/Abyss/Bloatfish.cs index 943294f0dd..44511aa4b1 100644 --- a/NPCs/Abyss/Bloatfish.cs +++ b/NPCs/Abyss/Bloatfish.cs @@ -106,15 +106,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index 4271037e73..ae8cc1e6d5 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -75,16 +75,16 @@ namespace CalamityMod.NPCs.Abyss if (NPC.ai[0] == 0f) { NPC.noTileCollide = true; - float num659 = 14f; - Vector2 vector79 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num660 = Main.npc[(int)NPC.ai[2]].Center.X - vector79.X; - float num661 = Main.npc[(int)NPC.ai[2]].Center.Y - vector79.Y; - float num662 = (float)Math.Sqrt((double)(num660 * num660 + num661 * num661)); - if (num662 < 11f + num659) + float launchSpeed = 14f; + Vector2 bobbitCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float segmentXDist = Main.npc[(int)NPC.ai[2]].Center.X - bobbitCenter.X; + float segmentYDist = Main.npc[(int)NPC.ai[2]].Center.Y - bobbitCenter.Y; + float segmentDistance = (float)Math.Sqrt((double)(segmentXDist * segmentXDist + segmentYDist * segmentYDist)); + if (segmentDistance < 11f + launchSpeed) { NPC.rotation = 0f; - NPC.velocity.X = num660; - NPC.velocity.Y = num661; + NPC.velocity.X = segmentXDist; + NPC.velocity.Y = segmentYDist; NPC.ai[1] += 1f; if (NPC.ai[1] >= 60f) { @@ -102,9 +102,9 @@ namespace CalamityMod.NPCs.Abyss } else { - num662 = num659 / num662; - NPC.velocity.X = num660 * num662; - NPC.velocity.Y = num661 * num662; + segmentDistance = launchSpeed / segmentDistance; + NPC.velocity.X = segmentXDist * segmentDistance; + NPC.velocity.Y = segmentYDist * segmentDistance; NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) - 1.57f; } } @@ -113,14 +113,14 @@ namespace CalamityMod.NPCs.Abyss NPC.noTileCollide = true; NPC.collideX = false; NPC.collideY = false; - float num663 = 16f; - Vector2 vector80 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num664 = Main.player[NPC.target].Center.X - vector80.X; - float num665 = Main.player[NPC.target].Center.Y - vector80.Y; - float num666 = (float)Math.Sqrt((double)(num664 * num664 + num665 * num665)); - num666 = num663 / num666; - NPC.velocity.X = num664 * num666; - NPC.velocity.Y = num665 * num666; + float returnSpeed = 16f; + Vector2 bobbitCenterReturn = new Vector2(NPC.Center.X, NPC.Center.Y); + float segmentReturnXDist = Main.player[NPC.target].Center.X - bobbitCenterReturn.X; + float segmentReturnYDist = Main.player[NPC.target].Center.Y - bobbitCenterReturn.Y; + float segmentReturnDistance = (float)Math.Sqrt((double)(segmentReturnXDist * segmentReturnXDist + segmentReturnYDist * segmentReturnYDist)); + segmentReturnDistance = returnSpeed / segmentReturnDistance; + NPC.velocity.X = segmentReturnXDist * segmentReturnDistance; + NPC.velocity.Y = segmentReturnYDist * segmentReturnDistance; NPC.ai[0] = 2f; NPC.rotation = (float)Math.Atan2((double)-(double)NPC.velocity.Y, (double)-(double)NPC.velocity.X) - 1.57f; } @@ -148,11 +148,11 @@ namespace CalamityMod.NPCs.Abyss NPC.noTileCollide = false; } } - Vector2 vector81 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num667 = Main.npc[(int)NPC.ai[2]].Center.X - vector81.X; - float num668 = Main.npc[(int)NPC.ai[2]].Center.Y - vector81.Y; - float num669 = (float)Math.Sqrt((double)(num667 * num667 + num668 * num668)); - if (num669 > 700f || NPC.collideX || NPC.collideY) + Vector2 bobbitCenterReturning = new Vector2(NPC.Center.X, NPC.Center.Y); + float segmentReturningXDist = Main.npc[(int)NPC.ai[2]].Center.X - bobbitCenterReturning.X; + float segmentReturningYDist = Main.npc[(int)NPC.ai[2]].Center.Y - bobbitCenterReturning.Y; + float segmentReturningDistance = (float)Math.Sqrt((double)(segmentReturningXDist * segmentReturningXDist + segmentReturningYDist * segmentReturningYDist)); + if (segmentReturningDistance > 700f || NPC.collideX || NPC.collideY) { NPC.noTileCollide = true; NPC.ai[0] = 0f; @@ -162,45 +162,45 @@ namespace CalamityMod.NPCs.Abyss else if (NPC.ai[0] == 3f) { NPC.noTileCollide = true; - float num671 = 16f; - float num672 = 0.25f; - Vector2 vector82 = new Vector2(NPC.Center.X, NPC.Center.Y); - float num673 = Main.player[NPC.target].Center.X - vector82.X; - float num674 = Main.player[NPC.target].Center.Y - vector82.Y; - float num675 = (float)Math.Sqrt((double)(num673 * num673 + num674 * num674)); - num675 = num671 / num675; - num673 *= num675; - num674 *= num675; - if (NPC.velocity.X < num673) + float unusedSpeed = 16f; + float unusedAcceleration = 0.25f; + Vector2 unusedBobbitCenter = new Vector2(NPC.Center.X, NPC.Center.Y); + float unusedTargetXDist = Main.player[NPC.target].Center.X - unusedBobbitCenter.X; + float unusedTargetYDist = Main.player[NPC.target].Center.Y - unusedBobbitCenter.Y; + float unusedTargetDistance = (float)Math.Sqrt((double)(unusedTargetXDist * unusedTargetXDist + unusedTargetYDist * unusedTargetYDist)); + unusedTargetDistance = unusedSpeed / unusedTargetDistance; + unusedTargetXDist *= unusedTargetDistance; + unusedTargetYDist *= unusedTargetDistance; + if (NPC.velocity.X < unusedTargetXDist) { - NPC.velocity.X = NPC.velocity.X + num672; - if (NPC.velocity.X < 0f && num673 > 0f) + NPC.velocity.X = NPC.velocity.X + unusedAcceleration; + if (NPC.velocity.X < 0f && unusedTargetXDist > 0f) { - NPC.velocity.X = NPC.velocity.X + num672 * 2f; + NPC.velocity.X = NPC.velocity.X + unusedAcceleration * 2f; } } - else if (NPC.velocity.X > num673) + else if (NPC.velocity.X > unusedTargetXDist) { - NPC.velocity.X = NPC.velocity.X - num672; - if (NPC.velocity.X > 0f && num673 < 0f) + NPC.velocity.X = NPC.velocity.X - unusedAcceleration; + if (NPC.velocity.X > 0f && unusedTargetXDist < 0f) { - NPC.velocity.X = NPC.velocity.X - num672 * 2f; + NPC.velocity.X = NPC.velocity.X - unusedAcceleration * 2f; } } - if (NPC.velocity.Y < num674) + if (NPC.velocity.Y < unusedTargetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num672; - if (NPC.velocity.Y < 0f && num674 > 0f) + NPC.velocity.Y = NPC.velocity.Y + unusedAcceleration; + if (NPC.velocity.Y < 0f && unusedTargetYDist > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num672 * 2f; + NPC.velocity.Y = NPC.velocity.Y + unusedAcceleration * 2f; } } - else if (NPC.velocity.Y > num674) + else if (NPC.velocity.Y > unusedTargetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num672; - if (NPC.velocity.Y > 0f && num674 < 0f) + NPC.velocity.Y = NPC.velocity.Y - unusedAcceleration; + if (NPC.velocity.Y > 0f && unusedTargetYDist < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num672 * 2f; + NPC.velocity.Y = NPC.velocity.Y - unusedAcceleration * 2f; } } NPC.rotation = (float)Math.Atan2((double)-(double)NPC.velocity.Y, (double)-(double)NPC.velocity.X); diff --git a/NPCs/Abyss/BoxJellyfish.cs b/NPCs/Abyss/BoxJellyfish.cs index 157eba50ad..a345647128 100644 --- a/NPCs/Abyss/BoxJellyfish.cs +++ b/NPCs/Abyss/BoxJellyfish.cs @@ -100,31 +100,31 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = 1f; } } - bool flag16 = false; + bool canAttack = false; NPC.TargetClosest(false); if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - flag16 = true; + canAttack = true; } - if (flag16) + if (canAttack) { NPC.localAI[2] = 1f; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + 1.57f; NPC.velocity *= 0.975f; - float num263 = 0.8f; - if (NPC.velocity.X > -num263 && NPC.velocity.X < num263 && NPC.velocity.Y > -num263 && NPC.velocity.Y < num263) + float lungeThreshold = 0.8f; + if (NPC.velocity.X > -lungeThreshold && NPC.velocity.X < lungeThreshold && NPC.velocity.Y > -lungeThreshold && NPC.velocity.Y < lungeThreshold) { NPC.TargetClosest(true); - float num264 = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; - Vector2 vector31 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num265 = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - vector31.X; - float num266 = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - vector31.Y; - float num267 = (float)Math.Sqrt(num265 * num265 + num266 * num266); - num267 = num264 / num267; - num265 *= num267; - num266 *= num267; - NPC.velocity.X = num265; - NPC.velocity.Y = num266; + float lungeSpeed = CalamityWorld.death ? 12f : CalamityWorld.revenge ? 10f : 8f; + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetX = Main.player[NPC.target].position.X + (Main.player[NPC.target].width / 2) - npcPosition.X; + float targetY = Main.player[NPC.target].position.Y + (Main.player[NPC.target].height / 2) - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetX * targetX + targetY * targetY); + targetDistance = lungeSpeed / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; + NPC.velocity.X = targetX; + NPC.velocity.Y = targetY; } } else @@ -152,15 +152,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/CannonballJellyfish.cs b/NPCs/Abyss/CannonballJellyfish.cs index 1cefcf6e86..9ac54fa763 100644 --- a/NPCs/Abyss/CannonballJellyfish.cs +++ b/NPCs/Abyss/CannonballJellyfish.cs @@ -120,22 +120,22 @@ namespace CalamityMod.NPCs.Abyss if (boomTimer >= (dyingDuration - 20)) //home for the first 20 frames, not beyond that { - float num543 = player.position.X + (float)(player.width / 2); - float num544 = player.position.Y + (float)(player.height / 2); - float num550 = 30f; - Vector2 vector43 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num551 = num543 - vector43.X; - float num552 = num544 - vector43.Y; - float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); - if (num553 < 100f) + float targetXDirection = player.position.X + (float)(player.width / 2); + float targetYDirection = player.position.Y + (float)(player.height / 2); + float homingSpeed = 30f; + Vector2 npcPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = targetXDirection - npcPosition.X; + float targetYDist = targetYDirection - npcPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (targetDistance < 100f) { - num550 = 10f; //5 + homingSpeed = 10f; //5 } - num553 = num550 / num553; - num551 *= num553; - num552 *= num553; - NPC.velocity.X = (NPC.velocity.X * 5f + num551) / 6f; - NPC.velocity.Y = (NPC.velocity.Y * 5f + num552) / 6f; + targetDistance = homingSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + NPC.velocity.X = (NPC.velocity.X * 5f + targetXDist) / 6f; + NPC.velocity.Y = (NPC.velocity.Y * 5f + targetYDist) / 6f; NPC.velocity *= 0.9f; //slow it down a bit to be fair @@ -250,14 +250,14 @@ namespace CalamityMod.NPCs.Abyss } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); var texture = TextureAssets.Npc[NPC.type]; - Vector2 vector11 = new Vector2((float)(texture.Value.Width / 2), (float)(texture.Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(texture.Value.Width / 2), (float)(texture.Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; var glowTexture = ModContent.Request("CalamityMod/NPCs/Abyss/CannonballJellyfishGlow"); vector -= new Vector2((float)glowTexture.Value.Width, (float)(glowTexture.Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(new Color(67, 218, 166)); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/CannonballJellyfishGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } private void Explode() diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 2fce5f13aa..c5677cd416 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -119,49 +119,49 @@ namespace CalamityMod.NPCs.Abyss } else { - Vector2 value29 = Main.player[NPC.target].Center - NPC.Center; - value29.Y -= (float)(Main.player[NPC.target].height / 4); - float num1310 = value29.Length(); - if (num1310 > 800f) + Vector2 targetDirection = Main.player[NPC.target].Center - NPC.Center; + targetDirection.Y -= (float)(Main.player[NPC.target].height / 4); + float targetDistance = targetDirection.Length(); + if (targetDistance > 800f) { NPC.ai[0] = 2f; } else { - Vector2 center26 = NPC.Center; - center26.X = Main.player[NPC.target].Center.X; - Vector2 vector230 = center26 - NPC.Center; - if (vector230.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, center26, 1, 1)) + Vector2 squidCenter = NPC.Center; + squidCenter.X = Main.player[NPC.target].Center.X; + Vector2 squidDirection = squidCenter - NPC.Center; + if (squidDirection.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, squidCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center26.X; - NPC.ai[2] = center26.Y; - Vector2 center27 = NPC.Center; - center27.Y = Main.player[NPC.target].Center.Y; - if (vector230.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, center27, 1, 1) && Collision.CanHit(center27, 1, 1, Main.player[NPC.target].position, 1, 1)) + NPC.ai[1] = squidCenter.X; + NPC.ai[2] = squidCenter.Y; + Vector2 squidCenterAgain = NPC.Center; + squidCenterAgain.Y = Main.player[NPC.target].Center.Y; + if (squidDirection.Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, squidCenterAgain, 1, 1) && Collision.CanHit(squidCenterAgain, 1, 1, Main.player[NPC.target].position, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center27.X; - NPC.ai[2] = center27.Y; + NPC.ai[1] = squidCenterAgain.X; + NPC.ai[2] = squidCenterAgain.Y; } } else { - center26 = NPC.Center; - center26.Y = Main.player[NPC.target].Center.Y; - if ((center26 - NPC.Center).Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, center26, 1, 1)) + squidCenter = NPC.Center; + squidCenter.Y = Main.player[NPC.target].Center.Y; + if ((squidCenter - NPC.Center).Length() > 8f && Collision.CanHit(NPC.Center, 1, 1, squidCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center26.X; - NPC.ai[2] = center26.Y; + NPC.ai[1] = squidCenter.X; + NPC.ai[2] = squidCenter.Y; } } if (NPC.ai[0] == 0f) { NPC.localAI[0] = 0f; - value29.Normalize(); - value29 *= 0.5f; - NPC.velocity += value29; + targetDirection.Normalize(); + targetDirection *= 0.5f; + NPC.velocity += targetDirection; NPC.ai[0] = 4f; NPC.ai[1] = 0f; } @@ -171,20 +171,20 @@ namespace CalamityMod.NPCs.Abyss else if (NPC.ai[0] == 1f) { NPC.rotation += (float)NPC.direction * 0.1f; - Vector2 value30 = Main.player[NPC.target].Top - NPC.Center; - float num1311 = value30.Length(); - float num1312 = 5f; - num1312 += num1311 / 100f; - int num1313 = 50; - value30.Normalize(); - value30 *= num1312; - NPC.velocity = (NPC.velocity * (float)(num1313 - 1) + value30) / (float)num1313; + Vector2 latchPosition = Main.player[NPC.target].Top - NPC.Center; + float latchDistance = latchPosition.Length(); + float latchLockSpeed = 5f; + latchLockSpeed += latchDistance / 100f; + int latchVelocity = 50; + latchPosition.Normalize(); + latchPosition *= latchLockSpeed; + NPC.velocity = (NPC.velocity * (float)(latchVelocity - 1) + latchPosition) / (float)latchVelocity; if (!Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; } - if (num1311 < 160f && Main.player[NPC.target].active && !Main.player[NPC.target].dead && !clone) + if (latchDistance < 160f && Main.player[NPC.target].active && !Main.player[NPC.target].dead && !clone) { NPC.Center = Main.player[NPC.target].Top; NPC.velocity = Vector2.Zero; @@ -197,14 +197,14 @@ namespace CalamityMod.NPCs.Abyss { NPC.rotation = NPC.velocity.X * 0.05f; NPC.noTileCollide = true; - Vector2 value31 = Main.player[NPC.target].Center - NPC.Center; - float num1315 = value31.Length(); - float scaleFactor11 = 3f; - int num1316 = 3; - value31.Normalize(); - value31 *= scaleFactor11; - NPC.velocity = (NPC.velocity * (float)(num1316 - 1) + value31) / (float)num1316; - if (num1315 < 600f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) + Vector2 lungeDirection = Main.player[NPC.target].Center - NPC.Center; + float lungeDistance = lungeDirection.Length(); + float lungeSpeed = 3f; + int lungeVelocity = 3; + lungeDirection.Normalize(); + lungeDirection *= lungeSpeed; + NPC.velocity = (NPC.velocity * (float)(lungeVelocity - 1) + lungeDirection) / (float)lungeVelocity; + if (lungeDistance < 600f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { NPC.ai[0] = 0f; } @@ -212,20 +212,20 @@ namespace CalamityMod.NPCs.Abyss else if (NPC.ai[0] == 3f) { NPC.rotation = NPC.velocity.X * 0.05f; - Vector2 value32 = new Vector2(NPC.ai[1], NPC.ai[2]); - Vector2 value33 = value32 - NPC.Center; - float num1317 = value33.Length(); - float num1318 = 2f; - float num1319 = 3f; - value33.Normalize(); - value33 *= num1318; - NPC.velocity = (NPC.velocity * (num1319 - 1f) + value33) / num1319; + Vector2 otherLungePos = new Vector2(NPC.ai[1], NPC.ai[2]); + Vector2 otherLungeDirection = otherLungePos - NPC.Center; + float otherLungeDistance = otherLungeDirection.Length(); + float otherLungeSpeed = 2f; + float otherLungeVelocity = 3f; + otherLungeDirection.Normalize(); + otherLungeDirection *= otherLungeSpeed; + NPC.velocity = (NPC.velocity * (otherLungeVelocity - 1f) + otherLungeDirection) / otherLungeVelocity; if (NPC.collideX || NPC.collideY) { NPC.ai[0] = 4f; NPC.ai[1] = 0f; } - if (num1317 < num1318 || num1317 > 800f || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) + if (otherLungeDistance < otherLungeSpeed || otherLungeDistance > 800f || Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1)) { NPC.ai[0] = 0f; } @@ -241,20 +241,19 @@ namespace CalamityMod.NPCs.Abyss { NPC.velocity.Y = NPC.velocity.Y * -0.8f; } - Vector2 value34; + Vector2 slowDownDirection; if (NPC.velocity.X == 0f && NPC.velocity.Y == 0f) { - value34 = Main.player[NPC.target].Center - NPC.Center; - value34.Y -= (float)(Main.player[NPC.target].height / 4); - value34.Normalize(); - NPC.velocity = value34 * 0.1f; + slowDownDirection = Main.player[NPC.target].Center - NPC.Center; + slowDownDirection.Y -= (float)(Main.player[NPC.target].height / 4); + slowDownDirection.Normalize(); + NPC.velocity = slowDownDirection * 0.1f; } - float scaleFactor12 = 2f; - float num1320 = 20f; - value34 = NPC.velocity; - value34.Normalize(); - value34 *= scaleFactor12; - NPC.velocity = (NPC.velocity * (num1320 - 1f) + value34) / num1320; + float slowDownVelocity = 20f; + slowDownDirection = NPC.velocity; + slowDownDirection.Normalize(); + slowDownDirection *= 2f; + NPC.velocity = (NPC.velocity * (slowDownVelocity - 1f) + slowDownDirection) / slowDownVelocity; NPC.ai[1] += 1f; if (NPC.ai[1] > 180f) { @@ -269,31 +268,31 @@ namespace CalamityMod.NPCs.Abyss if (NPC.localAI[0] >= 5f && !Collision.SolidCollision(NPC.position - new Vector2(10f, 10f), NPC.width + 20, NPC.height + 20)) { NPC.localAI[0] = 0f; - Vector2 center28 = NPC.Center; - center28.X = Main.player[NPC.target].Center.X; - if (Collision.CanHit(NPC.Center, 1, 1, center28, 1, 1) && Collision.CanHit(NPC.Center, 1, 1, center28, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, center28, 1, 1)) + Vector2 slowDownCenter = NPC.Center; + slowDownCenter.X = Main.player[NPC.target].Center.X; + if (Collision.CanHit(NPC.Center, 1, 1, slowDownCenter, 1, 1) && Collision.CanHit(NPC.Center, 1, 1, slowDownCenter, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, slowDownCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center28.X; - NPC.ai[2] = center28.Y; + NPC.ai[1] = slowDownCenter.X; + NPC.ai[2] = slowDownCenter.Y; } else { - center28 = NPC.Center; - center28.Y = Main.player[NPC.target].Center.Y; - if (Collision.CanHit(NPC.Center, 1, 1, center28, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, center28, 1, 1)) + slowDownCenter = NPC.Center; + slowDownCenter.Y = Main.player[NPC.target].Center.Y; + if (Collision.CanHit(NPC.Center, 1, 1, slowDownCenter, 1, 1) && Collision.CanHit(Main.player[NPC.target].Center, 1, 1, slowDownCenter, 1, 1)) { NPC.ai[0] = 3f; - NPC.ai[1] = center28.X; - NPC.ai[2] = center28.Y; + NPC.ai[1] = slowDownCenter.X; + NPC.ai[2] = slowDownCenter.Y; } } } } else if (NPC.ai[0] == 5f) { - Player player7 = Main.player[NPC.target]; - if (!player7.active || player7.dead || clone) + Player latchedTarget = Main.player[NPC.target]; + if (!latchedTarget.active || latchedTarget.dead || clone) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -301,10 +300,10 @@ namespace CalamityMod.NPCs.Abyss } else { - NPC.Center = ((player7.gravDir == 1f) ? player7.Top : player7.Bottom) + new Vector2((float)(player7.direction * 4), 0f); - NPC.gfxOffY = player7.gfxOffY; + NPC.Center = ((latchedTarget.gravDir == 1f) ? latchedTarget.Top : latchedTarget.Bottom) + new Vector2((float)(latchedTarget.direction * 4), 0f); + NPC.gfxOffY = latchedTarget.gfxOffY; NPC.velocity = Vector2.Zero; - player7.AddBuff(BuffID.Obstructed, 59, true); + latchedTarget.AddBuff(BuffID.Obstructed, 59, true); } } NPC.rotation = NPC.velocity.X * 0.05f; @@ -436,20 +435,19 @@ namespace CalamityMod.NPCs.Abyss } NPC.rotation = NPC.velocity.X * 0.05f; NPC.velocity *= 0.975f; - float num263 = 2.5f; - if (NPC.velocity.X > -num263 && NPC.velocity.X < num263 && NPC.velocity.Y > -num263 && NPC.velocity.Y < num263) + float hitLungeThreshold = 2.5f; + if (NPC.velocity.X > -hitLungeThreshold && NPC.velocity.X < hitLungeThreshold && NPC.velocity.Y > -hitLungeThreshold && NPC.velocity.Y < hitLungeThreshold) { NPC.TargetClosest(true); - float num264 = 20f; - Vector2 vector31 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num265 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector31.X; - float num266 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector31.Y; - float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); - num267 = num264 / num267; - num265 *= num267; - num266 *= num267; - NPC.velocity.X = num265; - NPC.velocity.Y = num266; + Vector2 hitLungePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float hitLungeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - hitLungePos.X; + float hitLungeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - hitLungePos.Y; + float hitLungeTargetDist = (float)Math.Sqrt((double)(hitLungeTargetX * hitLungeTargetX + hitLungeTargetY * hitLungeTargetY)); + hitLungeTargetDist = 20f / hitLungeTargetDist; + hitLungeTargetX *= hitLungeTargetDist; + hitLungeTargetY *= hitLungeTargetDist; + NPC.velocity.X = hitLungeTargetX; + NPC.velocity.Y = hitLungeTargetY; return; } } @@ -482,15 +480,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index 6827b05362..6afe61c019 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -58,10 +58,10 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - int num = 150; + int alphaControl = 150; if (NPC.ai[2] == 0f) { - NPC.alpha = num; + NPC.alpha = alphaControl; NPC.TargetClosest(true); if (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) @@ -114,15 +114,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } @@ -141,7 +141,7 @@ namespace CalamityMod.NPCs.Abyss { if (NPC.alpha > 0) { - NPC.alpha -= num / 16; + NPC.alpha -= alphaControl / 16; if (NPC.alpha < 0) { NPC.alpha = 0; @@ -165,13 +165,13 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.wet || NPC.noTileCollide) { - bool flag14 = false; + bool canAttack = false; NPC.TargetClosest(false); if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead) { - flag14 = true; + canAttack = true; } - if (!flag14) + if (!canAttack) { if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { @@ -200,7 +200,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { @@ -279,15 +279,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileXAgain = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileYAgain = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileXAgain, npcTileYAgain - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileXAgain, npcTileYAgain + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileXAgain, npcTileYAgain + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/DevilFish.cs b/NPCs/Abyss/DevilFish.cs index 648d6e913e..546982c7ab 100644 --- a/NPCs/Abyss/DevilFish.cs +++ b/NPCs/Abyss/DevilFish.cs @@ -112,17 +112,17 @@ namespace CalamityMod.NPCs.Abyss if (NPC.wet) { - bool flag14 = brokenMask; + bool canAttack = brokenMask; NPC.TargetClosest(false); if (player.statLife <= player.statLifeMax2 / 4) { - flag14 = true; + canAttack = true; } - if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && flag14) + if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -147,7 +147,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * (CalamityWorld.death ? 0.5f : CalamityWorld.revenge ? 0.375f : 0.25f) * speedBoost; @@ -194,15 +194,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/DevilFishAlt.cs b/NPCs/Abyss/DevilFishAlt.cs index 0f47772731..44060ffa94 100644 --- a/NPCs/Abyss/DevilFishAlt.cs +++ b/NPCs/Abyss/DevilFishAlt.cs @@ -94,17 +94,17 @@ namespace CalamityMod.NPCs.Abyss if (NPC.wet) { - bool flag14 = brokenMask; + bool canAttack = brokenMask; NPC.TargetClosest(false); if (player.statLife <= player.statLifeMax2 / 4) { - flag14 = true; + canAttack = true; } - if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && flag14) + if ((!player.wet || player.dead || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -129,7 +129,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * (CalamityWorld.death ? 0.5f : CalamityWorld.revenge ? 0.375f : 0.25f) * speedBoost; @@ -176,15 +176,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index 133c3a2d6b..c1a8c86b08 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -82,39 +82,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } @@ -127,13 +127,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index f50ca655ac..2cbfd9e8f6 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -82,39 +82,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } @@ -127,13 +127,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.White); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 5e335d9a5a..3746bc643e 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -145,12 +145,12 @@ namespace CalamityMod.NPCs.Abyss if (!TailSpawned && NPC.ai[0] == 0f) { int Previous = NPC.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (segments >= 0 && segments < minLength) { - if (num36 % 2 == 0) + if (segments % 2 == 0) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -208,167 +208,167 @@ namespace CalamityMod.NPCs.Abyss NPC.active = false; } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float currentSpeed = speed; + float currentTurnSpeed = turnSpeed; + Vector2 segmentPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); if (patrolSpot == Vector2.Zero) patrolSpot = Main.player[NPC.target].Center; - float num191 = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; + float targetXDirection = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; + float targetYDirection = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; if (!detectsPlayer) { - num192 += 800; - if (Math.Abs(NPC.Center.X - num191) < 400f) //500 + targetYDirection += 800; + if (Math.Abs(NPC.Center.X - targetXDirection) < 400f) //500 { if (NPC.velocity.X > 0f) { - num191 += 500f; + targetXDirection += 500f; } else { - num191 -= 500f; + targetXDirection -= 500f; } } } else { - num188 = 7.5f; - num189 = 0.125f; + currentSpeed = 7.5f; + currentTurnSpeed = 0.125f; if (!Main.player[NPC.target].wet) { - num188 = 15f; - num189 = 0.25f; + currentSpeed = 15f; + currentTurnSpeed = 0.25f; } if (adultWyrmAlive) { if (!Main.player[NPC.target].Calamity().ZoneAbyssLayer4) { - num188 = 22.5f; - num189 = 0.375f; + currentSpeed = 22.5f; + currentTurnSpeed = 0.375f; } } } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float speedComparison = NPC.velocity.Length(); + if (speedComparison > 0f) { - if (num50 > num48) + if (speedComparison > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (speedComparison < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float absolutetargetX = System.Math.Abs(targetXDirection); + float absolutetargetY = System.Math.Abs(targetYDirection); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDirection *= timeToReachTarget; + targetYDirection *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f) || (NPC.velocity.Y > 0f && targetYDirection > 0f) || (NPC.velocity.Y < 0f && targetYDirection < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDirection < 0f) || (NPC.velocity.X < 0f && targetXDirection > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDirection < 0f) || (NPC.velocity.Y < 0f && targetYDirection > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absolutetargetX > absolutetargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } @@ -390,18 +390,18 @@ namespace CalamityMod.NPCs.Abyss Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 40f; } @@ -423,13 +423,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.White); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index e1f8c42a2a..463c697b83 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -82,39 +82,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } @@ -127,13 +127,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/GiantSquid.cs b/NPCs/Abyss/GiantSquid.cs index 5edb35afd8..9806b3eafc 100644 --- a/NPCs/Abyss/GiantSquid.cs +++ b/NPCs/Abyss/GiantSquid.cs @@ -125,20 +125,20 @@ namespace CalamityMod.NPCs.Abyss { NPC.localAI[2] = 1f; NPC.velocity *= 0.975f; - float num263 = 1.6f; - if (NPC.velocity.X > -num263 && NPC.velocity.X < num263 && NPC.velocity.Y > -num263 && NPC.velocity.Y < num263) + float lungeThreshold = 1.6f; + if (NPC.velocity.X > -lungeThreshold && NPC.velocity.X < lungeThreshold && NPC.velocity.Y > -lungeThreshold && NPC.velocity.Y < lungeThreshold) { NPC.TargetClosest(true); - float num264 = CalamityWorld.death ? 24f : CalamityWorld.revenge ? 20f : 16f; - Vector2 vector31 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num265 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector31.X; - float num266 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector31.Y; - float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); - num267 = num264 / num267; - num265 *= num267; - num266 *= num267; - NPC.velocity.X = num265; - NPC.velocity.Y = num266; + float lungeSpeed = CalamityWorld.death ? 24f : CalamityWorld.revenge ? 20f : 16f; + Vector2 lungeNPCPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float lungeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - lungeNPCPos.X; + float lungeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - lungeNPCPos.Y; + float lungeTargetDist = (float)Math.Sqrt((double)(lungeTargetX * lungeTargetX + lungeTargetY * lungeTargetY)); + lungeTargetDist = lungeSpeed / lungeTargetDist; + lungeTargetX *= lungeTargetDist; + lungeTargetY *= lungeTargetDist; + NPC.velocity.X = lungeTargetX; + NPC.velocity.Y = lungeTargetY; return; } } @@ -166,15 +166,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num268 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num269 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num268, num269 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num268, num269 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num268, num269 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index 910f9d5539..8fab0776de 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = -1; } } @@ -132,13 +132,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Color.White); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index faf194b425..292bae06f1 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = -1; } } @@ -132,13 +132,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index eaac1c3142..98a75fac66 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -123,12 +123,12 @@ namespace CalamityMod.NPCs.Abyss if (!TailSpawned && NPC.ai[0] == 0f) { int Previous = NPC.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (segments >= 0 && segments < minLength) { - if (num36 == 0) + if (segments == 0) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -173,154 +173,154 @@ namespace CalamityMod.NPCs.Abyss NPC.active = false; } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float currentSpeed = speed; + float currentTurnSpeed = turnSpeed; + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); if (patrolSpot == Vector2.Zero) patrolSpot = Main.player[NPC.target].Center; - float num191 = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; + float targetXDirection = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; + float targetYDirection = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; if (!detectsPlayer) { - num192 += 500; - if (Math.Abs(NPC.Center.X - num191) < 300f) //500 + targetYDirection += 500; + if (Math.Abs(NPC.Center.X - targetXDirection) < 300f) //500 { if (NPC.velocity.X > 0f) { - num191 += 400f; + targetXDirection += 400f; } else { - num191 -= 400f; + targetXDirection -= 400f; } } } else { - num188 *= 1.5f; - num189 *= 1.5f; + currentSpeed *= 1.5f; + currentTurnSpeed *= 1.5f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float speedCompare = NPC.velocity.Length(); + if (speedCompare > 0f) { - if (num50 > num48) + if (speedCompare > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (speedCompare < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float absoluteTargetX = System.Math.Abs(targetXDirection); + float absoluteTargetY = System.Math.Abs(targetYDirection); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDirection *= timeToReachTarget; + targetYDirection *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f) || (NPC.velocity.Y > 0f && targetYDirection > 0f) || (NPC.velocity.Y < 0f && targetYDirection < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDirection < 0f) || (NPC.velocity.X < 0f && targetXDirection > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDirection < 0f) || (NPC.velocity.Y < 0f && targetYDirection > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } @@ -345,13 +345,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index bab56e99fc..7381e75b4f 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = 1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = -1; } } @@ -132,13 +132,13 @@ namespace CalamityMod.NPCs.Abyss spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool CheckActive() diff --git a/NPCs/Abyss/LuminousCorvina.cs b/NPCs/Abyss/LuminousCorvina.cs index d9f0601f21..d0b2b2bc6d 100644 --- a/NPCs/Abyss/LuminousCorvina.cs +++ b/NPCs/Abyss/LuminousCorvina.cs @@ -91,13 +91,13 @@ namespace CalamityMod.NPCs.Abyss NPC.chaseable = hasBeenHit; if (NPC.wet) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); if ((Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && ((NPC.Center.X - 15f < Main.player[NPC.target].Center.X && NPC.direction == 1) || (NPC.Center.X + 15f > Main.player[NPC.target].Center.X && NPC.direction == -1))) || (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, - Main.player[NPC.target].width, Main.player[NPC.target].height) && flag14)) + Main.player[NPC.target].width, Main.player[NPC.target].height) && canAttack)) { ++screamTimer; @@ -122,7 +122,7 @@ namespace CalamityMod.NPCs.Abyss return; } } - if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && canAttack) { } if (NPC.collideX) @@ -168,15 +168,15 @@ namespace CalamityMod.NPCs.Abyss NPC.ai[0] = -1f; } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 37670fd456..8005102f35 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -107,41 +107,41 @@ namespace CalamityMod.NPCs.Abyss { teleporting = false; NPC.TargetClosest(true); - int num1249 = 0; - int num1250; - int num1251; + int teleportTries = 0; + int teleportTileX; + int teleportTileY; while (true) { - num1249++; - num1250 = (int)player.Center.X / 16; - num1251 = (int)player.Center.Y / 16; + teleportTries++; + teleportTileX = (int)player.Center.X / 16; + teleportTileY = (int)player.Center.Y / 16; int min = 6; int max = 9; if (Main.rand.NextBool()) - num1250 += Main.rand.Next(min, max); + teleportTileX += Main.rand.Next(min, max); else - num1250 -= Main.rand.Next(min, max); + teleportTileX -= Main.rand.Next(min, max); min = 11; max = 26; - num1251 += Main.rand.Next(min, max); + teleportTileY += Main.rand.Next(min, max); - if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, player.position, player.width, player.height) && - Main.tile[num1250, num1251].LiquidAmount > 204) + if (!WorldGen.SolidTile(teleportTileX, teleportTileY) && Collision.CanHit(new Vector2((float)(teleportTileX * 16), (float)(teleportTileY * 16)), 1, 1, player.position, player.width, player.height) && + Main.tile[teleportTileX, teleportTileY].LiquidAmount > 204) { break; } - if (num1249 > 100) + if (teleportTries > 100) { goto Block; } } NPC.ai[0] = 1f; - NPC.ai[1] = (float)num1250; - NPC.ai[2] = (float)num1251; + NPC.ai[1] = (float)teleportTileX; + NPC.ai[2] = (float)teleportTileY; NPC.netUpdate = true; Block: ; diff --git a/NPCs/Abyss/OarfishBody.cs b/NPCs/Abyss/OarfishBody.cs index b1a9017a0a..71dad1d575 100644 --- a/NPCs/Abyss/OarfishBody.cs +++ b/NPCs/Abyss/OarfishBody.cs @@ -84,39 +84,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 3c563516ad..2f17785853 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -116,10 +116,10 @@ namespace CalamityMod.NPCs.Abyss if (!TailSpawned && NPC.ai[0] == 0f) { int Previous = NPC.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int segments = 0; segments < maxLength; segments++) { int lol; - if (num36 >= 0 && num36 < minLength) + if (segments >= 0 && segments < minLength) { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); } @@ -153,154 +153,154 @@ namespace CalamityMod.NPCs.Abyss if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) NPC.active = false; - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float currentSpeed = speed; + float currentTurnSpeed = turnSpeed; + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); if (patrolSpot == Vector2.Zero) patrolSpot = Main.player[NPC.target].Center; - float num191 = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; + float targetXDirection = detectsPlayer ? Main.player[NPC.target].Center.X : patrolSpot.X; + float targetYDirection = detectsPlayer ? Main.player[NPC.target].Center.Y : patrolSpot.Y; if (!detectsPlayer) { - num192 += 300; - if (Math.Abs(NPC.Center.X - num191) < 250f) //500 + targetYDirection += 300; + if (Math.Abs(NPC.Center.X - targetXDirection) < 250f) //500 { if (NPC.velocity.X > 0f) { - num191 += 300f; + targetXDirection += 300f; } else { - num191 -= 300f; + targetXDirection -= 300f; } } } else { - num188 *= 1.5f; - num189 *= 1.5f; + currentSpeed *= 1.5f; + currentTurnSpeed *= 1.5f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float currentSpeedCheck = NPC.velocity.Length(); + if (currentSpeedCheck > 0f) { - if (num50 > num48) + if (currentSpeedCheck > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (currentSpeedCheck < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float absoluteTargetX = System.Math.Abs(targetXDirection); + float absoluteTargetY = System.Math.Abs(targetYDirection); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDirection *= timeToReachTarget; + targetYDirection *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f) || (NPC.velocity.Y > 0f && targetYDirection > 0f) || (NPC.velocity.Y < 0f && targetYDirection < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDirection < 0f) || (NPC.velocity.X < 0f && targetXDirection > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDirection) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDirection < 0f) || (NPC.velocity.Y < 0f && targetYDirection > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } diff --git a/NPCs/Abyss/OarfishTail.cs b/NPCs/Abyss/OarfishTail.cs index 01db892718..f9bf228a3c 100644 --- a/NPCs/Abyss/OarfishTail.cs +++ b/NPCs/Abyss/OarfishTail.cs @@ -84,39 +84,39 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 16f) * 16); + targetYDirection = (float)((int)(targetYDirection / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDirection -= segmentPosition.X; + targetYDirection -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDirection = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDirection = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDirection, (double)targetXDirection) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDirection; + NPC.position.Y = NPC.position.Y + targetYDirection; - if (num191 < 0f) + if (targetXDirection < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDirection > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/Abyss/ReaperShark.cs b/NPCs/Abyss/ReaperShark.cs index 13e6a10229..1f7b10c7a0 100644 --- a/NPCs/Abyss/ReaperShark.cs +++ b/NPCs/Abyss/ReaperShark.cs @@ -163,7 +163,7 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.wet || NPC.noTileCollide) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); @@ -175,7 +175,7 @@ namespace CalamityMod.NPCs.Abyss hasBeenHit = true; } - if (!flag14) + if (!canAttack) { if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { @@ -204,7 +204,7 @@ namespace CalamityMod.NPCs.Abyss } } } - if (flag14) + if (canAttack) { if (NPC.ai[3] > 0f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { @@ -283,15 +283,15 @@ namespace CalamityMod.NPCs.Abyss } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } @@ -346,14 +346,11 @@ namespace CalamityMod.NPCs.Abyss NPC.netUpdate = true; } bool expertMode = Main.expertMode; - int num2 = 30; - float num3 = expertMode ? 0.4f : 0.35f; - float scaleFactor = expertMode ? 6f : 5.5f; - int num4 = expertMode ? 28 : 30; - float num5 = expertMode ? 12f : 11f; - int num9 = 90; - int num16 = 75; - Vector2 vector = NPC.Center; + float chargeAcceleration = expertMode ? 0.4f : 0.35f; + float chargeThreshold = expertMode ? 6f : 5.5f; + int phase2Delay = expertMode ? 28 : 30; + float chargeVelocity = expertMode ? 12f : 11f; + Vector2 shorkCenter = NPC.Center; Player player = Main.player[NPC.target]; if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active) { @@ -361,7 +358,7 @@ namespace CalamityMod.NPCs.Abyss player = Main.player[NPC.target]; NPC.netUpdate = true; } - if (player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (player.dead || Vector2.Distance(player.Center, shorkCenter) > 5600f) { NPC.velocity.Y = NPC.velocity.Y + 0.4f; if (NPC.timeLeft > 10) @@ -382,53 +379,53 @@ namespace CalamityMod.NPCs.Abyss NPC.netUpdate = true; } } - float num17 = (float)Math.Atan2((double)(player.Center.Y - vector.Y), (double)(player.Center.X - vector.X)); + float getRotatedIdiot = (float)Math.Atan2((double)(player.Center.Y - shorkCenter.Y), (double)(player.Center.X - shorkCenter.X)); if (NPC.spriteDirection == 1) { - num17 += 3.14159274f; + getRotatedIdiot += 3.14159274f; } - if (num17 < 0f) + if (getRotatedIdiot < 0f) { - num17 += 6.28318548f; + getRotatedIdiot += 6.28318548f; } - if (num17 > 6.28318548f) + if (getRotatedIdiot > 6.28318548f) { - num17 -= 6.28318548f; + getRotatedIdiot -= 6.28318548f; } if (NPC.ai[0] == -1f) { - num17 = 0f; + getRotatedIdiot = 0f; } - float num18 = 0.04f; + float rotationSpeed = 0.04f; if (NPC.ai[0] == 1f) { - num18 = 0f; + rotationSpeed = 0f; } - if (NPC.rotation < num17) + if (NPC.rotation < getRotatedIdiot) { - if ((double)(num17 - NPC.rotation) > 3.1415926535897931) + if ((double)(getRotatedIdiot - NPC.rotation) > 3.1415926535897931) { - NPC.rotation -= num18; + NPC.rotation -= rotationSpeed; } else { - NPC.rotation += num18; + NPC.rotation += rotationSpeed; } } - if (NPC.rotation > num17) + if (NPC.rotation > getRotatedIdiot) { - if ((double)(NPC.rotation - num17) > 3.1415926535897931) + if ((double)(NPC.rotation - getRotatedIdiot) > 3.1415926535897931) { - NPC.rotation += num18; + NPC.rotation += rotationSpeed; } else { - NPC.rotation -= num18; + NPC.rotation -= rotationSpeed; } } - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) { - NPC.rotation = num17; + NPC.rotation = getRotatedIdiot; } if (NPC.rotation < 0f) { @@ -438,9 +435,9 @@ namespace CalamityMod.NPCs.Abyss { NPC.rotation -= 6.28318548f; } - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) { - NPC.rotation = num17; + NPC.rotation = getRotatedIdiot; } if (NPC.ai[0] != -1f) { @@ -466,10 +463,10 @@ namespace CalamityMod.NPCs.Abyss NPC.dontTakeDamage = true; NPC.chaseable = false; NPC.velocity *= 0.98f; - int num19 = Math.Sign(player.Center.X - vector.X); - if (num19 != 0) + int spriteFaceDirection = Math.Sign(player.Center.X - shorkCenter.X); + if (spriteFaceDirection != 0) { - NPC.direction = num19; + NPC.direction = spriteFaceDirection; NPC.spriteDirection = -NPC.direction; } if (NPC.ai[2] > 20f) @@ -489,22 +486,22 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 150; } } - if (NPC.ai[2] == (float)(num9 - 30)) + if (NPC.ai[2] == 60f) { - int num20 = 36; - for (int i = 0; i < num20; i++) + int dustAmt = 36; + for (int i = 0; i < dustAmt; i++) { - Vector2 expr_80F = (Vector2.Normalize(NPC.velocity) * new Vector2((float)NPC.width / 2f, (float)NPC.height) * 0.75f * 0.5f).RotatedBy((double)((float)(i - (num20 / 2 - 1)) * 6.28318548f / (float)num20), default) + NPC.Center; - Vector2 vector2 = expr_80F - NPC.Center; - int num21 = Dust.NewDust(expr_80F + vector2, 0, 0, 172, vector2.X * 2f, vector2.Y * 2f, 100, default, 1.4f); - Main.dust[num21].noGravity = true; - Main.dust[num21].noLight = true; - Main.dust[num21].velocity = Vector2.Normalize(vector2) * 3f; + Vector2 expr_80F = (Vector2.Normalize(NPC.velocity) * new Vector2((float)NPC.width / 2f, (float)NPC.height) * 0.75f * 0.5f).RotatedBy((double)((float)(i - (dustAmt / 2 - 1)) * 6.28318548f / (float)dustAmt), default) + NPC.Center; + Vector2 dustDirection = expr_80F - NPC.Center; + int chargeDust = Dust.NewDust(expr_80F + dustDirection, 0, 0, 172, dustDirection.X * 2f, dustDirection.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity = Vector2.Normalize(dustDirection) * 3f; } SoundEngine.PlaySound(EnragedRoarSound, NPC.Center); } NPC.ai[2] += 1f; - if (NPC.ai[2] >= (float)num16) + if (NPC.ai[2] >= 75f) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -519,49 +516,49 @@ namespace CalamityMod.NPCs.Abyss NPC.chaseable = true; if (NPC.ai[1] == 0f) { - NPC.ai[1] = (float)(300 * Math.Sign((vector - player.Center).X)); + NPC.ai[1] = (float)(300 * Math.Sign((shorkCenter - player.Center).X)); } - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - vector - NPC.velocity) * scaleFactor; - if (NPC.velocity.X < vector3.X) + Vector2 chargeDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - shorkCenter - NPC.velocity) * chargeThreshold; + if (NPC.velocity.X < chargeDirection.X) { - NPC.velocity.X = NPC.velocity.X + num3; - if (NPC.velocity.X < 0f && vector3.X > 0f) + NPC.velocity.X = NPC.velocity.X + chargeAcceleration; + if (NPC.velocity.X < 0f && chargeDirection.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num3; + NPC.velocity.X = NPC.velocity.X + chargeAcceleration; } } - else if (NPC.velocity.X > vector3.X) + else if (NPC.velocity.X > chargeDirection.X) { - NPC.velocity.X = NPC.velocity.X - num3; - if (NPC.velocity.X > 0f && vector3.X < 0f) + NPC.velocity.X = NPC.velocity.X - chargeAcceleration; + if (NPC.velocity.X > 0f && chargeDirection.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num3; + NPC.velocity.X = NPC.velocity.X - chargeAcceleration; } } - if (NPC.velocity.Y < vector3.Y) + if (NPC.velocity.Y < chargeDirection.Y) { - NPC.velocity.Y = NPC.velocity.Y + num3; - if (NPC.velocity.Y < 0f && vector3.Y > 0f) + NPC.velocity.Y = NPC.velocity.Y + chargeAcceleration; + if (NPC.velocity.Y < 0f && chargeDirection.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num3; + NPC.velocity.Y = NPC.velocity.Y + chargeAcceleration; } } - else if (NPC.velocity.Y > vector3.Y) + else if (NPC.velocity.Y > chargeDirection.Y) { - NPC.velocity.Y = NPC.velocity.Y - num3; - if (NPC.velocity.Y > 0f && vector3.Y < 0f) + NPC.velocity.Y = NPC.velocity.Y - chargeAcceleration; + if (NPC.velocity.Y > 0f && chargeDirection.Y < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num3; + NPC.velocity.Y = NPC.velocity.Y - chargeAcceleration; } } - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) + int shorkFacingSign = Math.Sign(player.Center.X - shorkCenter.X); + if (shorkFacingSign != 0) { - if (NPC.ai[2] == 0f && num22 != NPC.direction) + if (NPC.ai[2] == 0f && shorkFacingSign != NPC.direction) { NPC.rotation += 3.14159274f; } - NPC.direction = num22; + NPC.direction = shorkFacingSign; if (NPC.spriteDirection != -NPC.direction) { NPC.rotation += 3.14159274f; @@ -569,16 +566,16 @@ namespace CalamityMod.NPCs.Abyss NPC.spriteDirection = -NPC.direction; } NPC.ai[2] += 1f; - if (NPC.ai[2] >= (float)num2) + if (NPC.ai[2] >= 30f) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; - NPC.velocity = Vector2.Normalize(player.Center - vector) * num5; + NPC.velocity = Vector2.Normalize(player.Center - shorkCenter) * chargeVelocity; NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X); - if (num22 != 0) + if (shorkFacingSign != 0) { - NPC.direction = num22; + NPC.direction = shorkFacingSign; if (NPC.spriteDirection == 1) { NPC.rotation += 3.14159274f; @@ -591,19 +588,19 @@ namespace CalamityMod.NPCs.Abyss } else if (NPC.ai[0] == 1f) { - int num24 = 7; - for (int j = 0; j < num24; j++) + int phase2DustAmt = 7; + for (int j = 0; j < phase2DustAmt; j++) { - Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((float)(NPC.width + 50) / 2f, (float)NPC.height) * 0.75f).RotatedBy((double)(j - (num24 / 2 - 1)) * 3.1415926535897931 / (double)(float)num24, default) + vector; - Vector2 vector4 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); - int num25 = Dust.NewDust(arg_E1C_0 + vector4, 0, 0, 172, vector4.X * 2f, vector4.Y * 2f, 100, default, 1.4f); - Main.dust[num25].noGravity = true; - Main.dust[num25].noLight = true; - Main.dust[num25].velocity /= 4f; - Main.dust[num25].velocity -= NPC.velocity; + Vector2 arg_E1C_0 = (Vector2.Normalize(NPC.velocity) * new Vector2((float)(NPC.width + 50) / 2f, (float)NPC.height) * 0.75f).RotatedBy((double)(j - (phase2DustAmt / 2 - 1)) * 3.1415926535897931 / (double)(float)phase2DustAmt, default) + shorkCenter; + Vector2 phase2DustRotation = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - 1.57079637f).ToRotationVector2() * (float)Main.rand.Next(3, 8); + int phase2Dust = Dust.NewDust(arg_E1C_0 + phase2DustRotation, 0, 0, 172, phase2DustRotation.X * 2f, phase2DustRotation.Y * 2f, 100, default, 1.4f); + Main.dust[phase2Dust].noGravity = true; + Main.dust[phase2Dust].noLight = true; + Main.dust[phase2Dust].velocity /= 4f; + Main.dust[phase2Dust].velocity -= NPC.velocity; } NPC.ai[2] += 1f; - if (NPC.ai[2] >= (float)num4) + if (NPC.ai[2] >= (float)phase2Delay) { NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -613,7 +610,7 @@ namespace CalamityMod.NPCs.Abyss } if (Main.zenithWorld && Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] % 5 == 0) { - Vector2 direction = vector - player.Center; + Vector2 direction = shorkCenter - player.Center; direction.Normalize(); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, direction * 10f, ProjectileID.DemonSickle, NPC.damage / 2, 0f, Main.myPlayer); } diff --git a/NPCs/AcidRain/Mauler.cs b/NPCs/AcidRain/Mauler.cs index 90ae7aa4e8..a835f8ee24 100644 --- a/NPCs/AcidRain/Mauler.cs +++ b/NPCs/AcidRain/Mauler.cs @@ -500,25 +500,25 @@ namespace CalamityMod.NPCs.AcidRain int boom2 = Projectile.NewProjectile(NPC.GetSource_Death(), valueBoom.X, valueBoom.Y, (float)(-Math.Sin(offsetAngleBoom) * 6f), (float)(-Math.Cos(offsetAngleBoom) * 6f), projectileType, damageBoom, 0f, Main.myPlayer, 0f, 0f); } } - for (int num621 = 0; num621 < 25; num621++) + for (int i = 0; i < 25; i++) { - int num622 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int deathDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[deathDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[deathDust].scale = 0.5f; + Main.dust[deathDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } - Main.dust[num622].noGravity = true; + Main.dust[deathDust].noGravity = true; } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - Main.dust[num624].noGravity = true; + int deathDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[deathDust2].noGravity = true; + Main.dust[deathDust2].velocity *= 5f; + deathDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[deathDust2].velocity *= 2f; + Main.dust[deathDust2].noGravity = true; } NPC.netUpdate = true; } diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 5e7a730b56..0b8165919e 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -523,17 +523,17 @@ namespace CalamityMod.NPCs.AcidRain NPC.alpha = 0; if (DeathrayTime < 240f) { - int num5 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 200, default, 1.5f); - Main.dust[num5].noGravity = true; - Main.dust[num5].velocity *= 0.75f; - Main.dust[num5].fadeIn = 1.3f; + int bigFuckOffDeathrayDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 200, default, 1.5f); + Main.dust[bigFuckOffDeathrayDust].noGravity = true; + Main.dust[bigFuckOffDeathrayDust].velocity *= 0.75f; + Main.dust[bigFuckOffDeathrayDust].fadeIn = 1.3f; Vector2 vector = new Vector2((float)Main.rand.Next(-200, 201), (float)Main.rand.Next(-200, 201)); vector.Normalize(); vector *= (float)Main.rand.Next(100, 200) * 0.04f; - Main.dust[num5].velocity = vector; + Main.dust[bigFuckOffDeathrayDust].velocity = vector; vector.Normalize(); vector *= 34f; - Main.dust[num5].position = NPC.Center - vector; + Main.dust[bigFuckOffDeathrayDust].position = NPC.Center - vector; } else if (DeathrayTime == 240f) { diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index 48db750c06..8b36b27fd9 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -3,13 +3,12 @@ using System.IO; using CalamityMod.BiomeManagers; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Particles.Metaballs; using CalamityMod.Projectiles.Enemy; using CalamityMod.Projectiles.Magic; -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; @@ -76,9 +75,9 @@ namespace CalamityMod.NPCs.AcidRain public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Orthocera") + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Orthocera") }); } @@ -212,7 +211,7 @@ namespace CalamityMod.NPCs.AcidRain if (NPC.Calamity().newAI[0] % 5 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Bottom, Main.rand.NextVector2Circular(4f, 8f), ModContent.ProjectileType(), 0, 0f, Main.myPlayer); - FusableParticleManager.GetParticleSetByType().SpawnParticle(NPC.Bottom + Main.rand.NextVector2Circular(10f, 10f), 135f); + RancorLavaMetaball.SpawnParticle(NPC.Bottom + Main.rand.NextVector2Circular(10f, 10f), 135f); } if (NPC.Calamity().newAI[0] % 30 == 0 && Main.netMode != NetmodeID.MultiplayerClient) { diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index baa847bb42..46a657a72e 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -65,36 +65,36 @@ namespace CalamityMod.NPCs.Astral { NPC.TargetClosest(true); } - float num = CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6.5f : 5f; - float num2 = CalamityWorld.death ? 0.08f : CalamityWorld.revenge ? 0.065f : 0.05f; - Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num4 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num5 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); - vector.X = (float)((int)(vector.X / 8f) * 8); - vector.Y = (float)((int)(vector.Y / 8f) * 8); - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - float num7 = num6; - bool flag = false; - if (num6 > 600f) + float probeSpeed = CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6.5f : 5f; + float probeAcceleration = CalamityWorld.death ? 0.08f : CalamityWorld.revenge ? 0.065f : 0.05f; + Vector2 probePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDirection = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDirection = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDirection = (float)((int)(targetXDirection / 8f) * 8); + targetYDirection = (float)((int)(targetYDirection / 8f) * 8); + probePosition.X = (float)((int)(probePosition.X / 8f) * 8); + probePosition.Y = (float)((int)(probePosition.Y / 8f) * 8); + targetXDirection -= probePosition.X; + targetYDirection -= probePosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDirection * targetXDirection + targetYDirection * targetYDirection)); + float accelerateDistance = targetDistance; + bool tooFar = false; + if (targetDistance > 600f) { - flag = true; + tooFar = true; } - if (num6 == 0f) + if (targetDistance == 0f) { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; + targetXDirection = NPC.velocity.X; + targetYDirection = NPC.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = probeSpeed / targetDistance; + targetXDirection *= targetDistance; + targetYDirection *= targetDistance; } - if (num7 > 100f) + if (accelerateDistance > 100f) { NPC.ai[0] += 1f; if (NPC.ai[0] > 0f) @@ -120,24 +120,24 @@ namespace CalamityMod.NPCs.Astral } if (Main.player[NPC.target].dead) { - num4 = (float)NPC.direction * num / 2f; - num5 = -num / 2f; + targetXDirection = (float)NPC.direction * probeSpeed / 2f; + targetYDirection = -probeSpeed / 2f; } - if (NPC.velocity.X < num4) + if (NPC.velocity.X < targetXDirection) { - NPC.velocity.X = NPC.velocity.X + num2; + NPC.velocity.X = NPC.velocity.X + probeAcceleration; } - else if (NPC.velocity.X > num4) + else if (NPC.velocity.X > targetXDirection) { - NPC.velocity.X = NPC.velocity.X - num2; + NPC.velocity.X = NPC.velocity.X - probeAcceleration; } - if (NPC.velocity.Y < num5) + if (NPC.velocity.Y < targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y + num2; + NPC.velocity.Y = NPC.velocity.Y + probeAcceleration; } - else if (NPC.velocity.Y > num5) + else if (NPC.velocity.Y > targetYDirection) { - NPC.velocity.Y = NPC.velocity.Y - num2; + NPC.velocity.Y = NPC.velocity.Y - probeAcceleration; } NPC.localAI[0] += 1f; if (NPC.justHit) @@ -149,37 +149,36 @@ namespace CalamityMod.NPCs.Astral NPC.localAI[0] = 0f; if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - int num8 = Main.expertMode ? 14 : 18; + int projDamage = Main.expertMode ? 14 : 18; if (DownedBossSystem.downedAstrumAureus) - num8 += 6; + projDamage += 6; - int num9 = ProjectileID.PinkLaser; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector.X, vector.Y, num4, num5, num9, num8, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), probePosition.X, probePosition.Y, targetXDirection, targetYDirection, ProjectileID.PinkLaser, projDamage, 0f, Main.myPlayer, 0f, 0f); } } - int num10 = (int)NPC.position.X + NPC.width / 2; - int num11 = (int)NPC.position.Y + NPC.height / 2; - num10 /= 16; - num11 /= 16; - if (!WorldGen.SolidTile(num10, num11)) + int npcTileX = (int)NPC.position.X + NPC.width / 2; + int npcTileY = (int)NPC.position.Y + NPC.height / 2; + npcTileX /= 16; + npcTileY /= 16; + if (!WorldGen.SolidTile(npcTileX, npcTileY)) { Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.3f, 0f, 0.25f); } - if (num4 > 0f) + if (targetXDirection > 0f) { NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4); + NPC.rotation = (float)Math.Atan2((double)targetYDirection, (double)targetXDirection); } - if (num4 < 0f) + if (targetXDirection < 0f) { NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f; + NPC.rotation = (float)Math.Atan2((double)targetYDirection, (double)targetXDirection) + 3.14f; } - float num12 = 0.7f; + float recoilVelocity = 0.7f; if (NPC.collideX) { NPC.netUpdate = true; - NPC.velocity.X = NPC.oldVelocity.X * -num12; + NPC.velocity.X = NPC.oldVelocity.X * -recoilVelocity; if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) { NPC.velocity.X = 2f; @@ -192,7 +191,7 @@ namespace CalamityMod.NPCs.Astral if (NPC.collideY) { NPC.netUpdate = true; - NPC.velocity.Y = NPC.oldVelocity.Y * -num12; + NPC.velocity.Y = NPC.oldVelocity.Y * -recoilVelocity; if (NPC.velocity.Y > 0f && (double)NPC.velocity.Y < 1.5) { NPC.velocity.Y = 2f; @@ -202,9 +201,9 @@ namespace CalamityMod.NPCs.Astral NPC.velocity.Y = -2f; } } - if (flag) + if (tooFar) { - if ((NPC.velocity.X > 0f && num4 > 0f) || (NPC.velocity.X < 0f && num4 < 0f)) + if ((NPC.velocity.X > 0f && targetXDirection > 0f) || (NPC.velocity.X < 0f && targetXDirection < 0f)) { if (Math.Abs(NPC.velocity.X) < 12f) { @@ -229,16 +228,16 @@ namespace CalamityMod.NPCs.Astral spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / 2)); + Vector2 drawPosition = NPC.Center - screenPos; + drawPosition -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height)) * NPC.scale / 2f; + drawPosition += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/Astral/AstralProbeGlow").Value; - spriteBatch.Draw(texture2D15, vector43, NPC.frame, Color.White * 0.6f, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawPosition, NPC.frame, Color.White * 0.6f, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 78d3b48537..361aa12d3c 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -2175,9 +2175,9 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[1] += 1f; + npc.localAI[1] += 3f; if (revenge) - npc.localAI[1] += 0.5f; + npc.localAI[1] += 1f; if (npc.localAI[1] > 12f) { @@ -7579,26 +7579,25 @@ namespace CalamityMod.NPCs #region Gem Crawler AI public static void GemCrawlerAI(NPC npc, Mod mod, float speedDetect, float speedAdditive) { - int num19 = 30; - int num20 = 10; - bool flag19 = false; - bool flag20 = false; - bool flag30 = false; + int turnAroundDelay = 30; + bool unusedFlag = false; + bool isRunning = false; + bool shouldTurnAround = false; if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction > 0) || (npc.velocity.X < 0f && npc.direction < 0))) { - flag20 = true; + isRunning = true; npc.ai[3] += 1f; } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num19) | flag20) + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay) | isRunning) { npc.ai[3] += 1f; - flag30 = true; + shouldTurnAround = true; } else if (npc.ai[3] > 0f) { npc.ai[3] -= 1f; } - if (npc.ai[3] > (float)(num19 * num20)) + if (npc.ai[3] > (float)(turnAroundDelay * 10)) { npc.ai[3] = 0f; } @@ -7606,7 +7605,7 @@ namespace CalamityMod.NPCs { npc.ai[3] = 0f; } - if (npc.ai[3] == (float)num19) + if (npc.ai[3] == (float)turnAroundDelay) { npc.netUpdate = true; } @@ -7614,11 +7613,11 @@ namespace CalamityMod.NPCs float xDist = Main.player[npc.target].Center.X - npcPos.X; float yDist = Main.player[npc.target].Center.Y - npcPos.Y; float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (targetDist < 200f && !flag30) + if (targetDist < 200f && !shouldTurnAround) { npc.ai[3] = 0f; } - if (npc.ai[3] < (float)num19) + if (npc.ai[3] < (float)turnAroundDelay) { npc.TargetClosest(true); } @@ -7647,50 +7646,50 @@ namespace CalamityMod.NPCs npc.direction = 1; } } - float num6 = speedDetect; //5 - float num70 = speedAdditive; //0.05 - if (!flag19 && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction > 0) || (npc.velocity.X >= 0f && npc.direction < 0))) + float maxVelocity = speedDetect; //5 + float acceleration = speedAdditive; //0.05 + if (!unusedFlag && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction > 0) || (npc.velocity.X >= 0f && npc.direction < 0))) { - if (npc.velocity.X < -num6 || npc.velocity.X > num6) + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num6 && npc.direction == -1) + else if (npc.velocity.X < maxVelocity && npc.direction == -1) { - npc.velocity.X = npc.velocity.X + num70; - if (npc.velocity.X > num6) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num6; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num6 && npc.direction == 1) + else if (npc.velocity.X > -maxVelocity && npc.direction == 1) { - npc.velocity.X = npc.velocity.X - num70; - if (npc.velocity.X < -num6) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num6; + npc.velocity.X = -maxVelocity; } } } if (npc.velocity.Y >= 0f) { - int num9 = 0; + int faceDirection = 0; if (npc.velocity.X < 0f) { - num9 = -1; + faceDirection = -1; } if (npc.velocity.X > 0f) { - num9 = 1; + faceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num9)) / 16f); + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - num9, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - num9, y - 3].TileType])) + if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) { float npcBottom = (float)(y * 16); if (Main.tile[x, y].IsHalfBlock) @@ -7703,12 +7702,12 @@ namespace CalamityMod.NPCs } if (npcBottom < position.Y + (float)npc.height) { - float num13 = position.Y + (float)npc.height - npcBottom; - if (num13 <= 16.1f) + float percentageTileRisen = position.Y + (float)npc.height - npcBottom; + if (percentageTileRisen <= 16.1f) { npc.gfxOffY += npc.position.Y + (float)npc.height - npcBottom; npc.position.Y = npcBottom - (float)npc.height; - if (num13 < 9f) + if (percentageTileRisen < 9f) { npc.stepSpeed = 1f; } @@ -7771,18 +7770,18 @@ namespace CalamityMod.NPCs { bool DogPhase1 = npc.type == ModContent.NPCType() && npc.life > npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); bool DogPhase2 = npc.type == ModContent.NPCType() && npc.life <= npc.lifeMax * (CalamityWorld.death ? 0.9 : CalamityWorld.revenge ? 0.7 : 0.5); - int num = 30; - bool flag2 = false; - bool flag3 = false; + int turnAroundDelay = 30; + bool isRunning = false; + bool shouldTurnAround = false; if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) { - flag2 = true; + isRunning = true; npc.ai[3] += 1f; } - int num2 = DogPhase1 ? 10 : 4; + int turnAroundDelayMult = DogPhase1 ? 10 : 4; if (!DogPhase1) { - bool flag4 = npc.velocity.Y == 0f; + bool noYVelocity = npc.velocity.Y == 0f; for (int i = 0; i < Main.maxNPCs; i++) { if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) @@ -7805,21 +7804,21 @@ namespace CalamityMod.NPCs } } } - if (flag4) + if (noYVelocity) { npc.velocity.Y = 0f; } } - if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num || flag2) + if (npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay || isRunning) { npc.ai[3] += 1f; - flag3 = true; + shouldTurnAround = true; } else if (npc.ai[3] > 0f) { npc.ai[3] -= 1f; } - if (npc.ai[3] > (float)(num * num2)) + if (npc.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) { npc.ai[3] = 0f; } @@ -7827,7 +7826,7 @@ namespace CalamityMod.NPCs { npc.ai[3] = 0f; } - if (npc.ai[3] == (float)num) + if (npc.ai[3] == (float)turnAroundDelay) { npc.netUpdate = true; } @@ -7835,7 +7834,7 @@ namespace CalamityMod.NPCs float xDist = Main.player[npc.target].Center.X - npcPos.X; float yDist = Main.player[npc.target].Center.Y - npcPos.Y; float targetDist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist)); - if (targetDist < 200f && !flag3) + if (targetDist < 200f && !shouldTurnAround) { npc.ai[3] = 0f; } @@ -7878,7 +7877,7 @@ namespace CalamityMod.NPCs } } } - if (npc.ai[3] < (float)num) + if (npc.ai[3] < (float)turnAroundDelay) { npc.TargetClosest(true); } @@ -7914,51 +7913,51 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.92f; } - float num9 = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); + float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); if (!Main.player[npc.target].ZoneSandstorm) { - num9 = 0f; + sandstormPush = 0f; } - float num7 = speedDetect; - float num8 = speedAdditive; - if (npc.velocity.X < -num7 || npc.velocity.X > num7) + float maxVelocity = speedDetect; + float acceleration = speedAdditive; + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num7 && npc.direction == 1) + else if (npc.velocity.X < maxVelocity && npc.direction == 1) { - npc.velocity.X += num8; - if (npc.velocity.X > num7) + npc.velocity.X += acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num7; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num7 && npc.direction == -1) + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) { - npc.velocity.X -= num8; - if (npc.velocity.X < -num7) + npc.velocity.X -= acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num7; + npc.velocity.X = -maxVelocity; } } } if (npc.velocity.Y >= 0f) { - int num10 = 0; + int faceDirection = 0; if (npc.velocity.X < 0f) { - num10 = -1; + faceDirection = -1; } if (npc.velocity.X > 0f) { - num10 = 1; + faceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num10)) / 16f); + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); int y = (int)((position.Y + (float)npc.height - 1f) / 16f); // 21JAN2023: Ozzatron -- this is probably the single most unmaintainable if statement I've ever seen @@ -7967,7 +7966,7 @@ namespace CalamityMod.NPCs Tile t_xy1 = CalamityUtils.ParanoidTileRetrieval(x, y - 1); Tile t_xy2 = CalamityUtils.ParanoidTileRetrieval(x, y - 2); Tile t_xy3 = CalamityUtils.ParanoidTileRetrieval(x, y - 3); - Tile t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - num10, y - 3); // 3 down, offset 1 in the direction of the NPC's movement + Tile t_xOffY3 = CalamityUtils.ParanoidTileRetrieval(x - faceDirection, y - 3); // 3 down, offset 1 in the direction of the NPC's movement Tile t_xy4 = CalamityUtils.ParanoidTileRetrieval(x, y - 4); bool positionCheck = (float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X; bool tileSolidityCheck1 = t_xy.HasUnactuatedTile && !t_xy.TopSlope && !t_xy1.TopSlope && Main.tileSolid[t_xy.TileType] && !Main.tileSolidTop[t_xy.TileType]; @@ -7979,23 +7978,23 @@ namespace CalamityMod.NPCs bool threeDownOffsetIsNonSolid = !t_xOffY3.HasUnactuatedTile || !Main.tileSolid[t_xOffY3.TileType]; if (positionCheck && (tileSolidityCheck1 || oneBelowIsSolidHalf) && canFallThrough && twoDownIsNonSolid && threeDownIsNonSolid && threeDownOffsetIsNonSolid) { - float num13 = (float)(y * 16); + float tilePixelPosition = (float)(y * 16); if (Main.tile[x, y].IsHalfBlock) { - num13 += 8f; + tilePixelPosition += 8f; } if (Main.tile[x, y - 1].IsHalfBlock) { - num13 -= 8f; + tilePixelPosition -= 8f; } - if (num13 < position.Y + (float)npc.height) + if (tilePixelPosition < position.Y + (float)npc.height) { - float num14 = position.Y + (float)npc.height - num13; - if ((double)num14 <= 16.1) + float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) { - npc.gfxOffY += npc.position.Y + (float)npc.height - num13; - npc.position.Y = num13 - (float)npc.height; - if (num14 < 9f) + npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - (float)npc.height; + if (percentageTileRisen < 9f) { npc.stepSpeed = 1f; } @@ -8009,16 +8008,15 @@ namespace CalamityMod.NPCs } if (npc.velocity.Y == 0f) { - int num15 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); - int num16 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - int num17 = npc.spriteDirection; - num17 *= -1; - if ((npc.velocity.X < 0f && num17 == -1) || (npc.velocity.X > 0f && num17 == 1)) + int npcTileX = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); + int npcTileY = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + int spriteDirection = npc.spriteDirection; + spriteDirection *= -1; + if ((npc.velocity.X < 0f && spriteDirection == -1) || (npc.velocity.X > 0f && spriteDirection == 1)) { - float num18 = 3f; - if (Main.tile[num15, num16 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num15, num16 - 2].TileType]) + if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) { - if (Main.tile[num15, num16 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num15, num16 - 3].TileType]) + if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) { npc.velocity.Y = bouncy1; npc.netUpdate = true; @@ -8029,17 +8027,17 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } } - else if (Main.tile[num15, num16 - 1].HasUnactuatedTile && !Main.tile[num15, num16 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num15, num16 - 1].TileType]) + else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) { npc.velocity.Y = bouncy3; npc.netUpdate = true; } - else if (npc.position.Y + (float)npc.height - (float)(num16 * 16) > 20f && Main.tile[num15, num16].HasUnactuatedTile && !Main.tile[num15, num16].TopSlope && Main.tileSolid[(int)Main.tile[num15, num16].TileType]) + else if (npc.position.Y + (float)npc.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) { npc.velocity.Y = bouncy4; npc.netUpdate = true; } - else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > num18) && (!Main.tile[num15, num16 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num15, num16 + 1].TileType]) && (!Main.tile[num15, num16 + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num15, num16 + 2].TileType]) && (!Main.tile[num15 + npc.direction, num16 + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num15 + npc.direction, num16 + 3].TileType])) + else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) { npc.velocity.Y = bouncy5; npc.netUpdate = true; @@ -8257,15 +8255,15 @@ namespace CalamityMod.NPCs } } } - int num258 = (int)(npc.position.X + (float)(npc.width / 2)) / 16; - int num259 = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(npc.position.X + (float)(npc.width / 2)) / 16; + int npcTileY = (int)(npc.position.Y + (float)(npc.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { npc.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { npc.ai[0] = -1f; } diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 48a955524b..6ca9db0a96 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -103,7 +103,7 @@ namespace CalamityMod.NPCs Vector2 headPosition = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f); float rotationVectorMult = MathHelper.Lerp(20f, 30f, (time * 3f + 50f) / 182f); Main.rand.NextFloat(); - for (float num17 = 0f; num17 < 2f; num17 += 1f) + for (float i = 0f; i < 2f; i += 1f) { Vector2 rotationVector = Vector2.UnitY.RotatedByRandom(Math.PI * 2.0) * (Main.rand.NextFloat() * 0.5f + 0.5f); Dust dust = Dust.NewDustDirect(headPosition, 0, 0, 228, 0f, 0f, 0, default, 1f); @@ -584,12 +584,12 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); float velocityMultiplier = 10f; float turnValue = 40f; - Vector2 value3 = Main.player[npc.target].Center - npc.Center; - float playerDistance = value3.Length(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + float playerDistance = targetDirection.Length(); velocityMultiplier += playerDistance / 200f; - value3.Normalize(); - value3 *= velocityMultiplier; - npc.velocity = (npc.velocity * (turnValue - 1f) + value3) / turnValue; + targetDirection.Normalize(); + targetDirection *= velocityMultiplier; + npc.velocity = (npc.velocity * (turnValue - 1f) + targetDirection) / turnValue; if (playerDistance < 500f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { // Go back to normal AI @@ -1038,10 +1038,10 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.Item8, npc.position); float distX = npc.oldPos[2].X + (float)npc.width * 0.5f - npc.Center.X; float distY = npc.oldPos[2].Y + (float)npc.height * 0.5f - npc.Center.Y; - float num38 = (float)Math.Sqrt((distX * distX + distY * distY)); - num38 = 2f / num38; - distX *= num38; - distY *= num38; + float distance = (float)Math.Sqrt((distX * distX + distY * distY)); + distance = 2f / distance; + distX *= distance; + distY *= distance; for (int m = 0; m < 20; m++) { int dustIdx = Dust.NewDust(npc.position, npc.width, npc.height, 71, distX, distY, 200, default, 2f); @@ -1083,12 +1083,7 @@ namespace CalamityMod.NPCs ableToAlterAI3 = true; } - // This variable means so many fucking things for different NPCs - // Such as npc spawn timer, projectile timer, ect - // From what I can gather, the ai2 value's max for spawning things also varies - // As a result, I'll just leave this as flag7. If anyone has - // Ideas for a better variable name, please change it - bool flag7 = npc.ai[2] <= 0f; + bool npcTimer = npc.ai[2] <= 0f; if (npcType <= NPCID.RayGunner) { if (npcType <= NPCID.PirateCaptain) @@ -1126,7 +1121,7 @@ namespace CalamityMod.NPCs //& and && (same with | and ||) with booleans, // I'd greatly appreciate it PrepareToShoot: - if (!ableToAlterAI3 & flag7) + if (!ableToAlterAI3 & npcTimer) { if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) { @@ -2509,17 +2504,17 @@ namespace CalamityMod.NPCs { bool npcAllowedToShoot = npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker; bool isAlienQueen = npcType == NPCID.VortexHornetQueen; - bool flag18 = true; - int num136 = -1; - int num137 = -1; + bool canShootAtTarget = true; + int stardustGateValue = -1; + int stardustGateValueAdd = -1; if (npcType == NPCID.StardustSoldier) { npcAllowedToShoot = true; - num136 = 90; - num137 = 90; + stardustGateValue = 90; + stardustGateValueAdd = 90; if (npc.ai[1] <= 150f) { - flag18 = false; + canShootAtTarget = false; } } if (npc.confused) @@ -2623,85 +2618,85 @@ namespace CalamityMod.NPCs } } attackTimeMax = (int)(attackTimeMax * 0.75); - int num139 = attackTimeMax / 2; + int modifiedAttackTime = attackTimeMax / 2; if (npcType == NPCID.NebulaSoldier) { - num139 = attackTimeMax - 1; + modifiedAttackTime = attackTimeMax - 1; } if (npcType == NPCID.VortexHornetQueen) { - num139 = attackTimeMax - 1; + modifiedAttackTime = attackTimeMax - 1; } if (npc.ai[2] > 0f) { - if (flag18) + if (canShootAtTarget) { npc.TargetClosest(true); } - if (npc.ai[1] == (float)num139) + if (npc.ai[1] == (float)modifiedAttackTime) { if (npcType == NPCID.PirateCaptain) { npc.localAI[2] += 1f; } - float num140 = CalamityWorld.death ? 6f : 11f; + float projSpeed = CalamityWorld.death ? 6f : 11f; if (npcType == NPCID.GoblinArcher) { - num140 = CalamityWorld.death ? 5f : 9f; + projSpeed = CalamityWorld.death ? 5f : 9f; } if (npcType == NPCID.IcyMerman) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } if (npcType == NPCID.Paladin) { - num140 = CalamityWorld.death ? 5f : 9f; + projSpeed = CalamityWorld.death ? 5f : 9f; } if (npcType == NPCID.SkeletonCommando) { - num140 = CalamityWorld.death ? 2.5f : 4f; + projSpeed = CalamityWorld.death ? 2.5f : 4f; } if (npcType == NPCID.PirateDeadeye) { - num140 = CalamityWorld.death ? 8f : 14f; + projSpeed = CalamityWorld.death ? 8f : 14f; } if (npcType == NPCID.PirateCrossbower) { - num140 = CalamityWorld.death ? 9f : 16f; + projSpeed = CalamityWorld.death ? 9f : 16f; } if (npcType == NPCID.RayGunner) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } if (npcType == NPCID.MartianWalker) { - num140 = CalamityWorld.death ? 5f : 8f; + projSpeed = CalamityWorld.death ? 5f : 8f; } if (npcType == NPCID.StardustSpiderBig) { - num140 = 4f; + projSpeed = 4f; } if (npcType >= 449 && npcType <= 452) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } if (npcType == NPCID.GreekSkeleton) { - num140 = CalamityWorld.death ? 5f : 8f; + projSpeed = CalamityWorld.death ? 5f : 8f; } if (npcType == NPCID.DrManFly) { - num140 = CalamityWorld.death ? 4.5f : 7.5f; + projSpeed = CalamityWorld.death ? 4.5f : 7.5f; } if (npcType == NPCID.StardustSoldier) { - num140 = 1f; + projSpeed = 1f; } if (npcType >= 498 && npcType <= 506) { - num140 = CalamityWorld.death ? 4f : 7f; + projSpeed = CalamityWorld.death ? 4f : 7f; } - num140 *= 1.25f; + projSpeed *= 1.25f; Vector2 spawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); if (npcType == NPCID.GreekSkeleton) { @@ -2732,43 +2727,43 @@ namespace CalamityMod.NPCs spawnPosition += new Vector2((float)(npc.spriteDirection * 2), -12f); } float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spawnPosition.X; - float num142 = Math.Abs(distX) * 0.1f; + float projOffset = Math.Abs(distX) * 0.1f; if (npcType == NPCID.SkeletonSniper || npcType == NPCID.TacticalSkeleton) { - num142 = 0f; + projOffset = 0f; } if (npcType == NPCID.PirateCrossbower) { - num142 = Math.Abs(distX) * 0.08f; + projOffset = Math.Abs(distX) * 0.08f; } if (npcType == NPCID.PirateDeadeye || (npcType == NPCID.PirateCaptain && !priateCaptainBoost)) { - num142 = 0f; + projOffset = 0f; } if (npcType == NPCID.BrainScrambler || npcType == NPCID.RayGunner || npcType == NPCID.MartianWalker) { - num142 = 0f; + projOffset = 0f; } if (npcType >= 449 && npcType <= 452) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; } if (npcType == NPCID.DrManFly) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(10, 50) * 0.01f; } if (npcType == NPCID.GreekSkeleton) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(-10, 11) * 0.0035f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(-10, 11) * 0.0035f; } if (npcType >= 498 && npcType <= 506) { - num142 = Math.Abs(distX) * (float)Main.rand.Next(1, 11) * 0.0025f; + projOffset = Math.Abs(distX) * (float)Main.rand.Next(1, 11) * 0.0025f; } - float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - spawnPosition.Y - num142; + float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - spawnPosition.Y - projOffset; float magnitude = (float)Math.Sqrt((distX * distX + distY * distY)); npc.netUpdate = true; - magnitude = num140 / magnitude; + magnitude = projSpeed / magnitude; distX *= magnitude; distY *= magnitude; int damage = 35; @@ -2980,7 +2975,7 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; npc.ai[1] = 0f; } - else if (!npcAllowedToShoot || (num136 != -1 && npc.ai[1] >= (float)num136 && npc.ai[1] < (float)(num136 + num137) && (!isAlienQueen || npc.velocity.Y == 0f))) + else if (!npcAllowedToShoot || (stardustGateValue != -1 && npc.ai[1] >= (float)stardustGateValue && npc.ai[1] < (float)(stardustGateValue + stardustGateValueAdd) && (!isAlienQueen || npc.velocity.Y == 0f))) { npc.velocity.X *= 0.9f; npc.spriteDirection = npc.direction; @@ -3004,10 +2999,10 @@ namespace CalamityMod.NPCs } if (canAttack) { - Vector2 vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector23.X; + Vector2 projSpawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float distX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - projSpawnPosition.X; float distXAbsolute = Math.Abs(distX) * 0.1f; - float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector23.Y - distXAbsolute; + float distY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - projSpawnPosition.Y - distXAbsolute; distX += (float)Main.rand.Next(-40, 41); distY += (float)Main.rand.Next(-40, 41); float playerDistance = (float)Math.Sqrt(distX * distX + distY * distY); @@ -3076,7 +3071,7 @@ namespace CalamityMod.NPCs } } - if (npc.ai[2] <= 0f || (npcAllowedToShoot && (num136 == -1 || npc.ai[1] < (float)num136 || npc.ai[1] >= (float)(num136 + num137)))) + if (npc.ai[2] <= 0f || (npcAllowedToShoot && (stardustGateValue == -1 || npc.ai[1] < (float)stardustGateValue || npc.ai[1] >= (float)(stardustGateValue + stardustGateValueAdd)))) { float maxVelocity = 1f; float acceleration = 0.07f; @@ -3175,12 +3170,12 @@ namespace CalamityMod.NPCs Vector2 spawnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f - (float)(npc.direction * 24), npc.position.Y + 4f); int velocityX = 3 * npc.direction; int velocityY = -5; - int num160 = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num160].timeLeft = 300; + int clownBomb = Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition.X, spawnPosition.Y, velocityX, velocityY, ProjectileID.HappyBomb, 0, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[clownBomb].timeLeft = 300; if (CalamityWorld.death) { - Main.projectile[num160].extraUpdates += 1; - Main.projectile[num160].timeLeft = 600; + Main.projectile[clownBomb].extraUpdates += 1; + Main.projectile[clownBomb].timeLeft = 600; } npc.ai[2] = 0f; } @@ -3336,26 +3331,26 @@ namespace CalamityMod.NPCs { if (Main.tile[x, y - 1].TileType == TileID.ClosedDoor) { - bool flag24 = WorldGen.OpenDoor(x, y - 1, npc.direction); - if (!flag24) + bool canOpenDoor = WorldGen.OpenDoor(x, y - 1, npc.direction); + if (!canOpenDoor) { npc.ai[3] = (float)aiGateValue; npc.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag24) + if (Main.netMode == NetmodeID.Server & canOpenDoor) { NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)x, (float)(y - 1), (float)npc.direction, 0, 0, 0); } } if (Main.tile[x, y - 1].TileType == TileID.TallGateClosed) { - bool flag25 = WorldGen.ShiftTallGate(x, y - 1, false); - if (!flag25) + bool canOpenTallGate = WorldGen.ShiftTallGate(x, y - 1, false); + if (!canOpenTallGate) { npc.ai[3] = (float)aiGateValue; npc.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag25) + if (Main.netMode == NetmodeID.Server & canOpenTallGate) { NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)x, (float)(y - 1), 0f, 0, 0, 0); } @@ -3473,25 +3468,25 @@ namespace CalamityMod.NPCs { tryCount++; int randX = Main.rand.Next(tileCoordsX - maxDistanceX, tileCoordsX + maxDistanceX); - for (int num181 = Main.rand.Next(tileCoordsY - maxDistanceX, tileCoordsY + maxDistanceX); num181 < tileCoordsY + maxDistanceX; num181++) + for (int t = Main.rand.Next(tileCoordsY - maxDistanceX, tileCoordsY + maxDistanceX); t < tileCoordsY + maxDistanceX; t++) { - if ((num181 < tileCoordsY - 4 || num181 > tileCoordsY + 4 || randX < tileCoordsX - 4 || randX > tileCoordsX + 4) && (num181 < tileCoordsY2 - 1 || num181 > tileCoordsY2 + 1 || randX < tileCoordsX2 - 1 || randX > tileCoordsX2 + 1) && Main.tile[randX, num181].HasUnactuatedTile) + if ((t < tileCoordsY - 4 || t > tileCoordsY + 4 || randX < tileCoordsX - 4 || randX > tileCoordsX + 4) && (t < tileCoordsY2 - 1 || t > tileCoordsY2 + 1 || randX < tileCoordsX2 - 1 || randX > tileCoordsX2 + 1) && Main.tile[randX, t].HasUnactuatedTile) { bool foundGoodTeleport = true; // I don't understand why the hell this exists if it's only for Chaos Elementals, but I suppose I'll // Leave it here - if (npcType == NPCID.DarkCaster && Main.tile[randX, num181 - 1].WallType == WallID.None) + if (npcType == NPCID.DarkCaster && Main.tile[randX, t - 1].WallType == WallID.None) { foundGoodTeleport = false; } - else if (Main.tile[randX, num181 - 1].LiquidType == LiquidID.Lava) + else if (Main.tile[randX, t - 1].LiquidType == LiquidID.Lava) { foundGoodTeleport = false; } - if (foundGoodTeleport && Main.tileSolid[(int)Main.tile[randX, num181].TileType] && !Collision.SolidTiles(randX - 1, randX + 1, num181 - 4, num181 - 1)) + if (foundGoodTeleport && Main.tileSolid[(int)Main.tile[randX, t].TileType] && !Collision.SolidTiles(randX - 1, randX + 1, t - 4, t - 1)) { npc.position.X = (float)(randX * 16 - npc.width / 2); - npc.position.Y = (float)(num181 * 16 - npc.height); + npc.position.Y = (float)(t * 16 - npc.height); npc.netUpdate = true; npc.ai[3] = -30f; } @@ -3540,11 +3535,11 @@ namespace CalamityMod.NPCs { for (int j = 0; j < 2; j++) { - Dust dust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - dust2.velocity *= 1f; - dust2.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust2.velocity += npc.velocity * 0.3f; + Dust eyeFishDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + eyeFishDust.velocity *= 1f; + eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.velocity += npc.velocity * 0.3f; } } @@ -3556,35 +3551,35 @@ namespace CalamityMod.NPCs if (targetData.Type == NPCTargetType.Player) targetDead = Main.player[npc.target].dead; - float num = 6f; - float num2 = 0.05f; + float maxVelocity = 6f; + float acceleration = 0.05f; if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Crimera) { - num = 4f; - num2 = 0.035f; + maxVelocity = 4f; + acceleration = 0.035f; } else if (npc.type == NPCID.Corruptor) { - num = 4.2f; - num2 = 0.022f; + maxVelocity = 4.2f; + acceleration = 0.022f; } else if (npc.type == NPCID.BloodSquid) { - num = 6f; - num2 = 0.1f; + maxVelocity = 6f; + acceleration = 0.1f; } else if (npc.type == NPCID.Hornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) { - num = 3.5f; - num2 = 0.021f; + maxVelocity = 3.5f; + acceleration = 0.021f; if (npc.type == NPCID.HornetFatty) { - num = 3f; - num2 = 0.017f; + maxVelocity = 3f; + acceleration = 0.017f; } - num *= 1f - npc.scale; - num2 *= 1f - npc.scale; + maxVelocity *= 1f - npc.scale; + acceleration *= 1f - npc.scale; if ((double)(npc.position.Y / 16f) < Main.worldSurface) { if (Main.player[npc.target].position.Y - npc.position.Y > 300f && npc.velocity.Y < 0f) @@ -3596,36 +3591,36 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.MossHornet) { - num = 4f; - num2 = 0.017f; + maxVelocity = 4f; + acceleration = 0.017f; } else if (npc.type == NPCID.Parrot) { if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - num = 6f; - num2 = 0.1f; + maxVelocity = 6f; + acceleration = 0.1f; } else { - num2 = 0.01f; - num = 2f; + acceleration = 0.01f; + maxVelocity = 2f; } } else if (npc.type == NPCID.Moth) { - num = 7f; - num2 = 0.06f; + maxVelocity = 7f; + acceleration = 0.06f; } else if (npc.type == NPCID.MeteorHead) { - num = 2f; - num2 = 0.05f; + maxVelocity = 2f; + acceleration = 0.05f; } else if (npc.type == NPCID.ServantofCthulhu) { - num = 5f; - num2 = 0.03f; + maxVelocity = 5f; + acceleration = 0.03f; } else if (npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall) { @@ -3635,10 +3630,10 @@ namespace CalamityMod.NPCs float originalFlyAwayVelocity = 6f; float flyAwayDistance = originalFlyAwayTime * originalFlyAwayVelocity; float flyAwayVelocity = flyAwayDistance / flyAwayTime; - float num3 = (npc.ai[1] - flyAwayTime) / flyAwayTime; - if (num3 > 1f) + float flyAwayAccel = (npc.ai[1] - flyAwayTime) / flyAwayTime; + if (flyAwayAccel > 1f) { - num3 = 1f; + flyAwayAccel = 1f; } else { @@ -3655,47 +3650,47 @@ namespace CalamityMod.NPCs npc.velocity.Y = -flyAwayVelocity; } - num = 5f; - num2 = 0.1f; - num2 *= num3; + maxVelocity = 5f; + acceleration = 0.1f; + acceleration *= flyAwayAccel; } - num *= 1.25f; - num2 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; if (CalamityWorld.death) { - num *= 1.25f; - num2 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num4 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num5 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); + float targetXDist = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float targetYDist = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + targetXDist = (float)((int)(targetXDist / 8f) * 8); + targetYDist = (float)((int)(targetYDist / 8f) * 8); vector.X = (float)((int)(vector.X / 8f) * 8); vector.Y = (float)((int)(vector.Y / 8f) * 8); - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - float num7 = num6; + targetXDist -= vector.X; + targetYDist -= vector.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float targetDistCheck = targetDistance; bool flag = false; - if (num6 > 600f) + if (targetDistance > 600f) { flag = true; } - if (num6 == 0f) + if (targetDistance == 0f) { - num4 = npc.velocity.X; - num5 = npc.velocity.Y; + targetXDist = npc.velocity.X; + targetYDist = npc.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = maxVelocity / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; } if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy) || npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Probe || npc.type == NPCID.Crimera || npc.type == NPCID.Moth || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid) { - if (num7 > 100f || npc.type == NPCID.Corruptor || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) + if (targetDistCheck > 100f || npc.type == NPCID.Corruptor || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) { npc.ai[0] += 1f; if (npc.ai[0] > 0f) @@ -3719,60 +3714,60 @@ namespace CalamityMod.NPCs npc.ai[0] = -200f; } } - if (num7 < 150f && (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid)) + if (targetDistCheck < 150f && (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid)) { - npc.velocity.X = npc.velocity.X + num4 * 0.009f; - npc.velocity.Y = npc.velocity.Y + num5 * 0.009f; + npc.velocity.X = npc.velocity.X + targetXDist * 0.009f; + npc.velocity.Y = npc.velocity.Y + targetYDist * 0.009f; } } if (targetDead) { - num4 = (float)npc.direction * num / 2f; - num5 = -num / 2f; + targetXDist = (float)npc.direction * maxVelocity / 2f; + targetYDist = -maxVelocity / 2f; } - if (npc.velocity.X < num4) + if (npc.velocity.X < targetXDist) { - npc.velocity.X = npc.velocity.X + num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X < 0f && num4 > 0f) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X < 0f && targetXDist > 0f) { - npc.velocity.X = npc.velocity.X + num2; + npc.velocity.X = npc.velocity.X + acceleration; } } - else if (npc.velocity.X > num4) + else if (npc.velocity.X > targetXDist) { - npc.velocity.X = npc.velocity.X - num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X > 0f && num4 < 0f) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.X > 0f && targetXDist < 0f) { - npc.velocity.X = npc.velocity.X - num2; + npc.velocity.X = npc.velocity.X - acceleration; } } - if (npc.velocity.Y < num5) + if (npc.velocity.Y < targetYDist) { - npc.velocity.Y = npc.velocity.Y + num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y < 0f && num5 > 0f) + npc.velocity.Y = npc.velocity.Y + acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y < 0f && targetYDist > 0f) { - npc.velocity.Y = npc.velocity.Y + num2; + npc.velocity.Y = npc.velocity.Y + acceleration; } } - else if (npc.velocity.Y > num5) + else if (npc.velocity.Y > targetYDist) { - npc.velocity.Y = npc.velocity.Y - num2; - if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y > 0f && num5 < 0f) + npc.velocity.Y = npc.velocity.Y - acceleration; + if (npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.Corruptor && npc.type != NPCID.Probe && npc.type != NPCID.BloodSquid && npc.velocity.Y > 0f && targetYDist < 0f) { - npc.velocity.Y = npc.velocity.Y - num2; + npc.velocity.Y = npc.velocity.Y - acceleration; } } if (npc.type == NPCID.MeteorHead) { - if (num4 > 0f) + if (targetXDist > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4); + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); } - else if (num4 < 0f) + else if (targetXDist < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + MathHelper.Pi; } } else if (npc.type == NPCID.Probe) @@ -3786,33 +3781,33 @@ namespace CalamityMod.NPCs npc.localAI[0] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - int num8 = 22; - int num9 = 84; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector.X, vector.Y, num4, num5, num9, num8, 0f, Main.myPlayer, 0f, 0f); + int projDamage = 22; + int projType = 84; + Projectile.NewProjectile(npc.GetSource_FromAI(), vector.X, vector.Y, targetXDist, targetYDist, projType, projDamage, 0f, Main.myPlayer, 0f, 0f); } } - int arg_A81_0 = (int)npc.position.X + npc.width / 2; - int num10 = (int)npc.position.Y + npc.height / 2; - int arg_A8B_0 = arg_A81_0 / 16; - num10 /= 16; - if (!WorldGen.SolidTile(arg_A8B_0, num10)) + int npcXPos = (int)npc.position.X + npc.width / 2; + int npcTileY = (int)npc.position.Y + npc.height / 2; + int npcTileX = npcXPos / 16; + npcTileY /= 16; + if (!WorldGen.SolidTile(npcTileX, npcTileY)) { Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.3f, 0.1f, 0.05f); } - if (num4 > 0f) + if (targetXDist > 0f) { npc.spriteDirection = 1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4); + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); } - if (num4 < 0f) + if (targetXDist < 0f) { npc.spriteDirection = -1; - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + MathHelper.Pi; } } else if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Corruptor || npc.type == NPCID.Crimera || npc.type == NPCID.BloodSquid) { - npc.rotation = (float)Math.Atan2((double)num5, (double)num4) - MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) - MathHelper.PiOver2; } else if (npc.type == NPCID.Moth || npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy)) { @@ -3832,15 +3827,15 @@ namespace CalamityMod.NPCs } if (npc.type == NPCID.Hornet || npc.type == NPCID.MossHornet || (npc.type >= NPCID.HornetFatty && npc.type <= NPCID.HornetStingy) || npc.type == NPCID.EaterofSouls || npc.type == NPCID.MeteorHead || npc.type == NPCID.Corruptor || npc.type == NPCID.Probe || npc.type == NPCID.Crimera || npc.type == NPCID.Moth || npc.type == NPCID.Bee || npc.type == NPCID.BeeSmall || npc.type == NPCID.BloodSquid) { - float num11 = 0.7f; + float reboundSpeed = 0.7f; if (npc.type == NPCID.EaterofSouls || npc.type == NPCID.Crimera) { - num11 = 0.4f; + reboundSpeed = 0.4f; } if (npc.collideX) { npc.netUpdate = true; - npc.velocity.X = npc.oldVelocity.X * -num11; + npc.velocity.X = npc.oldVelocity.X * -reboundSpeed; if (npc.direction == -1 && npc.velocity.X > 0f && npc.velocity.X < 2f) { npc.velocity.X = 2f; @@ -3853,7 +3848,7 @@ namespace CalamityMod.NPCs if (npc.collideY) { npc.netUpdate = true; - npc.velocity.Y = npc.oldVelocity.Y * -num11; + npc.velocity.Y = npc.oldVelocity.Y * -reboundSpeed; if (npc.velocity.Y > 0f && (double)npc.velocity.Y < 1.5) { npc.velocity.Y = 2f; @@ -3865,34 +3860,34 @@ namespace CalamityMod.NPCs } if (npc.type == NPCID.BloodSquid) { - int num13 = Dust.NewDust(npc.position, npc.width, npc.height, 5, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100); - Main.dust[num13].velocity *= 0.5f; + int bloodDust = Dust.NewDust(npc.position, npc.width, npc.height, 5, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100); + Main.dust[bloodDust].velocity *= 0.5f; } else if (npc.type == NPCID.MeteorHead) { - int num12 = Dust.NewDust(new Vector2(npc.position.X - npc.velocity.X, npc.position.Y - npc.velocity.Y), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Dust dust = Main.dust[num12]; + int meteorDust = Dust.NewDust(new Vector2(npc.position.X - npc.velocity.X, npc.position.Y - npc.velocity.Y), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); + Dust dust = Main.dust[meteorDust]; dust.noGravity = true; dust.velocity.X *= 0.3f; dust.velocity.Y *= 0.3f; } else if (npc.type != NPCID.Probe && npc.type != NPCID.Moth && npc.type != NPCID.Parrot && npc.type != NPCID.Bee && npc.type != NPCID.BeeSmall && Main.rand.NextBool(20)) { - int num13 = 18; + int dustType = 18; if (npc.type == NPCID.Crimera) { - num13 = 5; + dustType = 5; } - int num14 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), num13, npc.velocity.X, 2f, 75, npc.color, npc.scale); - Dust dust = Main.dust[num14]; + int idleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), dustType, npc.velocity.X, 2f, 75, npc.color, npc.scale); + Dust dust = Main.dust[idleDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } } else if (npc.type != NPCID.Parrot && Main.rand.NextBool(40)) { - int num15 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default(Color), 1f); - Dust dust = Main.dust[num15]; + int otherIdleDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + (float)npc.height * 0.25f), npc.width, (int)((float)npc.height * 0.5f), 5, npc.velocity.X, 2f, 0, default(Color), 1f); + Dust dust = Main.dust[otherIdleDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.1f; } @@ -3949,24 +3944,24 @@ namespace CalamityMod.NPCs { if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) { - float num17 = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; - Vector2 vector2 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); - float num18 = targetData.Center.X - vector2.X; - float num19 = targetData.Center.Y - vector2.Y; - if ((num18 < 0f && npc.velocity.X < 0f) || (num18 > 0f && npc.velocity.X > 0f)) + float projSpeed = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; + Vector2 projSpawnPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); + float projTargetXDist = targetData.Center.X - projSpawnPosition.X; + float projTargetYDist = targetData.Center.Y - projSpawnPosition.Y; + if ((projTargetXDist < 0f && npc.velocity.X < 0f) || (projTargetXDist > 0f && npc.velocity.X > 0f)) { - float num20 = (float)Math.Sqrt(num18 * num18 + num19 * num19); - num20 = num17 / num20; - num18 *= num20; - num19 *= num20; - int num21 = (int)(10f * npc.scale); + float projTargetDistance = (float)Math.Sqrt(projTargetXDist * projTargetXDist + projTargetYDist * projTargetYDist); + projTargetDistance = projSpeed / projTargetDistance; + projTargetXDist *= projTargetDistance; + projTargetYDist *= projTargetDistance; + int projDamage = (int)(10f * npc.scale); if (npc.type == NPCID.MossHornet) - num21 = (int)(30f * npc.scale); + projDamage = (int)(30f * npc.scale); - int num22 = ProjectileID.Stinger; - int num23 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector2.X, vector2.Y, num18, num19, num22, num21, 0f, Main.myPlayer); - Main.projectile[num23].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300; - Main.projectile[num23].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0; + int stingerType = ProjectileID.Stinger; + int stingerSpawn = Projectile.NewProjectile(npc.GetSource_FromAI(), projSpawnPosition.X, projSpawnPosition.Y, projTargetXDist, projTargetYDist, stingerType, projDamage, 0f, Main.myPlayer); + Main.projectile[stingerSpawn].timeLeft = (CalamityWorld.death || Main.hardMode) ? 600 : 300; + Main.projectile[stingerSpawn].extraUpdates += (CalamityWorld.death || Main.hardMode) ? 1 : 0; npc.ai[1] = 301f; npc.netUpdate = true; } @@ -3981,7 +3976,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.Probe & flag) { - if ((npc.velocity.X > 0f && num4 > 0f) || (npc.velocity.X < 0f && num4 < 0f)) + if ((npc.velocity.X > 0f && targetXDist > 0f) || (npc.velocity.X < 0f && targetXDist < 0f)) { if (Math.Abs(npc.velocity.X) < 12f) npc.velocity.X = npc.velocity.X * 1.05f; @@ -4037,12 +4032,12 @@ namespace CalamityMod.NPCs { if ((npc.Center - targetData.Center).Length() < 400f) { - Vector2 vector3 = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); - npc.velocity = -vector3 * 5f; + Vector2 bloodShotPosition = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); + npc.velocity = -bloodShotPosition * 5f; npc.netUpdate = true; npc.localAI[0] = 0f; - vector3 = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, vector3 * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer); + bloodShotPosition = npc.DirectionTo(new Vector2(targetData.Center.X, targetData.Position.Y)); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, bloodShotPosition * (CalamityWorld.death ? 6f : 10f), ProjectileID.BloodShot, 50, 1f, Main.myPlayer); if (CalamityWorld.death) { Main.projectile[proj].extraUpdates += 1; @@ -4060,7 +4055,7 @@ namespace CalamityMod.NPCs if ((Main.dayTime && npc.type != NPCID.Crimera && npc.type != NPCID.EaterofSouls && npc.type != NPCID.MeteorHead && npc.type != NPCID.Bee && npc.type != NPCID.BeeSmall && npc.type != NPCID.Corruptor && npc.type != NPCID.Moth && npc.type != NPCID.Parrot && npc.type != NPCID.BloodSquid) || Main.player[npc.target].dead) { - npc.velocity.Y = npc.velocity.Y - num2 * 2f; + npc.velocity.Y = npc.velocity.Y - acceleration * 2f; if (npc.timeLeft > 10) npc.timeLeft = 10; } @@ -4079,14 +4074,14 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 1f; SoundEngine.PlaySound(SoundID.NPCDeath13, npc.position); - int num = 1; + int dustVelocity = 1; if (npc.velocity.X < 0f) { - num = -1; + dustVelocity = -1; } for (int i = 0; i < 20; i++) { - Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y - 20f), npc.width + 40, npc.height + 40, 5, (float)(num * 8), -1f, 0, default(Color), 1f); + Dust.NewDust(new Vector2(npc.position.X - 20f, npc.position.Y - 20f), npc.width + 40, npc.height + 40, 5, (float)(dustVelocity * 8), -1f, 0, default(Color), 1f); } } @@ -4120,8 +4115,8 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - bool flag = npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || (!Main.player[npc.target].ZoneUndergroundDesert && npc.type == NPCID.TombCrawlerHead); - float num4 = npc.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; + bool wormHead = npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || (!Main.player[npc.target].ZoneUndergroundDesert && npc.type == NPCID.TombCrawlerHead); + float acceleration = npc.type == NPCID.TombCrawlerHead ? 0.1f : 0.2f; bool isSplittingNPC = (npc.type >= NPCID.DiggerHead && npc.type <= NPCID.DiggerTail) || (npc.type >= NPCID.SeekerHead && npc.type <= NPCID.SeekerTail) || (npc.type >= NPCID.DuneSplicerHead && npc.type <= NPCID.DuneSplicerTail); @@ -4143,20 +4138,20 @@ namespace CalamityMod.NPCs npc.realLife = (int)npc.ai[3]; } - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || (flag && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) { npc.TargetClosest(true); } - if (Main.player[npc.target].dead || (flag && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) + if (Main.player[npc.target].dead || (wormHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0)) { if (npc.timeLeft > 300) { npc.timeLeft = 300; } - if (flag) + if (wormHead) { - npc.velocity.Y = npc.velocity.Y + num4; + npc.velocity.Y = npc.velocity.Y + acceleration; } } @@ -4173,33 +4168,33 @@ namespace CalamityMod.NPCs int maxParts = CalamityWorld.death ? 30 : 21; npc.ai[3] = (float)npc.whoAmI; npc.realLife = npc.whoAmI; - int num6 = npc.whoAmI; + int currentNPC = npc.whoAmI; for (int k = 0; k < maxParts; k++) { - int num7 = NPCID.WyvernBody; + int wyvernSegmentType = NPCID.WyvernBody; if (k == 1 || k == 12) { - num7 = NPCID.WyvernLegs; + wyvernSegmentType = NPCID.WyvernLegs; } else if (k == maxParts - 3) { - num7 = NPCID.WyvernBody2; + wyvernSegmentType = NPCID.WyvernBody2; } else if (k == maxParts - 2) { - num7 = NPCID.WyvernBody3; + wyvernSegmentType = NPCID.WyvernBody3; } else if (k == maxParts - 1) { - num7 = NPCID.WyvernTail; + wyvernSegmentType = NPCID.WyvernTail; } - int num8 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num7, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num8].ai[3] = (float)npc.whoAmI; - Main.npc[num8].realLife = npc.whoAmI; - Main.npc[num8].ai[1] = (float)num6; - Main.npc[num6].ai[0] = (float)num8; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num8, 0f, 0f, 0f, 0, 0, 0); - num6 = num8; + int wyvernSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), wyvernSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[wyvernSegment].ai[3] = (float)npc.whoAmI; + Main.npc[wyvernSegment].realLife = npc.whoAmI; + Main.npc[wyvernSegment].ai[1] = (float)currentNPC; + Main.npc[currentNPC].ai[0] = (float)wyvernSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, wyvernSegment, 0f, 0f, 0f, 0, 0, 0); + currentNPC = wyvernSegment; } } @@ -4207,22 +4202,22 @@ namespace CalamityMod.NPCs { npc.ai[3] = (float)npc.whoAmI; npc.realLife = npc.whoAmI; - int num12 = npc.whoAmI; - int num13 = Main.rand.Next(11, CalamityWorld.death ? 25 : 15); - for (int m = 0; m < num13; m++) + int currentTombCrawler = npc.whoAmI; + int tombCrawlerSegments = Main.rand.Next(11, CalamityWorld.death ? 25 : 15); + for (int m = 0; m < tombCrawlerSegments; m++) { - int num14 = NPCID.TombCrawlerBody; - if (m == num13 - 1) + int tombCrawlerSegmentType = NPCID.TombCrawlerBody; + if (m == tombCrawlerSegments - 1) { - num14 = NPCID.TombCrawlerTail; + tombCrawlerSegmentType = NPCID.TombCrawlerTail; } - int num15 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num14, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num15].ai[3] = (float)npc.whoAmI; - Main.npc[num15].realLife = npc.whoAmI; - Main.npc[num15].ai[1] = (float)num12; - Main.npc[num12].ai[0] = (float)num15; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num15, 0f, 0f, 0f, 0, 0, 0); - num12 = num15; + int tombCrawlerSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), tombCrawlerSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[tombCrawlerSegment].ai[3] = (float)npc.whoAmI; + Main.npc[tombCrawlerSegment].realLife = npc.whoAmI; + Main.npc[tombCrawlerSegment].ai[1] = (float)currentTombCrawler; + Main.npc[currentTombCrawler].ai[0] = (float)tombCrawlerSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, tombCrawlerSegment, 0f, 0f, 0f, 0, 0, 0); + currentTombCrawler = tombCrawlerSegment; } } @@ -4230,22 +4225,22 @@ namespace CalamityMod.NPCs { npc.ai[3] = (float)npc.whoAmI; npc.realLife = npc.whoAmI; - int num20 = npc.whoAmI; - int num21 = CalamityWorld.death ? 70 : 50; - for (int num22 = 0; num22 < num21; num22++) + int projTargetDistance = npc.whoAmI; + int crawltipedeSegments = CalamityWorld.death ? 70 : 50; + for (int n = 0; n < crawltipedeSegments; n++) { - int num23 = NPCID.SolarCrawltipedeBody; - if (num22 == num21 - 1) + int crawltipedeSegmentType = NPCID.SolarCrawltipedeBody; + if (n == crawltipedeSegments - 1) { - num23 = NPCID.SolarCrawltipedeTail; + crawltipedeSegmentType = NPCID.SolarCrawltipedeTail; } - int num24 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num23, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num24].ai[3] = (float)npc.whoAmI; - Main.npc[num24].realLife = npc.whoAmI; - Main.npc[num24].ai[1] = (float)num20; - Main.npc[num20].ai[0] = (float)num24; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num24, 0f, 0f, 0f, 0, 0, 0); - num20 = num24; + int crawltipedeSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), crawltipedeSegmentType, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[crawltipedeSegment].ai[3] = (float)npc.whoAmI; + Main.npc[crawltipedeSegment].realLife = npc.whoAmI; + Main.npc[crawltipedeSegment].ai[1] = (float)projTargetDistance; + Main.npc[projTargetDistance].ai[0] = (float)crawltipedeSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, crawltipedeSegment, 0f, 0f, 0f, 0, 0, 0); + projTargetDistance = crawltipedeSegment; } } @@ -4253,23 +4248,23 @@ namespace CalamityMod.NPCs { npc.ai[3] = npc.whoAmI; npc.realLife = npc.whoAmI; - int num22 = 0; - int num23 = npc.whoAmI; - int num24 = CalamityWorld.death ? 44 : 34; - for (int num25 = 0; num25 < num24; num25++) + int bloodEelSegment = 0; + int currentBloodEel = npc.whoAmI; + int bloodEelSegments = CalamityWorld.death ? 44 : 34; + for (int p = 0; p < bloodEelSegments; p++) { - int num26 = NPCID.BloodEelBody; - if (num25 == num24 - 1) - num26 = NPCID.BloodEelTail; + int bloodEelSegmentType = NPCID.BloodEelBody; + if (p == bloodEelSegments - 1) + bloodEelSegmentType = NPCID.BloodEelTail; - num22 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), num26, npc.whoAmI); - Main.npc[num22].ai[3] = npc.whoAmI; - Main.npc[num22].realLife = npc.whoAmI; - Main.npc[num22].ai[1] = num23; - Main.npc[num22].CopyInteractions(npc); - Main.npc[num23].ai[0] = num22; - NetMessage.SendData(23, -1, -1, null, num22); - num23 = num22; + bloodEelSegment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)(npc.position.Y + (float)npc.height), bloodEelSegmentType, npc.whoAmI); + Main.npc[bloodEelSegment].ai[3] = npc.whoAmI; + Main.npc[bloodEelSegment].realLife = npc.whoAmI; + Main.npc[bloodEelSegment].ai[1] = currentBloodEel; + Main.npc[bloodEelSegment].CopyInteractions(npc); + Main.npc[currentBloodEel].ai[0] = bloodEelSegment; + NetMessage.SendData(23, -1, -1, null, bloodEelSegment); + currentBloodEel = bloodEelSegment; } } else if ((isSplittingNPCHead || isSplittingNPCBody || npc.type == NPCID.GiantWormHead || npc.type == NPCID.GiantWormBody || npc.type == NPCID.DevourerHead || npc.type == NPCID.DevourerBody || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.BoneSerpentBody || npc.type == NPCID.LeechHead || npc.type == NPCID.LeechBody) && npc.ai[0] == 0f) @@ -4381,11 +4376,11 @@ namespace CalamityMod.NPCs { npc.type = npc.type - 1; int whoAmI = npc.whoAmI; - float num25 = (float)npc.life / (float)npc.lifeMax; - float num26 = npc.ai[0]; + float currentHealthAmt = (float)npc.life / (float)npc.lifeMax; + float newSegment = npc.ai[0]; npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num25); - npc.ai[0] = num26; + npc.life = (int)((float)npc.lifeMax * currentHealthAmt); + npc.ai[0] = newSegment; npc.TargetClosest(true); npc.netUpdate = true; npc.whoAmI = whoAmI; @@ -4393,11 +4388,11 @@ namespace CalamityMod.NPCs if (isSplittingNPCBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle)) { int whoAmI2 = npc.whoAmI; - float num27 = (float)npc.life / (float)npc.lifeMax; - float num28 = npc.ai[1]; + float currentHealthAmt2 = (float)npc.life / (float)npc.lifeMax; + float newSegment = npc.ai[1]; npc.SetDefaultsKeepPlayerInteraction(npc.type); - npc.life = (int)((float)npc.lifeMax * num27); - npc.ai[1] = num28; + npc.life = (int)((float)npc.lifeMax * currentHealthAmt2); + npc.ai[1] = newSegment; npc.TargetClosest(true); npc.netUpdate = true; npc.whoAmI = whoAmI2; @@ -4410,61 +4405,61 @@ namespace CalamityMod.NPCs } } - int num29 = (int)(npc.position.X / 16f) - 1; - int num30 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; - int num31 = (int)(npc.position.Y / 16f) - 1; - int num32 = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; - if (num29 < 0) + int tilePositionX = (int)(npc.position.X / 16f) - 1; + int tileWidthPosX = (int)((npc.position.X + (float)npc.width) / 16f) + 2; + int tilePositionY = (int)(npc.position.Y / 16f) - 1; + int tileWidthPosY = (int)((npc.position.Y + (float)npc.height) / 16f) + 2; + if (tilePositionX < 0) { - num29 = 0; + tilePositionX = 0; } - if (num30 > Main.maxTilesX) + if (tileWidthPosX > Main.maxTilesX) { - num30 = Main.maxTilesX; + tileWidthPosX = Main.maxTilesX; } - if (num31 < 0) + if (tilePositionY < 0) { - num31 = 0; + tilePositionY = 0; } - if (num32 > Main.maxTilesY) + if (tileWidthPosY > Main.maxTilesY) { - num32 = Main.maxTilesY; + tileWidthPosY = Main.maxTilesY; } - bool flag2 = false; + bool flying = false; if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) { - flag2 = true; + flying = true; } if (npc.type == NPCID.StardustWormHead && npc.ai[1] == -1f) { - flag2 = true; + flying = true; } if (npc.type >= NPCID.SolarCrawltipedeHead && npc.type <= NPCID.SolarCrawltipedeTail) { - flag2 = true; + flying = true; } if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) { - flag2 = true; + flying = true; } - if (!flag2) + if (!flying) { - for (int num33 = num29; num33 < num30; num33++) + for (int x = tilePositionX; x < tileWidthPosX; x++) { - for (int num34 = num31; num34 < num32; num34++) + for (int y = tilePositionY; y < tileWidthPosY; y++) { - if (Main.tile[num33, num34] != null && ((Main.tile[num33, num34].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[num33, num34].TileType] || (Main.tileSolidTop[(int)Main.tile[num33, num34].TileType] && Main.tile[num33, num34].TileFrameY == 0))) || Main.tile[num33, num34].LiquidAmount > 64)) + if (Main.tile[x, y] != null && ((Main.tile[x, y].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[x, y].TileType] || (Main.tileSolidTop[(int)Main.tile[x, y].TileType] && Main.tile[x, y].TileFrameY == 0))) || Main.tile[x, y].LiquidAmount > 64)) { - Vector2 vector; - vector.X = (float)(num33 * 16); - vector.Y = (float)(num34 * 16); - if (npc.position.X + (float)npc.width > vector.X && npc.position.X < vector.X + 16f && npc.position.Y + (float)npc.height > vector.Y && npc.position.Y < vector.Y + 16f) + Vector2 flyingPos; + flyingPos.X = (float)(x * 16); + flyingPos.Y = (float)(y * 16); + if (npc.position.X + (float)npc.width > flyingPos.X && npc.position.X < flyingPos.X + 16f && npc.position.Y + (float)npc.height > flyingPos.Y && npc.position.Y < flyingPos.Y + 16f) { - flag2 = true; - if (Main.rand.NextBool(100) && npc.type != NPCID.LeechHead && Main.tile[num33, num34].HasUnactuatedTile) + flying = true; + if (Main.rand.NextBool(100) && npc.type != NPCID.LeechHead && Main.tile[x, y].HasUnactuatedTile) { - WorldGen.KillTile(num33, num34, true, true, false); + WorldGen.KillTile(x, y, true, true, false); } } } @@ -4472,26 +4467,26 @@ namespace CalamityMod.NPCs } } - if (!flag2 && (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) + if (!flying && (isSplittingNPCHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.DevourerHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.LeechHead || npc.type == NPCID.TombCrawlerHead)) { Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num35 = 1000; - bool flag3 = true; - for (int num36 = 0; num36 < Main.maxPlayers; num36++) + int noFlyZone = 1000; + bool outsideNoFlyZone = true; + for (int f = 0; f < Main.maxPlayers; f++) { - if (Main.player[num36].active) + if (Main.player[f].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[num36].position.X - num35, (int)Main.player[num36].position.Y - num35, num35 * 2, num35 * 2); + Rectangle rectangle2 = new Rectangle((int)Main.player[f].position.X - noFlyZone, (int)Main.player[f].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); if (rectangle.Intersects(rectangle2)) { - flag3 = false; + outsideNoFlyZone = false; break; } } } - if (flag3) + if (outsideNoFlyZone) { - flag2 = true; + flying = true; } } @@ -4534,242 +4529,242 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.SolarCrawltipedeHead) { - Vector2 value = npc.Center + (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; - Vector2 value2 = npc.rotation.ToRotationVector2() * 16f; - Dust expr_1AAB = Main.dust[Dust.NewDust(value + value2, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; - expr_1AAB.noGravity = true; - expr_1AAB.noLight = true; - expr_1AAB.position -= new Vector2(4f); - expr_1AAB.fadeIn = 1f; - expr_1AAB.velocity = Vector2.Zero; - Dust expr_1B33 = Main.dust[Dust.NewDust(value - value2, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; - expr_1B33.noGravity = true; - expr_1B33.noLight = true; - expr_1B33.position -= new Vector2(4f); - expr_1B33.fadeIn = 1f; - expr_1B33.velocity = Vector2.Zero; + Vector2 crawltipedeDustPos = npc.Center + (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 8f; + Vector2 crawltipedeDustRotation = npc.rotation.ToRotationVector2() * 16f; + Dust crawltipedeDust = Main.dust[Dust.NewDust(crawltipedeDustPos + crawltipedeDustRotation, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; + crawltipedeDust.noGravity = true; + crawltipedeDust.noLight = true; + crawltipedeDust.position -= new Vector2(4f); + crawltipedeDust.fadeIn = 1f; + crawltipedeDust.velocity = Vector2.Zero; + Dust crawltipedeDust2 = Main.dust[Dust.NewDust(crawltipedeDustPos - crawltipedeDustRotation, 0, 0, 6, npc.velocity.X, npc.velocity.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 3f)]; + crawltipedeDust2.noGravity = true; + crawltipedeDust2.noLight = true; + crawltipedeDust2.position -= new Vector2(4f); + crawltipedeDust2.fadeIn = 1f; + crawltipedeDust2.velocity = Vector2.Zero; } - float num37 = 10f; - float num38 = 0.09f; + float wormSpeed = 10f; + float wormAccel = 0.09f; if (npc.type == NPCID.DiggerHead) { - num37 = 6.5f; - num38 = 0.05f; + wormSpeed = 6.5f; + wormAccel = 0.05f; } if (npc.type == NPCID.GiantWormHead) { - num37 = 7.5f; - num38 = 0.06f; + wormSpeed = 7.5f; + wormAccel = 0.06f; } if (npc.type == NPCID.TombCrawlerHead) { - num37 = 8f; - num38 = 0.13f; + wormSpeed = 8f; + wormAccel = 0.13f; } if (npc.type == NPCID.DuneSplicerHead) { if (!Main.player[npc.target].dead && Main.player[npc.target].ZoneSandstorm) { - num37 = 16f; - num38 = 0.35f; + wormSpeed = 16f; + wormAccel = 0.35f; } else { - num38 = 0.25f; + wormAccel = 0.25f; } } if (npc.type == NPCID.WyvernHead) { - num37 = 11f; - num38 = 0.3f; + wormSpeed = 11f; + wormAccel = 0.3f; } if (npc.type == NPCID.StardustWormHead) { - num37 = 9f; - num38 = 0.25f; + wormSpeed = 9f; + wormAccel = 0.25f; } if (npc.type == NPCID.LeechHead && Main.wofNPCIndex >= 0) { float lifeRatio = (float)Main.npc[Main.wofNPCIndex].life / (float)Main.npc[Main.wofNPCIndex].lifeMax; if (lifeRatio < 0.75f) { - num37 += 1f; - num38 += 0.1f; + wormSpeed += 1f; + wormAccel += 0.1f; } if (lifeRatio < 0.5f) { - num37 += 1f; - num38 += 0.1f; + wormSpeed += 1f; + wormAccel += 0.1f; } if (lifeRatio < 0.25f) { - num37 += 2f; - num38 += 0.1f; + wormSpeed += 2f; + wormAccel += 0.1f; } } if (npc.type == NPCID.BloodEelHead) { - num37 = 18f; - num38 = 0.6f; + wormSpeed = 18f; + wormAccel = 0.6f; } if (CalamityWorld.death) { - num37 *= 1.25f; - num38 *= 1.25f; + wormSpeed *= 1.25f; + wormAccel *= 1.25f; } - Vector2 vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num39 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num40 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); + Vector2 segmentPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float wormTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); + float wormTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); if (npc.type == NPCID.SolarCrawltipedeHead) { - num37 = 12f; - num38 = 0.32f; - int num41 = -1; - int num42 = (int)(Main.player[npc.target].Center.X / 16f); - int num43 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num44 = num42 - 2; num44 <= num42 + 2; num44++) + wormSpeed = 12f; + wormAccel = 0.32f; + int crawltipedeTargetY = -1; + int targetTileX = (int)(Main.player[npc.target].Center.X / 16f); + int targetTileY = (int)(Main.player[npc.target].Center.Y / 16f); + for (int i = targetTileX - 2; i <= targetTileX + 2; i++) { - for (int num45 = num43; num45 <= num43 + 15; num45++) + for (int j = targetTileY; j <= targetTileY + 15; j++) { - if (WorldGen.SolidTile2(num44, num45)) + if (WorldGen.SolidTile2(i, j)) { - num41 = num45; + crawltipedeTargetY = j; break; } } - if (num41 > 0) + if (crawltipedeTargetY > 0) { break; } } - if (num41 > 0) + if (crawltipedeTargetY > 0) { - num41 *= 16; - float num46 = (float)(num41 - 800); - if (Main.player[npc.target].position.Y > num46) + crawltipedeTargetY *= 16; + float crawltipedeYTarget = (float)(crawltipedeTargetY - 800); + if (Main.player[npc.target].position.Y > crawltipedeYTarget) { - num40 = num46; + wormTargetY = crawltipedeYTarget; if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 500f) { if (npc.velocity.X > 0f) { - num39 = Main.player[npc.target].Center.X + 600f; + wormTargetX = Main.player[npc.target].Center.X + 600f; } else { - num39 = Main.player[npc.target].Center.X - 600f; + wormTargetX = Main.player[npc.target].Center.X - 600f; } } } } else { - num37 = 28f; - num38 = 0.8f; + wormSpeed = 28f; + wormAccel = 0.8f; } - float num47 = num37 * 1.3f; - float num48 = num37 * 0.7f; - float num49 = npc.velocity.Length(); - if (num49 > 0f) + float maxWormSpeed = wormSpeed * 1.3f; + float minWormSpeed = wormSpeed * 0.7f; + float velocityCheck = npc.velocity.Length(); + if (velocityCheck > 0f) { - if (num49 > num47) + if (velocityCheck > maxWormSpeed) { npc.velocity.Normalize(); - npc.velocity *= num47; + npc.velocity *= maxWormSpeed; } - else if (num49 < num48) + else if (velocityCheck < minWormSpeed) { npc.velocity.Normalize(); - npc.velocity *= num48; + npc.velocity *= minWormSpeed; } } - if (num41 > 0) + if (crawltipedeTargetY > 0) { - for (int num50 = 0; num50 < Main.maxNPCs; num50++) + for (int k = 0; k < Main.maxNPCs; k++) { - if (Main.npc[num50].active && Main.npc[num50].type == npc.type && num50 != npc.whoAmI) + if (Main.npc[k].active && Main.npc[k].type == npc.type && k != npc.whoAmI) { - Vector2 vector3 = Main.npc[num50].Center - npc.Center; - if (vector3.Length() < 400f) + Vector2 targetDirection = Main.npc[k].Center - npc.Center; + if (targetDirection.Length() < 400f) { - vector3.Normalize(); - vector3 *= 1000f; - num39 -= vector3.X; - num40 -= vector3.Y; + targetDirection.Normalize(); + targetDirection *= 1000f; + wormTargetX -= targetDirection.X; + wormTargetY -= targetDirection.Y; } } } } else { - for (int num51 = 0; num51 < Main.maxNPCs; num51++) + for (int l = 0; l < Main.maxNPCs; l++) { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) + if (Main.npc[l].active && Main.npc[l].type == npc.type && l != npc.whoAmI) { - Vector2 vector4 = Main.npc[num51].Center - npc.Center; - if (vector4.Length() < 60f) + Vector2 idleDirection = Main.npc[l].Center - npc.Center; + if (idleDirection.Length() < 60f) { - vector4.Normalize(); - vector4 *= 200f; - num39 -= vector4.X; - num40 -= vector4.Y; + idleDirection.Normalize(); + idleDirection *= 200f; + wormTargetX -= idleDirection.X; + wormTargetY -= idleDirection.Y; } } } } } - num39 = (float)((int)(num39 / 16f) * 16); - num40 = (float)((int)(num40 / 16f) * 16); - vector2.X = (float)((int)(vector2.X / 16f) * 16); - vector2.Y = (float)((int)(vector2.Y / 16f) * 16); - num39 -= vector2.X; - num40 -= vector2.Y; - float num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); + wormTargetX = (float)((int)(wormTargetX / 16f) * 16); + wormTargetY = (float)((int)(wormTargetY / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + wormTargetX -= segmentPosition.X; + wormTargetY -= segmentPosition.Y; + float wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) { try { - vector2 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num39 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector2.X; - num40 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector2.Y; + segmentPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + wormTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - segmentPosition.X; + wormTargetY = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - segmentPosition.Y; } catch { } - npc.rotation = (float)Math.Atan2((double)num40, (double)num39) + MathHelper.PiOver2; - num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); - int num53 = npc.width; + npc.rotation = (float)Math.Atan2((double)wormTargetY, (double)wormTargetX) + MathHelper.PiOver2; + wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + int segmentWidth = npc.width; if (npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) { - num53 = 42; + segmentWidth = 42; } if (npc.type >= NPCID.SolarCrawltipedeHead && npc.type <= NPCID.SolarCrawltipedeTail) { - num53 += 6; + segmentWidth += 6; } if (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail) { - num53 = 24; + segmentWidth = 24; } - num52 = (num52 - (float)num53) / num52; - num39 *= num52; - num40 *= num52; + wormTargetDist = (wormTargetDist - (float)segmentWidth) / wormTargetDist; + wormTargetX *= wormTargetDist; + wormTargetY *= wormTargetDist; npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num39; - npc.position.Y = npc.position.Y + num40; + npc.position.X = npc.position.X + wormTargetX; + npc.position.Y = npc.position.Y + wormTargetY; if ((npc.type >= NPCID.WyvernHead && npc.type <= NPCID.WyvernTail) || (npc.type >= NPCID.BloodEelHead && npc.type <= NPCID.BloodEelTail)) { - if (num39 < 0f) + if (wormTargetX < 0f) { npc.spriteDirection = 1; } - else if (num39 > 0f) + else if (wormTargetX > 0f) { npc.spriteDirection = -1; } @@ -4777,45 +4772,45 @@ namespace CalamityMod.NPCs } else { - if (!flag2) + if (!flying) { npc.TargetClosest(true); npc.velocity.Y = npc.velocity.Y + 0.11f; - if (npc.velocity.Y > num37) + if (npc.velocity.Y > wormSpeed) { - npc.velocity.Y = num37; + npc.velocity.Y = wormSpeed; } - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.4) + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.4) { if (npc.velocity.X < 0f) { - npc.velocity.X = npc.velocity.X - num38 * 1.1f; + npc.velocity.X = npc.velocity.X - wormAccel * 1.1f; } else { - npc.velocity.X = npc.velocity.X + num38 * 1.1f; + npc.velocity.X = npc.velocity.X + wormAccel * 1.1f; } } - else if (npc.velocity.Y == num37) + else if (npc.velocity.Y == wormSpeed) { - if (npc.velocity.X < num39) + if (npc.velocity.X < wormTargetX) { - npc.velocity.X = npc.velocity.X + num38; + npc.velocity.X = npc.velocity.X + wormAccel; } - else if (npc.velocity.X > num39) + else if (npc.velocity.X > wormTargetX) { - npc.velocity.X = npc.velocity.X - num38; + npc.velocity.X = npc.velocity.X - wormAccel; } } else if (npc.velocity.Y > 4f) { if (npc.velocity.X < 0f) { - npc.velocity.X = npc.velocity.X + num38 * 0.9f; + npc.velocity.X = npc.velocity.X + wormAccel * 0.9f; } else { - npc.velocity.X = npc.velocity.X - num38 * 0.9f; + npc.velocity.X = npc.velocity.X - wormAccel * 0.9f; } } } @@ -4823,184 +4818,183 @@ namespace CalamityMod.NPCs { if (npc.type != NPCID.WyvernHead && npc.type != NPCID.LeechHead && npc.type != NPCID.SolarCrawltipedeHead && npc.type != NPCID.BloodEelHead && npc.soundDelay == 0) { - float num54 = num52 / 40f; - if (num54 < 10f) + float soundDelay = wormTargetDist / 40f; + if (soundDelay < 10f) { - num54 = 10f; + soundDelay = 10f; } - if (num54 > 20f) + if (soundDelay > 20f) { - num54 = 20f; + soundDelay = 20f; } - npc.soundDelay = (int)num54; + npc.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, npc.position); } - num52 = (float)Math.Sqrt((double)(num39 * num39 + num40 * num40)); - float num55 = Math.Abs(num39); - float num56 = Math.Abs(num40); - float num57 = num37 / num52; - num39 *= num57; - num40 *= num57; + wormTargetDist = (float)Math.Sqrt((double)(wormTargetX * wormTargetX + wormTargetY * wormTargetY)); + float absoluteTargetX = Math.Abs(wormTargetX); + float absoluteTargetY = Math.Abs(wormTargetY); + float timeToReachTarget = wormSpeed / wormTargetDist; + wormTargetX *= timeToReachTarget; + wormTargetY *= timeToReachTarget; - bool flag4 = false; + bool wormShouldFlee = false; if (npc.type == NPCID.DevourerHead && ((!Main.player[npc.target].ZoneCorrupt && !Main.player[npc.target].ZoneCrimson) || Main.player[npc.target].dead)) { - flag4 = true; + wormShouldFlee = true; } if ((npc.type == NPCID.TombCrawlerHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 && !Main.player[npc.target].ZoneSandstorm && !Main.player[npc.target].ZoneUndergroundDesert) || Main.player[npc.target].dead) { - flag4 = true; + wormShouldFlee = true; } if ((npc.type == NPCID.DuneSplicerHead && (double)Main.player[npc.target].position.Y < Main.worldSurface * 16.0 && !Main.player[npc.target].ZoneSandstorm && !Main.player[npc.target].ZoneUndergroundDesert) || Main.player[npc.target].dead) { - flag4 = true; + wormShouldFlee = true; } - if (flag4) + if (wormShouldFlee) { - bool flag5 = true; - for (int num58 = 0; num58 < Main.maxPlayers; num58++) + bool definitelyFlee = true; + for (int p = 0; p < Main.maxPlayers; p++) { - if (Main.player[num58].active && !Main.player[num58].dead && Main.player[num58].ZoneCorrupt) + if (Main.player[p].active && !Main.player[p].dead && Main.player[p].ZoneCorrupt) { - flag5 = false; + definitelyFlee = false; } } - if (flag5) + if (definitelyFlee) { if (Main.netMode != NetmodeID.MultiplayerClient && (double)(npc.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0) { npc.active = false; - int num59 = (int)npc.ai[0]; - while (num59 > 0 && num59 < Main.maxNPCs && Main.npc[num59].active && Main.npc[num59].aiStyle == npc.aiStyle) + int q = (int)npc.ai[0]; + while (q > 0 && q < Main.maxNPCs && Main.npc[q].active && Main.npc[q].aiStyle == npc.aiStyle) { - int arg_2853_0 = (int)Main.npc[num59].ai[0]; - Main.npc[num59].active = false; + int differentSegment = (int)Main.npc[q].ai[0]; + Main.npc[q].active = false; npc.life = 0; if (Main.netMode == NetmodeID.Server) { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num59, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, q, 0f, 0f, 0f, 0, 0, 0); } - num59 = arg_2853_0; + q = differentSegment; } if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); } } - num39 = 0f; - num40 = num37; + wormTargetX = 0f; + wormTargetY = wormSpeed; } } - bool flag6 = false; + bool shouldSwoopDown = false; if (npc.type == NPCID.WyvernHead) { - if (((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f) || (npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > num38 / 2f && num52 < 300f) + if (((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f) || (npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > wormAccel / 2f && wormTargetDist < 300f) { - flag6 = true; + shouldSwoopDown = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num37) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < wormSpeed) npc.velocity *= 1.1f; } if (npc.position.Y > Main.player[npc.target].position.Y || (double)(Main.player[npc.target].position.Y / 16f) > Main.worldSurface || Main.player[npc.target].dead) { - flag6 = true; + shouldSwoopDown = true; - if (Math.Abs(npc.velocity.X) < num37 / 2f) + if (Math.Abs(npc.velocity.X) < wormSpeed / 2f) { if (npc.velocity.X == 0f) npc.velocity.X = npc.velocity.X - npc.direction; npc.velocity.X = npc.velocity.X * 1.1f; } - else if (npc.velocity.Y > -num37) - npc.velocity.Y = npc.velocity.Y - num38; + else if (npc.velocity.Y > -wormSpeed) + npc.velocity.Y = npc.velocity.Y - wormAccel; } } if (npc.type == NPCID.BloodEelHead) { - float num69 = 120f; - if (((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f) || (npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > num38 / 2f && num52 < num69) + if (((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f) || (npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f)) && Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) > wormAccel / 2f && wormTargetDist < 120f) { - flag6 = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < num37) + shouldSwoopDown = true; + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < wormSpeed) npc.velocity *= 1.1f; } if (npc.position.Y > Main.player[npc.target].position.Y || Main.player[npc.target].dead) { - flag6 = true; - if (Math.Abs(npc.velocity.X) < num37 / 2f) + shouldSwoopDown = true; + if (Math.Abs(npc.velocity.X) < wormSpeed / 2f) { if (npc.velocity.X == 0f) npc.velocity.X -= npc.direction; npc.velocity.X *= 1.1f; } - else if (npc.velocity.Y > 0f - num37) - npc.velocity.Y -= num38; + else if (npc.velocity.Y > 0f - wormSpeed) + npc.velocity.Y -= wormAccel; } } - if (!flag6) + if (!shouldSwoopDown) { - if ((npc.velocity.X > 0f && num39 > 0f) || (npc.velocity.X < 0f && num39 < 0f) || (npc.velocity.Y > 0f && num40 > 0f) || (npc.velocity.Y < 0f && num40 < 0f)) + if ((npc.velocity.X > 0f && wormTargetX > 0f) || (npc.velocity.X < 0f && wormTargetX < 0f) || (npc.velocity.Y > 0f && wormTargetY > 0f) || (npc.velocity.Y < 0f && wormTargetY < 0f)) { - if (npc.velocity.X < num39) - npc.velocity.X = npc.velocity.X + num38; - else if (npc.velocity.X > num39) - npc.velocity.X = npc.velocity.X - num38; + if (npc.velocity.X < wormTargetX) + npc.velocity.X = npc.velocity.X + wormAccel; + else if (npc.velocity.X > wormTargetX) + npc.velocity.X = npc.velocity.X - wormAccel; - if (npc.velocity.Y < num40) - npc.velocity.Y = npc.velocity.Y + num38; - else if (npc.velocity.Y > num40) - npc.velocity.Y = npc.velocity.Y - num38; + if (npc.velocity.Y < wormTargetY) + npc.velocity.Y = npc.velocity.Y + wormAccel; + else if (npc.velocity.Y > wormTargetY) + npc.velocity.Y = npc.velocity.Y - wormAccel; - if ((double)Math.Abs(num40) < (double)num37 * 0.2 && ((npc.velocity.X > 0f && num39 < 0f) || (npc.velocity.X < 0f && num39 > 0f))) + if ((double)Math.Abs(wormTargetY) < (double)wormSpeed * 0.2 && ((npc.velocity.X > 0f && wormTargetX < 0f) || (npc.velocity.X < 0f && wormTargetX > 0f))) { if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num38 * 2f; + npc.velocity.Y = npc.velocity.Y + wormAccel * 2f; else - npc.velocity.Y = npc.velocity.Y - num38 * 2f; + npc.velocity.Y = npc.velocity.Y - wormAccel * 2f; } - if ((double)Math.Abs(num39) < (double)num37 * 0.2 && ((npc.velocity.Y > 0f && num40 < 0f) || (npc.velocity.Y < 0f && num40 > 0f))) + if ((double)Math.Abs(wormTargetX) < (double)wormSpeed * 0.2 && ((npc.velocity.Y > 0f && wormTargetY < 0f) || (npc.velocity.Y < 0f && wormTargetY > 0f))) { if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num38 * 2f; + npc.velocity.X = npc.velocity.X + wormAccel * 2f; else - npc.velocity.X = npc.velocity.X - num38 * 2f; + npc.velocity.X = npc.velocity.X - wormAccel * 2f; } } - else if (num55 > num56) + else if (absoluteTargetX > absoluteTargetY) { - if (npc.velocity.X < num39) - npc.velocity.X = npc.velocity.X + num38 * 1.1f; - else if (npc.velocity.X > num39) - npc.velocity.X = npc.velocity.X - num38 * 1.1f; + if (npc.velocity.X < wormTargetX) + npc.velocity.X = npc.velocity.X + wormAccel * 1.1f; + else if (npc.velocity.X > wormTargetX) + npc.velocity.X = npc.velocity.X - wormAccel * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.5) + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.5) { if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num38; + npc.velocity.Y = npc.velocity.Y + wormAccel; else - npc.velocity.Y = npc.velocity.Y - num38; + npc.velocity.Y = npc.velocity.Y - wormAccel; } } else { - if (npc.velocity.Y < num40) - npc.velocity.Y = npc.velocity.Y + num38 * 1.1f; - else if (npc.velocity.Y > num40) - npc.velocity.Y = npc.velocity.Y - num38 * 1.1f; + if (npc.velocity.Y < wormTargetY) + npc.velocity.Y = npc.velocity.Y + wormAccel * 1.1f; + else if (npc.velocity.Y > wormTargetY) + npc.velocity.Y = npc.velocity.Y - wormAccel * 1.1f; - if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)num37 * 0.5) + if ((double)(Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < (double)wormSpeed * 0.5) { if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num38; + npc.velocity.X = npc.velocity.X + wormAccel; else - npc.velocity.X = npc.velocity.X - num38; + npc.velocity.X = npc.velocity.X - wormAccel; } } } @@ -5009,7 +5003,7 @@ namespace CalamityMod.NPCs npc.rotation = (float)Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + MathHelper.PiOver2; if (npc.type == NPCID.DevourerHead || npc.type == NPCID.GiantWormHead || npc.type == NPCID.BoneSerpentHead || npc.type == NPCID.DiggerHead || npc.type == NPCID.SeekerHead || npc.type == NPCID.LeechHead || npc.type == NPCID.DuneSplicerHead || npc.type == NPCID.TombCrawlerHead) { - if (flag2) + if (flying) { if (npc.localAI[0] != 1f) npc.netUpdate = true; @@ -5065,69 +5059,69 @@ namespace CalamityMod.NPCs npc.alpha = 255; } SoundEngine.PlaySound(SoundID.Item8, npc.position); - int num; - for (int num68 = 0; num68 < 50; num68 = num + 1) + int dustIncrement; + for (int i = 0; i < 50; i = dustIncrement + 1) { if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) { - int num69 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); - Dust dust = Main.dust[num69]; + int goblinDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); + Dust dust = Main.dust[goblinDust]; dust.velocity *= 3f; - if (Main.dust[num69].scale > 1f) + if (Main.dust[goblinDust].scale > 1f) { - Main.dust[num69].noGravity = true; + Main.dust[goblinDust].noGravity = true; } } else if (npc.type == NPCID.DarkCaster) { - int num70 = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num70]; + int darkCasterDust = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[darkCasterDust]; dust.velocity *= 3f; - Main.dust[num70].noGravity = true; + Main.dust[darkCasterDust].noGravity = true; } else if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) { - int num71 = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[num71]; + int necromancerDust = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necromancerDust]; dust.velocity *= 2f; - Main.dust[num71].scale = 1.4f; + Main.dust[necromancerDust].scale = 1.4f; } else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) { - int num72 = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num72]; + int diabolistDust = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[diabolistDust]; dust.velocity *= 3f; - Main.dust[num72].noGravity = true; + Main.dust[diabolistDust].noGravity = true; } else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) { - int num73 = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num73]; + int raggedCasterDust = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[raggedCasterDust]; dust.velocity *= 3f; - Main.dust[num73].noGravity = true; + Main.dust[raggedCasterDust].noGravity = true; } else if (npc.type == NPCID.RuneWizard) { - int num74 = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num74]; + int runeWizardDust = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[runeWizardDust]; dust.velocity *= 3f; - Main.dust[num74].noGravity = true; + Main.dust[runeWizardDust].noGravity = true; } else if (npc.type == NPCID.DesertDjinn) { - int num75 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num75]; + int desertSpiritDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[desertSpiritDust]; dust.velocity *= 3f; - Main.dust[num75].noGravity = true; + Main.dust[desertSpiritDust].noGravity = true; } else { - int num76 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num76]; + int fireImpDust = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[fireImpDust]; dust.velocity *= 3f; - Main.dust[num76].noGravity = true; + Main.dust[fireImpDust].noGravity = true; } - num = num68; + dustIncrement = i; } npc.position.X = npc.ai[2] * 16f - (float)(npc.width / 2) + 8f; npc.position.Y = npc.ai[3] * 16f - (float)npc.height; @@ -5136,68 +5130,68 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; npc.ai[3] = 0f; SoundEngine.PlaySound(SoundID.Item8, npc.position); - for (int num77 = 0; num77 < 50; num77 = num + 1) + for (int j = 0; j < 50; j = dustIncrement + 1) { if (npc.type == NPCID.GoblinSorcerer || npc.type == NPCID.Tim) { - int num78 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); - Dust dust = Main.dust[num78]; + int goblinCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), (float)Main.rand.Next(1, 3)); + Dust dust = Main.dust[goblinCastDust]; dust.velocity *= 3f; - if (Main.dust[num78].scale > 1f) + if (Main.dust[goblinCastDust].scale > 1f) { - Main.dust[num78].noGravity = true; + Main.dust[goblinCastDust].noGravity = true; } } else if (npc.type == NPCID.DarkCaster) { - int num79 = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num79]; + int darkCasterCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 172, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[darkCasterCastDust]; dust.velocity *= 3f; - Main.dust[num79].noGravity = true; + Main.dust[darkCasterCastDust].noGravity = true; } else if (npc.type == NPCID.RuneWizard) { - int num80 = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num80]; + int runeWizardCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 106, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[runeWizardCastDust]; dust.velocity *= 3f; - Main.dust[num80].noGravity = true; + Main.dust[runeWizardCastDust].noGravity = true; } else if (npc.type == NPCID.Necromancer || npc.type == NPCID.NecromancerArmored) { - int num81 = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[num81]; + int necromancerCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necromancerCastDust]; dust.velocity *= 2f; - Main.dust[num81].scale = 1.4f; + Main.dust[necromancerCastDust].scale = 1.4f; } else if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) { - int num82 = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num82]; + int diabolistCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 174, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[diabolistCastDust]; dust.velocity *= 3f; - Main.dust[num82].noGravity = true; + Main.dust[diabolistCastDust].noGravity = true; } else if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) { - int num83 = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num83]; + int raggedCasterCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 175, 0f, 0f, 100, default(Color), 1.5f); + Dust dust = Main.dust[raggedCasterCastDust]; dust.velocity *= 3f; - Main.dust[num83].noGravity = true; + Main.dust[raggedCasterCastDust].noGravity = true; } else if (npc.type == NPCID.DesertDjinn) { - int num84 = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num84]; + int desertSpiritCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[desertSpiritCastDust]; dust.velocity *= 3f; - Main.dust[num84].noGravity = true; + Main.dust[desertSpiritCastDust].noGravity = true; } else { - int num85 = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num85]; + int fireImpCastDust = Dust.NewDust(npc.position, npc.width, npc.height, 6, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[fireImpCastDust]; dust.velocity *= 3f; - Main.dust[num85].noGravity = true; + Main.dust[fireImpCastDust].noGravity = true; } - num = num77; + dustIncrement = j; } } @@ -5262,47 +5256,47 @@ namespace CalamityMod.NPCs if (npc.ai[0] >= 650f && Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[0] = 2f; - int num86 = (int)Main.player[npc.target].position.X / 16; - int num87 = (int)Main.player[npc.target].position.Y / 16; - int num88 = (int)npc.position.X / 16; - int num89 = (int)npc.position.Y / 16; - int num90 = 20; - int num91 = 0; - bool flag4 = false; + int targetTileX = (int)Main.player[npc.target].position.X / 16; + int targetTileY = (int)Main.player[npc.target].position.Y / 16; + int npcTileX = (int)npc.position.X / 16; + int npcTileY = (int)npc.position.Y / 16; + int randTeleportOffset = 20; + int teleportTries = 0; + bool canTeleport = false; if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) + Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) { - num91 = 100; - flag4 = true; + teleportTries = 100; + canTeleport = true; } - while (!flag4 && num91 < 100) + while (!canTeleport && teleportTries < 100) { - num91++; - int num92 = Main.rand.Next(num86 - num90, num86 + num90); - int num93 = Main.rand.Next(num87 - num90, num87 + num90); - int num; - for (int num94 = num93; num94 < num87 + num90; num94 = num + 1) + teleportTries++; + int teleportTileX = Main.rand.Next(targetTileX - randTeleportOffset, targetTileX + randTeleportOffset); + int teleportTileY = Main.rand.Next(targetTileY - randTeleportOffset, targetTileY + randTeleportOffset); + int dustIncrement; + for (int k = teleportTileY; k < targetTileY + randTeleportOffset; k = dustIncrement + 1) { - if ((num94 < num87 - 4 || num94 > num87 + 4 || num92 < num86 - 4 || num92 > num86 + 4) && (num94 < num89 - 1 || num94 > num89 + 1 || num92 < num88 - 1 || num92 > num88 + 1) && Main.tile[num92, num94].HasUnactuatedTile) + if ((k < targetTileY - 4 || k > targetTileY + 4 || teleportTileX < targetTileX - 4 || teleportTileX > targetTileX + 4) && (k < npcTileY - 1 || k > npcTileY + 1 || teleportTileX < npcTileX - 1 || teleportTileX > npcTileX + 1) && Main.tile[teleportTileX, k].HasUnactuatedTile) { - bool flag5 = true; - if ((npc.type == NPCID.DarkCaster || (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite)) && !Main.wallDungeon[(int)Main.tile[num92, num94 - 1].WallType]) + bool validTeleportSpot = true; + if ((npc.type == NPCID.DarkCaster || (npc.type >= NPCID.RaggedCaster && npc.type <= NPCID.DiabolistWhite)) && !Main.wallDungeon[(int)Main.tile[teleportTileX, k - 1].WallType]) { - flag5 = false; + validTeleportSpot = false; } - else if (Main.tile[num92, num94 - 1].LiquidType == LiquidID.Lava) + else if (Main.tile[teleportTileX, k - 1].LiquidType == LiquidID.Lava) { - flag5 = false; + validTeleportSpot = false; } - if (flag5 && Main.tileSolid[(int)Main.tile[num92, num94].TileType] && !Collision.SolidTiles(num92 - 1, num92 + 1, num94 - 4, num94 - 1)) + if (validTeleportSpot && Main.tileSolid[(int)Main.tile[teleportTileX, k].TileType] && !Collision.SolidTiles(teleportTileX - 1, teleportTileX + 1, k - 4, k - 1)) { npc.ai[1] = 20f; - npc.ai[2] = (float)num92; - npc.ai[3] = (float)num94; - flag4 = true; + npc.ai[2] = (float)teleportTileX; + npc.ai[3] = (float)k; + canTeleport = true; break; } } - num = num94; + dustIncrement = k; } } npc.netUpdate = true; @@ -5317,42 +5311,42 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.Item8, npc.position); if (Main.netMode != NetmodeID.MultiplayerClient) { - Point point = npc.Center.ToTileCoordinates(); - Point point2 = Main.player[npc.target].Center.ToTileCoordinates(); - Vector2 vector12 = Main.player[npc.target].Center - npc.Center; - int num95 = 6; - int num96 = 6; - int num97 = 0; - int num98 = 2; - int num99 = 0; - bool flag6 = false; - if (vector12.Length() > 2000f) + Point spiritCenter = npc.Center.ToTileCoordinates(); + Point targetCenter = Main.player[npc.target].Center.ToTileCoordinates(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + int randProjRadius = 6; + int spiritSpawnRadius = 6; + int targetSpawnRadius = 0; + int solidTileCheckRadius = 2; + int projSpawnTries = 0; + bool targetTooFar = false; + if (targetDirection.Length() > 2000f) { - flag6 = true; + targetTooFar = true; } - while (!flag6) + while (!targetTooFar) { - if (num99 >= 50) + if (projSpawnTries >= 50) { break; } - num99++; - int num100 = Main.rand.Next(point2.X - num95, point2.X + num95 + 1); - int num101 = Main.rand.Next(point2.Y - num95, point2.Y + num95 + 1); - if ((num101 < point2.Y - num97 || num101 > point2.Y + num97 || num100 < point2.X - num97 || num100 > point2.X + num97) && (num101 < point.Y - num96 || num101 > point.Y + num96 || num100 < point.X - num96 || num100 > point.X + num96) && !Main.tile[num100, num101].HasUnactuatedTile) + projSpawnTries++; + int spiritProjSpawnX = Main.rand.Next(targetCenter.X - randProjRadius, targetCenter.X + randProjRadius + 1); + int spiritProjSpawnY = Main.rand.Next(targetCenter.Y - randProjRadius, targetCenter.Y + randProjRadius + 1); + if ((spiritProjSpawnY < targetCenter.Y - targetSpawnRadius || spiritProjSpawnY > targetCenter.Y + targetSpawnRadius || spiritProjSpawnX < targetCenter.X - targetSpawnRadius || spiritProjSpawnX > targetCenter.X + targetSpawnRadius) && (spiritProjSpawnY < spiritCenter.Y - spiritSpawnRadius || spiritProjSpawnY > spiritCenter.Y + spiritSpawnRadius || spiritProjSpawnX < spiritCenter.X - spiritSpawnRadius || spiritProjSpawnX > spiritCenter.X + spiritSpawnRadius) && !Main.tile[spiritProjSpawnX, spiritProjSpawnY].HasUnactuatedTile) { - bool flag7 = true; - if (flag7 && Main.tile[num100, num101].LiquidType == LiquidID.Lava) + bool canSpawnProj = true; + if (canSpawnProj && Main.tile[spiritProjSpawnX, spiritProjSpawnY].LiquidType == LiquidID.Lava) { - flag7 = false; + canSpawnProj = false; } - if (flag7 && Collision.SolidTiles(num100 - num98, num100 + num98, num101 - num98, num101 + num98)) + if (canSpawnProj && Collision.SolidTiles(spiritProjSpawnX - solidTileCheckRadius, spiritProjSpawnX + solidTileCheckRadius, spiritProjSpawnY - solidTileCheckRadius, spiritProjSpawnY + solidTileCheckRadius)) { - flag7 = false; + canSpawnProj = false; } - if (flag7) + if (canSpawnProj) { - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), (float)(num100 * 16 + 8), (float)(num101 * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)npc.target, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), (float)(spiritProjSpawnX * 16 + 8), (float)(spiritProjSpawnY * 16 + 8), 0f, 0f, ProjectileID.DesertDjinnCurse, 0, 1f, Main.myPlayer, (float)npc.target, 0f); if (CalamityWorld.death) Main.projectile[proj].extraUpdates += 1; break; @@ -5368,22 +5362,22 @@ namespace CalamityMod.NPCs { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num102 = CalamityWorld.death ? 8f : 6f; + float dungeonCasterProjSpeed = CalamityWorld.death ? 8f : 6f; if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) { - num102 = CalamityWorld.death ? 10f : 8f; + dungeonCasterProjSpeed = CalamityWorld.death ? 10f : 8f; } if (npc.type == NPCID.RaggedCaster || npc.type == NPCID.RaggedCasterOpenCoat) { - num102 = CalamityWorld.death ? 5f : 4f; + dungeonCasterProjSpeed = CalamityWorld.death ? 5f : 4f; } - Vector2 vector13 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y); - float num103 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector13.X; - float num104 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector13.Y; - float num105 = (float)Math.Sqrt((double)(num103 * num103 + num104 * num104)); - num105 = num102 / num105; - num103 *= num105; - num104 *= num105; + Vector2 dungeonCasterPos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y); + float dungeonCasterTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - dungeonCasterPos.X; + float dungeonCasterTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - dungeonCasterPos.Y; + float dungeonCasterTargetDist = (float)Math.Sqrt((double)(dungeonCasterTargetX * dungeonCasterTargetX + dungeonCasterTargetY * dungeonCasterTargetY)); + dungeonCasterTargetDist = dungeonCasterProjSpeed / dungeonCasterTargetDist; + dungeonCasterTargetX *= dungeonCasterTargetDist; + dungeonCasterTargetY *= dungeonCasterTargetDist; int damage = 16; int projType = ProjectileID.ShadowBeamHostile; if (npc.type == NPCID.DiabolistRed || npc.type == NPCID.DiabolistWhite) @@ -5396,13 +5390,13 @@ namespace CalamityMod.NPCs projType = ProjectileID.LostSoulHostile; damage = 32; } - int num108 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector13.X, vector13.Y, num103, num104, projType, damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num108].timeLeft = 300; + int dungeonCasterProj = Projectile.NewProjectile(npc.GetSource_FromAI(), dungeonCasterPos.X, dungeonCasterPos.Y, dungeonCasterTargetX, dungeonCasterTargetY, projType, damage, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[dungeonCasterProj].timeLeft = 300; if (projType == ProjectileID.InfernoHostileBolt) { - Main.projectile[num108].ai[0] = Main.player[npc.target].Center.X; - Main.projectile[num108].ai[1] = Main.player[npc.target].Center.Y; - Main.projectile[num108].netUpdate = true; + Main.projectile[dungeonCasterProj].ai[0] = Main.player[npc.target].Center.X; + Main.projectile[dungeonCasterProj].ai[1] = Main.player[npc.target].Center.Y; + Main.projectile[dungeonCasterProj].netUpdate = true; } npc.localAI[0] = 0f; } @@ -5425,18 +5419,16 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.RuneWizard) { - float num109 = CalamityWorld.death ? 12f : 10f; + float runeWizardProjSpeed = CalamityWorld.death ? 12f : 10f; Vector2 vector14 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num110 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector14.X; - float num111 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector14.Y; - float num112 = (float)Math.Sqrt((double)(num110 * num110 + num111 * num111)); - num112 = num109 / num112; - num110 *= num112; - num111 *= num112; - int num113 = 40; - int num114 = ProjectileID.RuneBlast; - int num115 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector14.X, vector14.Y, num110, num111, num114, num113, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num115].timeLeft = 300; + float runeWizardTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector14.X; + float runeWizardTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector14.Y; + float runeWizardTargetDist = (float)Math.Sqrt((double)(runeWizardTargetX * runeWizardTargetX + runeWizardTargetY * runeWizardTargetY)); + runeWizardTargetDist = runeWizardProjSpeed / runeWizardTargetDist; + runeWizardTargetX *= runeWizardTargetDist; + runeWizardTargetY *= runeWizardTargetDist; + int runeWizardProj = Projectile.NewProjectile(npc.GetSource_FromAI(), vector14.X, vector14.Y, runeWizardTargetX, runeWizardTargetY, ProjectileID.RuneBlast, 40, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[runeWizardProj].timeLeft = 300; npc.localAI[0] = 0f; } else @@ -5451,8 +5443,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool(5)) { - int num116 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 27, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.5f); - Dust dust = Main.dust[num116]; + int shadowflameSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 27, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.5f); + Dust dust = Main.dust[shadowflameSpawnDust]; dust.noGravity = true; dust.velocity.X *= 0.5f; dust.velocity.Y = -2f; @@ -5462,8 +5454,8 @@ namespace CalamityMod.NPCs { if (Main.rand.Next(3) != 0) { - int num117 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 172, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.9f); - Dust dust = Main.dust[num117]; + int waterSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 172, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.9f); + Dust dust = Main.dust[waterSpawnDust]; dust.noGravity = true; dust.velocity.X *= 0.3f; dust.velocity.Y *= 0.2f; @@ -5474,24 +5466,24 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.RuneWizard) { - int num118 = 1; + int runeWizardDustAmt = 1; if (npc.alpha == 255) { - num118 = 2; + runeWizardDustAmt = 2; } - int num; - for (int num119 = 0; num119 < num118; num119 = num + 1) + int dustIncrement; + for (int r = 0; r < runeWizardDustAmt; r = dustIncrement + 1) { if (Main.rand.Next(255) > 255 - npc.alpha) { - int num120 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 106, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.2f); - Dust dust = Main.dust[num120]; + int runeSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 106, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1.2f); + Dust dust = Main.dust[runeSpawnDust]; dust.noGravity = true; dust.velocity.X *= (0.1f + (float)Main.rand.Next(30) * 0.01f); dust.velocity.Y *= (0.1f + (float)Main.rand.Next(30) * 0.01f); dust.scale *= 1f + (float)Main.rand.Next(6) * 0.1f; } - num = num119; + dustIncrement = r; } return false; } @@ -5499,8 +5491,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool()) { - int num121 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); - Dust dust = Main.dust[num121]; + int necroSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 173, 0f, 0f, 0, default(Color), 1f); + Dust dust = Main.dust[necroSpawnDust]; dust.velocity.X *= 0.5f; dust.velocity.Y *= 0.5f; } @@ -5509,8 +5501,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool()) { - int num122 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 174, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1f); - Dust dust = Main.dust[num122]; + int flameSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 174, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 1f); + Dust dust = Main.dust[flameSpawnDust]; dust.noGravity = true; dust.velocity *= 0.4f; dust.velocity.Y -= 0.7f; @@ -5521,8 +5513,8 @@ namespace CalamityMod.NPCs { if (Main.rand.NextBool()) { - int num123 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 175, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.1f); - Dust dust = Main.dust[num123]; + int ghostSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 175, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 0.1f); + Dust dust = Main.dust[ghostSpawnDust]; dust.noGravity = true; dust.velocity *= 0.5f; dust.fadeIn = 1.2f; @@ -5537,8 +5529,8 @@ namespace CalamityMod.NPCs } if (Main.rand.NextBool()) { - int num124 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Dust dust = Main.dust[num124]; + int desertSpawnDust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y + 2f), npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); + Dust dust = Main.dust[desertSpawnDust]; dust.noGravity = true; dust.velocity.X *= 1f; dust.velocity.Y *= 1f; @@ -5758,16 +5750,16 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Hellbat || npc.type == NPCID.Lavabat) { - int num203 = Dust.NewDust(npc.position, npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); - Main.dust[num203].noGravity = true; + int lavaDust = Dust.NewDust(npc.position, npc.width, npc.height, 6, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, 100, default(Color), 2f); + Main.dust[lavaDust].noGravity = true; } if (npc.type == NPCID.IceBat && Main.rand.NextBool(10)) { - int num204 = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[num204].noGravity = true; - Dust dust = Main.dust[num204]; + int iceDust = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceDust].noGravity = true; + Dust dust = Main.dust[iceDust]; dust.velocity *= 0.2f; - Main.dust[num204].noLight = true; + Main.dust[iceDust].noLight = true; } npc.noGravity = true; // Collision on the X axis. @@ -6680,51 +6672,51 @@ namespace CalamityMod.NPCs } else { - float num282 = (CalamityWorld.death ? 12f : 9f) * npc.ai[3]; - float num283 = (CalamityWorld.death ? 0.4f : 0.3f) * npc.ai[3]; - float num284 = num282 / num283 / 2f; - if (npc.ai[0] >= 1f && npc.ai[0] < (float)((int)num284)) + float maxSpinSpeed = (CalamityWorld.death ? 12f : 9f) * npc.ai[3]; + float spinAcceleration = (CalamityWorld.death ? 0.4f : 0.3f) * npc.ai[3]; + float timeToReachMaxSpeed = maxSpinSpeed / spinAcceleration / 2f; + if (npc.ai[0] >= 1f && npc.ai[0] < (float)((int)timeToReachMaxSpeed)) { - npc.velocity.Y = (float)npc.directionY * num282; + npc.velocity.Y = (float)npc.directionY * maxSpinSpeed; npc.ai[0] += 1f; return false; } - if (npc.ai[0] >= (float)((int)num284)) + if (npc.ai[0] >= (float)((int)timeToReachMaxSpeed)) { npc.velocity.Y = 0f; npc.directionY *= -1; - npc.velocity.X = num282 * (float)npc.direction; + npc.velocity.X = maxSpinSpeed * (float)npc.direction; npc.ai[0] = -1f; return false; } if (npc.directionY > 0) { - if (npc.velocity.Y >= num282) + if (npc.velocity.Y >= maxSpinSpeed) { npc.directionY *= -1; - npc.velocity.Y = num282; + npc.velocity.Y = maxSpinSpeed; } } - else if (npc.directionY < 0 && npc.velocity.Y <= -num282) + else if (npc.directionY < 0 && npc.velocity.Y <= -maxSpinSpeed) { npc.directionY *= -1; - npc.velocity.Y = -num282; + npc.velocity.Y = -maxSpinSpeed; } if (npc.direction > 0) { - if (npc.velocity.X >= num282) + if (npc.velocity.X >= maxSpinSpeed) { npc.direction *= -1; - npc.velocity.X = num282; + npc.velocity.X = maxSpinSpeed; } } - else if (npc.direction < 0 && npc.velocity.X <= -num282) + else if (npc.direction < 0 && npc.velocity.X <= -maxSpinSpeed) { npc.direction *= -1; - npc.velocity.X = -num282; + npc.velocity.X = -maxSpinSpeed; } - npc.velocity.X = npc.velocity.X + num283 * (float)npc.direction; - npc.velocity.Y = npc.velocity.Y + num283 * (float)npc.directionY; + npc.velocity.X = npc.velocity.X + spinAcceleration * (float)npc.direction; + npc.velocity.Y = npc.velocity.Y + spinAcceleration * (float)npc.directionY; } return false; } @@ -6739,7 +6731,7 @@ namespace CalamityMod.NPCs npc.directionY = 1; npc.ai[0] = 1f; } - int num285 = CalamityWorld.death ? 9 : 6; + int wheelVelocity = CalamityWorld.death ? 9 : 6; if (npc.ai[1] == 0f) { npc.rotation += (float)(npc.direction * npc.directionY) * 0.13f; @@ -6778,19 +6770,19 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; } } - npc.velocity.X = (float)(num285 * npc.direction); - npc.velocity.Y = (float)(num285 * npc.directionY); - float num286 = (float)(270 - (int)Main.mouseTextColor) / 400f; - Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2)) / 16, (int)(npc.position.Y + (float)(npc.height / 2)) / 16, 0.9f, 0.3f + num286, 0.2f); + npc.velocity.X = (float)(wheelVelocity * npc.direction); + npc.velocity.Y = (float)(wheelVelocity * npc.directionY); + float lighting = (float)(270 - (int)Main.mouseTextColor) / 400f; + Lighting.AddLight((int)(npc.position.X + (float)(npc.width / 2)) / 16, (int)(npc.position.Y + (float)(npc.height / 2)) / 16, 0.9f, 0.3f + lighting, 0.2f); if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[0] += 1f; if (npc.localAI[0] >= (CalamityWorld.death ? 90f : 120f)) { npc.localAI[0] = 0f; - for (int num1501 = 0; num1501 < 4; num1501++) + for (int i = 0; i < 4; i++) { - Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)num1501)); + Vector2 vector255 = new Vector2(0f, -5f).RotatedBy((double)(MathHelper.PiOver2 * (float)i)); int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, vector255.X, vector255.Y, ProjectileID.FlamesTrap, 20, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj].tileCollide = false; Main.projectile[proj].friendly = false; @@ -6805,39 +6797,39 @@ namespace CalamityMod.NPCs #region Hovering AI public static bool BuffedHoveringAI(NPC npc, Mod mod) { - bool flag19 = false; - bool flag20 = npc.type == NPCID.Poltergeist && !Main.pumpkinMoon; + bool hoverDownDistCheck = false; + bool runAway = npc.type == NPCID.Poltergeist && !Main.pumpkinMoon; if (npc.type == NPCID.Reaper && !Main.eclipse) { - flag20 = true; + runAway = true; } if (npc.type == NPCID.Drippler && Main.dayTime) { - flag20 = true; + runAway = true; } - if (!flag20) + if (!runAway) { if (npc.ai[2] >= 0f) { - int num287 = 16; - bool flag21 = false; - bool flag22 = false; - if (npc.position.X > npc.ai[0] - (float)num287 && npc.position.X < npc.ai[0] + (float)num287) + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (npc.position.X > npc.ai[0] - (float)hoverDistance && npc.position.X < npc.ai[0] + (float)hoverDistance) { - flag21 = true; + changeDirectionX = true; } else if ((npc.velocity.X < 0f && npc.direction > 0) || (npc.velocity.X > 0f && npc.direction < 0)) { - flag21 = true; + changeDirectionX = true; } - num287 += 24; - if (npc.position.Y > npc.ai[1] - (float)num287 && npc.position.Y < npc.ai[1] + (float)num287) + hoverDistance += 24; + if (npc.position.Y > npc.ai[1] - (float)hoverDistance && npc.position.Y < npc.ai[1] + (float)hoverDistance) { - flag22 = true; + changeDirectionY = true; } - if (flag21 & flag22) + if (changeDirectionX & changeDirectionY) { npc.ai[2] += 1f; if (npc.ai[2] >= 40f) @@ -6882,23 +6874,23 @@ namespace CalamityMod.NPCs } } - int num288 = (int)((npc.position.X + (float)(npc.width / 2)) / 16f) + npc.direction * 2; - int num289 = (int)((npc.position.Y + (float)npc.height) / 16f); - bool flag23 = true; - bool flag24 = false; - int num290 = 6; + int npcTileX = (int)((npc.position.X + (float)(npc.width / 2)) / 16f) + npc.direction * 2; + int npcTileY = (int)((npc.position.Y + (float)npc.height) / 16f); + bool hoverDownwards = true; + bool canOpenDoor = false; + int tileCheckLoopAmt = 6; if (npc.type == NPCID.Gastropod) { - float num291 = 6f; - Vector2 vector33 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num292 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector33.X; - float num293 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector33.Y; - float num294 = (float)Math.Sqrt((double)(num292 * num292 + num293 * num293)); + float gastropodProjSpeed = 6f; + Vector2 gastropodPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float gastropodTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - gastropodPosition.X; + float gastropodTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - gastropodPosition.Y; + float gastropodTargetDist = (float)Math.Sqrt((double)(gastropodTargetX * gastropodTargetX + gastropodTargetY * gastropodTargetY)); - num294 = num291 / num294; - num292 *= num294; - num293 *= num294; + gastropodTargetDist = gastropodProjSpeed / gastropodTargetDist; + gastropodTargetX *= gastropodTargetDist; + gastropodTargetY *= gastropodTargetDist; if (npc.justHit) { @@ -6910,10 +6902,10 @@ namespace CalamityMod.NPCs { int damage = 25; int projType = ProjectileID.PinkLaser; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector33.X, vector33.Y, num292, num293, projType, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), gastropodPosition.X, gastropodPosition.Y, gastropodTargetX, gastropodTargetY, projType, damage, 0f, Main.myPlayer, 0f, 0f); } - num290 = 12; + tileCheckLoopAmt = 12; if (npc.ai[3] > 0f) { @@ -6937,12 +6929,12 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.Pixie) { - num290 = 8; + tileCheckLoopAmt = 8; if (Main.rand.NextBool(6)) { - int num298 = Dust.NewDust(npc.position, npc.width, npc.height, 55, 0f, 0f, 200, npc.color, 1f); - Dust dust = Main.dust[num298]; + int pixieDust = Dust.NewDust(npc.position, npc.width, npc.height, 55, 0f, 0f, 200, npc.color, 1f); + Dust dust = Main.dust[pixieDust]; dust.velocity *= 0.3f; } @@ -6959,23 +6951,23 @@ namespace CalamityMod.NPCs if (Main.rand.NextBool(3)) { - int num299 = Dust.NewDust(npc.position, npc.width, npc.height, 92, 0f, 0f, 200, default(Color), 1f); - Dust dust = Main.dust[num299]; + int iceEleDust = Dust.NewDust(npc.position, npc.width, npc.height, 92, 0f, 0f, 200, default(Color), 1f); + Dust dust = Main.dust[iceEleDust]; dust.velocity *= 0.3f; - Main.dust[num299].noGravity = true; + Main.dust[iceEleDust].noGravity = true; } - float num300 = 6f; - Vector2 vector34 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num301 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector34.X; - float num302 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector34.Y; - float num303 = (float)Math.Sqrt((double)(num301 * num301 + num302 * num302)); + float iceElementalProjSpeed = 6f; + Vector2 iceElementalPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float iceElementalTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - iceElementalPosition.X; + float iceElementalTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - iceElementalPosition.Y; + float iceElementalTargetDist = (float)Math.Sqrt((double)(iceElementalTargetX * iceElementalTargetX + iceElementalTargetY * iceElementalTargetY)); - num303 = num300 / num303; - num301 *= num303; - num302 *= num303; + iceElementalTargetDist = iceElementalProjSpeed / iceElementalTargetDist; + iceElementalTargetX *= iceElementalTargetDist; + iceElementalTargetY *= iceElementalTargetDist; - if (num301 > 0f) + if (iceElementalTargetX > 0f) { npc.direction = 1; } @@ -6988,11 +6980,11 @@ namespace CalamityMod.NPCs if (npc.direction < 0) { - npc.rotation = (float)Math.Atan2((double)(-(double)num302), (double)(-(double)num301)); + npc.rotation = (float)Math.Atan2((double)(-(double)iceElementalTargetY), (double)(-(double)iceElementalTargetX)); } else { - npc.rotation = (float)Math.Atan2((double)num302, (double)num301); + npc.rotation = (float)Math.Atan2((double)iceElementalTargetY, (double)iceElementalTargetX); } if (npc.justHit) @@ -7005,10 +6997,10 @@ namespace CalamityMod.NPCs { int dmg = 45; int projType = ProjectileID.FrostBlastHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector34.X, vector34.Y, num301, num302, projType, dmg, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), iceElementalPosition.X, iceElementalPosition.Y, iceElementalTargetX, iceElementalTargetY, projType, dmg, 0f, Main.myPlayer, 0f, 0f); } - num290 = 15; + tileCheckLoopAmt = 15; if (npc.ai[3] > 0f) { @@ -7036,11 +7028,11 @@ namespace CalamityMod.NPCs if (Main.player[npc.target].Center.Y < npc.Center.Y) { - num290 = 18; + tileCheckLoopAmt = 18; } else { - num290 = 9; + tileCheckLoopAmt = 9; } if (npc.justHit) @@ -7054,18 +7046,18 @@ namespace CalamityMod.NPCs npc.ai[3] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].head)) { - float num307 = 10f; - Vector2 vector35 = new Vector2(npc.position.X + (float)npc.width * 0.5f - 4f, npc.position.Y + (float)npc.height * 0.7f); - float num308 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector35.X; - float num309 = Math.Abs(num308) * 0.1f; - float num310 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector35.Y - num309; - float num311 = (float)Math.Sqrt((double)(num308 * num308 + num310 * num310)); - num311 = num307 / num311; - num308 *= num311; - num310 *= num311; + float ichorStickerProjSpeed = 10f; + Vector2 ichorStickerPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f - 4f, npc.position.Y + (float)npc.height * 0.7f); + float ichorStickerTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - ichorStickerPosition.X; + float ichorStickerAbsTargetX = Math.Abs(ichorStickerTargetX) * 0.1f; + float ichorStickerTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - ichorStickerPosition.Y - ichorStickerAbsTargetX; + float ichorStickerTargetDist = (float)Math.Sqrt((double)(ichorStickerTargetX * ichorStickerTargetX + ichorStickerTargetY * ichorStickerTargetY)); + ichorStickerTargetDist = ichorStickerProjSpeed / ichorStickerTargetDist; + ichorStickerTargetX *= ichorStickerTargetDist; + ichorStickerTargetY *= ichorStickerTargetDist; int dmg = 40; int projType = ProjectileID.GoldenShowerHostile; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector35.X, vector35.Y, num308, num310, projType, dmg, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), ichorStickerPosition.X, ichorStickerPosition.Y, ichorStickerTargetX, ichorStickerTargetY, projType, dmg, 0f, Main.myPlayer, 0f, 0f); } } } @@ -7073,70 +7065,70 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.Drippler) { - num290 = 8; + tileCheckLoopAmt = 8; if (npc.target >= 0) { - float num315 = (Main.player[npc.target].Center - npc.Center).Length(); - num315 /= 70f; - if (num315 > 8f) + float dripperTargetDist = (Main.player[npc.target].Center - npc.Center).Length(); + dripperTargetDist /= 70f; + if (dripperTargetDist > 8f) { - num315 = 8f; + dripperTargetDist = 8f; } - num290 += (int)num315; + tileCheckLoopAmt += (int)dripperTargetDist; } } - for (int num316 = num289; num316 < num289 + num290; num316++) + for (int y = npcTileY; y < npcTileY + tileCheckLoopAmt; y++) { - if ((Main.tile[num288, num316].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num288, num316].TileType]) || Main.tile[num288, num316].LiquidAmount > 0) + if ((Main.tile[npcTileX, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, y].TileType]) || Main.tile[npcTileX, y].LiquidAmount > 0) { - if (num316 <= num289 + 1) + if (y <= npcTileY + 1) { - flag24 = true; + canOpenDoor = true; } - flag23 = false; + hoverDownwards = false; break; } } if (Main.player[npc.target].npcTypeNoAggro[npc.type]) { - bool flag25 = false; - for (int num317 = num289; num317 < num289 + num290 - 2; num317++) + bool canOpenTallGate = false; + for (int yInc = npcTileY; yInc < npcTileY + tileCheckLoopAmt - 2; yInc++) { - if ((Main.tile[num288, num317].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num288, num317].TileType]) || Main.tile[num288, num317].LiquidAmount > 0) + if ((Main.tile[npcTileX, yInc].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, yInc].TileType]) || Main.tile[npcTileX, yInc].LiquidAmount > 0) { - flag25 = true; + canOpenTallGate = true; break; } } - npc.directionY = (!flag25).ToDirectionInt(); + npc.directionY = (!canOpenTallGate).ToDirectionInt(); } if (npc.type == NPCID.IceElemental || npc.type == NPCID.IchorSticker) { - for (int num318 = num289 - 3; num318 < num289; num318++) + for (int iceIchorY = npcTileY - 3; iceIchorY < npcTileY; iceIchorY++) { - if ((Main.tile[num288, num318].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num288, num318].TileType]) || Main.tile[num288, num318].LiquidAmount > 0) + if ((Main.tile[npcTileX, iceIchorY].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, iceIchorY].TileType]) || Main.tile[npcTileX, iceIchorY].LiquidAmount > 0) { - flag24 = false; - flag19 = true; + canOpenDoor = false; + hoverDownDistCheck = true; break; } } } - if (flag19) + if (hoverDownDistCheck) { - flag23 = true; + hoverDownwards = true; if (npc.type == NPCID.IchorSticker) { npc.velocity.Y = npc.velocity.Y + 3f; } } - if (flag23) + if (hoverDownwards) { if (npc.type == NPCID.Pixie || npc.type == NPCID.IceElemental) { @@ -7167,14 +7159,14 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Pixie || npc.type == NPCID.IceElemental) { - if ((npc.directionY < 0 && npc.velocity.Y > 0f) | flag24) + if ((npc.directionY < 0 && npc.velocity.Y > 0f) | canOpenDoor) { npc.velocity.Y = npc.velocity.Y - 0.3f; } } else if (npc.type == NPCID.Drippler) { - if ((npc.directionY < 0 && npc.velocity.Y > 0f) | flag24) + if ((npc.directionY < 0 && npc.velocity.Y > 0f) | canOpenDoor) { npc.velocity.Y = npc.velocity.Y - 0.1f; } @@ -7228,29 +7220,29 @@ namespace CalamityMod.NPCs } } - float num319 = 4f; + float maxHoverVel = 4f; if (npc.type == NPCID.Pixie) { - num319 = 5f; + maxHoverVel = 5f; } if (npc.type == NPCID.Reaper) { - num319 = 6f; + maxHoverVel = 6f; } if (npc.type == NPCID.Drippler) { - num319 = 2.5f; + maxHoverVel = 2.5f; } if (CalamityWorld.death) { - num319 *= 1.25f; + maxHoverVel *= 1.25f; } if (npc.type == NPCID.Poltergeist) { npc.alpha = 0; - num319 = 6f; - if (!flag20) + maxHoverVel = 6f; + if (!runAway) { npc.TargetClosest(true); } @@ -7268,10 +7260,10 @@ namespace CalamityMod.NPCs } } - if (npc.direction == -1 && npc.velocity.X > -num319) + if (npc.direction == -1 && npc.velocity.X > -maxHoverVel) { npc.velocity.X = npc.velocity.X - 0.15f; - if (npc.velocity.X > num319) + if (npc.velocity.X > maxHoverVel) { npc.velocity.X = npc.velocity.X - 0.15f; } @@ -7279,15 +7271,15 @@ namespace CalamityMod.NPCs { npc.velocity.X = npc.velocity.X + 0.1f; } - if (npc.velocity.X < -num319) + if (npc.velocity.X < -maxHoverVel) { - npc.velocity.X = -num319; + npc.velocity.X = -maxHoverVel; } } - else if (npc.direction == 1 && npc.velocity.X < num319) + else if (npc.direction == 1 && npc.velocity.X < maxHoverVel) { npc.velocity.X = npc.velocity.X + 0.15f; - if (npc.velocity.X < -num319) + if (npc.velocity.X < -maxHoverVel) { npc.velocity.X = npc.velocity.X + 0.15f; } @@ -7295,29 +7287,29 @@ namespace CalamityMod.NPCs { npc.velocity.X = npc.velocity.X - 0.1f; } - if (npc.velocity.X > num319) + if (npc.velocity.X > maxHoverVel) { - npc.velocity.X = num319; + npc.velocity.X = maxHoverVel; } } if (npc.type == NPCID.Drippler) { - num319 = 1.5f; + maxHoverVel = 1.5f; } else { - num319 = 2.5f; + maxHoverVel = 2.5f; } if (CalamityWorld.death) { - num319 *= 1.25f; + maxHoverVel *= 1.25f; } - if (npc.directionY == -1 && npc.velocity.Y > -num319) + if (npc.directionY == -1 && npc.velocity.Y > -maxHoverVel) { npc.velocity.Y = npc.velocity.Y - 0.06f; - if (npc.velocity.Y > num319) + if (npc.velocity.Y > maxHoverVel) { npc.velocity.Y = npc.velocity.Y - 0.1f; } @@ -7325,15 +7317,15 @@ namespace CalamityMod.NPCs { npc.velocity.Y = npc.velocity.Y + 0.05f; } - if (npc.velocity.Y < -num319) + if (npc.velocity.Y < -maxHoverVel) { - npc.velocity.Y = -num319; + npc.velocity.Y = -maxHoverVel; } } - else if (npc.directionY == 1 && npc.velocity.Y < num319) + else if (npc.directionY == 1 && npc.velocity.Y < maxHoverVel) { npc.velocity.Y = npc.velocity.Y + 0.06f; - if (npc.velocity.Y < -num319) + if (npc.velocity.Y < -maxHoverVel) { npc.velocity.Y = npc.velocity.Y + 0.1f; } @@ -7341,9 +7333,9 @@ namespace CalamityMod.NPCs { npc.velocity.Y = npc.velocity.Y - 0.05f; } - if (npc.velocity.Y > num319) + if (npc.velocity.Y > maxHoverVel) { - npc.velocity.Y = num319; + npc.velocity.Y = maxHoverVel; } } @@ -7549,23 +7541,23 @@ namespace CalamityMod.NPCs #region Unicorn AI public static bool BuffedUnicornAI(NPC npc, Mod mod) { - int num = 30; - int num2 = 8; + int turnAroundDelay = 30; + int turnAroundDelayMult = 8; bool flag = false; - bool flag2 = false; - bool flag3 = false; + bool isRunning = false; + bool shouldTurnAround = false; if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) { - flag2 = true; + isRunning = true; npc.ai[3] += 1f; } if (npc.type == NPCID.Tumbleweed) { - num2 = 3; - bool flag4 = npc.velocity.Y == 0f; + turnAroundDelayMult = 3; + bool noYVelocity = npc.velocity.Y == 0f; for (int i = 0; i < Main.maxNPCs; i++) { if (i != npc.whoAmI && Main.npc[i].active && Main.npc[i].type == npc.type && Math.Abs(npc.position.X - Main.npc[i].position.X) + Math.Abs(npc.position.Y - Main.npc[i].position.Y) < (float)npc.width) @@ -7588,23 +7580,23 @@ namespace CalamityMod.NPCs } } } - if (flag4) + if (noYVelocity) { npc.velocity.Y = 0f; } } - if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num) | flag2) + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)turnAroundDelay) | isRunning) { npc.ai[3] += 1f; - flag3 = true; + shouldTurnAround = true; } else if (npc.ai[3] > 0f) { npc.ai[3] -= 1f; } - if (npc.ai[3] > (float)(num * num2)) + if (npc.ai[3] > (float)(turnAroundDelay * turnAroundDelayMult)) { npc.ai[3] = 0f; } @@ -7614,17 +7606,17 @@ namespace CalamityMod.NPCs npc.ai[3] = 0f; } - if (npc.ai[3] == (float)num) + if (npc.ai[3] == (float)turnAroundDelay) { npc.netUpdate = true; } - Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float arg_31B_0 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector.X; - float num3 = Main.player[npc.target].position.Y - vector.Y; - float num4 = (float)Math.Sqrt((double)(arg_31B_0 * arg_31B_0 + num3 * num3)); + Vector2 npcPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float targetXDist = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[npc.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); - if (num4 < 200f && !flag3) + if (targetDistance < 200f && !shouldTurnAround) { npc.ai[3] = 0f; } @@ -7632,20 +7624,20 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.StardustSpiderSmall) { npc.ai[1] += 1f; - bool flag5 = npc.ai[1] >= (CalamityWorld.death ? 60f : 120f); - if (!flag5 && npc.velocity.Y == 0f) + bool spawnTwinkle = npc.ai[1] >= (CalamityWorld.death ? 60f : 120f); + if (!spawnTwinkle && npc.velocity.Y == 0f) { for (int j = 0; j < Main.maxPlayers; j++) { if (Main.player[j].active && !Main.player[j].dead && Main.player[j].Distance(npc.Center) < 800f && Main.player[j].Center.Y < npc.Center.Y && Math.Abs(Main.player[j].Center.X - npc.Center.X) < 20f) { - flag5 = true; + spawnTwinkle = true; break; } } } - if (flag5 && Main.netMode != NetmodeID.MultiplayerClient) + if (spawnTwinkle && Main.netMode != NetmodeID.MultiplayerClient) { for (int k = 0; k < 3; k++) { @@ -7664,27 +7656,27 @@ namespace CalamityMod.NPCs npc.velocity.X = npc.velocity.X * 0.7f; if (npc.ai[1] < 30f) { - Vector2 vector2 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; - Dust arg_5A4_0 = Main.dust[Dust.NewDust(vector2, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector3 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - arg_5A4_0.position = vector2 + vector3 * 20f; - arg_5A4_0.velocity = -vector3 * 2f; - arg_5A4_0.scale = 0.5f + vector3.X * (float)(-(float)npc.spriteDirection); - arg_5A4_0.fadeIn = 1f; - arg_5A4_0.noGravity = true; + Vector2 nebulaBeastDustRotation = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; + Dust nebulaBeastDust = Main.dust[Dust.NewDust(nebulaBeastDustRotation, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; + Vector2 nebulaBeastDustVelocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + nebulaBeastDust.position = nebulaBeastDustRotation + nebulaBeastDustVelocity * 20f; + nebulaBeastDust.velocity = -nebulaBeastDustVelocity * 2f; + nebulaBeastDust.scale = 0.5f + nebulaBeastDustVelocity.X * (float)(-(float)npc.spriteDirection); + nebulaBeastDust.fadeIn = 1f; + nebulaBeastDust.noGravity = true; } else if (npc.ai[1] == 30f) { for (int l = 0; l < 20; l++) { - Vector2 vector4 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; - Dust arg_68B_0 = Main.dust[Dust.NewDust(vector4, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; - Vector2 vector5 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); - arg_68B_0.position = vector4 + vector5 * 4f; - arg_68B_0.velocity = vector5 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * -5f; - arg_68B_0.scale = 0.5f + vector5.X * (float)(-(float)npc.spriteDirection); - arg_68B_0.fadeIn = 1f; - arg_68B_0.noGravity = true; + Vector2 nebulaBeastDustRotation2 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * -20f; + Dust nebulaBeastDust2 = Main.dust[Dust.NewDust(nebulaBeastDustRotation2, 0, 0, 242, 0f, 0f, 0, default(Color), 1f)]; + Vector2 nebulaBeastDustVelocity2 = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi); + nebulaBeastDust2.position = nebulaBeastDustRotation2 + nebulaBeastDustVelocity2 * 4f; + nebulaBeastDust2.velocity = nebulaBeastDustVelocity2 * 4f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * -5f; + nebulaBeastDust2.scale = 0.5f + nebulaBeastDustVelocity2.X * (float)(-(float)npc.spriteDirection); + nebulaBeastDust2.fadeIn = 1f; + nebulaBeastDust2.noGravity = true; } } @@ -7695,8 +7687,8 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 30f && Main.netMode != NetmodeID.MultiplayerClient) { - int num5 = Main.expertMode ? 35 : 50; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (float)(npc.spriteDirection * -20), npc.Center.Y, (float)(npc.spriteDirection * -7), 0f, ProjectileID.NebulaSphere, num5, 0f, Main.myPlayer, (float)npc.target, 0f); + int nebulaBeastProjDamage = Main.expertMode ? 35 : 50; + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X + (float)(npc.spriteDirection * -20), npc.Center.Y, (float)(npc.spriteDirection * -7), 0f, ProjectileID.NebulaSphere, nebulaBeastProjDamage, 0f, Main.myPlayer, (float)npc.target, 0f); } if (npc.ai[1] >= 60f) @@ -7708,14 +7700,14 @@ namespace CalamityMod.NPCs else { npc.ai[1] += 1f; - if (npc.ai[1] >= 180f && num4 < 500f && npc.velocity.Y == 0f) + if (npc.ai[1] >= 180f && targetDistance < 500f && npc.velocity.Y == 0f) { flag = true; npc.ai[1] = 0f; npc.ai[2] = 1f; npc.netUpdate = true; } - else if (npc.velocity.Y == 0f && num4 < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) + else if (npc.velocity.Y == 0f && targetDistance < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.Center.X < Main.player[npc.target].Center.X && npc.velocity.X > 0f) || (npc.Center.X > Main.player[npc.target].Center.X && npc.velocity.X < 0f))) { npc.velocity.Y = npc.velocity.Y - 6f; } @@ -7723,7 +7715,7 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.Wolf || npc.type == NPCID.Hellhound || npc.type == ModContent.NPCType()) { - if (npc.velocity.Y == 0f && num4 < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X > 0f) || (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X < 0f))) + if (npc.velocity.Y == 0f && targetDistance < 100f && Math.Abs(npc.velocity.X) > 3f && ((npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X > 0f) || (npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) && npc.velocity.X < 0f))) { npc.velocity.Y -= 6f; } @@ -7734,7 +7726,7 @@ namespace CalamityMod.NPCs SoundEngine.PlaySound(SoundID.NPCHit11, npc.Center); } - if (npc.ai[3] < (float)num) + if (npc.ai[3] < (float)turnAroundDelay) { if ((npc.type == NPCID.Hellhound || npc.type == NPCID.HeadlessHorseman) && !Main.pumpkinMoon) { @@ -7774,12 +7766,12 @@ namespace CalamityMod.NPCs } } - float num6 = 9f; - float num7 = 0.1f; + float maxVelocity = 9f; + float acceleration = 0.1f; if (CalamityWorld.death) { - num6 *= 1.25f; - num7 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } if (!flag && (npc.velocity.Y == 0f || npc.wet || (npc.velocity.X <= 0f && npc.direction < 0) || (npc.velocity.X >= 0f && npc.direction > 0))) @@ -7824,27 +7816,27 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.9f; } - if (npc.velocity.X < -num6 || npc.velocity.X > num6) + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num6 && npc.direction == 1) + else if (npc.velocity.X < maxVelocity && npc.direction == 1) { npc.velocity.X += 0.1f; - if (npc.velocity.X > num6) + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num6; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num6 && npc.direction == -1) + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) { npc.velocity.X -= 0.1f; - if (npc.velocity.X < -num6) + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num6; + npc.velocity.X = -maxVelocity; } } } @@ -7854,7 +7846,7 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.8f; } - num7 = 0.2f; + acceleration = 0.2f; } else if (npc.type == NPCID.NebulaBeast) { @@ -7862,8 +7854,8 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.8f; } - num6 = 12f; - num7 = 0.2f; + maxVelocity = 12f; + acceleration = 0.2f; } else if (npc.type == NPCID.Tumbleweed) { @@ -7871,80 +7863,80 @@ namespace CalamityMod.NPCs { npc.velocity.X *= 0.9f; } - float num8 = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); + float sandstormPush = MathHelper.Lerp(0.6f, 1f, Math.Abs(Main.windSpeedCurrent)) * (float)Math.Sign(Main.windSpeedCurrent); if (!Main.player[npc.target].ZoneSandstorm) { - num8 = 0f; + sandstormPush = 0f; } - num6 = 6f + num8 * (float)npc.direction * 4f; - num7 = 0.2f; + maxVelocity = 6f + sandstormPush * (float)npc.direction * 4f; + acceleration = 0.2f; } if (CalamityWorld.death) { - num6 *= 1.25f; - num7 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } - if (npc.velocity.X < -num6 || npc.velocity.X > num6) + if (npc.velocity.X < -maxVelocity || npc.velocity.X > maxVelocity) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num6 && npc.direction == 1) + else if (npc.velocity.X < maxVelocity && npc.direction == 1) { - npc.velocity.X = npc.velocity.X + num7; - if (npc.velocity.X > num6) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num6; + npc.velocity.X = maxVelocity; } } - else if (npc.velocity.X > -num6 && npc.direction == -1) + else if (npc.velocity.X > -maxVelocity && npc.direction == -1) { - npc.velocity.X = npc.velocity.X - num7; - if (npc.velocity.X < -num6) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num6; + npc.velocity.X = -maxVelocity; } } } if (npc.velocity.Y >= 0f) { - int num9 = 0; + int faceDirection = 0; if (npc.velocity.X < 0f) { - num9 = -1; + faceDirection = -1; } if (npc.velocity.X > 0f) { - num9 = 1; + faceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int num10 = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num9)) / 16f); - int num11 = (int)((position.Y + (float)npc.height - 1f) / 16f); + int x = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * faceDirection)) / 16f); + int y = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(num10 * 16) < position.X + (float)npc.width && (float)(num10 * 16 + 16) > position.X && ((Main.tile[num10, num11].HasUnactuatedTile && !Main.tile[num10, num11].TopSlope && !Main.tile[num10, num11 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num10, num11].TileType] && !Main.tileSolidTop[(int)Main.tile[num10, num11].TileType]) || (Main.tile[num10, num11 - 1].IsHalfBlock && Main.tile[num10, num11 - 1].HasUnactuatedTile)) && (!Main.tile[num10, num11 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 1].TileType] || (Main.tile[num10, num11 - 1].IsHalfBlock && (!Main.tile[num10, num11 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 4].TileType]))) && (!Main.tile[num10, num11 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 2].TileType]) && (!Main.tile[num10, num11 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10, num11 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num10, num11 - 3].TileType]) && (!Main.tile[num10 - num9, num11 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num10 - num9, num11 - 3].TileType])) + if ((float)(x * 16) < position.X + (float)npc.width && (float)(x * 16 + 16) > position.X && ((Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]) || (Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile)) && (!Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || (Main.tile[x, y - 1].IsHalfBlock && (!Main.tile[x, y - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 4].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 4].TileType]))) && (!Main.tile[x, y - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 2].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 2].TileType]) && (!Main.tile[x, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 3].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 3].TileType]) && (!Main.tile[x - faceDirection, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - faceDirection, y - 3].TileType])) { - float num12 = (float)(num11 * 16); - if (Main.tile[num10, num11].IsHalfBlock) + float tilePixelPosition = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) { - num12 += 8f; + tilePixelPosition += 8f; } - if (Main.tile[num10, num11 - 1].IsHalfBlock) + if (Main.tile[x, y - 1].IsHalfBlock) { - num12 -= 8f; + tilePixelPosition -= 8f; } - if (num12 < position.Y + (float)npc.height) + if (tilePixelPosition < position.Y + (float)npc.height) { - float num13 = position.Y + (float)npc.height - num12; - if ((double)num13 <= 16.1) + float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) { - npc.gfxOffY += npc.position.Y + (float)npc.height - num12; - npc.position.Y = num12 - (float)npc.height; - if (num13 < 9f) + npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - (float)npc.height; + if (percentageTileRisen < 9f) { npc.stepSpeed = 1f; } @@ -7959,23 +7951,22 @@ namespace CalamityMod.NPCs if (npc.velocity.Y == 0f) { - int num14 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); - int num15 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + int npcTileX = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 2) * npc.direction) + npc.velocity.X * 5f) / 16f); + int npcTileY = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); - int num16 = npc.spriteDirection; + int spriteDirection = npc.spriteDirection; if (npc.type == NPCID.NebulaBeast || npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.Tumbleweed) { - num16 *= -1; + spriteDirection *= -1; } - if ((npc.velocity.X < 0f && num16 == -1) || (npc.velocity.X > 0f && num16 == 1)) + if ((npc.velocity.X < 0f && spriteDirection == -1) || (npc.velocity.X > 0f && spriteDirection == 1)) { - bool flag6 = npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.NebulaBeast; - float num17 = 3f; + bool pillarEnemy = npc.type == NPCID.StardustSpiderSmall || npc.type == NPCID.NebulaBeast; - if (Main.tile[num14, num15 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num14, num15 - 2].TileType]) + if (Main.tile[npcTileX, npcTileY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 2].TileType]) { - if (Main.tile[num14, num15 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num14, num15 - 3].TileType]) + if (Main.tile[npcTileX, npcTileY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 3].TileType]) { npc.velocity.Y = -10.5f; npc.netUpdate = true; @@ -7986,17 +7977,17 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } } - else if (Main.tile[num14, num15 - 1].HasUnactuatedTile && !Main.tile[num14, num15 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num14, num15 - 1].TileType]) + else if (Main.tile[npcTileX, npcTileY - 1].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY - 1].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY - 1].TileType]) { npc.velocity.Y = -9f; npc.netUpdate = true; } - else if (npc.position.Y + (float)npc.height - (float)(num15 * 16) > 20f && Main.tile[num14, num15].HasUnactuatedTile && !Main.tile[num14, num15].TopSlope && Main.tileSolid[(int)Main.tile[num14, num15].TileType]) + else if (npc.position.Y + (float)npc.height - (float)(npcTileY * 16) > 20f && Main.tile[npcTileX, npcTileY].HasUnactuatedTile && !Main.tile[npcTileX, npcTileY].TopSlope && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType]) { npc.velocity.Y = -7f; npc.netUpdate = true; } - else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > num17) && (!flag6 || !Main.tile[num14, num15 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num14, num15 + 1].TileType]) && (!Main.tile[num14, num15 + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num14, num15 + 2].TileType]) && (!Main.tile[num14 + npc.direction, num15 + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num14 + npc.direction, num15 + 3].TileType])) + else if ((npc.directionY < 0 || Math.Abs(npc.velocity.X) > 3f) && (!pillarEnemy || !Main.tile[npcTileX, npcTileY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 1].TileType]) && (!Main.tile[npcTileX, npcTileY + 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX, npcTileY + 2].TileType]) && (!Main.tile[npcTileX + npc.direction, npcTileY + 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[npcTileX + npc.direction, npcTileY + 3].TileType])) { npc.velocity.Y = -10f; npc.netUpdate = true; @@ -8004,18 +7995,18 @@ namespace CalamityMod.NPCs } } - if (npc.type == NPCID.NebulaBeast && Math.Abs(npc.velocity.X) >= num6 * 0.95f) + if (npc.type == NPCID.NebulaBeast && Math.Abs(npc.velocity.X) >= maxVelocity * 0.95f) { Rectangle hitbox = npc.Hitbox; for (int m = 0; m < 2; m++) { if (Main.rand.NextBool(3)) { - Dust expr_1B5F = Main.dust[Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, 242, 0f, 0f, 0, default(Color), 1f)]; - expr_1B5F.velocity = Vector2.Zero; - expr_1B5F.noGravity = true; - expr_1B5F.fadeIn = 1f; - expr_1B5F.scale = 0.5f + Main.rand.NextFloat(); + Dust nebulaBeastIdleDust = Main.dust[Dust.NewDust(hitbox.TopLeft(), hitbox.Width, hitbox.Height, 242, 0f, 0f, 0, default(Color), 1f)]; + nebulaBeastIdleDust.velocity = Vector2.Zero; + nebulaBeastIdleDust.noGravity = true; + nebulaBeastIdleDust.fadeIn = 1f; + nebulaBeastIdleDust.scale = 0.5f + Main.rand.NextFloat(); } } } @@ -8038,43 +8029,41 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); } - bool flag31 = true; - - int num532 = 0; + int turtleFaceDirection = 0; if (npc.velocity.X < 0f) { - num532 = -1; + turtleFaceDirection = -1; } if (npc.velocity.X > 0f) { - num532 = 1; + turtleFaceDirection = 1; } Vector2 position = npc.position; position.X += npc.velocity.X; - int num533 = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num532)) / 16f); - int num534 = (int)((position.Y + (float)npc.height - 1f) / 16f); + int turtleTileX = (int)((position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * turtleFaceDirection)) / 16f); + int turtleTileY = (int)((position.Y + (float)npc.height - 1f) / 16f); - if ((float)(num533 * 16) < position.X + (float)npc.width && (float)(num533 * 16 + 16) > position.X && ((Main.tile[num533, num534].HasUnactuatedTile && !Main.tile[num533, num534].TopSlope && !Main.tile[num533, num534 - 1].TopSlope && ((Main.tileSolid[(int)Main.tile[num533, num534].TileType] && !Main.tileSolidTop[(int)Main.tile[num533, num534].TileType]) || (flag31 && Main.tileSolidTop[(int)Main.tile[num533, num534].TileType] && (!Main.tileSolid[(int)Main.tile[num533, num534 - 1].TileType] || !Main.tile[num533, num534 - 1].HasUnactuatedTile) && Main.tile[num533, num534].TileType != 16 && Main.tile[num533, num534].TileType != 18 && Main.tile[num533, num534].TileType != 134))) || (Main.tile[num533, num534 - 1].IsHalfBlock && Main.tile[num533, num534 - 1].HasUnactuatedTile)) && (!Main.tile[num533, num534 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 1].TileType] || (Main.tile[num533, num534 - 1].IsHalfBlock && (!Main.tile[num533, num534 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 4].TileType]))) && (!Main.tile[num533, num534 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 2].TileType]) && (!Main.tile[num533, num534 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533, num534 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num533, num534 - 3].TileType]) && (!Main.tile[num533 - num532, num534 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num533 - num532, num534 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num533 - num532, num534 - 3].TileType])) + if ((float)(turtleTileX * 16) < position.X + (float)npc.width && (float)(turtleTileX * 16 + 16) > position.X && ((Main.tile[turtleTileX, turtleTileY].HasUnactuatedTile && !Main.tile[turtleTileX, turtleTileY].TopSlope && !Main.tile[turtleTileX, turtleTileY - 1].TopSlope && ((Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY].TileType] && !Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType]) || (Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY].TileType] && (!Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || !Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile) && Main.tile[turtleTileX, turtleTileY].TileType != 16 && Main.tile[turtleTileX, turtleTileY].TileType != 18 && Main.tile[turtleTileX, turtleTileY].TileType != 134))) || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile)) && (!Main.tile[turtleTileX, turtleTileY - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 1].TileType] || (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock && (!Main.tile[turtleTileX, turtleTileY - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 4].TileType]))) && (!Main.tile[turtleTileX, turtleTileY - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 2].TileType]) && (!Main.tile[turtleTileX, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX, turtleTileY - 3].TileType]) && (!Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType] || Main.tileSolidTop[(int)Main.tile[turtleTileX - turtleFaceDirection, turtleTileY - 3].TileType])) { - float num535 = (float)(num534 * 16); - if (Main.tile[num533, num534].IsHalfBlock) + float tilePixelPosition = (float)(turtleTileY * 16); + if (Main.tile[turtleTileX, turtleTileY].IsHalfBlock) { - num535 += 8f; + tilePixelPosition += 8f; } - if (Main.tile[num533, num534 - 1].IsHalfBlock) + if (Main.tile[turtleTileX, turtleTileY - 1].IsHalfBlock) { - num535 -= 8f; + tilePixelPosition -= 8f; } - if (num535 < position.Y + (float)npc.height) + if (tilePixelPosition < position.Y + (float)npc.height) { - float num536 = position.Y + (float)npc.height - num535; - if ((double)num536 <= 16.1) + float percentageTileRisen = position.Y + (float)npc.height - tilePixelPosition; + if ((double)percentageTileRisen <= 16.1) { - npc.gfxOffY += npc.position.Y + (float)npc.height - num535; - npc.position.Y = num535 - (float)npc.height; - if (num536 < 9f) + npc.gfxOffY += npc.position.Y + (float)npc.height - tilePixelPosition; + npc.position.Y = tilePixelPosition - (float)npc.height; + if (percentageTileRisen < 9f) { npc.stepSpeed = 0.75f; } @@ -8088,9 +8077,9 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.IceTortoise && Main.rand.NextBool(10)) { - int num537 = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[num537].noGravity = true; - Dust dust = Main.dust[num537]; + int iceTortoiseDust = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceTortoiseDust].noGravity = true; + Dust dust = Main.dust[iceTortoiseDust]; dust.velocity *= 0.2f; } @@ -8107,30 +8096,30 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; - Vector2 vector66 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num538 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector66.X; - float num539 = Main.player[npc.target].position.Y - vector66.Y; - float num540 = (float)Math.Sqrt((double)(num538 * num538 + num539 * num539)); + Vector2 tortoisePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float tortoiseTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - tortoisePosition.X; + float tortoiseTargetY = Main.player[npc.target].position.Y - tortoisePosition.Y; + float tortoiseTargetDist = (float)Math.Sqrt((double)(tortoiseTargetX * tortoiseTargetX + tortoiseTargetY * tortoiseTargetY)); - bool flag32 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + bool canHitPlayer = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) { - if (num540 > 200f & flag32) + if (tortoiseTargetDist > 200f & canHitPlayer) { npc.ai[1] += 3f; } - if (num540 > 600f && (flag32 || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) + if (tortoiseTargetDist > 600f && (canHitPlayer || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) { npc.ai[1] += 6f; } } else { - if (num540 > 200f & flag32) + if (tortoiseTargetDist > 200f & canHitPlayer) { npc.ai[1] += 6f; } - if (num540 > 600f && (flag32 || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) + if (tortoiseTargetDist > 600f && (canHitPlayer || npc.position.Y + (float)npc.height > Main.player[npc.target].position.Y - 200f)) { npc.ai[1] += 15f; } @@ -8167,34 +8156,34 @@ namespace CalamityMod.NPCs if (npc.velocity.Y == 0f && Main.player[npc.target].position.Y < npc.position.Y + (float)npc.height) { - int num541; - int num542; + int tortoiseLeftTileX; + int tortoiseRightTileX; if (npc.direction > 0) { - num541 = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); - num542 = num541 + 3; + tortoiseLeftTileX = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); + tortoiseRightTileX = tortoiseLeftTileX + 3; } else { - num542 = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); - num541 = num542 - 3; + tortoiseRightTileX = (int)(((double)npc.position.X + (double)npc.width * 0.5) / 16.0); + tortoiseLeftTileX = tortoiseRightTileX - 3; } - int num543 = (int)((npc.position.Y + (float)npc.height + 2f) / 16f) - 1; - int num544 = num543 + 4; - bool flag33 = false; - for (int num545 = num541; num545 <= num542; num545++) + int tortoiseBotTileY = (int)((npc.position.Y + (float)npc.height + 2f) / 16f) - 1; + int tortoiseTopTileY = tortoiseBotTileY + 4; + bool onSolidTile = false; + for (int x = tortoiseLeftTileX; x <= tortoiseRightTileX; x++) { - for (int num546 = num543; num546 <= num544; num546++) + for (int y = tortoiseBotTileY; y <= tortoiseTopTileY; y++) { - if (Main.tile[num545, num546] != null && Main.tile[num545, num546].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num545, num546].TileType]) + if (Main.tile[x, y] != null && Main.tile[x, y].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[x, y].TileType]) { - flag33 = true; + onSolidTile = true; } } } - if (!flag33) + if (!onSolidTile) { npc.direction *= -1; npc.velocity.X = 0.1f * (float)npc.direction; @@ -8203,57 +8192,57 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) { - float num547 = 1f; - if (npc.velocity.X < -num547 || npc.velocity.X > num547) + float giantShellyMaxVel = 1f; + if (npc.velocity.X < -giantShellyMaxVel || npc.velocity.X > giantShellyMaxVel) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num547 && npc.direction == 1) + else if (npc.velocity.X < giantShellyMaxVel && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > num547) + if (npc.velocity.X > giantShellyMaxVel) { - npc.velocity.X = num547; + npc.velocity.X = giantShellyMaxVel; } } - else if (npc.velocity.X > -num547 && npc.direction == -1) + else if (npc.velocity.X > -giantShellyMaxVel && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -num547) + if (npc.velocity.X < -giantShellyMaxVel) { - npc.velocity.X = -num547; + npc.velocity.X = -giantShellyMaxVel; } } } else { - float num548 = 2f; - if (num540 < 400f) + float tortoiseMaxVel = 2f; + if (tortoiseTargetDist < 400f) { - if (npc.velocity.X < -num548 || npc.velocity.X > num548) + if (npc.velocity.X < -tortoiseMaxVel || npc.velocity.X > tortoiseMaxVel) { if (npc.velocity.Y == 0f) { npc.velocity *= 0.8f; } } - else if (npc.velocity.X < num548 && npc.direction == 1) + else if (npc.velocity.X < tortoiseMaxVel && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; - if (npc.velocity.X > num548) + if (npc.velocity.X > tortoiseMaxVel) { - npc.velocity.X = num548; + npc.velocity.X = tortoiseMaxVel; } } - else if (npc.velocity.X > -num548 && npc.direction == -1) + else if (npc.velocity.X > -tortoiseMaxVel && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; - if (npc.velocity.X < -num548) + if (npc.velocity.X < -tortoiseMaxVel) { - npc.velocity.X = -num548; + npc.velocity.X = -tortoiseMaxVel; } } } @@ -8316,9 +8305,9 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.IceTortoise && Main.rand.Next(3) < 2) { - int num549 = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Main.dust[num549].noGravity = true; - Dust dust = Main.dust[num549]; + int iceTortoiseSpinDust = Dust.NewDust(npc.position, npc.width, npc.height, 67, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Main.dust[iceTortoiseSpinDust].noGravity = true; + Dust dust = Main.dust[iceTortoiseSpinDust]; dust.velocity *= 0.2f; } @@ -8343,39 +8332,39 @@ namespace CalamityMod.NPCs npc.rotation += npc.ai[2] * (float)npc.direction; npc.ai[1] += 1f; - bool flag34 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float num550 = 15f; - if (!flag34) + bool spinAttackCanHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float spinAttackSpeed = 15f; + if (!spinAttackCanHit) { - num550 = 6f; + spinAttackSpeed = 6f; } if (npc.type == NPCID.GiantShelly || npc.type == NPCID.GiantShelly2) { - num550 *= 0.75f; + spinAttackSpeed *= 0.75f; } - Vector2 vector67 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num551 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector67.X; - float num552 = Math.Abs(num551) * 0.2f; + Vector2 spinAttackPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float spinAttackTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - spinAttackPosition.X; + float absoluteSpinTargetX = Math.Abs(spinAttackTargetX) * 0.2f; if (npc.directionY > 0) { - num552 = 0f; + absoluteSpinTargetX = 0f; } - float num553 = Main.player[npc.target].position.Y - vector67.Y - num552; - float num554 = (float)Math.Sqrt((double)(num551 * num551 + num553 * num553)); + float spinAttackTargetY = Main.player[npc.target].position.Y - spinAttackPosition.Y - absoluteSpinTargetX; + float spinAttackTargetDist = (float)Math.Sqrt((double)(spinAttackTargetX * spinAttackTargetX + spinAttackTargetY * spinAttackTargetY)); npc.netUpdate = true; - num554 = num550 / num554; - num551 *= num554; - num553 *= num554; + spinAttackTargetDist = spinAttackSpeed / spinAttackTargetDist; + spinAttackTargetX *= spinAttackTargetDist; + spinAttackTargetY *= spinAttackTargetDist; - if (!flag34) + if (!spinAttackCanHit) { - num553 = -10f; + spinAttackTargetY = -10f; } - npc.velocity.X = num551; - npc.velocity.Y = num553; + npc.velocity.X = spinAttackTargetX; + npc.velocity.Y = spinAttackTargetY; npc.ai[3] = npc.velocity.X; } else @@ -8452,8 +8441,8 @@ namespace CalamityMod.NPCs if (Main.rand.Next(3) < 2) { - int num555 = Dust.NewDust(npc.Center - new Vector2(30f), 60, 60, 6, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); - Dust dust = Main.dust[num555]; + int spinAttackDust = Dust.NewDust(npc.Center - new Vector2(30f), 60, 60, 6, npc.velocity.X * 0.5f, npc.velocity.Y * 0.5f, 90, default(Color), 1.5f); + Dust dust = Main.dust[spinAttackDust]; dust.noGravity = true; dust.velocity *= 0.2f; dust.fadeIn = 1f; @@ -8465,23 +8454,23 @@ namespace CalamityMod.NPCs if (npc.ai[3] == 1f) { Vector2 vector68 = npc.Center - new Vector2(50f); - for (int num556 = 0; num556 < 32; num556++) + for (int i = 0; i < 32; i++) { - int num557 = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 2.5f); - Dust dust = Main.dust[num557]; + int spinEndDust = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 2.5f); + Dust dust = Main.dust[spinEndDust]; dust.noGravity = true; dust.velocity *= 3f; - num557 = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 1.5f); + spinEndDust = Dust.NewDust(vector68, 100, 100, 6, 0f, 0f, 100, default(Color), 1.5f); dust.velocity *= 2f; dust.noGravity = true; } if (Main.netMode != NetmodeID.Server) { - for (int num558 = 0; num558 < 4; num558++) + for (int j = 0; j < 4; j++) { - int num559 = Gore.NewGore(npc.GetSource_FromAI(), vector68 + new Vector2((float)(50 * Main.rand.Next(100)) / 100f, (float)(50 * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64), 1f); - Gore gore = Main.gore[num559]; + int spinEndGore = Gore.NewGore(npc.GetSource_FromAI(), vector68 + new Vector2((float)(50 * Main.rand.Next(100)) / 100f, (float)(50 * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64), 1f); + Gore gore = Main.gore[spinEndGore]; gore.velocity *= 0.3f; gore.velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f; gore.velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f; @@ -8489,10 +8478,10 @@ namespace CalamityMod.NPCs } } - for (int num560 = 0; num560 < 5; num560++) + for (int k = 0; k < 5; k++) { - int num561 = Dust.NewDust(npc.position, npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 1.5f); - Main.dust[num561].velocity *= Main.rand.NextFloat(); + int moreSpinEndDust = Dust.NewDust(npc.position, npc.width, npc.height, 31, 0f, 0f, 100, default(Color), 1.5f); + Main.dust[moreSpinEndDust].velocity *= Main.rand.NextFloat(); } npc.ai[3] += 1f; @@ -8507,35 +8496,35 @@ namespace CalamityMod.NPCs npc.netUpdate = true; npc.TargetClosest(true); - bool flag35 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); - float num562 = 24f; - if (!flag35) + bool spinAboveCanHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float spinAboveSpeed = 24f; + if (!spinAboveCanHit) { - num562 = 10f; + spinAboveSpeed = 10f; } Vector2 vector69 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num563 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector69.X; - float num564 = Math.Abs(num563) * 0.2f; + float spinAboveTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector69.X; + float absoluteSpinAboveTargetX = Math.Abs(spinAboveTargetX) * 0.2f; if (npc.directionY > 0) { - num564 = 0f; + absoluteSpinAboveTargetX = 0f; } - float num565 = Main.player[npc.target].position.Y - vector69.Y - num564; - float num566 = (float)Math.Sqrt((double)(num563 * num563 + num565 * num565)); + float spinAboveTargetY = Main.player[npc.target].position.Y - vector69.Y - absoluteSpinAboveTargetX; + float spinAboveTargetDist = (float)Math.Sqrt((double)(spinAboveTargetX * spinAboveTargetX + spinAboveTargetY * spinAboveTargetY)); npc.netUpdate = true; - num566 = num562 / num566; - num563 *= num566; - num565 *= num566; + spinAboveTargetDist = spinAboveSpeed / spinAboveTargetDist; + spinAboveTargetX *= spinAboveTargetDist; + spinAboveTargetY *= spinAboveTargetDist; - if (!flag35) + if (!spinAboveCanHit) { - num565 = -12f; + spinAboveTargetY = -12f; } - npc.velocity.X = num563; - npc.velocity.Y = num565; + npc.velocity.X = spinAboveTargetX; + npc.velocity.Y = spinAboveTargetY; } else { @@ -8924,27 +8913,27 @@ namespace CalamityMod.NPCs npc.ai[0] += 10f; } - Vector2 vector72 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num585 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector72.X; - float num586 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector72.Y; - float num587 = (float)Math.Sqrt((double)(num585 * num585 + num586 * num586)); - float num588 = 400f / num587; + Vector2 herplingPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float herplingTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - herplingPosition.X; + float herplingTargetY = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - herplingPosition.Y; + float herplingTargetDist = (float)Math.Sqrt((double)(herplingTargetX * herplingTargetX + herplingTargetY * herplingTargetY)); + float herplingJumpHeight = 400f / herplingTargetDist; if (npc.type == NPCID.Derpling) { - num588 *= 5f; + herplingJumpHeight *= 5f; } else { - num588 *= 10f; + herplingJumpHeight *= 10f; } - if (num588 > 30f) + if (herplingJumpHeight > 30f) { - num588 = 30f; + herplingJumpHeight = 30f; } - npc.ai[0] += (float)((int)num588); + npc.ai[0] += (float)((int)herplingJumpHeight); if (npc.ai[0] >= 0f) { @@ -8961,7 +8950,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -14f; npc.velocity.X = npc.velocity.X + 3f * (float)npc.direction; - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -8973,7 +8962,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -10f; npc.velocity.X = npc.velocity.X + (float)(5 * npc.direction); - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -8985,7 +8974,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -9f; npc.velocity.X = npc.velocity.X + (float)(2 * npc.direction); - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -8997,7 +8986,7 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -5f; npc.velocity.X = npc.velocity.X + (float)(4 * npc.direction); - if (num587 < 350f && num587 > 200f) + if (herplingTargetDist < 350f && herplingTargetDist > 200f) { npc.velocity.X = npc.velocity.X + (float)npc.direction; } @@ -9019,10 +9008,10 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.Derpling) { - bool flag37 = false; + bool derplingDropOnTarget = false; if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && npc.position.X + (float)npc.width > Main.player[npc.target].position.X && npc.position.X < Main.player[npc.target].position.X + (float)Main.player[npc.target].width) { - flag37 = true; + derplingDropOnTarget = true; npc.velocity.X = npc.velocity.X * 0.9f; if (npc.velocity.Y < 0f) { @@ -9031,7 +9020,7 @@ namespace CalamityMod.NPCs } } - if (!flag37 && ((npc.direction == 1 && npc.velocity.X < 4f) || (npc.direction == -1 && npc.velocity.X > -4f))) + if (!derplingDropOnTarget && ((npc.direction == 1 && npc.velocity.X < 4f) || (npc.direction == -1 && npc.velocity.X > -4f))) { if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) { @@ -9091,14 +9080,14 @@ namespace CalamityMod.NPCs { npc.velocity.Y = -6f; npc.netUpdate = true; - for (int num662 = 0; num662 < 15; num662++) + for (int i = 0; i < 15; i++) { - Dust dust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - Dust dust = dust2; + Dust eyeFishDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + Dust dust = eyeFishDust; dust.velocity *= 0.5f; - dust2.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust = dust2; + eyeFishDust.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishDust; dust.velocity += npc.velocity * 0.5f; } } @@ -9109,33 +9098,33 @@ namespace CalamityMod.NPCs if (npc.alpha != 0) { - for (int num663 = 0; num663 < 2; num663++) + for (int j = 0; j < 2; j++) { - Dust dust3 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - Dust dust = dust3; + Dust eyeFishDust2 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + Dust dust = eyeFishDust2; dust.velocity *= 1f; - dust3.scale = 1f + Main.rand.NextFloat() * 0.5f; - dust3.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; - dust = dust3; + eyeFishDust2.scale = 1f + Main.rand.NextFloat() * 0.5f; + eyeFishDust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishDust2; dust.velocity += npc.velocity * 0.3f; } } if (Main.rand.NextBool(3)) { - Dust dust4 = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); - Dust dust = dust4; + Dust eyeFishIdleDust = Dust.NewDustDirect(npc.position, npc.width, npc.height, 5); + Dust dust = eyeFishIdleDust; dust.velocity *= 0f; - dust4.alpha = 120; - dust4.scale = 0.7f + Main.rand.NextFloat() * 0.5f; - dust = dust4; + eyeFishIdleDust.alpha = 120; + eyeFishIdleDust.scale = 0.7f + Main.rand.NextFloat() * 0.5f; + dust = eyeFishIdleDust; dust.velocity += npc.velocity * 0.3f; } npc.position -= npc.netOffset; } - int num631 = npc.target; - int direction2 = npc.direction; + int fishTarget = npc.target; + int fishDirection = npc.direction; if (npc.target == Main.maxPlayers || (Main.player[npc.target].wet && npc.type != NPCID.EyeballFlyingFish) || Main.player[npc.target].dead || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { npc.ai[0] = 90f; @@ -9146,34 +9135,34 @@ namespace CalamityMod.NPCs npc.ai[0] -= 1f; npc.TargetClosest(true); } - if (npc.netUpdate && num631 == npc.target && direction2 == npc.direction) + if (npc.netUpdate && fishTarget == npc.target && fishDirection == npc.direction) { npc.netUpdate = false; } - float num632 = 0.05f; - float num633 = 0.01f; - float num634 = 6f; - float num635 = 3f; - float num636 = 30f; - float num637 = 100f; - float num638 = Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))); - float num639 = Main.player[npc.target].position.Y - (float)(npc.height / 2); + float acceleration = 0.05f; + float verticalAcceleration = 0.01f; + float maxVelocity = 6f; + float maxYSpeed = 3f; + float turnAroundXDist = 30f; + float turnAroundYDist = 100f; + float targetXDist = Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))); + float targetYDist = Main.player[npc.target].position.Y - (float)(npc.height / 2); if (npc.type == NPCID.FlyingAntlion || npc.type == NPCID.GiantFlyingAntlion) { - num632 = 0.09f; - num633 = 0.03f; - num634 = 9f; - num635 = 6f; - num636 = 40f; - num637 = 150f; - num639 = Main.player[npc.target].Center.Y - (float)(npc.height / 2); + acceleration = 0.09f; + verticalAcceleration = 0.03f; + maxVelocity = 9f; + maxYSpeed = 6f; + turnAroundXDist = 40f; + turnAroundYDist = 150f; + targetYDist = Main.player[npc.target].Center.Y - (float)(npc.height / 2); npc.rotation = npc.velocity.X * 0.1f; - int num; - for (int num640 = 0; num640 < Main.maxNPCs; num640 = num + 1) + int playerInc; + for (int p = 0; p < Main.maxNPCs; p = playerInc + 1) { - if (num640 != npc.whoAmI && Main.npc[num640].active && Main.npc[num640].type == npc.type && Math.Abs(npc.position.X - Main.npc[num640].position.X) + Math.Abs(npc.position.Y - Main.npc[num640].position.Y) < (float)npc.width) + if (p != npc.whoAmI && Main.npc[p].active && Main.npc[p].type == npc.type && Math.Abs(npc.position.X - Main.npc[p].position.X) + Math.Abs(npc.position.Y - Main.npc[p].position.Y) < (float)npc.width) { - if (npc.position.X < Main.npc[num640].position.X) + if (npc.position.X < Main.npc[p].position.X) { npc.velocity.X = npc.velocity.X - 0.05f; } @@ -9181,7 +9170,7 @@ namespace CalamityMod.NPCs { npc.velocity.X = npc.velocity.X + 0.05f; } - if (npc.position.Y < Main.npc[num640].position.Y) + if (npc.position.Y < Main.npc[p].position.Y) { npc.velocity.Y = npc.velocity.Y - 0.05f; } @@ -9190,34 +9179,34 @@ namespace CalamityMod.NPCs npc.velocity.Y = npc.velocity.Y + 0.05f; } } - num = num640; + playerInc = p; } } else if (npc.type == NPCID.EyeballFlyingFish) { - num632 = 0.16f; - num633 = 0.12f; - num634 = 9f; - num635 = 5f; - num636 = 0f; - num637 = 250f; - num639 = Main.player[npc.target].position.Y; + acceleration = 0.16f; + verticalAcceleration = 0.12f; + maxVelocity = 9f; + maxYSpeed = 5f; + turnAroundXDist = 0f; + turnAroundYDist = 250f; + targetYDist = Main.player[npc.target].position.Y; if (Main.dayTime) { - num639 = 0f; + targetYDist = 0f; npc.direction *= -1; } } if (CalamityWorld.death) { - num634 *= 1.25f; - num632 *= 1.25f; + maxVelocity *= 1.25f; + acceleration *= 1.25f; } if (npc.ai[0] <= 0f) { - num634 *= 0.8f; - num632 *= 0.7f; - num639 = npc.Center.Y + (float)(npc.directionY * 1000); + maxVelocity *= 0.8f; + acceleration *= 0.7f; + targetYDist = npc.Center.Y + (float)(npc.directionY * 1000); if (npc.velocity.X < 0f) { npc.direction = -1; @@ -9227,68 +9216,68 @@ namespace CalamityMod.NPCs npc.direction = 1; } } - if (num638 > num636) + if (targetXDist > turnAroundXDist) { - if (npc.direction == -1 && npc.velocity.X > -num634) + if (npc.direction == -1 && npc.velocity.X > -maxVelocity) { - npc.velocity.X = npc.velocity.X - num632; - if (npc.velocity.X > num634) + npc.velocity.X = npc.velocity.X - acceleration; + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = npc.velocity.X - num632; + npc.velocity.X = npc.velocity.X - acceleration; } else if (npc.velocity.X > 0f) { - npc.velocity.X = npc.velocity.X - num632 / 2f; + npc.velocity.X = npc.velocity.X - acceleration / 2f; } - if (npc.velocity.X < -num634) + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = -num634; + npc.velocity.X = -maxVelocity; } } - else if (npc.direction == 1 && npc.velocity.X < num634) + else if (npc.direction == 1 && npc.velocity.X < maxVelocity) { - npc.velocity.X = npc.velocity.X + num632; - if (npc.velocity.X < -num634) + npc.velocity.X = npc.velocity.X + acceleration; + if (npc.velocity.X < -maxVelocity) { - npc.velocity.X = npc.velocity.X + num632; + npc.velocity.X = npc.velocity.X + acceleration; } else if (npc.velocity.X < 0f) { - npc.velocity.X = npc.velocity.X + num632 / 2f; + npc.velocity.X = npc.velocity.X + acceleration / 2f; } - if (npc.velocity.X > num634) + if (npc.velocity.X > maxVelocity) { - npc.velocity.X = num634; + npc.velocity.X = maxVelocity; } } } - if (num638 > num637) + if (targetXDist > turnAroundYDist) { - num639 -= num637 / 2f; + targetYDist -= turnAroundYDist / 2f; } - if (npc.position.Y < num639) + if (npc.position.Y < targetYDist) { - npc.velocity.Y = npc.velocity.Y + num633; + npc.velocity.Y = npc.velocity.Y + verticalAcceleration; if (npc.velocity.Y < 0f) { - npc.velocity.Y = npc.velocity.Y + num633; + npc.velocity.Y = npc.velocity.Y + verticalAcceleration; } } else { - npc.velocity.Y = npc.velocity.Y - num633; + npc.velocity.Y = npc.velocity.Y - verticalAcceleration; if (npc.velocity.Y > 0f) { - npc.velocity.Y = npc.velocity.Y - num633; + npc.velocity.Y = npc.velocity.Y - verticalAcceleration; } } - if (npc.velocity.Y < -num635) + if (npc.velocity.Y < -maxYSpeed) { - npc.velocity.Y = -num635; + npc.velocity.Y = -maxYSpeed; } - if (npc.velocity.Y > num635) + if (npc.velocity.Y > maxYSpeed) { - npc.velocity.Y = num635; + npc.velocity.Y = maxYSpeed; } if (npc.wet && npc.type != NPCID.EyeballFlyingFish) { @@ -9654,7 +9643,7 @@ namespace CalamityMod.NPCs { int dustSpawnChance = (npc.ai[0] == 2f) ? 2 : 1; int dustSpawnAreaSize = (npc.ai[0] == 2f) ? 30 : 20; - for (int num1055 = 0; num1055 < 2; num1055++) + for (int i = 0; i < 2; i++) { if (Main.rand.Next(3) < dustSpawnChance) { @@ -10079,62 +10068,62 @@ namespace CalamityMod.NPCs npc.ai[0] = 1f; return false; } - Vector2 value46 = Main.player[npc.target].Center - npc.Center; - value46.Y -= (float)(Main.player[npc.target].height / 4); - float attackTimeMax1 = value46.Length(); + Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + targetDirection.Y -= (float)(Main.player[npc.target].height / 4); + float attackTimeMax1 = targetDirection.Length(); if (attackTimeMax1 > (CalamityWorld.death ? 400f : 800f)) { npc.ai[0] = 2f; return false; } - Vector2 center30 = npc.Center; - center30.X = Main.player[npc.target].Center.X; - Vector2 vector243 = center30 - npc.Center; - if (vector243.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center30, 1, 1)) + Vector2 elementalCenter = npc.Center; + elementalCenter.X = Main.player[npc.target].Center.X; + Vector2 targetDistance = elementalCenter - npc.Center; + if (targetDistance.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center30.X; - npc.ai[2] = center30.Y; - Vector2 center31 = npc.Center; - center31.Y = Main.player[npc.target].Center.Y; - if (vector243.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center31, 1, 1) && Collision.CanHit(center31, 1, 1, Main.player[npc.target].position, 1, 1)) + npc.ai[1] = elementalCenter.X; + npc.ai[2] = elementalCenter.Y; + Vector2 elementalCenter2 = npc.Center; + elementalCenter2.Y = Main.player[npc.target].Center.Y; + if (targetDistance.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter2, 1, 1) && Collision.CanHit(elementalCenter2, 1, 1, Main.player[npc.target].position, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center31.X; - npc.ai[2] = center31.Y; + npc.ai[1] = elementalCenter2.X; + npc.ai[2] = elementalCenter2.Y; } } else { - center30 = npc.Center; - center30.Y = Main.player[npc.target].Center.Y; - if ((center30 - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center30, 1, 1)) + elementalCenter = npc.Center; + elementalCenter.Y = Main.player[npc.target].Center.Y; + if ((elementalCenter - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, elementalCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center30.X; - npc.ai[2] = center30.Y; + npc.ai[1] = elementalCenter.X; + npc.ai[2] = elementalCenter.Y; } } if (npc.ai[0] == 0f) { npc.localAI[0] = 0f; - value46.Normalize(); - value46 *= 0.5f; - npc.velocity += value46; + targetDirection.Normalize(); + targetDirection *= 0.5f; + npc.velocity += targetDirection; npc.ai[0] = 4f; npc.ai[1] = 0f; } } else if (npc.ai[0] == 1f) { - Vector2 value47 = Main.player[npc.target].Center - npc.Center; - float attackTimeMax2 = value47.Length(); + Vector2 targetDirectionAgain = Main.player[npc.target].Center - npc.Center; + float attackTimeMax2 = targetDirectionAgain.Length(); float attackTimeMax3 = 2f; attackTimeMax3 += attackTimeMax2 / (CalamityWorld.death ? 160f : 180f); int attackTimeMax4 = 50; - value47.Normalize(); - value47 *= attackTimeMax3; - npc.velocity = (npc.velocity * (float)(attackTimeMax4 - 1) + value47) / (float)attackTimeMax4; + targetDirectionAgain.Normalize(); + targetDirectionAgain *= attackTimeMax3; + npc.velocity = (npc.velocity * (float)(attackTimeMax4 - 1) + targetDirectionAgain) / (float)attackTimeMax4; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { npc.ai[0] = 0f; @@ -10144,13 +10133,13 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 2f) { npc.noTileCollide = true; - Vector2 value48 = Main.player[npc.target].Center - npc.Center; - float attackTimeMax5 = value48.Length(); + Vector2 targetDirection3 = Main.player[npc.target].Center - npc.Center; + float attackTimeMax5 = targetDirection3.Length(); float scaleFactor23 = CalamityWorld.death ? 3f : 2.5f; int attackTimeMax6 = 4; - value48.Normalize(); - value48 *= scaleFactor23; - npc.velocity = (npc.velocity * (float)(attackTimeMax6 - 1) + value48) / (float)attackTimeMax6; + targetDirection3.Normalize(); + targetDirection3 *= scaleFactor23; + npc.velocity = (npc.velocity * (float)(attackTimeMax6 - 1) + targetDirection3) / (float)attackTimeMax6; if (attackTimeMax5 < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[0] = 0f; @@ -10158,14 +10147,14 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 3f) { - Vector2 value49 = new Vector2(npc.ai[1], npc.ai[2]); - Vector2 value50 = value49 - npc.Center; - float attackTimeMax7 = value50.Length(); + Vector2 elementalCenter3 = new Vector2(npc.ai[1], npc.ai[2]); + Vector2 elementalDirection = elementalCenter3 - npc.Center; + float attackTimeMax7 = elementalDirection.Length(); float attackTimeMax8 = 2f; float attackTimeMax9 = 3f; - value50.Normalize(); - value50 *= attackTimeMax8; - npc.velocity = (npc.velocity * (attackTimeMax9 - 1f) + value50) / attackTimeMax9; + elementalDirection.Normalize(); + elementalDirection *= attackTimeMax8; + npc.velocity = (npc.velocity * (attackTimeMax9 - 1f) + elementalDirection) / attackTimeMax9; if (npc.collideX || npc.collideY) { npc.ai[0] = 4f; @@ -10186,20 +10175,19 @@ namespace CalamityMod.NPCs { npc.velocity.Y = npc.velocity.Y * -0.8f; } - Vector2 value51; + Vector2 stationaryTargetDist; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { - value51 = Main.player[npc.target].Center - npc.Center; - value51.Y -= (float)(Main.player[npc.target].height / 4); - value51.Normalize(); - npc.velocity = value51 * 0.1f; + stationaryTargetDist = Main.player[npc.target].Center - npc.Center; + stationaryTargetDist.Y -= (float)(Main.player[npc.target].height / 4); + stationaryTargetDist.Normalize(); + npc.velocity = stationaryTargetDist * 0.1f; } float scaleFactor24 = CalamityWorld.death ? 2.5f : 2f; - float num1390 = 20f; - value51 = npc.velocity; - value51.Normalize(); - value51 *= scaleFactor24; - npc.velocity = (npc.velocity * (num1390 - 1f) + value51) / num1390; + stationaryTargetDist = npc.velocity; + stationaryTargetDist.Normalize(); + stationaryTargetDist *= scaleFactor24; + npc.velocity = (npc.velocity * 19f + stationaryTargetDist) / 20f; npc.ai[1] += 1f; if (npc.ai[1] > 180f) { @@ -10214,22 +10202,22 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= 5f && !Collision.SolidCollision(npc.position - new Vector2(10f, 10f), npc.width + 20, npc.height + 20)) { npc.localAI[0] = 0f; - Vector2 center32 = npc.Center; - center32.X = Main.player[npc.target].Center.X; - if (Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center32, 1, 1)) + Vector2 elementalCenter4 = npc.Center; + elementalCenter4.X = Main.player[npc.target].Center.X; + if (Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, elementalCenter4, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center32.X; - npc.ai[2] = center32.Y; + npc.ai[1] = elementalCenter4.X; + npc.ai[2] = elementalCenter4.Y; return false; } - center32 = npc.Center; - center32.Y = Main.player[npc.target].Center.Y; - if (Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center32, 1, 1)) + elementalCenter4 = npc.Center; + elementalCenter4.Y = Main.player[npc.target].Center.Y; + if (Collision.CanHit(npc.Center, 1, 1, elementalCenter4, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, elementalCenter4, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center32.X; - npc.ai[2] = center32.Y; + npc.ai[1] = elementalCenter4.X; + npc.ai[2] = elementalCenter4.Y; } } } @@ -10250,50 +10238,50 @@ namespace CalamityMod.NPCs } else { - Vector2 vector204 = Main.player[npc.target].Center - npc.Center; - vector204.Y -= Main.player[npc.target].height / 4; - float num1324 = vector204.Length(); - if (num1324 > 800f) + Vector2 cellTargetDirection = Main.player[npc.target].Center - npc.Center; + cellTargetDirection.Y -= Main.player[npc.target].height / 4; + float cellTargetDist = cellTargetDirection.Length(); + if (cellTargetDist > 800f) { npc.ai[0] = 2f; } else { - Vector2 center31 = npc.Center; - center31.X = Main.player[npc.target].Center.X; - Vector2 vector205 = center31 - npc.Center; - if (vector205.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center31, 1, 1)) + Vector2 cellCenter = npc.Center; + cellCenter.X = Main.player[npc.target].Center.X; + Vector2 cellFaceDirection = cellCenter - npc.Center; + if (cellFaceDirection.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center31.X; - npc.ai[2] = center31.Y; - Vector2 center32 = npc.Center; - center32.Y = Main.player[npc.target].Center.Y; - if (vector205.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center32, 1, 1) && Collision.CanHit(center32, 1, 1, Main.player[npc.target].position, 1, 1)) + npc.ai[1] = cellCenter.X; + npc.ai[2] = cellCenter.Y; + Vector2 cellCenter2 = npc.Center; + cellCenter2.Y = Main.player[npc.target].Center.Y; + if (cellFaceDirection.Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter2, 1, 1) && Collision.CanHit(cellCenter2, 1, 1, Main.player[npc.target].position, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center32.X; - npc.ai[2] = center32.Y; + npc.ai[1] = cellCenter2.X; + npc.ai[2] = cellCenter2.Y; } } else { - center31 = npc.Center; - center31.Y = Main.player[npc.target].Center.Y; - if ((center31 - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, center31, 1, 1)) + cellCenter = npc.Center; + cellCenter.Y = Main.player[npc.target].Center.Y; + if ((cellCenter - npc.Center).Length() > 8f && Collision.CanHit(npc.Center, 1, 1, cellCenter, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center31.X; - npc.ai[2] = center31.Y; + npc.ai[1] = cellCenter.X; + npc.ai[2] = cellCenter.Y; } } if (npc.ai[0] == 0f) { npc.localAI[0] = 0f; - vector204.Normalize(); - vector204 *= 0.5f; - npc.velocity += vector204; + cellTargetDirection.Normalize(); + cellTargetDirection *= 0.5f; + npc.velocity += cellTargetDirection; npc.ai[0] = 4f; npc.ai[1] = 0f; } @@ -10303,37 +10291,37 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 1f) { npc.rotation += npc.direction * 0.3f; - Vector2 value35 = Main.player[npc.target].Center - npc.Center; + Vector2 attacktargetDirection = Main.player[npc.target].Center - npc.Center; if (npc.type == NPCID.NebulaHeadcrab) - value35 = Main.player[npc.target].Top - npc.Center; + attacktargetDirection = Main.player[npc.target].Top - npc.Center; - float num1325 = value35.Length(); - float num1326 = CalamityWorld.death ? 9f : 7.5f; - num1326 += num1325 / 100f; - int num1327 = CalamityWorld.death ? 40 : 45; - value35.Normalize(); - value35 *= num1326; - npc.velocity = (npc.velocity * (num1327 - 1) + value35) / num1327; + float attackTargetDist = attacktargetDirection.Length(); + float attackVelocity = CalamityWorld.death ? 9f : 7.5f; + attackVelocity += attackTargetDist / 100f; + int attackVelocityMult = CalamityWorld.death ? 40 : 45; + attacktargetDirection.Normalize(); + attacktargetDirection *= attackVelocity; + npc.velocity = (npc.velocity * (attackVelocityMult - 1) + attacktargetDirection) / attackVelocityMult; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) { npc.ai[0] = 0f; npc.ai[1] = 0f; } - if (npc.type == NPCID.NebulaHeadcrab && num1325 < 40f && Main.player[npc.target].active && !Main.player[npc.target].dead) + if (npc.type == NPCID.NebulaHeadcrab && attackTargetDist < 40f && Main.player[npc.target].active && !Main.player[npc.target].dead) { - bool flag84 = true; - for (int num1328 = 0; num1328 < Main.maxNPCs; num1328++) + bool headcrabAttach = true; + for (int p = 0; p < Main.maxNPCs; p++) { - NPC nPC7 = Main.npc[num1328]; + NPC nPC7 = Main.npc[p]; if (nPC7.active && nPC7.type == npc.type && nPC7.ai[0] == 5f && nPC7.target == npc.target) { - flag84 = false; + headcrabAttach = false; break; } } - if (flag84) + if (headcrabAttach) { npc.Center = Main.player[npc.target].Top; npc.velocity = Vector2.Zero; @@ -10347,34 +10335,34 @@ namespace CalamityMod.NPCs { npc.rotation = npc.velocity.X * 0.1f; npc.noTileCollide = true; - Vector2 value36 = Main.player[npc.target].Center - npc.Center; - float num1329 = value36.Length(); - float num1330 = CalamityWorld.death ? 6f : 4.5f; - int num1331 = 2; - value36.Normalize(); - value36 *= num1330; - npc.velocity = (npc.velocity * (num1331 - 1) + value36) / num1331; - if (num1329 < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + Vector2 idleTargetDirection = Main.player[npc.target].Center - npc.Center; + float idleTargetDist = idleTargetDirection.Length(); + float idleVelocity = CalamityWorld.death ? 6f : 4.5f; + int idleVelocityMult = 2; + idleTargetDirection.Normalize(); + idleTargetDirection *= idleVelocity; + npc.velocity = (npc.velocity * (idleVelocityMult - 1) + idleTargetDirection) / idleVelocityMult; + if (idleTargetDist < 600f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) npc.ai[0] = 0f; } else if (npc.ai[0] == 3f) { npc.rotation = npc.velocity.X * 0.1f; - Vector2 value37 = new Vector2(npc.ai[1], npc.ai[2]); - Vector2 value38 = value37 - npc.Center; - float num1332 = value38.Length(); - float num1333 = CalamityWorld.death ? 4f : 3f; - float num1334 = 2f; - value38.Normalize(); - value38 *= num1333; - npc.velocity = (npc.velocity * (num1334 - 1f) + value38) / num1334; + Vector2 blockedCellCenter = new Vector2(npc.ai[1], npc.ai[2]); + Vector2 blockedCellDirection = blockedCellCenter - npc.Center; + float blockedTargetDist = blockedCellDirection.Length(); + float blockedVelocity = CalamityWorld.death ? 4f : 3f; + float blockedVelocityMult = 2f; + blockedCellDirection.Normalize(); + blockedCellDirection *= blockedVelocity; + npc.velocity = (npc.velocity * (blockedVelocityMult - 1f) + blockedCellDirection) / blockedVelocityMult; if (npc.collideX || npc.collideY) { npc.ai[0] = 4f; npc.ai[1] = 0f; } - if (num1332 < num1333 || num1332 > 800f || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + if (blockedTargetDist < blockedVelocity || blockedTargetDist > 800f || Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) npc.ai[0] = 0f; } else if (npc.ai[0] == 4f) @@ -10386,21 +10374,21 @@ namespace CalamityMod.NPCs if (npc.collideY) npc.velocity.Y *= -0.8f; - Vector2 value39; + Vector2 smolCellDirection; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { - value39 = Main.player[npc.target].Center - npc.Center; - value39.Y -= Main.player[npc.target].height / 4; - value39.Normalize(); - npc.velocity = value39 * 0.1f; + smolCellDirection = Main.player[npc.target].Center - npc.Center; + smolCellDirection.Y -= Main.player[npc.target].height / 4; + smolCellDirection.Normalize(); + npc.velocity = smolCellDirection * 0.1f; } - float num1335 = CalamityWorld.death ? 4f : 3f; - float num1336 = CalamityWorld.death ? 16f : 18f; - value39 = npc.velocity; - value39.Normalize(); - value39 *= num1335; - npc.velocity = (npc.velocity * (num1336 - 1f) + value39) / num1336; + float smolCellVelocity = CalamityWorld.death ? 4f : 3f; + float smolCellVelocityMult = CalamityWorld.death ? 16f : 18f; + smolCellDirection = npc.velocity; + smolCellDirection.Normalize(); + smolCellDirection *= smolCellVelocity; + npc.velocity = (npc.velocity * (smolCellVelocityMult - 1f) + smolCellDirection) / smolCellVelocityMult; npc.ai[1] += 1f; if (npc.ai[1] > 180f) { @@ -10415,23 +10403,23 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= 5f && !Collision.SolidCollision(npc.position - new Vector2(10f, 10f), npc.width + 20, npc.height + 20)) { npc.localAI[0] = 0f; - Vector2 center33 = npc.Center; - center33.X = Main.player[npc.target].Center.X; - if (Collision.CanHit(npc.Center, 1, 1, center33, 1, 1) && Collision.CanHit(npc.Center, 1, 1, center33, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center33, 1, 1)) + Vector2 cellCentered = npc.Center; + cellCentered.X = Main.player[npc.target].Center.X; + if (Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, cellCentered, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center33.X; - npc.ai[2] = center33.Y; + npc.ai[1] = cellCentered.X; + npc.ai[2] = cellCentered.Y; } else { - center33 = npc.Center; - center33.Y = Main.player[npc.target].Center.Y; - if (Collision.CanHit(npc.Center, 1, 1, center33, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, center33, 1, 1)) + cellCentered = npc.Center; + cellCentered.Y = Main.player[npc.target].Center.Y; + if (Collision.CanHit(npc.Center, 1, 1, cellCentered, 1, 1) && Collision.CanHit(Main.player[npc.target].Center, 1, 1, cellCentered, 1, 1)) { npc.ai[0] = 3f; - npc.ai[1] = center33.X; - npc.ai[2] = center33.Y; + npc.ai[1] = cellCentered.X; + npc.ai[2] = cellCentered.Y; } } } @@ -10458,16 +10446,16 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.StardustCellBig) { npc.rotation = 0f; - for (int num1337 = 0; num1337 < Main.maxNPCs; num1337++) + for (int r = 0; r < Main.maxNPCs; r++) { - if (num1337 != npc.whoAmI && Main.npc[num1337].active && Main.npc[num1337].type == npc.type && Math.Abs(npc.position.X - Main.npc[num1337].position.X) + Math.Abs(npc.position.Y - Main.npc[num1337].position.Y) < npc.width) + if (r != npc.whoAmI && Main.npc[r].active && Main.npc[r].type == npc.type && Math.Abs(npc.position.X - Main.npc[r].position.X) + Math.Abs(npc.position.Y - Main.npc[r].position.Y) < npc.width) { - if (npc.position.X < Main.npc[num1337].position.X) + if (npc.position.X < Main.npc[r].position.X) npc.velocity.X -= 0.05f; else npc.velocity.X += 0.05f; - if (npc.position.Y < Main.npc[num1337].position.Y) + if (npc.position.Y < Main.npc[r].position.Y) npc.velocity.Y -= 0.05f; else npc.velocity.Y += 0.05f; @@ -10481,16 +10469,16 @@ namespace CalamityMod.NPCs npc.hide = npc.ai[0] == 5f; npc.rotation = npc.velocity.X * 0.1f; - for (int num1338 = 0; num1338 < Main.maxNPCs; num1338++) + for (int s = 0; s < Main.maxNPCs; s++) { - if (num1338 != npc.whoAmI && Main.npc[num1338].active && Main.npc[num1338].type == npc.type && Math.Abs(npc.position.X - Main.npc[num1338].position.X) + Math.Abs(npc.position.Y - Main.npc[num1338].position.Y) < npc.width) + if (s != npc.whoAmI && Main.npc[s].active && Main.npc[s].type == npc.type && Math.Abs(npc.position.X - Main.npc[s].position.X) + Math.Abs(npc.position.Y - Main.npc[s].position.Y) < npc.width) { - if (npc.position.X < Main.npc[num1338].position.X) + if (npc.position.X < Main.npc[s].position.X) npc.velocity.X -= 0.05f; else npc.velocity.X += 0.05f; - if (npc.position.Y < Main.npc[num1338].position.Y) + if (npc.position.Y < Main.npc[s].position.Y) npc.velocity.Y -= 0.05f; else npc.velocity.Y += 0.05f; @@ -10516,34 +10504,33 @@ namespace CalamityMod.NPCs npc.noTileCollide = true; npc.knockBackResist = 0f; - for (int num1339 = 0; num1339 < Main.maxNPCs; num1339++) + for (int i = 0; i < Main.maxNPCs; i++) { - if (num1339 == npc.whoAmI || !Main.npc[num1339].active || Main.npc[num1339].type != npc.type) + if (i == npc.whoAmI || !Main.npc[i].active || Main.npc[i].type != npc.type) continue; - Vector2 vector206 = Main.npc[num1339].Center - npc.Center; - if (!(vector206.Length() < 50f)) + Vector2 targetDirection = Main.npc[i].Center - npc.Center; + if (!(targetDirection.Length() < 50f)) continue; - vector206.Normalize(); - if (vector206.X == 0f && vector206.Y == 0f) + targetDirection.Normalize(); + if (targetDirection.X == 0f && targetDirection.Y == 0f) { - if (num1339 > npc.whoAmI) - vector206.X = 1f; + if (i > npc.whoAmI) + targetDirection.X = 1f; else - vector206.X = -1f; + targetDirection.X = -1f; } - vector206 *= 0.4f; - npc.velocity -= vector206; - NPC nPC = Main.npc[num1339]; - nPC.velocity += vector206; + targetDirection *= 0.4f; + npc.velocity -= targetDirection; + NPC nPC = Main.npc[i]; + nPC.velocity += targetDirection; } if (npc.type == NPCID.ShadowFlameApparition) { - float num1340 = 120f; - if (npc.localAI[0] < num1340) + if (npc.localAI[0] < 120f) { if (npc.localAI[0] == 0f) { @@ -10555,23 +10542,23 @@ namespace CalamityMod.NPCs npc.velocity.X -= 2f; npc.position += npc.netOffset; - for (int num1341 = 0; num1341 < 20; num1341++) + for (int j = 0; j < 20; j++) { - Vector2 center34 = npc.Center; - center34.Y -= 18f; - Vector2 vector207 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - vector207.Normalize(); - vector207 *= Main.rand.Next(0, 100) * 0.1f; - center34 += vector207; - vector207.Normalize(); - vector207 *= Main.rand.Next(50, 90) * 0.2f; - int num1342 = Dust.NewDust(center34, 1, 1, 27); - Main.dust[num1342].velocity = -vector207 * 0.3f; - Main.dust[num1342].alpha = 100; + Vector2 apparitionCenter = npc.Center; + apparitionCenter.Y -= 18f; + Vector2 apparitionRandVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); + apparitionRandVelocity.Normalize(); + apparitionRandVelocity *= Main.rand.Next(0, 100) * 0.1f; + apparitionCenter += apparitionRandVelocity; + apparitionRandVelocity.Normalize(); + apparitionRandVelocity *= Main.rand.Next(50, 90) * 0.2f; + int shadowflameDust = Dust.NewDust(apparitionCenter, 1, 1, 27); + Main.dust[shadowflameDust].velocity = -apparitionRandVelocity * 0.3f; + Main.dust[shadowflameDust].alpha = 100; if (Main.rand.NextBool()) { - Main.dust[num1342].noGravity = true; - Dust dust = Main.dust[num1342]; + Main.dust[shadowflameDust].noGravity = true; + Dust dust = Main.dust[shadowflameDust]; dust.scale += 0.3f; } } @@ -10580,20 +10567,20 @@ namespace CalamityMod.NPCs } npc.localAI[0] += 1f; - float num1343 = 1f - npc.localAI[0] / num1340; - float num1344 = num1343 * 20f; - for (int num1345 = 0; num1345 < num1344; num1345++) + float localAIDustControl = 1f - npc.localAI[0] / 120f; + float dustAmt = localAIDustControl * 20f; + for (int k = 0; k < dustAmt; k++) { if (Main.rand.NextBool(5)) { npc.position += npc.netOffset; - int num1346 = Dust.NewDust(npc.position, npc.width, npc.height, 27); - Main.dust[num1346].alpha = 100; - Dust dust = Main.dust[num1346]; + int idleShadowflameDust = Dust.NewDust(npc.position, npc.width, npc.height, 27); + Main.dust[idleShadowflameDust].alpha = 100; + Dust dust = Main.dust[idleShadowflameDust]; dust.velocity *= 0.3f; - dust = Main.dust[num1346]; + dust = Main.dust[idleShadowflameDust]; dust.velocity += npc.velocity * 0.75f; - Main.dust[num1346].noGravity = true; + Main.dust[idleShadowflameDust].noGravity = true; npc.position -= npc.netOffset; } } @@ -10602,8 +10589,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.AncientCultistSquidhead) { - float num1347 = 120f; - if (npc.localAI[0] < num1347) + if (npc.localAI[0] < 120f) { if (npc.localAI[0] == 0f) { @@ -10616,13 +10602,13 @@ namespace CalamityMod.NPCs } npc.localAI[0] += 1f; - int num1348 = 10; - for (int num1349 = 0; num1349 < 2; num1349++) + int dustPosition = 10; + for (int l = 0; l < 2; l++) { npc.position += npc.netOffset; - int num1350 = Dust.NewDust(npc.position - new Vector2(num1348), npc.width + num1348 * 2, npc.height + num1348 * 2, 228, 0f, 0f, 100, default(Color), 2f); - Main.dust[num1350].noGravity = true; - Main.dust[num1350].noLight = true; + int visionDust = Dust.NewDust(npc.position - new Vector2(dustPosition), npc.width + dustPosition * 2, npc.height + dustPosition * 2, 228, 0f, 0f, 100, default(Color), 2f); + Main.dust[visionDust].noGravity = true; + Main.dust[visionDust].noLight = true; npc.position -= npc.netOffset; } } @@ -10637,44 +10623,44 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 1f) { npc.TargetClosest(); - float num1351 = 0.5f; - float num1352 = 10f; - float num1353 = 4f; - float num1354 = 550f; - float num1355 = 3f; + float xVelocityMult1 = 0.5f; + float maxXVelocity1 = 10f; + float maxYVelocity1 = 4f; + float turnAroundDist1 = 550f; + float yVelocityMult1 = 3f; if (npc.type == NPCID.AncientCultistSquidhead) { - num1351 = 0.8f; - num1352 = 16f; - num1354 = 440f; - num1353 = 6f; + xVelocityMult1 = 0.8f; + maxXVelocity1 = 16f; + turnAroundDist1 = 440f; + maxYVelocity1 = 6f; } if (CalamityWorld.death) { - num1351 *= 1.25f; - num1352 *= 1.25f; - num1354 *= 0.9f; - num1355 -= 1f; + xVelocityMult1 *= 1.25f; + maxXVelocity1 *= 1.25f; + turnAroundDist1 *= 0.9f; + yVelocityMult1 -= 1f; } - npc.velocity.X += npc.ai[1] * num1351; - if (npc.velocity.X > num1352) - npc.velocity.X = num1352; + npc.velocity.X += npc.ai[1] * xVelocityMult1; + if (npc.velocity.X > maxXVelocity1) + npc.velocity.X = maxXVelocity1; - if (npc.velocity.X < 0f - num1352) - npc.velocity.X = 0f - num1352; + if (npc.velocity.X < 0f - maxXVelocity1) + npc.velocity.X = 0f - maxXVelocity1; - float num1356 = Main.player[npc.target].Center.Y - npc.Center.Y; - if (Math.Abs(num1356) > num1353) - num1355 = CalamityWorld.death ? 10f : 12f; + float targetYDist1 = Main.player[npc.target].Center.Y - npc.Center.Y; + if (Math.Abs(targetYDist1) > maxYVelocity1) + yVelocityMult1 = CalamityWorld.death ? 10f : 12f; - if (num1356 > num1353) - num1356 = num1353; - else if (num1356 < 0f - num1353) - num1356 = 0f - num1353; + if (targetYDist1 > maxYVelocity1) + targetYDist1 = maxYVelocity1; + else if (targetYDist1 < 0f - maxYVelocity1) + targetYDist1 = 0f - maxYVelocity1; - npc.velocity.Y = (npc.velocity.Y * (num1355 - 1f) + num1356) / num1355; - if ((npc.ai[1] > 0f && Main.player[npc.target].Center.X - npc.Center.X < 0f - num1354) || (npc.ai[1] < 0f && Main.player[npc.target].Center.X - npc.Center.X > num1354)) + npc.velocity.Y = (npc.velocity.Y * (yVelocityMult1 - 1f) + targetYDist1) / yVelocityMult1; + if ((npc.ai[1] > 0f && Main.player[npc.target].Center.X - npc.Center.X < 0f - turnAroundDist1) || (npc.ai[1] < 0f && Main.player[npc.target].Center.X - npc.Center.X > turnAroundDist1)) { npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -10686,25 +10672,25 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 2f) { - float num1357 = 0.6f; - float num1358 = 0.93f; - float num1359 = 7f; + float decelYVelocityMult = 0.6f; + float deceleration = 0.93f; + float decelerationDist = 7f; if (npc.type == NPCID.AncientCultistSquidhead) { - num1357 = 0.45f; - num1359 = 10f; - num1358 = 0.87f; + decelYVelocityMult = 0.45f; + decelerationDist = 10f; + deceleration = 0.87f; } if (CalamityWorld.death) { - num1357 *= 1.25f; - num1358 *= 0.9f; - num1359 *= 1.25f; + decelYVelocityMult *= 1.25f; + deceleration *= 0.9f; + decelerationDist *= 1.25f; } - npc.velocity.Y += npc.ai[1] * num1357; - if (npc.velocity.Length() > num1359) - npc.velocity *= num1358; + npc.velocity.Y += npc.ai[1] * decelYVelocityMult; + if (npc.velocity.Length() > decelerationDist) + npc.velocity *= deceleration; if (npc.velocity.X > -1f && npc.velocity.X < 1f) { @@ -10715,33 +10701,33 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 3f) { - float num1360 = 0.6f; - float num1361 = 0.3f; - float num1362 = 7f; - float num1363 = 0.93f; + float xVelocityMult3 = 0.6f; + float yAlignSpeed = 0.3f; + float decelerationDist3 = 7f; + float deceleration3 = 0.93f; if (npc.type == NPCID.AncientCultistSquidhead) { - num1360 = 0.8f; - num1361 = 0.45f; - num1362 = 9f; - num1363 = 0.87f; + xVelocityMult3 = 0.8f; + yAlignSpeed = 0.45f; + decelerationDist3 = 9f; + deceleration3 = 0.87f; } if (CalamityWorld.death) { - num1360 *= 1.25f; - num1361 *= 1.25f; - num1362 *= 1.25f; - num1363 *= 0.9f; + xVelocityMult3 *= 1.25f; + yAlignSpeed *= 1.25f; + decelerationDist3 *= 1.25f; + deceleration3 *= 0.9f; } - npc.velocity.X += npc.ai[1] * num1360; + npc.velocity.X += npc.ai[1] * xVelocityMult3; if (npc.Center.Y > Main.player[npc.target].Center.Y) - npc.velocity.Y -= num1361; + npc.velocity.Y -= yAlignSpeed; else - npc.velocity.Y += num1361; + npc.velocity.Y += yAlignSpeed; - if (npc.velocity.Length() > num1362) - npc.velocity *= num1363; + if (npc.velocity.Length() > decelerationDist3) + npc.velocity *= deceleration3; if (npc.velocity.Y > -1f && npc.velocity.Y < 1f) { @@ -10753,12 +10739,12 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.AncientCultistSquidhead) { - int num1364 = 10; + int squidDustVelocity = 10; npc.position += npc.netOffset; - int num1366 = Dust.NewDust(npc.position - new Vector2(num1364), npc.width + num1364 * 2, npc.height + num1364 * 2, 228, 0f, 0f, 100, default(Color), 2f); - Main.dust[num1366].noGravity = true; - Main.dust[num1366].noLight = true; + int squidDust = Dust.NewDust(npc.position - new Vector2(squidDustVelocity), npc.width + squidDustVelocity * 2, npc.height + squidDustVelocity * 2, 228, 0f, 0f, 100, default(Color), 2f); + Main.dust[squidDust].noGravity = true; + Main.dust[squidDust].noLight = true; npc.position -= npc.netOffset; } @@ -10791,8 +10777,8 @@ namespace CalamityMod.NPCs if (npc.ai[0] == 0f) { npc.TargetClosest(); - Vector2 vector208 = Main.player[npc.target].Center - npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && (npc.velocity.X != 0f || npc.velocity.Y > 100f || npc.justHit || vector208.Length() < 80f)) + Vector2 mimicTargetDirection = Main.player[npc.target].Center - npc.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && (npc.velocity.X != 0f || npc.velocity.Y > 100f || npc.justHit || mimicTargetDirection.Length() < 80f)) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -10811,8 +10797,8 @@ namespace CalamityMod.NPCs } else if (npc.ai[0] == 2f) { - Vector2 vector209 = Main.player[npc.target].Center - npc.Center; - if (Main.netMode != NetmodeID.MultiplayerClient && vector209.Length() > 600f) + Vector2 mimicTargetDirection2 = Main.player[npc.target].Center - npc.Center; + if (Main.netMode != NetmodeID.MultiplayerClient && mimicTargetDirection2.Length() > 600f) { npc.ai[0] = 5f; npc.ai[1] = 0f; @@ -10826,25 +10812,25 @@ namespace CalamityMod.NPCs npc.TargetClosest(); npc.velocity.X *= 0.85f; npc.ai[1] += 1f; - float num1367 = 10f + (CalamityWorld.death ? 10f : 20f) * (npc.life / (float)npc.lifeMax); - float num1368 = 5f + (CalamityWorld.death ? 7f : 5f) * (1f - npc.life / (float)npc.lifeMax); - float num1369 = CalamityWorld.death ? 7f : 5f; + float jumpDelay = 10f + (CalamityWorld.death ? 10f : 20f) * (npc.life / (float)npc.lifeMax); + float jumpXVelocity = 5f + (CalamityWorld.death ? 7f : 5f) * (1f - npc.life / (float)npc.lifeMax); + float jumpYVelocity = CalamityWorld.death ? 7f : 5f; if (!Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - num1369 += 2f; + jumpYVelocity += 2f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > num1367) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > jumpDelay) { npc.ai[3] += 1f; if (npc.ai[3] >= 3f) { npc.ai[3] = 0f; - num1369 *= 2f; - num1368 /= 2f; + jumpYVelocity *= 2f; + jumpXVelocity /= 2f; } npc.ai[1] = 0f; - npc.velocity.Y -= num1369; - npc.velocity.X = num1368 * npc.direction; + npc.velocity.Y -= jumpYVelocity; + npc.velocity.X = jumpXVelocity * npc.direction; npc.netUpdate = true; } } @@ -10919,22 +10905,22 @@ namespace CalamityMod.NPCs npc.spriteDirection = npc.direction; npc.TargetClosest(); - Vector2 center35 = Main.player[npc.target].Center; - center35.Y -= 350f; - Vector2 value40 = center35 - npc.Center; + Vector2 mimicTargetCenter = Main.player[npc.target].Center; + mimicTargetCenter.Y -= 350f; + Vector2 mimicTargetDirection = mimicTargetCenter - npc.Center; if (npc.ai[2] == 1f) { npc.ai[1] += 1f; - value40 = Main.player[npc.target].Center - npc.Center; - value40.Normalize(); - value40 *= CalamityWorld.death ? 12f : 10f; - npc.velocity = (npc.velocity * 4f + value40) / 5f; + mimicTargetDirection = Main.player[npc.target].Center - npc.Center; + mimicTargetDirection.Normalize(); + mimicTargetDirection *= CalamityWorld.death ? 12f : 10f; + npc.velocity = (npc.velocity * 4f + mimicTargetDirection) / 5f; if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] > 6f) { npc.ai[1] = 0f; npc.ai[0] = 4.1f; npc.ai[2] = 0f; - npc.velocity = value40; + npc.velocity = mimicTargetDirection; npc.netUpdate = true; } } @@ -10949,9 +10935,9 @@ namespace CalamityMod.NPCs } else { - value40.Normalize(); - value40 *= CalamityWorld.death ? 16f : 14f; - npc.velocity = (npc.velocity * 5f + value40) / 6f; + mimicTargetDirection.Normalize(); + mimicTargetDirection *= CalamityWorld.death ? 16f : 14f; + npc.velocity = (npc.velocity * 5f + mimicTargetDirection) / 6f; } } else if (npc.ai[0] == 4.1f) @@ -10996,9 +10982,9 @@ namespace CalamityMod.NPCs npc.noTileCollide = true; npc.noGravity = true; npc.knockBackResist = 0f; - Vector2 value41 = Main.player[npc.target].Center - npc.Center; - value41.Y -= 4f; - if (Main.netMode != NetmodeID.MultiplayerClient && value41.Length() < 200f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + Vector2 chaseTargetDirection = Main.player[npc.target].Center - npc.Center; + chaseTargetDirection.Y -= 4f; + if (Main.netMode != NetmodeID.MultiplayerClient && chaseTargetDirection.Length() < 200f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) { npc.ai[0] = 2f; npc.ai[1] = 0f; @@ -11007,13 +10993,13 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - if (value41.Length() > 10f) + if (chaseTargetDirection.Length() > 10f) { - value41.Normalize(); - value41 *= CalamityWorld.death ? 15f : 12.5f; + chaseTargetDirection.Normalize(); + chaseTargetDirection *= CalamityWorld.death ? 15f : 12.5f; } - npc.velocity = (npc.velocity * 4f + value41) / 5f; + npc.velocity = (npc.velocity * 4f + chaseTargetDirection) / 5f; } else if (npc.ai[0] == 6f) { @@ -11106,21 +11092,21 @@ namespace CalamityMod.NPCs { int itemID = ItemID.Sets.ItemsForStuffCannon[Main.rand.Next(ItemID.Sets.ItemsForStuffCannon.Length)]; int item = Item.NewItem(npc.GetSource_Loot(), (int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, itemID, 1, noBroadcast: false, -1, noGrabDelay: true); - float num2 = Main.rand.Next(10, 26); + float randomSpeed = Main.rand.Next(10, 26); Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); Vector2 vector2 = Main.player[npc.target].Center - new Vector2(0f, 120f); - float num3 = vector2.X - vector.X; - float num4 = vector2.Y - vector.Y; - num3 += Main.rand.Next(-50, 51) * 0.1f; - num4 += Main.rand.Next(-50, 51) * 0.1f; - float num5 = (float)Math.Sqrt(num3 * num3 + num4 * num4); - num5 = num2 / num5; - num3 *= num5; - num4 *= num5; - num3 += Main.rand.Next(-50, 51) * 0.1f; - num4 += Main.rand.Next(-50, 51) * 0.1f; - Main.item[item].velocity.X = num3; - Main.item[item].velocity.Y = num4; + float targetXDist = vector2.X - vector.X; + float targetYDist = vector2.Y - vector.Y; + targetXDist += Main.rand.Next(-50, 51) * 0.1f; + targetYDist += Main.rand.Next(-50, 51) * 0.1f; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = randomSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist += Main.rand.Next(-50, 51) * 0.1f; + targetYDist += Main.rand.Next(-50, 51) * 0.1f; + Main.item[item].velocity.X = targetXDist; + Main.item[item].velocity.Y = targetYDist; Main.item[item].noGrabDelay = 100; if (Main.netMode != NetmodeID.SinglePlayer) NetMessage.SendData(MessageID.SyncItem, -1, -1, null, item); @@ -11135,15 +11121,15 @@ namespace CalamityMod.NPCs #region Small Star Cell AI public static bool BuffedSmallStarCellAI(NPC npc, Mod mod) { - float num1470 = CalamityWorld.death ? 100f : 200f; + float turnBigDelay = CalamityWorld.death ? 100f : 200f; if (npc.velocity.Length() > 4f) npc.velocity *= 0.95f; npc.velocity *= 0.99f; npc.ai[0]++; - float num1471 = MathHelper.Clamp(npc.ai[0] / num1470, 0f, 1f); - npc.scale = 1f + 0.3f * num1471; - if (npc.ai[0] >= num1470) + float cellScale = MathHelper.Clamp(npc.ai[0] / turnBigDelay, 0f, 1f); + npc.scale = 1f + 0.3f * cellScale; + if (npc.ai[0] >= turnBigDelay) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -11158,28 +11144,26 @@ namespace CalamityMod.NPCs if (!(npc.ai[0] > 20f)) return false; - Vector2 center39 = npc.Center; - int num1472 = (int)(npc.ai[0] / (num1470 / 2f)); - for (int num1473 = 0; num1473 < num1472 + 1; num1473++) + Vector2 cellCenter = npc.Center; + int dustAmt = (int)(npc.ai[0] / (turnBigDelay / 2f)); + for (int i = 0; i < dustAmt + 1; i++) { if (Main.rand.NextBool()) { - int num1474 = 226; - float num1475 = 0.4f; - if (num1473 % 2 == 1) + float dustScale = 0.4f; + if (i % 2 == 1) { - num1474 = 226; - num1475 = 0.65f; + dustScale = 0.65f; } - Vector2 vector222 = center39 + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - num1472 * 2); - int num1476 = Dust.NewDust(vector222 - Vector2.One * 12f, 24, 24, num1474, npc.velocity.X / 2f, npc.velocity.Y / 2f); - Dust dust = Main.dust[num1476]; + Vector2 dustRotation = cellCenter + ((float)Main.rand.NextDouble() * ((float)Math.PI * 2f)).ToRotationVector2() * (12f - dustAmt * 2); + int cellDust = Dust.NewDust(dustRotation - Vector2.One * 12f, 24, 24, 226, npc.velocity.X / 2f, npc.velocity.Y / 2f); + Dust dust = Main.dust[cellDust]; dust.position -= new Vector2(2f); - Main.dust[num1476].velocity = Vector2.Normalize(center39 - vector222) * 1.5f * (10f - num1472 * 2f) / 10f; - Main.dust[num1476].noGravity = true; - Main.dust[num1476].scale = num1475; - Main.dust[num1476].customData = npc; + Main.dust[cellDust].velocity = Vector2.Normalize(cellCenter - dustRotation) * 1.5f * (10f - dustAmt * 2f) / 10f; + Main.dust[cellDust].noGravity = true; + Main.dust[cellDust].scale = dustScale; + Main.dust[cellDust].customData = npc; } } @@ -11190,29 +11174,29 @@ namespace CalamityMod.NPCs #region Flow Invader AI public static bool BuffedFlowInvaderAI(NPC npc, Mod mod) { - float num1477 = CalamityWorld.death ? 8f : 6.5f; + float velocityMult = CalamityWorld.death ? 8f : 6.5f; float moveSpeed = CalamityWorld.death ? 0.25f : 0.2f; npc.TargetClosest(); Vector2 desiredVelocity3 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, -300f); - float num1478 = desiredVelocity3.Length(); - if (num1478 < 20f) + float velocityCheck = desiredVelocity3.Length(); + if (velocityCheck < 20f) { desiredVelocity3 = npc.velocity; } - else if (num1478 < 40f) + else if (velocityCheck < 40f) { desiredVelocity3.Normalize(); - desiredVelocity3 *= num1477 * 0.35f; + desiredVelocity3 *= velocityMult * 0.35f; } - else if (num1478 < 80f) + else if (velocityCheck < 80f) { desiredVelocity3.Normalize(); - desiredVelocity3 *= num1477 * 0.65f; + desiredVelocity3 *= velocityMult * 0.65f; } else { desiredVelocity3.Normalize(); - desiredVelocity3 *= num1477; + desiredVelocity3 *= velocityMult; } npc.SimpleFlyMovement(desiredVelocity3, moveSpeed); @@ -11223,11 +11207,11 @@ namespace CalamityMod.NPCs npc.ai[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector223 = Vector2.Zero; - while (Math.Abs(vector223.X) < 1.5f) - vector223 = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f); + Vector2 projDirection = Vector2.Zero; + while (Math.Abs(projDirection.X) < 1.5f) + projDirection = Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2) * new Vector2(5f, 3f); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, vector223, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, projDirection, ProjectileID.StardustJellyfishSmall, 60, 0f, Main.myPlayer, 0f, npc.whoAmI); Main.projectile[proj].extraUpdates += 1; } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 739342f210..d848ddaca9 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3771,15 +3771,15 @@ namespace CalamityMod.NPCs else if (Vector2.Distance(npc.Center, targetData.Center) > 80f) { Rectangle r = Utils.CenteredRectangle(targetData.Center, new Vector2(targetData.Width + 60, targetData.Height / 2)); - Vector2 vector3 = r.ClosestPointInRect(npc.Center); - Vector2 value = npc.DirectionTo(vector3) * ((targetData.Velocity.Length() * 0.5f) + 2f); - float num8 = npc.Distance(vector3); - if (num8 > 225f) - value *= 2f; - else if (num8 > 120f) - value *= 1.5f; + Vector2 closestTargetPoint = r.ClosestPointInRect(npc.Center); + Vector2 targetPointDir = npc.DirectionTo(closestTargetPoint) * ((targetData.Velocity.Length() * 0.5f) + 2f); + float targetPointDist = npc.Distance(closestTargetPoint); + if (targetPointDist > 225f) + targetPointDir *= 2f; + else if (targetPointDist > 120f) + targetPointDir *= 1.5f; - npc.velocity = Vector2.Lerp(npc.velocity, value, 0.07f); + npc.velocity = Vector2.Lerp(npc.velocity, targetPointDir, 0.07f); } for (int k = 0; k < Main.maxNPCs; k++) @@ -3796,25 +3796,25 @@ namespace CalamityMod.NPCs npc.direction = (npc.velocity.X >= 0f) ? 1 : (-1); npc.spriteDirection = -npc.direction; - Color value3 = Color.HotPink; - Color value4 = Color.LightPink; - int num17 = 4; + Color dustLerpColor1 = Color.HotPink; + Color dustLerpColor2 = Color.LightPink; + int dustPosition = 4; if (npc.type == NPCID.FairyCritterGreen) { - value3 = Color.LimeGreen; - value4 = Color.LightSeaGreen; + dustLerpColor1 = Color.LimeGreen; + dustLerpColor2 = Color.LightSeaGreen; } if (npc.type == NPCID.FairyCritterBlue) { - value3 = Color.RoyalBlue; - value4 = Color.LightBlue; + dustLerpColor1 = Color.RoyalBlue; + dustLerpColor2 = Color.LightBlue; } if ((int)Main.timeForVisualEffects % 2 == 0) { npc.position += npc.netOffset; - Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(num17) * 0.5f, num17 + 4, num17 + 4, 278, 0f, 0f, 200, Color.Lerp(value3, value4, Main.rand.NextFloat()), 0.65f); + Dust dust = Dust.NewDustDirect(npc.Center - new Vector2(dustPosition) * 0.5f, dustPosition + 4, dustPosition + 4, 278, 0f, 0f, 200, Color.Lerp(dustLerpColor1, dustLerpColor2, Main.rand.NextFloat()), 0.65f); dust.velocity *= 0f; dust.velocity += npc.velocity * 0.3f; dust.noGravity = true; @@ -3822,7 +3822,7 @@ namespace CalamityMod.NPCs npc.position -= npc.netOffset; } - Lighting.AddLight(npc.Center, value3.ToVector3() * 0.7f); + Lighting.AddLight(npc.Center, dustLerpColor1.ToVector3() * 0.7f); if (Main.netMode != NetmodeID.Server) { Player localPlayer = Main.LocalPlayer; @@ -5443,79 +5443,48 @@ namespace CalamityMod.NPCs return null; } - public static List<(Texture2D, Predicate)> debuffTextureList = new List<(Texture2D, Predicate)> + public static List<(string, Predicate)> moddedDebuffTextureList = new List<(string, Predicate)> { // All Calamity DoTs in alphabetical order - (Request("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff").Value, NPC => NPC.Calamity().astralInfection > 0), - (Request("CalamityMod/Buffs/DamageOverTime/BanishingFire").Value, NPC => NPC.Calamity().banishingFire > 0), - (Request("CalamityMod/Buffs/DamageOverTime/BrainRot").Value, NPC => NPC.Calamity().brainRot > 0), - (Request("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames").Value, NPC => NPC.Calamity().bFlames > 0), - (Request("CalamityMod/Buffs/DamageOverTime/BurningBlood").Value, NPC => NPC.Calamity().bBlood > 0), - (Request("CalamityMod/Buffs/DamageOverTime/CrushDepth").Value, NPC => NPC.Calamity().cDepth > 0), - (Request("CalamityMod/Buffs/DamageOverTime/Dragonfire").Value, NPC => NPC.Calamity().dragonFire > 0), - (Request("CalamityMod/Buffs/DamageOverTime/ElementalMix").Value, NPC => NPC.Calamity().elementalMix > 0), - (Request("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno").Value, NPC => NPC.Calamity().gsInferno > 0), - (Request("CalamityMod/Buffs/DamageOverTime/HolyFlames").Value, NPC => NPC.Calamity().hFlames > 0), - (Request("CalamityMod/Buffs/DamageOverTime/MiracleBlight").Value, NPC => NPC.Calamity().miracleBlight > 0), - (Request("CalamityMod/Buffs/DamageOverTime/Nightwither").Value, NPC => NPC.Calamity().nightwither > 0), - (Request("CalamityMod/Buffs/DamageOverTime/Plague").Value, NPC => NPC.Calamity().pFlames > 0), - (Request("CalamityMod/Buffs/DamageOverTime/RancorBurn").Value, NPC => NPC.Calamity().RancorBurnTime > 0), - (Request("CalamityMod/Buffs/DamageOverTime/RiptideDebuff").Value, NPC => NPC.Calamity().rTide > 0), - (Request("CalamityMod/Buffs/DamageOverTime/SagePoison").Value, NPC => NPC.Calamity().sagePoisonTime > 0), - (Request("CalamityMod/Buffs/DamageOverTime/ShellfishClaps").Value, NPC => NPC.Calamity().shellfishVore > 0), - (Request("CalamityMod/Buffs/DamageOverTime/Shred").Value, NPC => NPC.Calamity().somaShredStacks > 0), - (Request("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff").Value, NPC => NPC.Calamity().clamDebuff > 0), - (Request("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning").Value, NPC => NPC.Calamity().sulphurPoison > 0), - (Request("CalamityMod/Buffs/DamageOverTime/Vaporfied").Value, NPC => NPC.Calamity().vaporfied > 0), - (Request("CalamityMod/Buffs/DamageOverTime/VulnerabilityHex").Value, NPC => NPC.Calamity().vulnerabilityHex > 0), + ("CalamityMod/Buffs/DamageOverTime/AstralInfectionDebuff", NPC => NPC.Calamity().astralInfection > 0), + ("CalamityMod/Buffs/DamageOverTime/BanishingFire", NPC => NPC.Calamity().banishingFire > 0), + ("CalamityMod/Buffs/DamageOverTime/BrainRot", NPC => NPC.Calamity().brainRot > 0), + ("CalamityMod/Buffs/DamageOverTime/BrimstoneFlames", NPC => NPC.Calamity().bFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/BurningBlood", NPC => NPC.Calamity().bBlood > 0), + ("CalamityMod/Buffs/DamageOverTime/CrushDepth", NPC => NPC.Calamity().cDepth > 0), + ("CalamityMod/Buffs/DamageOverTime/Dragonfire", NPC => NPC.Calamity().dragonFire > 0), + ("CalamityMod/Buffs/DamageOverTime/ElementalMix", NPC => NPC.Calamity().elementalMix > 0), + ("CalamityMod/Buffs/DamageOverTime/GodSlayerInferno", NPC => NPC.Calamity().gsInferno > 0), + ("CalamityMod/Buffs/DamageOverTime/HolyFlames", NPC => NPC.Calamity().hFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/MiracleBlight", NPC => NPC.Calamity().miracleBlight > 0), + ("CalamityMod/Buffs/DamageOverTime/Nightwither", NPC => NPC.Calamity().nightwither > 0), + ("CalamityMod/Buffs/DamageOverTime/Plague", NPC => NPC.Calamity().pFlames > 0), + ("CalamityMod/Buffs/DamageOverTime/RancorBurn", NPC => NPC.Calamity().RancorBurnTime > 0), + ("CalamityMod/Buffs/DamageOverTime/RiptideDebuff", NPC => NPC.Calamity().rTide > 0), + ("CalamityMod/Buffs/DamageOverTime/SagePoison", NPC => NPC.Calamity().sagePoisonTime > 0), + ("CalamityMod/Buffs/DamageOverTime/ShellfishClaps", NPC => NPC.Calamity().shellfishVore > 0), + ("CalamityMod/Buffs/DamageOverTime/Shred", NPC => NPC.Calamity().somaShredStacks > 0), + ("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff", NPC => NPC.Calamity().clamDebuff > 0), + ("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning", NPC => NPC.Calamity().sulphurPoison > 0), + ("CalamityMod/Buffs/DamageOverTime/Vaporfied", NPC => NPC.Calamity().vaporfied > 0), + ("CalamityMod/Buffs/DamageOverTime/VulnerabilityHex", NPC => NPC.Calamity().vulnerabilityHex > 0), // All other important Calamity debuffs, in alphabetical order - (Request("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction").Value, NPC => NPC.Calamity().absorberAffliction > 0), - (Request("CalamityMod/Buffs/StatDebuffs/ArmorCrunch").Value, NPC => NPC.Calamity().aCrunch > 0), - (Request("CalamityMod/Buffs/StatDebuffs/Crumbling").Value, NPC => NPC.Calamity().crumble > 0), - (Request("CalamityMod/Buffs/StatDebuffs/Eutrophication").Value, NPC => NPC.Calamity().eutrophication > 0), - (Request("CalamityMod/Buffs/StatDebuffs/GalvanicCorrosion").Value, NPC => NPC.Calamity().tesla > 0), - (Request("CalamityMod/Buffs/StatDebuffs/GlacialState").Value, NPC => NPC.Calamity().gState > 0), - (Request("CalamityMod/Buffs/StatDebuffs/Irradiated").Value, NPC => NPC.Calamity().irradiated > 0), - (Request("CalamityMod/Buffs/StatDebuffs/KamiFlu").Value, NPC => NPC.Calamity().kamiFlu > 0), - (Request("CalamityMod/Buffs/StatDebuffs/MarkedforDeath").Value, NPC => NPC.Calamity().marked > 0), - (Request("CalamityMod/Buffs/StatDebuffs/PearlAura").Value, NPC => NPC.Calamity().pearlAura > 0), - (Request("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness").Value, NPC => NPC.Calamity().relicOfResilienceWeakness > 0), - (Request("CalamityMod/Buffs/StatDebuffs/TemporalSadness").Value, NPC => NPC.Calamity().tSad > 0), - (Request("CalamityMod/Buffs/StatDebuffs/TimeDistortion").Value, NPC => NPC.Calamity().timeSlow > 0), - (Request("CalamityMod/Buffs/StatDebuffs/WhisperingDeath").Value, NPC => NPC.Calamity().wDeath > 0), - (Request("CalamityMod/Buffs/StatDebuffs/WitherDebuff").Value, NPC => NPC.Calamity().wither > 0), - - // Vanilla debuffs, in alphabetical order - (TextureAssets.Buff[BuffID.BetsysCurse].Value, NPC => NPC.betsysCurse), - (TextureAssets.Buff[BuffID.BoneJavelin].Value, NPC => NPC.javelined), - (TextureAssets.Buff[BuffID.Confused].Value, NPC => NPC.confused), - (TextureAssets.Buff[BuffID.CursedInferno].Value, NPC => NPC.onFire2), - (TextureAssets.Buff[BuffID.Daybreak].Value, NPC => NPC.daybreak), - (TextureAssets.Buff[BuffID.DryadsWard].Value, NPC => NPC.dryadWard), - (TextureAssets.Buff[BuffID.DryadsWardDebuff].Value, NPC => NPC.dryadBane), - (TextureAssets.Buff[BuffID.Electrified].Value, NPC => NPC.Calamity().electrified > 0), - (TextureAssets.Buff[BuffID.Frostburn].Value, NPC => NPC.onFrostBurn), - (TextureAssets.Buff[BuffID.Frostburn2].Value, NPC => NPC.onFrostBurn2), - (TextureAssets.Buff[BuffID.GelBalloonBuff].Value, NPC => NPC.drippingSparkleSlime), - (TextureAssets.Buff[BuffID.Ichor].Value, NPC => NPC.ichor), - (TextureAssets.Buff[BuffID.Lovestruck].Value, NPC => NPC.loveStruck), - (TextureAssets.Buff[BuffID.Midas].Value, NPC => NPC.midas), - (TextureAssets.Buff[BuffID.Oiled].Value, NPC => NPC.oiled), - (TextureAssets.Buff[BuffID.OnFire].Value, NPC => NPC.onFire), - (TextureAssets.Buff[BuffID.OnFire3].Value, NPC => NPC.onFire3), - (TextureAssets.Buff[BuffID.Poisoned].Value, NPC => NPC.poisoned), - (TextureAssets.Buff[BuffID.ScytheWhipEnemyDebuff].Value, NPC => NPC.markedByScytheWhip), - (TextureAssets.Buff[BuffID.ShadowFlame].Value, NPC => NPC.shadowFlame), - (TextureAssets.Buff[BuffID.Slimed].Value, NPC => NPC.drippingSlime), - (TextureAssets.Buff[BuffID.Slow].Value, NPC => NPC.Calamity().slowed > 0), - (TextureAssets.Buff[BuffID.SoulDrain].Value, NPC => NPC.soulDrain && NPC.realLife == -1), - (TextureAssets.Buff[BuffID.StardustMinionBleed].Value, NPC => NPC.celled), - (TextureAssets.Buff[BuffID.Stinky].Value, NPC => NPC.stinky), - (TextureAssets.Buff[BuffID.TentacleSpike].Value, NPC => NPC.tentacleSpiked), - (TextureAssets.Buff[BuffID.Venom].Value, NPC => NPC.venom), - (TextureAssets.Buff[BuffID.Webbed].Value, NPC => NPC.Calamity().webbed > 0), - (TextureAssets.Buff[BuffID.Wet].Value, NPC => NPC.dripping), + ("CalamityMod/Buffs/StatDebuffs/AbsorberAffliction", NPC => NPC.Calamity().absorberAffliction > 0), + ("CalamityMod/Buffs/StatDebuffs/ArmorCrunch", NPC => NPC.Calamity().aCrunch > 0), + ("CalamityMod/Buffs/StatDebuffs/Crumbling", NPC => NPC.Calamity().crumble > 0), + ("CalamityMod/Buffs/StatDebuffs/Eutrophication", NPC => NPC.Calamity().eutrophication > 0), + ("CalamityMod/Buffs/StatDebuffs/GalvanicCorrosion", NPC => NPC.Calamity().tesla > 0), + ("CalamityMod/Buffs/StatDebuffs/GlacialState", NPC => NPC.Calamity().gState > 0), + ("CalamityMod/Buffs/StatDebuffs/Irradiated", NPC => NPC.Calamity().irradiated > 0), + ("CalamityMod/Buffs/StatDebuffs/KamiFlu", NPC => NPC.Calamity().kamiFlu > 0), + ("CalamityMod/Buffs/StatDebuffs/MarkedforDeath", NPC => NPC.Calamity().marked > 0), + ("CalamityMod/Buffs/StatDebuffs/PearlAura", NPC => NPC.Calamity().pearlAura > 0), + ("CalamityMod/Buffs/StatDebuffs/ProfanedWeakness", NPC => NPC.Calamity().relicOfResilienceWeakness > 0), + ("CalamityMod/Buffs/StatDebuffs/TemporalSadness", NPC => NPC.Calamity().tSad > 0), + ("CalamityMod/Buffs/StatDebuffs/TimeDistortion", NPC => NPC.Calamity().timeSlow > 0), + ("CalamityMod/Buffs/StatDebuffs/WhisperingDeath", NPC => NPC.Calamity().wDeath > 0), + ("CalamityMod/Buffs/StatDebuffs/WitherDebuff", NPC => NPC.Calamity().wither > 0), }; public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) @@ -5526,14 +5495,76 @@ namespace CalamityMod.NPCs { List currentDebuffs = new List() { }; - for (int b = 0; b < debuffTextureList.Count(); b++) + for (int b = 0; b < moddedDebuffTextureList.Count(); b++) { - if (debuffTextureList[b].Item2.Invoke(npc)) + if (moddedDebuffTextureList[b].Item2.Invoke(npc)) { - currentDebuffs.Add(debuffTextureList[b].Item1); + currentDebuffs.Add(Request(moddedDebuffTextureList[b].Item1).Value); } } + // Vanilla damage over time debuffs + if (electrified > 0) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Electrified].Value); + if (npc.onFire) + currentDebuffs.Add(TextureAssets.Buff[BuffID.OnFire].Value); + if (npc.poisoned) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Poisoned].Value); + if (npc.onFire2) + currentDebuffs.Add(TextureAssets.Buff[BuffID.CursedInferno].Value); + if (npc.onFrostBurn) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Frostburn].Value); + if (npc.venom) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Venom].Value); + if (npc.shadowFlame) + currentDebuffs.Add(TextureAssets.Buff[BuffID.ShadowFlame].Value); + if (npc.oiled) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Oiled].Value); + if (npc.javelined) + currentDebuffs.Add(TextureAssets.Buff[BuffID.BoneJavelin].Value); + if (npc.daybreak) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Daybreak].Value); + if (npc.celled) + currentDebuffs.Add(TextureAssets.Buff[BuffID.StardustMinionBleed].Value); + if (npc.dryadBane) + currentDebuffs.Add(TextureAssets.Buff[BuffID.DryadsWardDebuff].Value); + if (npc.dryadWard) + currentDebuffs.Add(TextureAssets.Buff[BuffID.DryadsWard].Value); + if (npc.soulDrain && npc.realLife == -1) + currentDebuffs.Add(TextureAssets.Buff[BuffID.SoulDrain].Value); + if (npc.onFire3) // Hellfire + currentDebuffs.Add(TextureAssets.Buff[BuffID.OnFire3].Value); + if (npc.onFrostBurn2) // Frostbite + currentDebuffs.Add(TextureAssets.Buff[BuffID.Frostburn2].Value); + if (npc.tentacleSpiked) + currentDebuffs.Add(TextureAssets.Buff[BuffID.TentacleSpike].Value); + + // Vanilla stat debuffs + if (npc.confused) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Confused].Value); + if (npc.ichor) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Ichor].Value); + if (slowed > 0) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Slow].Value); + if (webbed > 0) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Webbed].Value); + if (npc.midas) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Midas].Value); + if (npc.loveStruck) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Lovestruck].Value); + if (npc.stinky) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Stinky].Value); + if (npc.betsysCurse) + currentDebuffs.Add(TextureAssets.Buff[BuffID.BetsysCurse].Value); + if (npc.dripping) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Wet].Value); + if (npc.drippingSlime) + currentDebuffs.Add(TextureAssets.Buff[BuffID.Slimed].Value); + if (npc.drippingSparkleSlime) + currentDebuffs.Add(TextureAssets.Buff[BuffID.GelBalloonBuff].Value); + if (npc.markedByScytheWhip) // Dark Harvest whip, the only Whip debuff that has an NPC bool + currentDebuffs.Add(TextureAssets.Buff[BuffID.ScytheWhipEnemyDebuff].Value); + // Total amount of elements in the buff list int buffTextureListLength = currentDebuffs.Count(); @@ -5608,38 +5639,37 @@ namespace CalamityMod.NPCs spriteEffects = SpriteEffects.FlipHorizontally; } - float num66 = 0f; - Vector2 vector11 = new Vector2(TextureAssets.Npc[npc.type].Value.Width / 2, TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2); - Color color9 = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - Color alpha15 = npc.GetAlpha(color9); - float num212 = 0.99f; - alpha15.R = (byte)(alpha15.R * num212); - alpha15.G = (byte)(alpha15.G * num212); - alpha15.B = (byte)(alpha15.B * num212); - alpha15.A = (byte)(alpha15.A * num212); - float xOffset = screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + vector11.X * npc.scale; - float yOffset = screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY; - for (int num213 = 0; num213 < 4; num213++) + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[npc.type].Value.Width / 2, TextureAssets.Npc[npc.type].Value.Height / Main.npcFrameCount[npc.type] / 2); + Color rainbow = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + Color alphaColor = npc.GetAlpha(rainbow); + float RGBMult = 0.99f; + alphaColor.R = (byte)(alphaColor.R * RGBMult); + alphaColor.G = (byte)(alphaColor.G * RGBMult); + alphaColor.B = (byte)(alphaColor.B * RGBMult); + alphaColor.A = (byte)(alphaColor.A * RGBMult); + float xOffset = screenPos.X + npc.width / 2 - TextureAssets.Npc[npc.type].Value.Width * npc.scale / 2f + halfSizeTexture.X * npc.scale; + float yOffset = screenPos.Y + npc.height - TextureAssets.Npc[npc.type].Value.Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + halfSizeTexture.Y * npc.scale + npc.gfxOffY; + for (int i = 0; i < 4; i++) { Vector2 position9 = npc.position; float num214 = Math.Abs(npc.Center.X - Main.LocalPlayer.Center.X); float num215 = Math.Abs(npc.Center.Y - Main.LocalPlayer.Center.Y); - if (num213 == 0 || num213 == 2) + if (i == 0 || i == 2) position9.X = Main.LocalPlayer.Center.X + num214; else position9.X = Main.LocalPlayer.Center.X - num214; position9.X -= npc.width / 2; - if (num213 == 0 || num213 == 1) + if (i == 0 || i == 1) position9.Y = Main.LocalPlayer.Center.Y + num215; else position9.Y = Main.LocalPlayer.Center.Y - num215; position9.Y -= npc.height / 2; - Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - xOffset, position9.Y - yOffset), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Main.spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position9.X - xOffset, position9.Y - yOffset), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alphaColor, npc.rotation, halfSizeTexture, npc.scale, spriteEffects, 0f); } } else diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 87a1085474..20316021c8 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -846,6 +846,16 @@ namespace CalamityMod.NPCs hardmode.Add(ModContent.ItemType()); break; + // Merchant + // 20-30 Gel, 30-50 Rope & 10-15 Bombs @ 100% IF named "Morshu" + case NPCID.Merchant: + LeadingConditionRule morshuLCR = new LeadingConditionRule(DropHelper.If((info) => info.npc.GivenName == "Morshu", false)); + morshuLCR.Add(ItemID.Gel, 1, 20, 30, true); // lamp oil? + morshuLCR.Add(ItemID.Rope, 1, 30, 50, true); // rope? + morshuLCR.Add(ItemID.Bomb, 1, 10, 15, true); // bombs? you want it? + npcLoot.Add(morshuLCR); // it's yours, my friend + break; + // Angler // Golden Fishing Rod @ 100% IF fed to a Trasher // OTHERWISE, diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 62780c8741..d59b915056 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -59,7 +59,6 @@ namespace CalamityMod.NPCs public static int TaxesToCollectLimit => (int)(Item.buyPrice(0, 50, 0, 0) * TaxYieldFactor); - // TODO -- Update all Discord tags here to new Discord usernames. #region Town NPC Patreon Name Sets private static readonly string[] AnglerNames = { @@ -70,18 +69,18 @@ namespace CalamityMod.NPCs { "Drifter", "Finchi", - "Heniek", // <@!363404700445442050> (Kazurgundu#3791) + "Heniek", // <@!363404700445442050> (kazurgundu) "Fire", // <@!354362326947856384> (fire#0692) - "Barney Calhoun", // <@!634462901431697410> (Potato Power#6578) + "Barney Calhoun", // <@!634462901431697410> (potatostego) "XiaoEn0426", // <@!440448864772816896> (XiaoEn0426#9157) "Jeffred", // <@!295362230038560768> (Knight Solaire#0873) - "The Cooler Arthur", // <@!568263512523014154> (better artilery#0001) - "Markie", // <@!291141964039061504> (Markie#6969) + "The Cooler Arthur", // <@!568263512523014154> (gokuartillery) + "Markie", // <@!291141964039061504> (markie_) }; private static readonly string[] ClothierNames = { "Joeseph Jostar", - "Storm Havik", //<@!1013452363178197072> (fishnotduck) + "Storm Havik", // <@!1013452363178197072> (fishnotduck) }; private static readonly string[] CyborgNames = { @@ -89,13 +88,13 @@ namespace CalamityMod.NPCs }; private static readonly string[] DemolitionistNames = { - "Tavish DeGroot", // <@!442447226992721930> (Magicoal#2655) + "Tavish DeGroot", // <@!442447226992721930> (magicoal) }; private static readonly string[] DryadNames = { "Rythmi", "Izuna", - "Jasmine", // <@!430532867479699456> (phantasmagoria#6777) + "Jasmine", // <@!430532867479699456> (phantasmagoria.) "Cybil", // <@!486507232666845185> (Captain Doofus#????) "Ruth", // <@!1001307586068492388> (Briny_Coffee#4393) }; @@ -104,12 +103,12 @@ namespace CalamityMod.NPCs { "Verth", "Gormer", // <@!287651204924833795> (Picasso's Bean#2819 -- RIP) - "TingFlarg", // <@!185605031716847616> (Smug#7160) + "TingFlarg", // <@!185605031716847616> (smugggo) "Driser", // <@!121996994406252544> (Driser#8630) - "Eddie Spaghetti", // <@!466397267407011841> (Eddie Spaghetti#0002) - "G'tok", // <@!335192200956608535> (gtoktas#7589) + "Eddie Spaghetti", // <@!466397267407011841> (nathansfriend) + "G'tok", // <@!335192200956608535> (gtoktas) "Katto", // <@!175972165504466944> (Katto#2858) - "Him", // <@!931019614958256139> (@himtheguy1) + "Him", // <@!931019614958256139> (himtheguy1) "Tooshiboots", // <@!333532730593771522> (ulmod) "Neesh", // <@!175803493464932352> (xjetty) }; @@ -122,12 +121,12 @@ namespace CalamityMod.NPCs "Necroplasmic", "Devin", "Woffle", // <@!185980979427540992> (Chipbeam#2268) - "Cameron", // <@!340401981711712258> (CammyWammy#8634) - "Wilbur", // <@!295171926324805634> (ChaosChaos#5979) - "Good Game Design", // <@!564267767042277385> (Dominic Karma#7777) + "Cameron", // <@!340401981711712258> (cammywammy.) + "Wilbur", // <@!295171926324805634> (all_imperfect_chaos) + "Good Game Design", // <@!564267767042277385> (dominickarma) "Danmaku", // <@!756259562268524555> (Danmaku#2659) "Grylken", // <@!299970404435361802> (Grylken#1569) - "Outlaw", // <@!918311619480657922> (TheChosenOutlaw#8746) + "Outlaw", // <@!918311619480657922> (thechosenoutlaw) "Alfred Rend", // <@!606301806481375255> (Deadsqurp300#0907) "Leeman", // <@!281999243168841728> (Tweee#5831) "Mihai", // <@!373941893467209730> (cmihaii.) @@ -136,23 +135,23 @@ namespace CalamityMod.NPCs private static readonly string[] MechanicNames = { "Lilly", - "Daawn", // <@!206162323541458944> (Daawnily#3859) + "Daawn", // <@!206162323541458944> (daawnily) "Robin", // <@!654737510030639112> (Altzeus#8687) - "Curly", // <@!673092101780668416> (Curly~Brace#4830) + "Curly", // <@!673092101780668416> (curly4830) }; private static readonly string[] MerchantNames = { - "Morshu", // <@!194931581826236416> (Uberransy#6969) + "Morshu", // <@!194931581826236416> (uberransy) }; private static readonly string[] NurseNames = { "Farsni", - "Fanny", // <@!799749125720637460> (zombiewolf511#4581) - "Mausi", // <@!194156349347594241> (Sadouken | Daniel#3996) + "Fanny", // <@!799749125720637460> (zombiewolf511) + "Mausi", // <@!194156349347594241> (sadouken) }; private static readonly string[] PainterNames = { - "Picasso", // <@!353316526306361347> (SCONICBOOM#2164 -- for the late Picasso's Bean#2819) + "Picasso", // <@!353316526306361347> (sconicboom -- for the late Picasso's Bean#2819) }; private static readonly string[] PartyGirlNames = { @@ -161,21 +160,28 @@ namespace CalamityMod.NPCs private static readonly string[] PirateNames = { "Tyler Van Hook", - "Cap'n Deek", // "Alex N" on Patreon - "Captain Billy Bones", // <@!699589229507772416> (DjackV#2882) + "Cap'n Deek", // "Alex N" on Patreon (No discord account) + "Captain Billy Bones", // <@!699589229507772416> (djackv) "Captain J. Crackers", // <@!233232602994049024> (Qyuuno#3031) }; private static readonly string[] PrincessNames = { - "Catalyst", // <@!156672312425316352> (xAqult#1122) - "Nyapano", // <@!120976656826368003> (Emi - Nyapano She/Her#4040) - "Jade", // <@!187395834625785869> (VeryMasterNinja#7728) - "Nyavi Aceso", // <@!270260920888852480> (Navigator#8739) + "Catalyst", // <@!156672312425316352> (xaqult) + "Nyapano", // <@!120976656826368003> (nyapano) + "Jade", // <@!187395834625785869> (verymasterninja) + "Nyavi Aceso", // <@!270260920888852480> (navigator.) + "everquartz", // <@!451343554451865611> (everquartz) + "Gwynevere", // <@!142752927348424704> (nuclearchaosazathoth) + }; + private static readonly string[] SantaClausNames = + { + "Jank", // <@!339950757472239616> (jankle_) }; private static readonly string[] SkeletonMerchantNames = { - "Sans Undertale", // <@!145379091648872450> (Shayy#5257) - "Papyrus Undertale", // <@!262663471189983242> (Nycro#0001) + "Sans Undertale", // <@!145379091648872450> (shayy) + "Papyrus Undertale", // <@!262663471189983242> (nycro) + "Mr. Bones", // <@!359215912856977408> (jaybones.) }; private static readonly string[] SteampunkerNames = { @@ -184,15 +190,15 @@ namespace CalamityMod.NPCs }; private static readonly string[] StylistNames = { - "Amber", // <@!114677116473180169> (Mishiro Usui#1295) - "Faith", // <@!509050283871961123> (Toasty#1007) - "Xsiana", // <@!625780237489143839> (xiana.#0015) + "Amber", // <@!114677116473180169> (mishirousui) + "Faith", // <@!509050283871961123> (toasty1007) + "Xsiana", // <@!625780237489143839> (lokistic) }; private static readonly string[] TavernkeepNames = { - "Tim Lockwood", // <@!605839945483026434> (Deimelo#0001) - "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (Ryaegos#1661) - "Brutus", // <@!591889650692521984> (Brutus#4337) + "Tim Lockwood", // <@!605839945483026434> (pomvoid) + "Sir Samuel Winchester Jenkins Kester II", // <@!107659695749070848> (ryaegos) + "Brutus", // <@!591889650692521984> (.brutus._) "Sloth", // <@!486265327387279391> (BossyPunch#4983) }; private static readonly string[] TaxCollectorNames = @@ -202,7 +208,7 @@ namespace CalamityMod.NPCs private static readonly string[] TravelingMerchantNames = { "Stan Pines", - "Slap Battles", // <@!923504188615450654> (Conquestor#9009) + "Slap Battles", // <@!923504188615450654> (gravityglider.) }; private static readonly string[] TruffleNames = { @@ -212,26 +218,26 @@ namespace CalamityMod.NPCs { "Sok'ar", "Toxin", // <@!348174404984766465> (Toxin#9598), - "Mixcoatl", // <@!284775927294984203> (SharZz#7777) - "Khatunz", // <@!303022375191183360> (jackshiz#7839) - "Amnesia Wapers", // <@!326821498323075073> (Retarded Advice from a Retard#6969) + "Mixcoatl", // <@!284775927294984203> (.sharzz) + "Khatunz", // <@!303022375191183360> (jackshiz) + "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) }; private static readonly string[] WizardNames = { - "Mage One-Trick", // <@!340996105460514816> (pixlgray) - going of off memory on this one + "Mage One-Trick", // <@!340996105460514816> (pixlgray) "Inorim, son of Ivukey", "Jensen", - "Merasmus", // <@!288066987819663360> (Spider pee pee#3328) + "Merasmus", // <@!288066987819663360> (spiderprovidence) "Habolo", // <@!163028025494077441> (ChristmasGoat#7810) - "Ortho", // <@!264984390910738432> (Worcuus#5225) - "Chris Tallballs", // <@!770211589076418571> (Bewearium#1111) - "Syethas", // <@!325413275066171393> (CosmicStarIight#4430) + "Ortho", // <@!264984390910738432> (worcuus) + "Chris Tallballs", // <@!770211589076418571> (bewearium) + "Syethas", // <@!325413275066171393> (cosmicstariight) "Nextdoor Psycho", // <@!173261518572486656> (⋈-NextdoorPsycho-⋈#0001) }; private static readonly string[] ZoologistNames = { "Kiriku", // <@!395312478160027668> (rulosss#6814) - "Lacuna", // <@!790746689211203604> (Lacuna#8629) + "Lacuna", // <@!790746689211203604> (_lacuna_) "Mae Borowski", //<@!219158690433990656> (justakkolite) }; @@ -247,19 +253,19 @@ namespace CalamityMod.NPCs private const int TownDogHuskyVanillaNames = 16; private static readonly string[] TownDogNames = { - "Ozymandias", // <@!146333264871686145> (Ozzatron#0001) + "Ozymandias", // <@!146333264871686145> (ozzatron) }; private static readonly string[] TownDogLabradorNames = { - "Riley", // <@!260875558592708619> (potion pal#9979) + "Riley", // <@!260875558592708619> (potionpal) }; private static readonly string[] TownDogPitBullNames = { - "Splinter", // <@!320320801213775873> (Kaimonick#1738) + "Splinter", // <@!320320801213775873> (kaimonick) }; private static readonly string[] TownDogBeagleNames = { - "Kendra", // <@!237247188005158912> (LordMetarex#6407) + "Kendra", // <@!237247188005158912> (lordmetarex) }; private static readonly string[] TownDogCorgiNames = null; private static readonly string[] TownDogDalmatianNames = null; @@ -276,21 +282,21 @@ namespace CalamityMod.NPCs private const int TownCatWhiteVanillaNames = 15; private static readonly string[] TownCatNames = { - "Smoogle", // <@!709968379334623274> (smoogle#5672) + "Smoogle", // <@!709968379334623274> (smooglin) "The Meowurer of Gods", // <@!385949114271268864> (GP#7876) - "Katsafaros", // <@!190595401328492544> (NavyGuy#2650) + "Katsafaros", // <@!190595401328492544> (gr_mm) "Lucerne", // <@!271954788676141066> (lord_lucerne) "Milo", // <@!401849201597874179> (maskedmilo) - "Octo", // <@!796112889353994281> (OctolingGrimm#8888) + "Octo", // <@!796112889353994281> (octolinggrimm) }; private static readonly string[] TownCatSiameseNames = null; private static readonly string[] TownCatBlackNames = { - "Bear", // <@!183424826407518208> (Lilac Vrt Olligoci#5585) + "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) }; private static readonly string[] TownCatOrangeTabbyNames = { - "Felix" // <@!183424826407518208> (Lilac Vrt Olligoci#5585) + "Felix" // <@!183424826407518208> (lilac_vrt_olligoci) }; private static readonly string[] TownCatRussianBlueNames = null; private static readonly string[] TownCatSilverNames = null; @@ -506,6 +512,9 @@ namespace CalamityMod.NPCs case NPCID.Princess: AddNewNames(nameList, PrincessNames); break; + case NPCID.SantaClaus: + AddNewNames(nameList, SantaClausNames); + break; case NPCID.SkeletonMerchant: AddNewNames(nameList, SkeletonMerchantNames); break; diff --git a/NPCs/CalamityVanillaMinibossesAI.cs b/NPCs/CalamityVanillaMinibossesAI.cs index 6decfe9f1c..9c8bb57cb4 100644 --- a/NPCs/CalamityVanillaMinibossesAI.cs +++ b/NPCs/CalamityVanillaMinibossesAI.cs @@ -468,22 +468,22 @@ namespace CalamityMod.NPCs } else if (npc.ai[3] == 0f && npc.localAI[2] % 30f == 0f && npc.localAI[2] > 30f) { - float num856 = 10f; - Vector2 vector109 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - if (!WorldGen.SolidTile((int)vector109.X / 16, (int)vector109.Y / 16)) + float greekFireSpeed = 10f; + Vector2 greekFireSpawnPos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); + if (!WorldGen.SolidTile((int)greekFireSpawnPos.X / 16, (int)greekFireSpawnPos.Y / 16)) { - float num857 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector109.X; - float num858 = Main.player[npc.target].position.Y - vector109.Y; - num857 += (float)Main.rand.Next(-50, 51); - num858 += (float)Main.rand.Next(50, 201); - num858 *= 0.2f; - float num859 = (float)Math.Sqrt((double)(num857 * num857 + num858 * num858)); - num859 = num856 / num859; - num857 *= num859; - num858 *= num859; - num857 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - num858 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector109.X, vector109.Y, num857, num858, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); + float greekFireTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - greekFireSpawnPos.X; + float greekFireTargetY = Main.player[npc.target].position.Y - greekFireSpawnPos.Y; + greekFireTargetX += (float)Main.rand.Next(-50, 51); + greekFireTargetY += (float)Main.rand.Next(50, 201); + greekFireTargetY *= 0.2f; + float greekFireTargetDist = (float)Math.Sqrt((double)(greekFireTargetX * greekFireTargetX + greekFireTargetY * greekFireTargetY)); + greekFireTargetDist = greekFireSpeed / greekFireTargetDist; + greekFireTargetX *= greekFireTargetDist; + greekFireTargetY *= greekFireTargetDist; + greekFireTargetX *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + greekFireTargetY *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f; + Projectile.NewProjectile(npc.GetSource_FromAI(), greekFireSpawnPos.X, greekFireSpawnPos.Y, greekFireTargetX, greekFireTargetY, ProjectileID.GreekFire1 + Main.rand.Next(3), 60, 0f, Main.myPlayer, 0f, 0f); } } } @@ -493,18 +493,18 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[0] = 1f; - int num861 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num861].ai[0] = -1f; - Main.npc[num861].ai[1] = (float)npc.whoAmI; - Main.npc[num861].target = npc.target; - Main.npc[num861].netUpdate = true; + int pumpkingBlades = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[pumpkingBlades].ai[0] = -1f; + Main.npc[pumpkingBlades].ai[1] = (float)npc.whoAmI; + Main.npc[pumpkingBlades].target = npc.target; + Main.npc[pumpkingBlades].netUpdate = true; - num861 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num861].ai[0] = 1f; - Main.npc[num861].ai[1] = (float)npc.whoAmI; - Main.npc[num861].ai[3] = 150f; - Main.npc[num861].target = npc.target; - Main.npc[num861].netUpdate = true; + pumpkingBlades = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.position.X + (float)(npc.width / 2)), (int)npc.position.Y + npc.height / 2, NPCID.PumpkingBlade, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[pumpkingBlades].ai[0] = 1f; + Main.npc[pumpkingBlades].ai[1] = (float)npc.whoAmI; + Main.npc[pumpkingBlades].ai[3] = 150f; + Main.npc[pumpkingBlades].target = npc.target; + Main.npc[pumpkingBlades].netUpdate = true; } if (Main.player[npc.target].dead || Math.Abs(npc.position.X - Main.player[npc.target].position.X) > 2000f || Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) @@ -539,27 +539,27 @@ namespace CalamityMod.NPCs } } - Vector2 vector110 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num862 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector110.X; - float num863 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector110.Y; - float num864 = (float)Math.Sqrt((double)(num862 * num862 + num863 * num863)); - float num865 = 8f; + Vector2 aggressivePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float aggressiveTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - aggressivePosition.X; + float aggressiveTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - aggressivePosition.Y; + float aggressiveTargetDist = (float)Math.Sqrt((double)(aggressiveTargetX * aggressiveTargetX + aggressiveTargetY * aggressiveTargetY)); + float aggressiveSpeed = 8f; if (npc.ai[3] == 1f) { - if (num864 > 900f) - num865 = 14f; - else if (num864 > 600f) - num865 = 12f; - else if (num864 > 300f) - num865 = 10f; + if (aggressiveTargetDist > 900f) + aggressiveSpeed = 14f; + else if (aggressiveTargetDist > 600f) + aggressiveSpeed = 12f; + else if (aggressiveTargetDist > 300f) + aggressiveSpeed = 10f; } - if (num864 > 50f) + if (aggressiveTargetDist > 50f) { - num864 = num865 / num864; - npc.velocity.X = (npc.velocity.X * 14f + num862 * num864) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + num863 * num864) / 15f; + aggressiveTargetDist = aggressiveSpeed / aggressiveTargetDist; + npc.velocity.X = (npc.velocity.X * 14f + aggressiveTargetX * aggressiveTargetDist) / 15f; + npc.velocity.Y = (npc.velocity.Y * 14f + aggressiveTargetY * aggressiveTargetDist) / 15f; } } else if (npc.ai[1] == 1f) @@ -571,14 +571,14 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; } - Vector2 vector111 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num866 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector111.X; - float num867 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector111.Y; - float num868 = (float)Math.Sqrt((double)(num866 * num866 + num867 * num867)); - num868 = 20f / num868; + Vector2 scytheAttackPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheAttackTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheAttackPosition.X; + float scytheAttackTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheAttackPosition.Y; + float scytheAttackTargetDist = (float)Math.Sqrt((double)(scytheAttackTargetX * scytheAttackTargetX + scytheAttackTargetY * scytheAttackTargetY)); + scytheAttackTargetDist = 20f / scytheAttackTargetDist; - npc.velocity.X = (npc.velocity.X * 49f + num866 * num868) / 50f; - npc.velocity.Y = (npc.velocity.Y * 49f + num867 * num868) / 50f; + npc.velocity.X = (npc.velocity.X * 49f + scytheAttackTargetX * scytheAttackTargetDist) / 50f; + npc.velocity.Y = (npc.velocity.Y * 49f + scytheAttackTargetY * scytheAttackTargetDist) / 50f; } else if (npc.ai[1] == 2f) { @@ -620,17 +620,17 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num869 = 0.01f; - Vector2 vector112 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); - float num870 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector112.X; - float num871 = Main.player[npc.target].position.Y - vector112.Y; - float num872 = (float)Math.Sqrt((double)(num870 * num870 + num871 * num871)); + float scytheProjSpeed = 0.01f; + Vector2 scytheProjSpawn = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f + 30f); + float scytheProjTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - scytheProjSpawn.X; + float scytheProjTargetY = Main.player[npc.target].position.Y - scytheProjSpawn.Y; + float scytheProjTargetDist = (float)Math.Sqrt((double)(scytheProjTargetX * scytheProjTargetX + scytheProjTargetY * scytheProjTargetY)); - num872 = num869 / num872; - num870 *= num872; - num871 *= num872; + scytheProjTargetDist = scytheProjSpeed / scytheProjTargetDist; + scytheProjTargetX *= scytheProjTargetDist; + scytheProjTargetY *= scytheProjTargetDist; - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, num870, num871, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, scytheProjTargetX, scytheProjTargetY, ProjectileID.FlamingScythe, 70, 0f, Main.myPlayer, npc.rotation, (float)npc.spriteDirection); } } @@ -654,53 +654,53 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - Vector2 vector113 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num874 = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; - float num875 = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; - num874 += -170f * npc.ai[0] - vector113.X; - num875 += 90f - vector113.Y; + Vector2 scytheSwipePosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheSwipeTargetX = (Main.player[npc.target].Center.X + Main.npc[(int)npc.ai[1]].Center.X) / 2f; + float scytheSwipeTargetY = (Main.player[npc.target].Center.Y + Main.npc[(int)npc.ai[1]].Center.Y) / 2f; + scytheSwipeTargetX += -170f * npc.ai[0] - scytheSwipePosition.X; + scytheSwipeTargetY += 90f - scytheSwipePosition.Y; - float num876 = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if (num876 > 700f) + float scytheSwipeReelbackDist = Math.Abs(Main.player[npc.target].Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(Main.player[npc.target].Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + if (scytheSwipeReelbackDist > 700f) { - num874 = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - vector113.X; - num875 = Main.npc[(int)npc.ai[1]].Center.Y + 90f - vector113.Y; + scytheSwipeTargetX = Main.npc[(int)npc.ai[1]].Center.X - 170f * npc.ai[0] - scytheSwipePosition.X; + scytheSwipeTargetY = Main.npc[(int)npc.ai[1]].Center.Y + 90f - scytheSwipePosition.Y; } - float num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); - float num878 = 8f; - if (num877 > 1000f) - num878 = 23f; - else if (num877 > 800f) - num878 = 20f; - else if (num877 > 600f) - num878 = 17f; - else if (num877 > 400f) - num878 = 14f; - else if (num877 > 200f) - num878 = 11f; + float scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); + float scytheSwipeSpeed = 8f; + if (scytheSwipeTargetDist > 1000f) + scytheSwipeSpeed = 23f; + else if (scytheSwipeTargetDist > 800f) + scytheSwipeSpeed = 20f; + else if (scytheSwipeTargetDist > 600f) + scytheSwipeSpeed = 17f; + else if (scytheSwipeTargetDist > 400f) + scytheSwipeSpeed = 14f; + else if (scytheSwipeTargetDist > 200f) + scytheSwipeSpeed = 11f; if (npc.ai[0] < 0f && npc.Center.X > Main.npc[(int)npc.ai[1]].Center.X) - num874 -= 4f; + scytheSwipeTargetX -= 4f; if (npc.ai[0] > 0f && npc.Center.X < Main.npc[(int)npc.ai[1]].Center.X) - num874 += 4f; + scytheSwipeTargetX += 4f; - num877 = num878 / num877; - npc.velocity.X = (npc.velocity.X * 14f + num874 * num877) / 15f; - npc.velocity.Y = (npc.velocity.Y * 14f + num875 * num877) / 15f; - num877 = (float)Math.Sqrt((double)(num874 * num874 + num875 * num875)); + scytheSwipeTargetDist = scytheSwipeSpeed / scytheSwipeTargetDist; + npc.velocity.X = (npc.velocity.X * 14f + scytheSwipeTargetX * scytheSwipeTargetDist) / 15f; + npc.velocity.Y = (npc.velocity.Y * 14f + scytheSwipeTargetY * scytheSwipeTargetDist) / 15f; + scytheSwipeTargetDist = (float)Math.Sqrt((double)(scytheSwipeTargetX * scytheSwipeTargetX + scytheSwipeTargetY * scytheSwipeTargetY)); - if (num877 > 20f) - npc.rotation = (float)Math.Atan2((double)num875, (double)num874) + MathHelper.PiOver2; + if (scytheSwipeTargetDist > 20f) + npc.rotation = (float)Math.Atan2((double)scytheSwipeTargetY, (double)scytheSwipeTargetX) + MathHelper.PiOver2; } else if (npc.ai[2] == 1f) { - Vector2 vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num879 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector114.X; - float num880 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector114.Y; - float num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); + Vector2 scytheReturnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheReturnTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - scytheReturnPosition.X; + float scytheReturnTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - scytheReturnPosition.Y; + float scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); - npc.rotation = (float)Math.Atan2((double)num880, (double)num879) + MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2((double)scytheReturnTargetY, (double)scytheReturnTargetX) + MathHelper.PiOver2; npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.3f; @@ -712,32 +712,32 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 2f; - vector114 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num879 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector114.X; - num880 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector114.Y; - num881 = (float)Math.Sqrt((double)(num879 * num879 + num880 * num880)); - num881 = 24f / num881; + scytheReturnPosition = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + scytheReturnTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheReturnPosition.X; + scytheReturnTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheReturnPosition.Y; + scytheReturnTargetDist = (float)Math.Sqrt((double)(scytheReturnTargetX * scytheReturnTargetX + scytheReturnTargetY * scytheReturnTargetY)); + scytheReturnTargetDist = 24f / scytheReturnTargetDist; - npc.velocity.X = num879 * num881; - npc.velocity.Y = num880 * num881; + npc.velocity.X = scytheReturnTargetX * scytheReturnTargetDist; + npc.velocity.Y = scytheReturnTargetY * scytheReturnTargetDist; npc.netUpdate = true; } } else if (npc.ai[2] == 2f) { - float num882 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + float scytheReturnDestination = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || num882 > 800f) + if (npc.position.Y > Main.player[npc.target].position.Y || npc.velocity.Y < 0f || scytheReturnDestination > 800f) npc.ai[2] = 3f; } else if (npc.ai[2] == 4f) { - Vector2 vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num883 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - vector115.X; - float num884 = Main.npc[(int)npc.ai[1]].position.Y + 230f - vector115.Y; - float num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); + Vector2 scytheLesserSwipePos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float scytheLesserSwipeTargetX = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - 200f * npc.ai[0] - scytheLesserSwipePos.X; + float scytheLesserSwipeTargetY = Main.npc[(int)npc.ai[1]].position.Y + 230f - scytheLesserSwipePos.Y; + float scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); - npc.rotation = (float)Math.Atan2((double)num884, (double)num883) + MathHelper.PiOver2; + npc.rotation = (float)Math.Atan2((double)scytheLesserSwipeTargetY, (double)scytheLesserSwipeTargetX) + MathHelper.PiOver2; npc.velocity.Y *= 0.95f; npc.velocity.X += 0.3f * -npc.ai[0]; @@ -751,22 +751,22 @@ namespace CalamityMod.NPCs npc.TargetClosest(true); npc.ai[2] = 5f; - vector115 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num883 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector115.X; - num884 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector115.Y; - num885 = (float)Math.Sqrt((double)(num883 * num883 + num884 * num884)); - num885 = 17f / num885; + scytheLesserSwipePos = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + scytheLesserSwipeTargetX = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - scytheLesserSwipePos.X; + scytheLesserSwipeTargetY = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - scytheLesserSwipePos.Y; + scytheLesserSwipeTargetDist = (float)Math.Sqrt((double)(scytheLesserSwipeTargetX * scytheLesserSwipeTargetX + scytheLesserSwipeTargetY * scytheLesserSwipeTargetY)); + scytheLesserSwipeTargetDist = 17f / scytheLesserSwipeTargetDist; - npc.velocity.X = num883 * num885; - npc.velocity.Y = num884 * num885; + npc.velocity.X = scytheLesserSwipeTargetX * scytheLesserSwipeTargetDist; + npc.velocity.Y = scytheLesserSwipeTargetY * scytheLesserSwipeTargetDist; npc.netUpdate = true; } } else if (npc.ai[2] == 5f) { - float num886 = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); + float scytheLesserSwipeReturnDest = Math.Abs(npc.Center.X - Main.npc[(int)npc.ai[1]].Center.X) + Math.Abs(npc.Center.Y - Main.npc[(int)npc.ai[1]].Center.Y); - if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || num886 > 800f) + if ((npc.velocity.X > 0f && npc.position.X + (float)(npc.width / 2) > Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || (npc.velocity.X < 0f && npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) || scytheLesserSwipeReturnDest > 800f) npc.ai[2] = 0f; } @@ -800,42 +800,41 @@ namespace CalamityMod.NPCs } npc.TargetClosest(true); - int num887 = 800; - float num888 = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); + float iceQueenTargetDist = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); - if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && num888 > (float)num887) + if (npc.Center.X < Main.player[npc.target].Center.X && npc.ai[2] < 0f && iceQueenTargetDist > 800f) npc.ai[2] = 0f; - if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && num888 > (float)num887) + if (npc.Center.X > Main.player[npc.target].Center.X && npc.ai[2] > 0f && iceQueenTargetDist > 800f) npc.ai[2] = 0f; - float num889 = 0.6f; - float num890 = 10f; + float iceQueenAcceleration = 0.6f; + float iceQueenMaxVelocity = 10f; if ((double)npc.life < (double)npc.lifeMax * 0.75) { - num889 = 0.7f; - num890 = 12f; + iceQueenAcceleration = 0.7f; + iceQueenMaxVelocity = 12f; } if ((double)npc.life < (double)npc.lifeMax * 0.5) { - num889 = 0.8f; - num890 = 14f; + iceQueenAcceleration = 0.8f; + iceQueenMaxVelocity = 14f; } if ((double)npc.life < (double)npc.lifeMax * 0.25) { - num889 = 0.95f; - num890 = 16f; + iceQueenAcceleration = 0.95f; + iceQueenMaxVelocity = 16f; } - npc.velocity.X += npc.ai[2] * num889; - if (npc.velocity.X > num890) - npc.velocity.X = num890; - if (npc.velocity.X < -num890) - npc.velocity.X = -num890; + npc.velocity.X += npc.ai[2] * iceQueenAcceleration; + if (npc.velocity.X > iceQueenMaxVelocity) + npc.velocity.X = iceQueenMaxVelocity; + if (npc.velocity.X < -iceQueenMaxVelocity) + npc.velocity.X = -iceQueenMaxVelocity; - float num891 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (num891 < 150f) + float iceQueenHoverHeight = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); + if (iceQueenHoverHeight < 150f) npc.velocity.Y -= 0.2f; - if (num891 > 200f) + if (iceQueenHoverHeight > 200f) npc.velocity.Y += 0.2f; if (npc.velocity.Y > 9f) npc.velocity.Y = 9f; @@ -844,42 +843,42 @@ namespace CalamityMod.NPCs npc.rotation = npc.velocity.X * 0.05f; - if ((num888 < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) + if ((iceQueenTargetDist < 500f || npc.ai[3] < 0f) && npc.position.Y < Main.player[npc.target].position.Y) { npc.ai[3] += 1f; - int num892 = 8; + int frostWaveFireDelay = 8; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num892 = 7; + frostWaveFireDelay = 7; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num892 = 6; + frostWaveFireDelay = 6; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num892 = 5; + frostWaveFireDelay = 5; - num892++; - if (npc.ai[3] > (float)num892) - npc.ai[3] = (float)-(float)num892; + frostWaveFireDelay++; + if (npc.ai[3] > (float)frostWaveFireDelay) + npc.ai[3] = (float)-(float)frostWaveFireDelay; if (npc.ai[3] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 vector116 = new Vector2(npc.Center.X, npc.Center.Y); - vector116.X += npc.velocity.X * 7f; - float num893 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector116.X; - float num894 = Main.player[npc.target].Center.Y - vector116.Y; - float num895 = (float)Math.Sqrt((double)(num893 * num893 + num894 * num894)); + Vector2 frostWavePosition = new Vector2(npc.Center.X, npc.Center.Y); + frostWavePosition.X += npc.velocity.X * 7f; + float frostWaveTargetX = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - frostWavePosition.X; + float frostWaveTargetY = Main.player[npc.target].Center.Y - frostWavePosition.Y; + float frostWaveTargetDist = (float)Math.Sqrt((double)(frostWaveTargetX * frostWaveTargetX + frostWaveTargetY * frostWaveTargetY)); - float num896 = 8f; + float frostWaveSpeed = 8f; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num896 = 9f; + frostWaveSpeed = 9f; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num896 = 10f; + frostWaveSpeed = 10f; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num896 = 11f; + frostWaveSpeed = 11f; - num895 = num896 / num895; - num893 *= num895; - num894 *= num895; + frostWaveTargetDist = frostWaveSpeed / frostWaveTargetDist; + frostWaveTargetX *= frostWaveTargetDist; + frostWaveTargetY *= frostWaveTargetDist; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector116.X, vector116.Y, num893, num894, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), frostWavePosition.X, frostWavePosition.Y, frostWaveTargetX, frostWaveTargetY, ProjectileID.FrostWave, 50, 0f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[3] < 0f) @@ -889,7 +888,7 @@ namespace CalamityMod.NPCs { npc.ai[1] += (float)Main.rand.Next(1, 4); - if (npc.ai[1] > 600f && num888 < 600f) + if (npc.ai[1] > 600f && iceQueenTargetDist < 600f) npc.ai[0] = -1f; } } @@ -897,45 +896,45 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); - float num898 = 0.2f; - float num899 = 10f; + float icicleAttackAcceleration = 0.2f; + float icicleAttackMaxVelocity = 10f; if ((double)npc.life < (double)npc.lifeMax * 0.75) { - num898 = 0.24f; - num899 = 12f; + icicleAttackAcceleration = 0.24f; + icicleAttackMaxVelocity = 12f; } if ((double)npc.life < (double)npc.lifeMax * 0.5) { - num898 = 0.28f; - num899 = 14f; + icicleAttackAcceleration = 0.28f; + icicleAttackMaxVelocity = 14f; } if ((double)npc.life < (double)npc.lifeMax * 0.25) { - num898 = 0.32f; - num899 = 16f; + icicleAttackAcceleration = 0.32f; + icicleAttackMaxVelocity = 16f; } - num898 -= 0.05f; - num899 -= 1f; + icicleAttackAcceleration -= 0.05f; + icicleAttackMaxVelocity -= 1f; if (npc.Center.X < Main.player[npc.target].Center.X) { - npc.velocity.X += num898; + npc.velocity.X += icicleAttackAcceleration; if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; } if (npc.Center.X > Main.player[npc.target].Center.X) { - npc.velocity.X -= num898; + npc.velocity.X -= icicleAttackAcceleration; if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; } - if (npc.velocity.X > num899 || npc.velocity.X < -num899) + if (npc.velocity.X > icicleAttackMaxVelocity || npc.velocity.X < -icicleAttackMaxVelocity) npc.velocity.X *= 0.95f; - float num900 = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); - if (num900 < 180f) + float icicleAttackHoverHeight = Main.player[npc.target].position.Y - (npc.position.Y + (float)npc.height); + if (icicleAttackHoverHeight < 180f) npc.velocity.Y -= 0.1f; - if (num900 > 200f) + if (icicleAttackHoverHeight > 200f) npc.velocity.Y += 0.1f; if (npc.velocity.Y > 7f) @@ -948,33 +947,33 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[3] += 1f; - int num901 = 10; + int icicleFireDelay = 10; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num901 = 8; + icicleFireDelay = 8; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num901 = 6; + icicleFireDelay = 6; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num901 = 4; + icicleFireDelay = 4; if ((double)npc.life < (double)npc.lifeMax * 0.1) - num901 = 2; + icicleFireDelay = 2; - num901 += 3; - if (npc.ai[3] >= (float)num901) + icicleFireDelay += 3; + if (npc.ai[3] >= (float)icicleFireDelay) { npc.ai[3] = 0f; - Vector2 vector117 = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); - int i2 = (int)(vector117.X / 16f); - int j2 = (int)(vector117.Y / 16f); + Vector2 icicleSpawnPos = new Vector2(npc.Center.X, npc.position.Y + (float)npc.height - 14f); + int i2 = (int)(icicleSpawnPos.X / 16f); + int j2 = (int)(icicleSpawnPos.Y / 16f); if (!WorldGen.SolidTile(i2, j2)) { - float num902 = npc.velocity.Y; + float icicleFallSpeed = npc.velocity.Y; - if (num902 < 0f) - num902 = 0f; + if (icicleFallSpeed < 0f) + icicleFallSpeed = 0f; - num902 += 3f; + icicleFallSpeed += 3f; float speedX2 = npc.velocity.X * 0.25f; - Projectile.NewProjectile(npc.GetSource_FromAI(), vector117.X, vector117.Y, speedX2, num902, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); + Projectile.NewProjectile(npc.GetSource_FromAI(), icicleSpawnPos.X, icicleSpawnPos.Y, speedX2, icicleFallSpeed, ProjectileID.FrostShard, 44, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f); } } } @@ -991,35 +990,35 @@ namespace CalamityMod.NPCs { npc.TargetClosest(true); - Vector2 vector118 = new Vector2(npc.Center.X, npc.Center.Y - 20f); - float num904 = (float)Main.rand.Next(-1000, 1001); - float num905 = (float)Main.rand.Next(-1000, 1001); - float num906 = (float)Math.Sqrt((double)(num904 * num904 + num905 * num905)); - float num907 = 20f; + Vector2 iceRainPosition = new Vector2(npc.Center.X, npc.Center.Y - 20f); + float iceRainXVel = (float)Main.rand.Next(-1000, 1001); + float iceRainYVel = (float)Main.rand.Next(-1000, 1001); + float iceRainVelocity = (float)Math.Sqrt((double)(iceRainXVel * iceRainXVel + iceRainYVel * iceRainYVel)); + float iceRainSpeed = 20f; npc.velocity *= 0.95f; - num906 = num907 / num906; - num904 *= num906; - num905 *= num906; + iceRainVelocity = iceRainSpeed / iceRainVelocity; + iceRainXVel *= iceRainVelocity; + iceRainYVel *= iceRainVelocity; npc.rotation += 0.2f; - vector118.X += num904 * 4f; - vector118.Y += num905 * 4f; + iceRainPosition.X += iceRainXVel * 4f; + iceRainPosition.Y += iceRainYVel * 4f; npc.ai[3] += 1f; - int num908 = 7; + int iceRainFireDelay = 7; if ((double)npc.life < (double)npc.lifeMax * 0.75) - num908--; + iceRainFireDelay--; if ((double)npc.life < (double)npc.lifeMax * 0.5) - num908 -= 2; + iceRainFireDelay -= 2; if ((double)npc.life < (double)npc.lifeMax * 0.25) - num908 -= 3; + iceRainFireDelay -= 3; if ((double)npc.life < (double)npc.lifeMax * 0.1) - num908 -= 4; + iceRainFireDelay -= 4; - if (npc.ai[3] > (float)num908) + if (npc.ai[3] > (float)iceRainFireDelay) { npc.ai[3] = 0f; - int num909 = Projectile.NewProjectile(npc.GetSource_FromAI(), vector118.X, vector118.Y, num904, num905, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); + int iceRainAttack = Projectile.NewProjectile(npc.GetSource_FromAI(), iceRainPosition.X, iceRainPosition.Y, iceRainXVel, iceRainYVel, ProjectileID.FrostShard, 40, 0f, Main.myPlayer, 0f, 0f); } if (Main.netMode != NetmodeID.MultiplayerClient) @@ -1032,13 +1031,13 @@ namespace CalamityMod.NPCs } if (npc.ai[0] == -1f) { - int num910 = Main.rand.Next(3); + int attackPicker = Main.rand.Next(3); npc.TargetClosest(true); if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 1000f) - num910 = 0; + attackPicker = 0; - npc.ai[0] = (float)num910; + npc.ai[0] = (float)attackPicker; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; diff --git a/NPCs/Crags/Scryllar.cs b/NPCs/Crags/Scryllar.cs index 2c6c0a48f5..01b59b4993 100644 --- a/NPCs/Crags/Scryllar.cs +++ b/NPCs/Crags/Scryllar.cs @@ -67,35 +67,35 @@ namespace CalamityMod.NPCs.Crags { NPC.rotation = NPC.velocity.X * 0.04f; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - bool flag19 = false; + bool hoverDownDistCheck = false; if (NPC.justHit) { NPC.ai[2] = 0f; } if (NPC.ai[2] >= 0f) { - int num282 = 16; - bool flag21 = false; - bool flag22 = false; - if (NPC.position.X > NPC.ai[0] - (float)num282 && NPC.position.X < NPC.ai[0] + (float)num282) + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (NPC.position.X > NPC.ai[0] - (float)hoverDistance && NPC.position.X < NPC.ai[0] + (float)hoverDistance) { - flag21 = true; + changeDirectionX = true; } else if ((NPC.velocity.X < 0f && NPC.direction > 0) || (NPC.velocity.X > 0f && NPC.direction < 0)) { - flag21 = true; + changeDirectionX = true; } - num282 += 24; - if (NPC.position.Y > NPC.ai[1] - (float)num282 && NPC.position.Y < NPC.ai[1] + (float)num282) + hoverDistance += 24; + if (NPC.position.Y > NPC.ai[1] - (float)hoverDistance && NPC.position.Y < NPC.ai[1] + (float)hoverDistance) { - flag22 = true; + changeDirectionY = true; } - if (flag21 && flag22) + if (changeDirectionX && changeDirectionY) { NPC.ai[2] += 1f; - if (NPC.ai[2] >= 30f && num282 == 16) + if (NPC.ai[2] >= 30f && hoverDistance == 16) { - flag19 = true; + hoverDownDistCheck = true; } if (NPC.ai[2] >= 60f) { @@ -118,36 +118,36 @@ namespace CalamityMod.NPCs.Crags NPC.TargetClosest(true); NPC.ai[2] += 2f; } - int num283 = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; - int num284 = (int)((NPC.position.Y + (float)NPC.height) / 16f); - bool flag23 = true; - int num285 = 3; - for (int num308 = num284; num308 < num284 + num285; num308++) + int npcTileX = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; + int npcTileY = (int)((NPC.position.Y + (float)NPC.height) / 16f); + bool hoverDownwards = true; + int tileCheckLoopAmt = 3; + for (int loopInc1 = npcTileY; loopInc1 < npcTileY + tileCheckLoopAmt; loopInc1++) { - if ((Main.tile[num283, num308].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num308].TileType]) || Main.tile[num283, num308].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc1].TileType]) || Main.tile[npcTileX, loopInc1].LiquidAmount > 0) { - flag23 = false; + hoverDownwards = false; break; } } if (Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - bool flag25 = false; - for (int num309 = num284; num309 < num284 + num285 - 2; num309++) + bool inTileNoAggro = false; + for (int loopInc2 = npcTileY; loopInc2 < npcTileY + tileCheckLoopAmt - 2; loopInc2++) { - if ((Main.tile[num283, num309].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num309].TileType]) || Main.tile[num283, num309].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc2].TileType]) || Main.tile[npcTileX, loopInc2].LiquidAmount > 0) { - flag25 = true; + inTileNoAggro = true; break; } } - NPC.directionY = (!flag25).ToDirectionInt(); + NPC.directionY = (!inTileNoAggro).ToDirectionInt(); } - if (flag19) + if (hoverDownDistCheck) { - flag23 = true; + hoverDownwards = true; } - if (flag23) + if (hoverDownwards) { NPC.velocity.Y = NPC.velocity.Y + 0.1f; if (NPC.velocity.Y > 3f) @@ -190,11 +190,11 @@ namespace CalamityMod.NPCs.Crags NPC.velocity.Y = -1f; } } - float num311 = 4f; - if (NPC.direction == -1 && NPC.velocity.X > -num311) + float maxXVelocity = 4f; + if (NPC.direction == -1 && NPC.velocity.X > -maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; } @@ -202,15 +202,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X + 0.05f; } - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { - NPC.velocity.X = -num311; + NPC.velocity.X = -maxXVelocity; } } - else if (NPC.direction == 1 && NPC.velocity.X < num311) + else if (NPC.direction == 1 && NPC.velocity.X < maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; } @@ -218,16 +218,16 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X - 0.05f; } - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { - NPC.velocity.X = num311; + NPC.velocity.X = maxXVelocity; } } - num311 = 1.5f; - if (NPC.directionY == -1 && NPC.velocity.Y > -num311) + maxXVelocity = 1.5f; + if (NPC.directionY == -1 && NPC.velocity.Y > -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.04f; - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.05f; } @@ -235,15 +235,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y + 0.03f; } - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { - NPC.velocity.Y = -num311; + NPC.velocity.Y = -maxXVelocity; } } - else if (NPC.directionY == 1 && NPC.velocity.Y < num311) + else if (NPC.directionY == 1 && NPC.velocity.Y < maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.04f; - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.05f; } @@ -251,9 +251,9 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y - 0.03f; } - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { - NPC.velocity.Y = num311; + NPC.velocity.Y = maxXVelocity; } } } diff --git a/NPCs/Crags/ScryllarRage.cs b/NPCs/Crags/ScryllarRage.cs index 5657aa505d..25025b69e0 100644 --- a/NPCs/Crags/ScryllarRage.cs +++ b/NPCs/Crags/ScryllarRage.cs @@ -49,35 +49,35 @@ namespace CalamityMod.NPCs.Crags { NPC.rotation = NPC.velocity.X * 0.04f; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - bool flag19 = false; + bool hoverDownDistCheck = false; if (NPC.justHit) { NPC.ai[2] = 0f; } if (NPC.ai[2] >= 0f) { - int num282 = 16; - bool flag21 = false; - bool flag22 = false; - if (NPC.position.X > NPC.ai[0] - (float)num282 && NPC.position.X < NPC.ai[0] + (float)num282) + int hoverDistance = 16; + bool changeDirectionX = false; + bool changeDirectionY = false; + if (NPC.position.X > NPC.ai[0] - (float)hoverDistance && NPC.position.X < NPC.ai[0] + (float)hoverDistance) { - flag21 = true; + changeDirectionX = true; } else if ((NPC.velocity.X < 0f && NPC.direction > 0) || (NPC.velocity.X > 0f && NPC.direction < 0)) { - flag21 = true; + changeDirectionX = true; } - num282 += 24; - if (NPC.position.Y > NPC.ai[1] - (float)num282 && NPC.position.Y < NPC.ai[1] + (float)num282) + hoverDistance += 24; + if (NPC.position.Y > NPC.ai[1] - (float)hoverDistance && NPC.position.Y < NPC.ai[1] + (float)hoverDistance) { - flag22 = true; + changeDirectionY = true; } - if (flag21 && flag22) + if (changeDirectionX && changeDirectionY) { NPC.ai[2] += 1f; - if (NPC.ai[2] >= 30f && num282 == 16) + if (NPC.ai[2] >= 30f && hoverDistance == 16) { - flag19 = true; + hoverDownDistCheck = true; } if (NPC.ai[2] >= 60f) { @@ -100,36 +100,36 @@ namespace CalamityMod.NPCs.Crags NPC.TargetClosest(true); NPC.ai[2] += 2f; } - int num283 = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; - int num284 = (int)((NPC.position.Y + (float)NPC.height) / 16f); - bool flag23 = true; - int num285 = 3; - for (int num308 = num284; num308 < num284 + num285; num308++) + int npcTileX = (int)((NPC.position.X + (float)(NPC.width / 2)) / 16f) + NPC.direction * 2; + int npcTileY = (int)((NPC.position.Y + (float)NPC.height) / 16f); + bool hoverDownwards = true; + int tileCheckLoopAmt = 3; + for (int loopInc1 = npcTileY; loopInc1 < npcTileY + tileCheckLoopAmt; loopInc1++) { - if ((Main.tile[num283, num308].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num308].TileType]) || Main.tile[num283, num308].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc1].TileType]) || Main.tile[npcTileX, loopInc1].LiquidAmount > 0) { - flag23 = false; + hoverDownwards = false; break; } } if (Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - bool flag25 = false; - for (int num309 = num284; num309 < num284 + num285 - 2; num309++) + bool inTileNoAggro = false; + for (int loopInc2 = npcTileY; loopInc2 < npcTileY + tileCheckLoopAmt - 2; loopInc2++) { - if ((Main.tile[num283, num309].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num283, num309].TileType]) || Main.tile[num283, num309].LiquidAmount > 0) + if ((Main.tile[npcTileX, loopInc2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, loopInc2].TileType]) || Main.tile[npcTileX, loopInc2].LiquidAmount > 0) { - flag25 = true; + inTileNoAggro = true; break; } } - NPC.directionY = (!flag25).ToDirectionInt(); + NPC.directionY = (!inTileNoAggro).ToDirectionInt(); } - if (flag19) + if (hoverDownDistCheck) { - flag23 = true; + hoverDownwards = true; } - if (flag23) + if (hoverDownwards) { NPC.velocity.Y = NPC.velocity.Y + 0.1f; if (NPC.velocity.Y > 3f) @@ -172,11 +172,11 @@ namespace CalamityMod.NPCs.Crags NPC.velocity.Y = -1f; } } - float num311 = 7f; - if (NPC.direction == -1 && NPC.velocity.X > -num311) + float maxXVelocity = 7f; + if (NPC.direction == -1 && NPC.velocity.X > -maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { NPC.velocity.X = NPC.velocity.X - 0.1f; } @@ -184,15 +184,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X + 0.05f; } - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { - NPC.velocity.X = -num311; + NPC.velocity.X = -maxXVelocity; } } - else if (NPC.direction == 1 && NPC.velocity.X < num311) + else if (NPC.direction == 1 && NPC.velocity.X < maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; - if (NPC.velocity.X < -num311) + if (NPC.velocity.X < -maxXVelocity) { NPC.velocity.X = NPC.velocity.X + 0.1f; } @@ -200,16 +200,16 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.X = NPC.velocity.X - 0.05f; } - if (NPC.velocity.X > num311) + if (NPC.velocity.X > maxXVelocity) { - NPC.velocity.X = num311; + NPC.velocity.X = maxXVelocity; } } - num311 = 1.5f; - if (NPC.directionY == -1 && NPC.velocity.Y > -num311) + maxXVelocity = 1.5f; + if (NPC.directionY == -1 && NPC.velocity.Y > -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.04f; - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y - 0.05f; } @@ -217,15 +217,15 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y + 0.03f; } - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { - NPC.velocity.Y = -num311; + NPC.velocity.Y = -maxXVelocity; } } - else if (NPC.directionY == 1 && NPC.velocity.Y < num311) + else if (NPC.directionY == 1 && NPC.velocity.Y < maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.04f; - if (NPC.velocity.Y < -num311) + if (NPC.velocity.Y < -maxXVelocity) { NPC.velocity.Y = NPC.velocity.Y + 0.05f; } @@ -233,9 +233,9 @@ namespace CalamityMod.NPCs.Crags { NPC.velocity.Y = NPC.velocity.Y - 0.03f; } - if (NPC.velocity.Y > num311) + if (NPC.velocity.Y > maxXVelocity) { - NPC.velocity.Y = num311; + NPC.velocity.Y = maxXVelocity; } } } diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index 72d8388085..4647877849 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -75,36 +75,36 @@ namespace CalamityMod.NPCs.Crags { NPC.TargetClosest(true); } - float num = 5f; - float num2 = 0.07f; - Vector2 source = NPC.Center; - float num4 = target.Center.X; - float num5 = target.Center.Y; - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); - source.X = (float)((int)(source.X / 8f) * 8); - source.Y = (float)((int)(source.Y / 8f) * 8); - num4 -= source.X; - num5 -= source.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - float num7 = num6; - bool flag = false; - if (num6 > 600f) + float npcSpeed = 5f; + float npcAcceleration = 0.07f; + Vector2 npcCenter = NPC.Center; + float targetX = target.Center.X; + float targetY = target.Center.Y; + targetX = (float)((int)(targetX / 8f) * 8); + targetY = (float)((int)(targetY / 8f) * 8); + npcCenter.X = (float)((int)(npcCenter.X / 8f) * 8); + npcCenter.Y = (float)((int)(npcCenter.Y / 8f) * 8); + targetX -= npcCenter.X; + targetY -= npcCenter.Y; + float targetDistance = (float)Math.Sqrt((double)(targetX * targetX + targetY * targetY)); + float accelerateDistance = targetDistance; + bool tooFar = false; + if (targetDistance > 600f) { - flag = true; + tooFar = true; } - if (num6 == 0f) + if (targetDistance == 0f) { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; + targetX = NPC.velocity.X; + targetY = NPC.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = npcSpeed / targetDistance; + targetX *= targetDistance; + targetY *= targetDistance; } - if (num7 > 100f) + if (accelerateDistance > 100f) { NPC.ai[0] += 1f; if (NPC.ai[0] > 0f) @@ -130,24 +130,24 @@ namespace CalamityMod.NPCs.Crags } if (target.dead) { - num4 = (float)NPC.direction * num / 2f; - num5 = -num / 2f; + targetX = (float)NPC.direction * npcSpeed / 2f; + targetY = -npcSpeed / 2f; } - if (NPC.velocity.X < num4) + if (NPC.velocity.X < targetX) { - NPC.velocity.X += num2; + NPC.velocity.X += npcAcceleration; } - else if (NPC.velocity.X > num4) + else if (NPC.velocity.X > targetX) { - NPC.velocity.X -= num2; + NPC.velocity.X -= npcAcceleration; } - if (NPC.velocity.Y < num5) + if (NPC.velocity.Y < targetY) { - NPC.velocity.Y += num2; + NPC.velocity.Y += npcAcceleration; } - else if (NPC.velocity.Y > num5) + else if (NPC.velocity.Y > targetY) { - NPC.velocity.Y -= num2; + NPC.velocity.Y -= npcAcceleration; } NPC.localAI[0] += 1f; if (NPC.justHit) @@ -165,32 +165,32 @@ namespace CalamityMod.NPCs.Crags dmg = 22; } int projType = ModContent.ProjectileType(); - Projectile.NewProjectile(NPC.GetSource_FromAI(), source.X, source.Y, num4, num5, projType, dmg + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcCenter.X, npcCenter.Y, targetX, targetY, projType, dmg + (provy ? 30 : 0), 0f, Main.myPlayer, 1f, 0f); } } - int num10 = (int)NPC.Center.X; - int num11 = (int)NPC.Center.Y; - num10 /= 16; - num11 /= 16; - if (!WorldGen.SolidTile(num10, num11)) + int npcTileX = (int)NPC.Center.X; + int npcTileY = (int)NPC.Center.Y; + npcTileX /= 16; + npcTileY /= 16; + if (!WorldGen.SolidTile(npcTileX, npcTileY)) { Lighting.AddLight((int)NPC.Center.X / 16, (int)NPC.Center.Y / 16, 0.75f, 0f, 0f); } - if (num4 > 0f) + if (targetX > 0f) { NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4); + NPC.rotation = (float)Math.Atan2((double)targetY, (double)targetX); } - if (num4 < 0f) + if (targetX < 0f) { NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4) + MathHelper.Pi; + NPC.rotation = (float)Math.Atan2((double)targetY, (double)targetX) + MathHelper.Pi; } - float num12 = 0.7f; + float recoilSpeed = 0.7f; if (NPC.collideX) { NPC.netUpdate = true; - NPC.velocity.X = NPC.oldVelocity.X * -num12; + NPC.velocity.X = NPC.oldVelocity.X * -recoilSpeed; if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) { NPC.velocity.X = 2f; @@ -203,7 +203,7 @@ namespace CalamityMod.NPCs.Crags if (NPC.collideY) { NPC.netUpdate = true; - NPC.velocity.Y = NPC.oldVelocity.Y * -num12; + NPC.velocity.Y = NPC.oldVelocity.Y * -recoilSpeed; if (NPC.velocity.Y > 0f && NPC.velocity.Y < 1.5f) { NPC.velocity.Y = 2f; @@ -213,9 +213,9 @@ namespace CalamityMod.NPCs.Crags NPC.velocity.Y = -2f; } } - if (flag) + if (tooFar) { - if ((NPC.velocity.X > 0f && num4 > 0f) || (NPC.velocity.X < 0f && num4 < 0f)) + if ((NPC.velocity.X > 0f && targetX > 0f) || (NPC.velocity.X < 0f && targetX < 0f)) { if (Math.Abs(NPC.velocity.X) < 12f) { @@ -240,49 +240,47 @@ namespace CalamityMod.NPCs.Crags spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(texture.Width / 2), (float)(texture.Height / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture = ModContent.Request("CalamityMod/NPCs/Crags/SoulSlurperGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redGlow = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + Color glowmaskAfterimageColor = redGlow; + glowmaskAfterimageColor = Color.Lerp(glowmaskAfterimageColor, Color.White, 0.5f); + glowmaskAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 glowmaskAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + glowmaskAfterimagePos -= new Vector2((float)texture.Width, (float)(texture.Height)) * NPC.scale / 2f; + glowmaskAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, glowmaskAfterimagePos, NPC.frame, glowmaskAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); } } - spriteBatch.Draw(texture, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); + spriteBatch.Draw(texture, drawLocation, NPC.frame, redGlow, NPC.rotation, halfSizeTexture, NPC.scale, NPC.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); return false; } @@ -325,23 +323,23 @@ namespace CalamityMod.NPCs.Crags NPC.height = 50; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 10; num621++) + for (int i = 0; i < 10; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int brimDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[brimDust].scale = 0.5f; + Main.dust[brimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 20; num623++) + for (int j = 0; j < 20; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); + Main.dust[brimDust2].noGravity = true; + Main.dust[brimDust2].velocity *= 5f; + brimDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + Main.dust[brimDust2].velocity *= 2f; } } } diff --git a/NPCs/Cryogen/CryogenShield.cs b/NPCs/Cryogen/CryogenShield.cs index b751db94af..4c07fcb1a8 100644 --- a/NPCs/Cryogen/CryogenShield.cs +++ b/NPCs/Cryogen/CryogenShield.cs @@ -1,5 +1,4 @@ -using System; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -156,6 +155,7 @@ namespace CalamityMod.NPCs.Cryogen } } + // Don't count towards NPC limit and don't despawn offscreen. public override bool CheckActive() => false; public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/GreatSandShark/GreatSandShark.cs b/NPCs/GreatSandShark/GreatSandShark.cs index c7ce1f87e5..4298f8a3d5 100644 --- a/NPCs/GreatSandShark/GreatSandShark.cs +++ b/NPCs/GreatSandShark/GreatSandShark.cs @@ -140,33 +140,33 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.netUpdate = true; } - int num2 = expertMode ? 35 : 50; - float num3 = expertMode ? 0.5f : 0.42f; - float scaleFactor = expertMode ? 7.5f : 6.7f; - int num4 = expertMode ? 28 : 30; - float num5 = expertMode ? 15.5f : 14f; + int chargeTime = expertMode ? 35 : 50; + float chargeAcceleration = expertMode ? 0.5f : 0.42f; + float chargeThreshold = expertMode ? 7.5f : 6.7f; + int chargeDelay = expertMode ? 28 : 30; + float chargeVelocity = expertMode ? 15.5f : 14f; if (revenge || lowerLife) { - num3 *= 1.1f; - scaleFactor *= 1.1f; - num5 *= 1.1f; + chargeAcceleration *= 1.1f; + chargeThreshold *= 1.1f; + chargeVelocity *= 1.1f; } if (death) { - num3 *= 1.1f; - scaleFactor *= 1.1f; - num5 *= 1.1f; - num4 = 25; + chargeAcceleration *= 1.1f; + chargeThreshold *= 1.1f; + chargeVelocity *= 1.1f; + chargeDelay = 25; } if (youMustDie) { - num3 *= 1.5f; - scaleFactor *= 1.5f; - num5 *= 1.5f; - num4 = 20; + chargeAcceleration *= 1.5f; + chargeThreshold *= 1.5f; + chargeVelocity *= 1.5f; + chargeDelay = 20; } - Vector2 vector = NPC.Center; + Vector2 shorkCenter = NPC.Center; Player player = Main.player[NPC.target]; if (NPC.target < 0 || NPC.target == Main.maxPlayers || player.dead || !player.active) @@ -176,7 +176,7 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.netUpdate = true; } - if (player.dead || Vector2.Distance(player.Center, vector) > 5600f) + if (player.dead || Vector2.Distance(player.Center, shorkCenter) > 5600f) { NPC.velocity.Y += 0.4f; if (NPC.timeLeft > 10) @@ -186,82 +186,82 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.ai[2] = 0f; } - float num17 = (float)Math.Atan2(player.Center.Y - vector.Y, player.Center.X - vector.X); + float getRotatedIdiot = (float)Math.Atan2(player.Center.Y - shorkCenter.Y, player.Center.X - shorkCenter.X); if (NPC.spriteDirection == 1) - num17 += MathHelper.Pi; - if (num17 < 0f) - num17 += MathHelper.TwoPi; - if (num17 > MathHelper.TwoPi) - num17 -= MathHelper.TwoPi; + getRotatedIdiot += MathHelper.Pi; + if (getRotatedIdiot < 0f) + getRotatedIdiot += MathHelper.TwoPi; + if (getRotatedIdiot > MathHelper.TwoPi) + getRotatedIdiot -= MathHelper.TwoPi; - float num18 = 0.04f; + float rotationSpeed = 0.04f; if (NPC.ai[0] == 1f) - num18 = 0f; + rotationSpeed = 0f; - if (NPC.rotation < num17) + if (NPC.rotation < getRotatedIdiot) { - if ((double)(num17 - NPC.rotation) > MathHelper.Pi) - NPC.rotation -= num18; + if ((double)(getRotatedIdiot - NPC.rotation) > MathHelper.Pi) + NPC.rotation -= rotationSpeed; else - NPC.rotation += num18; + NPC.rotation += rotationSpeed; } - if (NPC.rotation > num17) + if (NPC.rotation > getRotatedIdiot) { - if ((double)(NPC.rotation - num17) > MathHelper.Pi) - NPC.rotation += num18; + if ((double)(NPC.rotation - getRotatedIdiot) > MathHelper.Pi) + NPC.rotation += rotationSpeed; else - NPC.rotation -= num18; + NPC.rotation -= rotationSpeed; } - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) - NPC.rotation = num17; + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) + NPC.rotation = getRotatedIdiot; if (NPC.rotation < 0f) NPC.rotation += MathHelper.TwoPi; if (NPC.rotation > MathHelper.TwoPi) NPC.rotation -= MathHelper.TwoPi; - if (NPC.rotation > num17 - num18 && NPC.rotation < num17 + num18) - NPC.rotation = num17; + if (NPC.rotation > getRotatedIdiot - rotationSpeed && NPC.rotation < getRotatedIdiot + rotationSpeed) + NPC.rotation = getRotatedIdiot; if (NPC.ai[0] == 0f && !player.dead) { if (NPC.ai[1] == 0f) - NPC.ai[1] = 300 * Math.Sign((vector - player.Center).X); + NPC.ai[1] = 300 * Math.Sign((shorkCenter - player.Center).X); - Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - vector - NPC.velocity) * scaleFactor; - if (NPC.velocity.X < vector3.X) + Vector2 chargeDirection = Vector2.Normalize(player.Center + new Vector2(NPC.ai[1], -200f) - shorkCenter - NPC.velocity) * chargeThreshold; + if (NPC.velocity.X < chargeDirection.X) { - NPC.velocity.X += num3; - if (NPC.velocity.X < 0f && vector3.X > 0f) - NPC.velocity.X += num3; + NPC.velocity.X += chargeAcceleration; + if (NPC.velocity.X < 0f && chargeDirection.X > 0f) + NPC.velocity.X += chargeAcceleration; } - else if (NPC.velocity.X > vector3.X) + else if (NPC.velocity.X > chargeDirection.X) { - NPC.velocity.X -= num3; - if (NPC.velocity.X > 0f && vector3.X < 0f) - NPC.velocity.X -= num3; + NPC.velocity.X -= chargeAcceleration; + if (NPC.velocity.X > 0f && chargeDirection.X < 0f) + NPC.velocity.X -= chargeAcceleration; } - if (NPC.velocity.Y < vector3.Y) + if (NPC.velocity.Y < chargeDirection.Y) { - NPC.velocity.Y += num3; - if (NPC.velocity.Y < 0f && vector3.Y > 0f) - NPC.velocity.Y += num3; + NPC.velocity.Y += chargeAcceleration; + if (NPC.velocity.Y < 0f && chargeDirection.Y > 0f) + NPC.velocity.Y += chargeAcceleration; } - else if (NPC.velocity.Y > vector3.Y) + else if (NPC.velocity.Y > chargeDirection.Y) { - NPC.velocity.Y -= num3; - if (NPC.velocity.Y > 0f && vector3.Y < 0f) - NPC.velocity.Y -= num3; + NPC.velocity.Y -= chargeAcceleration; + if (NPC.velocity.Y > 0f && chargeDirection.Y < 0f) + NPC.velocity.Y -= chargeAcceleration; } - int num22 = Math.Sign(player.Center.X - vector.X); - if (num22 != 0) + int shorkFaceDirection = Math.Sign(player.Center.X - shorkCenter.X); + if (shorkFaceDirection != 0) { - if (NPC.ai[2] == 0f && num22 != NPC.direction) + if (NPC.ai[2] == 0f && shorkFaceDirection != NPC.direction) NPC.rotation += MathHelper.Pi; - NPC.direction = num22; + NPC.direction = shorkFaceDirection; if (NPC.spriteDirection != -NPC.direction) NPC.rotation += MathHelper.Pi; @@ -269,17 +269,17 @@ namespace CalamityMod.NPCs.GreatSandShark } NPC.ai[2] += 1f; - if (NPC.ai[2] >= num2) + if (NPC.ai[2] >= chargeTime) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; - NPC.velocity = Vector2.Normalize(player.Center - vector) * num5; + NPC.velocity = Vector2.Normalize(player.Center - shorkCenter) * chargeVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - if (num22 != 0) + if (shorkFaceDirection != 0) { - NPC.direction = num22; + NPC.direction = shorkFaceDirection; if (NPC.spriteDirection == 1) NPC.rotation += MathHelper.Pi; @@ -293,7 +293,7 @@ namespace CalamityMod.NPCs.GreatSandShark else if (NPC.ai[0] == 1f) { NPC.ai[2] += 1f; - if (NPC.ai[2] >= num4) + if (NPC.ai[2] >= chargeDelay) { NPC.localAI[3] += 1f; if (NPC.localAI[3] >= 2f) @@ -313,15 +313,15 @@ namespace CalamityMod.NPCs.GreatSandShark if (NPC.direction == 0) NPC.TargetClosest(); - Point point15 = NPC.Center.ToTileCoordinates(); - Tile tileSafely = Framing.GetTileSafely(point15); - bool flag121 = tileSafely.HasUnactuatedTile || tileSafely.LiquidAmount > 0; - bool flag122 = false; + Point shorkTileCenter = NPC.Center.ToTileCoordinates(); + Tile tileSafely = Framing.GetTileSafely(shorkTileCenter); + bool isInSolidTile = tileSafely.HasUnactuatedTile || tileSafely.LiquidAmount > 0; + bool shouldDoLunge = false; NPC.TargetClosest(false); - Vector2 vector260 = NPC.targetRect.Center.ToVector2(); - if (Main.player[NPC.target].velocity.Y > -0.1f && !Main.player[NPC.target].dead && NPC.Distance(vector260) > 150f) - flag122 = true; + Vector2 targetLungeDirection = NPC.targetRect.Center.ToVector2(); + if (Main.player[NPC.target].velocity.Y > -0.1f && !Main.player[NPC.target].dead && NPC.Distance(targetLungeDirection) > 150f) + shouldDoLunge = true; NPC.localAI[1] += 1f; @@ -365,25 +365,24 @@ namespace CalamityMod.NPCs.GreatSandShark NPC.netUpdate = true; } - if (NPC.localAI[0] == -1f && !flag121) + if (NPC.localAI[0] == -1f && !isInSolidTile) NPC.localAI[0] = 20f; if (NPC.localAI[0] > 0f) NPC.localAI[0] -= 1f; - if (flag121) + if (isInSolidTile) { - float num1534 = NPC.ai[1]; - bool flag123 = false; - point15 = (NPC.Center + new Vector2(0f, 24f)).ToTileCoordinates(); - tileSafely = Framing.GetTileSafely(point15.X, point15.Y - 2); + bool lungeShouldDecelerate = false; + shorkTileCenter = (NPC.Center + new Vector2(0f, 24f)).ToTileCoordinates(); + tileSafely = Framing.GetTileSafely(shorkTileCenter.X, shorkTileCenter.Y - 2); if (tileSafely.HasUnactuatedTile) - flag123 = true; + lungeShouldDecelerate = true; - NPC.ai[1] = flag123.ToInt(); + NPC.ai[1] = lungeShouldDecelerate.ToInt(); if (NPC.ai[2] < 30f) NPC.ai[2] += 1f; - if (flag122) + if (shouldDoLunge) { NPC.TargetClosest(); NPC.velocity.X += NPC.direction * 0.15f; @@ -417,34 +416,34 @@ namespace CalamityMod.NPCs.GreatSandShark } NPC.velocity.X = MathHelper.Clamp(NPC.velocity.X, -velocityX, velocityX); NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y, -velocityY, velocityY); - Vector2 vec4 = NPC.Center + NPC.velocity.SafeNormalize(Vector2.Zero) * NPC.Size.Length() / 2f + NPC.velocity; - point15 = vec4.ToTileCoordinates(); - tileSafely = Framing.GetTileSafely(point15); - bool flag124 = tileSafely.HasUnactuatedTile; - if (!flag124 && Math.Sign(NPC.velocity.X) == NPC.direction && (NPC.Distance(vector260) < 600f || youMustDie) && (NPC.ai[2] >= 30f || NPC.ai[2] < 0f)) + Vector2 shorkDirection = NPC.Center + NPC.velocity.SafeNormalize(Vector2.Zero) * NPC.Size.Length() / 2f + NPC.velocity; + shorkTileCenter = shorkDirection.ToTileCoordinates(); + tileSafely = Framing.GetTileSafely(shorkTileCenter); + bool isInTile = tileSafely.HasUnactuatedTile; + if (!isInTile && Math.Sign(NPC.velocity.X) == NPC.direction && (NPC.Distance(targetLungeDirection) < 600f || youMustDie) && (NPC.ai[2] >= 30f || NPC.ai[2] < 0f)) { if (NPC.localAI[0] == 0f) { SoundEngine.PlaySound(SoundID.NPCDeath15, NPC.position); NPC.localAI[0] = -1f; - for (int num621 = 0; num621 < 25; num621++) + for (int i = 0; i < 25; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 32, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity.Y *= 6f; - Main.dust[num622].velocity.X *= 3f; + int burrowDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 32, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust].velocity.Y *= 6f; + Main.dust[burrowDust].velocity.X *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[burrowDust].scale = 0.5f; + Main.dust[burrowDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 50; num623++) + for (int j = 0; j < 50; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 85, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity.Y *= 10f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 268, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity.X *= 2f; + int burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 85, 0f, 0f, 100, default, 3f); + Main.dust[burrowDust2].noGravity = true; + Main.dust[burrowDust2].velocity.Y *= 10f; + burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 268, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust2].velocity.X *= 2f; } int spawnX = (int)(NPC.width / 2); int projType = Main.zenithWorld ? ModContent.ProjectileType() : ModContent.ProjectileType(); @@ -454,34 +453,34 @@ namespace CalamityMod.NPCs.GreatSandShark } NPC.ai[2] = -30f; - Vector2 upwardChargeDirection = NPC.SafeDirectionTo(vector260 + new Vector2(0f, -80f), -Vector2.UnitY); + Vector2 upwardChargeDirection = NPC.SafeDirectionTo(targetLungeDirection + new Vector2(0f, -80f), -Vector2.UnitY); NPC.velocity = upwardChargeDirection * 18f; } } else { - float num1535 = 6f; + float decelerationXThreshold = 6f; NPC.velocity.X += NPC.direction * 0.1f; - if (NPC.velocity.X < -num1535 || NPC.velocity.X > num1535) + if (NPC.velocity.X < -decelerationXThreshold || NPC.velocity.X > decelerationXThreshold) NPC.velocity.X *= 0.95f; - if (flag123) + if (lungeShouldDecelerate) NPC.ai[0] = -1f; else NPC.ai[0] = 1f; - float num1536 = 0.06f; - float num1537 = 0.01f; + float decelerationYThreshold = 0.06f; + float decelerationAmt = 0.01f; if (NPC.ai[0] == -1f) { - NPC.velocity.Y -= num1537; - if (NPC.velocity.Y < -num1536) + NPC.velocity.Y -= decelerationAmt; + if (NPC.velocity.Y < -decelerationYThreshold) NPC.ai[0] = 1f; } else { - NPC.velocity.Y += num1537; - if (NPC.velocity.Y > num1536) + NPC.velocity.Y += decelerationAmt; + if (NPC.velocity.Y > decelerationYThreshold) NPC.ai[0] = -1f; } @@ -493,12 +492,12 @@ namespace CalamityMod.NPCs.GreatSandShark { if (NPC.velocity.Y == 0f) { - if (flag122) + if (shouldDoLunge) NPC.TargetClosest(); - float num1538 = 1f; + float smallDecelerationXThreshold = 1f; NPC.velocity.X += NPC.direction * 0.1f; - if (NPC.velocity.X < -num1538 || NPC.velocity.X > num1538) + if (NPC.velocity.X < -smallDecelerationXThreshold || NPC.velocity.X > smallDecelerationXThreshold) NPC.velocity.X *= 0.95f; } @@ -587,46 +586,44 @@ namespace CalamityMod.NPCs.GreatSandShark { spriteEffects = SpriteEffects.FlipHorizontally; } - Color color24 = NPC.GetAlpha(drawColor); - Color color25 = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); + Color mainAfterimageColor = NPC.GetAlpha(drawColor); + Color extraAfterimageColor = Lighting.GetColor((int)((double)NPC.position.X + (double)NPC.width * 0.5) / 16, (int)(((double)NPC.position.Y + (double)NPC.height * 0.5) / 16.0)); if (Main.zenithWorld) { - color24 = Color.Silver; - color25 = Color.Orange; + mainAfterimageColor = Color.Silver; + extraAfterimageColor = Color.Orange; } Texture2D texture2D3 = TextureAssets.Npc[NPC.type].Value; - int num156 = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; - int y3 = num156 * (int)NPC.frameCounter; - Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); - Vector2 origin2 = rectangle.Size() / 2f; - int num157 = 8; - int num158 = 2; - int num159 = 1; - float num160 = 0f; - int num161 = num159; - while (((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) && CalamityConfig.Instance.Afterimages) + int currentFrame = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + int y3 = currentFrame * (int)NPC.frameCounter; + Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, currentFrame); + Vector2 halfRectSize = rectangle.Size() / 2f; + int eightConst = 8; + int afterimageInc = 2; + int afterimageCounter = 1; + while (((afterimageInc > 0 && afterimageCounter < eightConst) || (afterimageInc < 0 && afterimageCounter > eightConst)) && CalamityConfig.Instance.Afterimages) { - Color color26 = NPC.GetAlpha(color25); + Color alphaAfterimageColor = NPC.GetAlpha(extraAfterimageColor); { goto IL_6899; } IL_6881: - num161 += num158; + afterimageCounter += afterimageInc; continue; IL_6899: - float num164 = (float)(num157 - num161); - if (num158 < 0) + float afterimagesRemaining = (float)(eightConst - afterimageCounter); + if (afterimageInc < 0) { - num164 = (float)(num159 - num161); + afterimagesRemaining = (float)(1 - afterimageCounter); } - color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); - Vector2 value4 = NPC.oldPos[num161]; - float num165 = NPC.rotation; - Main.spriteBatch.Draw(texture2D3, value4 + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + NPC.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, NPC.scale, spriteEffects, 0f); + alphaAfterimageColor *= afterimagesRemaining / ((float)NPCID.Sets.TrailCacheLength[NPC.type] * 1.5f); + Vector2 afterimagePos = NPC.oldPos[afterimageCounter]; + float afterimageRotation = NPC.rotation; + Main.spriteBatch.Draw(texture2D3, afterimagePos + NPC.Size / 2f - screenPos + new Vector2(0, NPC.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), alphaAfterimageColor, afterimageRotation + NPC.rotation * 0f * (float)(afterimageCounter - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), halfRectSize, NPC.scale, spriteEffects, 0f); goto IL_6881; } var something = NPC.direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, color24, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); + spriteBatch.Draw(texture2D3, NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY), NPC.frame, mainAfterimageColor, NPC.rotation, NPC.frame.Size() / 2, NPC.scale, something, 0); return false; } @@ -646,23 +643,23 @@ namespace CalamityMod.NPCs.GreatSandShark } if (NPC.life <= 0) { - for (int num621 = 0; num621 < 50; num621++) + for (int i = 0; i < 50; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int burrowDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[burrowDust].scale = 0.5f; + Main.dust[burrowDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 100; num623++) + for (int j = 0; j < 100; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 3f); + Main.dust[burrowDust2].noGravity = true; + Main.dust[burrowDust2].velocity *= 5f; + burrowDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 5, 0f, 0f, 100, default, 2f); + Main.dust[burrowDust2].velocity *= 2f; } } } diff --git a/NPCs/NormalNPCs/ArmoredDiggerBody.cs b/NPCs/NormalNPCs/ArmoredDiggerBody.cs index 7b5e104bf5..0a3b9e0fb0 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerBody.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerBody.cs @@ -57,16 +57,16 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.TargetClosest(true); } - bool flag = false; + bool shouldDie = false; if (NPC.ai[1] <= 0f) { - flag = true; + shouldDie = true; } else if (Main.npc[(int)NPC.ai[1]].life <= 0) { - flag = true; + shouldDie = true; } - if (flag) + if (shouldDie) { if (!Main.zenithWorld) { @@ -87,7 +87,7 @@ namespace CalamityMod.NPCs.NormalNPCs break; } } - // if it goes through the loop withuot finding an npc to attatch to (aka, ai[1] never changes and the head is still dead) kill as normal + // if it goes through the loop without finding an npc to attatch to (aka, ai[1] never changes and the head is still dead) kill as normal if (Main.npc[(int)NPC.ai[1]].life <= 0) { NPC.life = 0; @@ -107,51 +107,50 @@ namespace CalamityMod.NPCs.NormalNPCs Main.player[NPC.target].width, Main.player[NPC.target].height)) { float speed = 7f; - Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float num6 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); - float num7 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; - int num9 = 30; - int num10 = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.SaucerScrap; - vector.X += num6 * 5f; - vector.Y += num7 * 5f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector.X, vector.Y, num6, num7, num10, num9, 0f, Main.myPlayer, 0f, 0f); + Vector2 projFirePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); + float projTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - projFirePosition.X + (float)Main.rand.Next(-20, 21); + float projTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - projFirePosition.Y + (float)Main.rand.Next(-20, 21); + float projTargetDist = (float)Math.Sqrt((double)(projTargetX * projTargetX + projTargetY * projTargetY)); + projTargetDist = speed / projTargetDist; + projTargetX *= projTargetDist; + projTargetY *= projTargetDist; + int projType = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.SaucerScrap; + projFirePosition.X += projTargetX * 5f; + projFirePosition.Y += projTargetY * 5f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), projFirePosition.X, projFirePosition.Y, projTargetX, projTargetY, projType, 30, 0f, Main.myPlayer, 0f, 0f); NPC.netUpdate = true; } } } - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num20 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector3.X; - num21 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector3.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)Math.Atan2((double)num21, (double)num20) + 1.57f; - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - int num23 = (int)(44f * NPC.scale); - num22 = (num22 - (float)num23) / num22; - num20 *= num22; - num21 *= num22; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = (int)(44f * NPC.scale); + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num20; - NPC.position.Y = NPC.position.Y + num21; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; } } diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index c9edca6759..a97631312d 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -96,90 +96,90 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = (float)NPC.whoAmI; NPC.realLife = NPC.whoAmI; - int num2 = NPC.whoAmI; - int num3 = 30; - for (int j = 0; j <= num3; j++) + int thisSegment = NPC.whoAmI; + int segmentAmt = 30; + for (int j = 0; j <= segmentAmt; j++) { - int num4 = ModContent.NPCType(); - if (j == num3) + int segmentType = ModContent.NPCType(); + if (j == segmentAmt) { - num4 = ModContent.NPCType(); + segmentType = ModContent.NPCType(); } - int num5 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), num4, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); - Main.npc[num5].ai[3] = (float)NPC.whoAmI; - Main.npc[num5].realLife = NPC.whoAmI; - Main.npc[num5].ai[1] = (float)num2; - Main.npc[num2].ai[0] = (float)num5; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, num5, 0f, 0f, 0f, 0, 0, 0); - num2 = num5; + int newSegment = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (float)(NPC.width / 2)), (int)(NPC.position.Y + (float)NPC.height), segmentType, NPC.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[newSegment].ai[3] = (float)NPC.whoAmI; + Main.npc[newSegment].realLife = NPC.whoAmI; + Main.npc[newSegment].ai[1] = (float)thisSegment; + Main.npc[thisSegment].ai[0] = (float)newSegment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, newSegment, 0f, 0f, 0f, 0, 0, 0); + thisSegment = newSegment; } TailSpawned = true; } } - int num12 = (int)(NPC.position.X / 16f) - 1; - int num13 = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; - int num14 = (int)(NPC.position.Y / 16f) - 1; - int num15 = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; - if (num12 < 0) + int tileXPosition = (int)(NPC.position.X / 16f) - 1; + int tileWidthXPos = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; + int tileYPosition = (int)(NPC.position.Y / 16f) - 1; + int tileWidthYPos = (int)((NPC.position.Y + (float)NPC.height) / 16f) + 2; + if (tileXPosition < 0) { - num12 = 0; + tileXPosition = 0; } - if (num13 > Main.maxTilesX) + if (tileWidthXPos > Main.maxTilesX) { - num13 = Main.maxTilesX; + tileWidthXPos = Main.maxTilesX; } - if (num14 < 0) + if (tileYPosition < 0) { - num14 = 0; + tileYPosition = 0; } - if (num15 > Main.maxTilesY) + if (tileWidthYPos > Main.maxTilesY) { - num15 = Main.maxTilesY; + tileWidthYPos = Main.maxTilesY; } - bool flag2 = false; - if (!flag2) + bool flying = false; + if (!flying) { - for (int k = num12; k < num13; k++) + for (int k = tileXPosition; k < tileWidthXPos; k++) { - for (int l = num14; l < num15; l++) + for (int l = tileYPosition; l < tileWidthYPos; l++) { if (Main.tile[k, l] != null && ((Main.tile[k, l].HasUnactuatedTile && (Main.tileSolid[(int)Main.tile[k, l].TileType] || (Main.tileSolidTop[(int)Main.tile[k, l].TileType] && Main.tile[k, l].TileFrameY == 0))) || Main.tile[k, l].LiquidAmount > 64)) { - Vector2 vector2; - vector2.X = (float)(k * 16); - vector2.Y = (float)(l * 16); - if (NPC.position.X + (float)NPC.width > vector2.X && NPC.position.X < vector2.X + 16f && NPC.position.Y + (float)NPC.height > vector2.Y && NPC.position.Y < vector2.Y + 16f) + Vector2 segmentPos; + segmentPos.X = (float)(k * 16); + segmentPos.Y = (float)(l * 16); + if (NPC.position.X + (float)NPC.width > segmentPos.X && NPC.position.X < segmentPos.X + 16f && NPC.position.Y + (float)NPC.height > segmentPos.Y && NPC.position.Y < segmentPos.Y + 16f) { - flag2 = true; + flying = true; break; } } } } } - if (!flag2) + if (!flying) { NPC.localAI[1] = 1f; Rectangle rectangle = new Rectangle((int)NPC.position.X, (int)NPC.position.Y, NPC.width, NPC.height); - int num16 = 1000; - bool flag3 = true; + int noFlyZone = 1000; + bool outsideNoFlyZone = true; if (NPC.position.Y > Main.player[NPC.target].position.Y) { for (int m = 0; m < 255; m++) { if (Main.player[m].active) { - Rectangle rectangle2 = new Rectangle((int)Main.player[m].position.X - num16, (int)Main.player[m].position.Y - num16, num16 * 2, num16 * 2); - if (rectangle.Intersects(rectangle2)) + Rectangle noFlyArea = new Rectangle((int)Main.player[m].position.X - noFlyZone, (int)Main.player[m].position.Y - noFlyZone, noFlyZone * 2, noFlyZone * 2); + if (rectangle.Intersects(noFlyArea)) { - flag3 = false; + outsideNoFlyZone = false; break; } } } - if (flag3) + if (outsideNoFlyZone) { - flag2 = true; + flying = true; } } } @@ -187,15 +187,15 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[1] = 0f; } - float num17 = death ? 13.5f : 10f; + float fallSpeed = death ? 13.5f : 10f; if (Main.player[NPC.target].dead || (!Main.zenithWorld && (double)Main.player[NPC.target].position.Y < Main.rockLayer * 16.0)) { - flag2 = false; + flying = false; NPC.velocity.Y = NPC.velocity.Y + 1f; if ((double)NPC.position.Y > Main.rockLayer * 16.0) { NPC.velocity.Y = NPC.velocity.Y + 1f; - num17 = death ? 27f : 20f; + fallSpeed = death ? 27f : 20f; } if ((double)NPC.position.Y > (double)((Main.maxTilesY - 200) * 16)) { @@ -209,57 +209,57 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - float num18 = death ? 0.0675f : 0.05f; - float num19 = death ? 0.10125f : 0.075f; - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - if (!flag2) + float acceleration = death ? 0.0675f : 0.05f; + float deceleration = death ? 0.10125f : 0.075f; + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (!flying) { NPC.TargetClosest(true); NPC.velocity.Y = NPC.velocity.Y + 0.15f; - if (NPC.velocity.Y > num17) + if (NPC.velocity.Y > fallSpeed) { - NPC.velocity.Y = num17; + NPC.velocity.Y = fallSpeed; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.4) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.4) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - acceleration * 1.1f; } else { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; } } - else if (NPC.velocity.Y == num17) + else if (NPC.velocity.Y == fallSpeed) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + acceleration; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - acceleration; } } else if (NPC.velocity.Y > 4f) { if (NPC.velocity.X < 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X + acceleration * 0.9f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 0.9f; + NPC.velocity.X = NPC.velocity.X - acceleration * 0.9f; } } } @@ -267,131 +267,131 @@ namespace CalamityMod.NPCs.NormalNPCs { if (NPC.soundDelay == 0) { - float num24 = num22 / 40f; - if (num24 < 10f) + float soundDelay = targetDistance / 40f; + if (soundDelay < 10f) { - num24 = 10f; + soundDelay = 10f; } - if (num24 > 20f) + if (soundDelay > 20f) { - num24 = 20f; + soundDelay = 20f; } - NPC.soundDelay = (int)num24; + NPC.soundDelay = (int)soundDelay; SoundEngine.PlaySound(SoundID.WormDig, NPC.Center); } - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - float num25 = Math.Abs(num20); - float num26 = Math.Abs(num21); - float num27 = num17 / num22; - num20 *= num27; - num21 *= num27; - if (((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f)) && ((NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f))) + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float absoluteTargetX = Math.Abs(targetXDist); + float absoluteTargetY = Math.Abs(targetYDist); + float timeToReachTarget = fallSpeed / targetDistance; + targetXDist *= timeToReachTarget; + targetYDist *= timeToReachTarget; + if (((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f)) && ((NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f))) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num19; + NPC.velocity.X = NPC.velocity.X + deceleration; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num19; + NPC.velocity.X = NPC.velocity.X - deceleration; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num19; + NPC.velocity.Y = NPC.velocity.Y + deceleration; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num19; + NPC.velocity.Y = NPC.velocity.Y - deceleration; } } - if ((NPC.velocity.X > 0f && num20 > 0f) || (NPC.velocity.X < 0f && num20 < 0f) || (NPC.velocity.Y > 0f && num21 > 0f) || (NPC.velocity.Y < 0f && num21 < 0f)) + if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f)) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + acceleration; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - acceleration; } - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + acceleration; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - acceleration; } - if ((double)Math.Abs(num21) < (double)num17 * 0.2 && ((NPC.velocity.X > 0f && num20 < 0f) || (NPC.velocity.X < 0f && num20 > 0f))) + if ((double)Math.Abs(targetYDist) < (double)fallSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y + acceleration * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num18 * 2f; + NPC.velocity.Y = NPC.velocity.Y - acceleration * 2f; } } - if ((double)Math.Abs(num20) < (double)num17 * 0.2 && ((NPC.velocity.Y > 0f && num21 < 0f) || (NPC.velocity.Y < 0f && num21 > 0f))) + if ((double)Math.Abs(targetXDist) < (double)fallSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18 * 2f; + NPC.velocity.X = NPC.velocity.X + acceleration * 2f; } else { - NPC.velocity.X = NPC.velocity.X - num18 * 2f; + NPC.velocity.X = NPC.velocity.X - acceleration * 2f; } } } - else if (num25 > num26) + else if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num20) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X + acceleration * 1.1f; } - else if (NPC.velocity.X > num20) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num18 * 1.1f; + NPC.velocity.X = NPC.velocity.X - acceleration * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num18; + NPC.velocity.Y = NPC.velocity.Y + acceleration; } else { - NPC.velocity.Y = NPC.velocity.Y - num18; + NPC.velocity.Y = NPC.velocity.Y - acceleration; } } } else { - if (NPC.velocity.Y < num21) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + acceleration * 1.1f; } - else if (NPC.velocity.Y > num21) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num18 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - acceleration * 1.1f; } - if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)num17 * 0.5) + if ((double)(Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y)) < (double)fallSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num18; + NPC.velocity.X = NPC.velocity.X + acceleration; } else { - NPC.velocity.X = NPC.velocity.X - num18; + NPC.velocity.X = NPC.velocity.X - acceleration; } } } } NPC.rotation = (float)Math.Atan2((double)NPC.velocity.Y, (double)NPC.velocity.X) + 1.57f; - if (flag2) + if (flying) { if (NPC.localAI[0] != 1f) { diff --git a/NPCs/NormalNPCs/ArmoredDiggerTail.cs b/NPCs/NormalNPCs/ArmoredDiggerTail.cs index cad5a06399..bb5027f029 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerTail.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerTail.cs @@ -56,50 +56,50 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.TargetClosest(true); } - bool flag = false; + bool shouldDie = false; if (NPC.ai[1] <= 0f) { - flag = true; + shouldDie = true; } else if (Main.npc[(int)NPC.ai[1]].life <= 0) { - flag = true; + shouldDie = true; } - if (flag && !Main.zenithWorld) + if (shouldDie && !Main.zenithWorld) { NPC.life = 0; NPC.HitEffect(0, 10.0); NPC.checkDead(); } - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num20 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num21 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num20 = (float)((int)(num20 / 16f) * 16); - num21 = (float)((int)(num21 / 16f) * 16); - vector3.X = (float)((int)(vector3.X / 16f) * 16); - vector3.Y = (float)((int)(vector3.Y / 16f) * 16); - num20 -= vector3.X; - num21 -= vector3.Y; - float num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num20 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector3.X; - num21 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector3.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)Math.Atan2((double)num21, (double)num20) + 1.57f; - num22 = (float)Math.Sqrt((double)(num20 * num20 + num21 * num21)); - int num23 = (int)(44f * NPC.scale); - num22 = (num22 - (float)num23) / num22; - num20 *= num22; - num21 *= num22; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = (int)(44f * NPC.scale); + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num20; - NPC.position.Y = NPC.position.Y + num21; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; } } diff --git a/NPCs/NormalNPCs/AuroraSpirit.cs b/NPCs/NormalNPCs/AuroraSpirit.cs index a09381ee88..da912b3ae0 100644 --- a/NPCs/NormalNPCs/AuroraSpirit.cs +++ b/NPCs/NormalNPCs/AuroraSpirit.cs @@ -53,12 +53,12 @@ namespace CalamityMod.NPCs.NormalNPCs public override void FindFrame(int frameHeight) { - int num1 = 1; + int currentFrame = 1; if (!Main.dedServ) { if (TextureAssets.Npc[NPC.type].Value == null) return; - num1 = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; + currentFrame = TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type]; } if (!NPC.IsABestiaryIconDummy) @@ -77,10 +77,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.frameCounter++; if (NPC.frameCounter > 4) { - NPC.frame.Y += num1; + NPC.frame.Y += currentFrame; NPC.frameCounter = 0; } - if (NPC.frame.Y / num1 >= Main.npcFrameCount[NPC.type]) + if (NPC.frame.Y / currentFrame >= Main.npcFrameCount[NPC.type]) NPC.frame.Y = 0; } diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index ec2b9f159a..650c200b5d 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -95,22 +95,22 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[NPC.target]; bool expertMode = Main.expertMode; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - float num823 = 1f; + float movementSpeed = 1f; NPC.TargetClosest(true); - bool flag51 = false; + bool stopMoving = false; int offsetX = 80; int projectileDamage = expertMode ? 9 : 12; if (NPC.life < NPC.lifeMax * 0.33 && CalamityWorld.death) { - num823 = 2f; + movementSpeed = 2f; } if (NPC.life < NPC.lifeMax * 0.1 && CalamityWorld.death) { - num823 = 4f; + movementSpeed = 4f; } if (Main.zenithWorld) { - num823 = 8f; + movementSpeed = 8f; } if (NPC.ai[0] == 0f) { @@ -143,22 +143,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 1f) { - flag51 = true; + stopMoving = true; NPC.ai[1] += 1f; if (NPC.ai[1] % 30f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num829 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num830 = Main.player[NPC.target].position.Y - vector18.Y; - float num831 = (float)Math.Sqrt(num829 * num829 + num830 * num830); - float num832 = 6f; - num831 = num832 / num831; - num829 *= num831; - num830 *= num831; - num829 *= 1f + Main.rand.Next(-10, 11) * 0.01f; - num830 *= 1f + Main.rand.Next(-10, 11) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num829, num830, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float waterSpeed = 6f; + targetDistance = waterSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist *= 1f + Main.rand.Next(-10, 11) * 0.01f; + targetYDist *= 1f + Main.rand.Next(-10, 11) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 120f) { @@ -168,22 +168,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 2f) { - flag51 = true; + stopMoving = true; NPC.ai[1] += 1f; if (NPC.ai[1] > 60f && NPC.ai[1] < 240f && NPC.ai[1] % 16f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num829 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num830 = Main.player[NPC.target].position.Y - vector18.Y; - float num831 = (float)Math.Sqrt(num829 * num829 + num830 * num830); - float num832 = 8f; - num831 = num832 / num831; - num829 *= num831; - num830 *= num831; - num829 *= 1f + Main.rand.Next(-15, 16) * 0.01f; - num830 *= 1f + Main.rand.Next(-15, 16) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num829, num830, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float waterSpeed = 8f; + targetDistance = waterSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist *= 1f + Main.rand.Next(-15, 16) * 0.01f; + targetYDist *= 1f + Main.rand.Next(-15, 16) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 300f) { @@ -193,22 +193,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 3f) { - num823 = 4f; + movementSpeed = 4f; NPC.ai[1] += 1f; if (NPC.ai[1] % 30f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num844 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num845 = Main.player[NPC.target].position.Y - vector18.Y; - float num846 = (float)Math.Sqrt(num844 * num844 + num845 * num845); - float num847 = 10f; - num846 = num847 / num846; - num844 *= num846; - num845 *= num846; - num844 *= 1f + Main.rand.Next(-10, 11) * 0.001f; - num845 *= 1f + Main.rand.Next(-10, 11) * 0.001f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num844, num845, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float fastTargetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float fastTargetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float fastTargetDistance = (float)Math.Sqrt(fastTargetXDist * fastTargetXDist + fastTargetYDist * fastTargetYDist); + float fastWaterSpeed = 10f; + fastTargetDistance = fastWaterSpeed / fastTargetDistance; + fastTargetXDist *= fastTargetDistance; + fastTargetYDist *= fastTargetDistance; + fastTargetXDist *= 1f + Main.rand.Next(-10, 11) * 0.001f; + fastTargetYDist *= 1f + Main.rand.Next(-10, 11) * 0.001f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, fastTargetXDist, fastTargetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 120f) { @@ -218,22 +218,22 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 4f) { - num823 = 4f; + movementSpeed = 4f; NPC.ai[1] += 1f; if (NPC.ai[1] % 20f == 0f) { - Vector2 vector18 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); - vector18.X += offsetX * NPC.direction; - float num829 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - vector18.X; - float num830 = Main.player[NPC.target].position.Y - vector18.Y; - float num831 = (float)Math.Sqrt(num829 * num829 + num830 * num830); - float num832 = 11f; - num831 = num832 / num831; - num829 *= num831; - num830 *= num831; - num829 *= 1f + Main.rand.Next(-5, 6) * 0.01f; - num830 *= 1f + Main.rand.Next(-5, 6) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector18.X, vector18.Y, num829, num830, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); + Vector2 npcPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + 20f); + npcPosition.X += offsetX * NPC.direction; + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - npcPosition.X; + float targetYDist = Main.player[NPC.target].position.Y - npcPosition.Y; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + float waterSpeed = 11f; + targetDistance = waterSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + targetXDist *= 1f + Main.rand.Next(-5, 6) * 0.01f; + targetYDist *= 1f + Main.rand.Next(-5, 6) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPosition.X, npcPosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer); } if (NPC.ai[1] >= 240f) { @@ -243,9 +243,9 @@ namespace CalamityMod.NPCs.NormalNPCs } if (Math.Abs(NPC.Center.X - player.Center.X) < 50f) - flag51 = true; + stopMoving = true; - if (flag51) + if (stopMoving) { NPC.velocity.X *= 0.9f; if (NPC.velocity.X > -0.1 && NPC.velocity.X < 0.1) @@ -257,9 +257,9 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.direction = playerLocation < 0 ? 1 : -1; if (NPC.direction > 0) - NPC.velocity.X = (NPC.velocity.X * 20f + num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f + movementSpeed) / 21f; if (NPC.direction < 0) - NPC.velocity.X = (NPC.velocity.X * 20f - num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f - movementSpeed) / 21f; } if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.Center, 1, 1) && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && player.position.Y <= NPC.position.Y + NPC.height && !NPC.collideX) @@ -272,10 +272,10 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.noGravity = true; NPC.noTileCollide = true; - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(NPC.Center.X - (num854 / 2), NPC.position.Y + NPC.height - num855); - if (Collision.SolidCollision(position2, num854, num855)) + int collisionWidth = 80; + int collisionHeight = 20; + Vector2 collisionSize = new Vector2(NPC.Center.X - (collisionWidth / 2), NPC.position.Y + NPC.height - collisionHeight); + if (Collision.SolidCollision(collisionSize, collisionWidth, collisionHeight)) { if (NPC.velocity.Y > 0f) NPC.velocity.Y = 0f; diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index 5fe8e3fa18..46fdd03225 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -152,22 +152,22 @@ namespace CalamityMod.NPCs.NormalNPCs return; } NPC.noTileCollide = true; - float num1446 = adultWyrmAlive ? 14f : 7f; - float num1447 = 480f; + float moveVelocity = adultWyrmAlive ? 14f : 7f; + float teleportTimer = 480f; if (NPC.localAI[1] == 1f) { NPC.localAI[1] = 0f; if (Main.rand.NextBool(4)) { - NPC.ai[0] = num1447; + NPC.ai[0] = teleportTimer; } } NPC.TargetClosest(true); NPC.rotation = Math.Abs(NPC.velocity.X) * (float)NPC.direction * 0.1f; NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - Vector2 value53 = NPC.Center + new Vector2((float)(NPC.direction * 20), 6f); - Vector2 vector251 = Main.player[NPC.target].Center - value53; - bool flag104 = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); + Vector2 moveDirection = NPC.Center + new Vector2((float)(NPC.direction * 20), 6f); + Vector2 attackDirection = Main.player[NPC.target].Center - moveDirection; + bool canAttackTarget = Collision.CanHit(NPC.Center, 1, 1, Main.player[NPC.target].Center, 1, 1); if (NPC.justHit) NPC.localAI[0] = -90f; @@ -195,29 +195,29 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - Vector2 vec = Vector2.Normalize(Main.player[NPC.target].Center - NPC.Center + Main.player[NPC.target].velocity * 20f); - if (vec.HasNaNs()) + Vector2 iceMistDirection = Vector2.Normalize(Main.player[NPC.target].Center - NPC.Center + Main.player[NPC.target].velocity * 20f); + if (iceMistDirection.HasNaNs()) { - vec = new Vector2((float)NPC.direction, 0f); + iceMistDirection = new Vector2((float)NPC.direction, 0f); } for (int n = 0; n < 1; n++) { - Vector2 vector4 = vec * 4f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector4, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); + Vector2 iceMistVelocity = iceMistDirection * 4f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, iceMistVelocity, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); } } } } - if (vector251.Length() > 400f || !flag104) + if (attackDirection.Length() > 400f || !canAttackTarget) { - Vector2 value54 = vector251; - if (value54.Length() > num1446) + Vector2 tooFarMoveVelocity = attackDirection; + if (tooFarMoveVelocity.Length() > moveVelocity) { - value54.Normalize(); - value54 *= num1446; + tooFarMoveVelocity.Normalize(); + tooFarMoveVelocity *= moveVelocity; } - int num1448 = 30; - NPC.velocity = (NPC.velocity * (float)(num1448 - 1) + value54) / (float)num1448; + int tooFarVelMult = 30; + NPC.velocity = (NPC.velocity * (float)(tooFarVelMult - 1) + tooFarMoveVelocity) / (float)tooFarVelMult; } else { @@ -226,10 +226,10 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.ai[2] != 0f && NPC.ai[3] != 0f) { SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - for (int num1449 = 0; num1449 < 20; num1449++) + for (int i = 0; i < 20; i++) { - int num1450 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); - Dust dust = Main.dust[num1450]; + int eidolistDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); + Dust dust = Main.dust[eidolistDust]; dust.velocity *= 3f; dust.noGravity = true; dust.scale = 2.5f; @@ -239,51 +239,51 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.ai[2] = 0f; NPC.ai[3] = 0f; SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - for (int num1451 = 0; num1451 < 20; num1451++) + for (int j = 0; j < 20; j++) { - int num1452 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); - Dust dust = Main.dust[num1452]; + int eidolistDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 20, 0f, 0f, 100, Color.Transparent, 1f); + Dust dust = Main.dust[eidolistDust2]; dust.velocity *= 3f; dust.noGravity = true; dust.scale = 2.5f; } } NPC.ai[0] += 1f; - if (NPC.ai[0] >= num1447 && Main.netMode != NetmodeID.MultiplayerClient) + if (NPC.ai[0] >= teleportTimer && Main.netMode != NetmodeID.MultiplayerClient) { NPC.ai[0] = 0f; - Point point12 = NPC.Center.ToTileCoordinates(); - Point point13 = Main.player[NPC.target].Center.ToTileCoordinates(); - int num1453 = 20; - int num1454 = 3; - int num1455 = 10; - int num1456 = 1; - int num1457 = 0; - bool flag106 = false; - if (vector251.Length() > 2000f) + Point npcTileCenter = NPC.Center.ToTileCoordinates(); + Point targetTileCenter = Main.player[NPC.target].Center.ToTileCoordinates(); + int randTeleportOffset = 20; + int npcTeleportRadius = 3; + int targetTeleportRadius = 10; + int teleportTileCheckRadius = 1; + int teleportTries = 0; + bool canTeleport = false; + if (attackDirection.Length() > 2000f) { - flag106 = true; + canTeleport = true; } - while (!flag106 && num1457 < 100) + while (!canTeleport && teleportTries < 100) { - num1457++; - int num1458 = Main.rand.Next(point13.X - num1453, point13.X + num1453 + 1); - int num1459 = Main.rand.Next(point13.Y - num1453, point13.Y + num1453 + 1); - if ((num1459 < point13.Y - num1455 || num1459 > point13.Y + num1455 || num1458 < point13.X - num1455 || num1458 > point13.X + num1455) && (num1459 < point12.Y - num1454 || num1459 > point12.Y + num1454 || num1458 < point12.X - num1454 || num1458 > point12.X + num1454) && !Main.tile[num1458, num1459].HasUnactuatedTile) + teleportTries++; + int teleportTileX = Main.rand.Next(targetTileCenter.X - randTeleportOffset, targetTileCenter.X + randTeleportOffset + 1); + int teleportTileY = Main.rand.Next(targetTileCenter.Y - randTeleportOffset, targetTileCenter.Y + randTeleportOffset + 1); + if ((teleportTileY < targetTileCenter.Y - targetTeleportRadius || teleportTileY > targetTileCenter.Y + targetTeleportRadius || teleportTileX < targetTileCenter.X - targetTeleportRadius || teleportTileX > targetTileCenter.X + targetTeleportRadius) && (teleportTileY < npcTileCenter.Y - npcTeleportRadius || teleportTileY > npcTileCenter.Y + npcTeleportRadius || teleportTileX < npcTileCenter.X - npcTeleportRadius || teleportTileX > npcTileCenter.X + npcTeleportRadius) && !Main.tile[teleportTileX, teleportTileY].HasUnactuatedTile) { - bool flag107 = true; - if (flag107 && Main.tile[num1458, num1459].LiquidType == LiquidID.Lava) + bool teleportSuccessful = true; + if (teleportSuccessful && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) { - flag107 = false; + teleportSuccessful = false; } - if (flag107 && Collision.SolidTiles(num1458 - num1456, num1458 + num1456, num1459 - num1456, num1459 + num1456)) + if (teleportSuccessful && Collision.SolidTiles(teleportTileX - teleportTileCheckRadius, teleportTileX + teleportTileCheckRadius, teleportTileY - teleportTileCheckRadius, teleportTileY + teleportTileCheckRadius)) { - flag107 = false; + teleportSuccessful = false; } - if (flag107) + if (teleportSuccessful) { - NPC.ai[2] = (float)num1458; - NPC.ai[3] = (float)num1459; + NPC.ai[2] = (float)teleportTileX; + NPC.ai[3] = (float)teleportTileY; break; } } diff --git a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs index b4fa74c3b0..323ad15220 100644 --- a/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs +++ b/NPCs/NormalNPCs/FearlessGoldfishWarrior.cs @@ -52,23 +52,23 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - bool flag3 = false; + bool noXMovement = false; if (NPC.velocity.X == 0f) { - flag3 = true; + noXMovement = true; } if (NPC.justHit) { - flag3 = false; + noXMovement = false; } - bool flag4 = false; - bool flag5 = false; - int num35 = 60; + bool isWalking = false; + bool unusedFlag = false; + int backUpTimer = 60; if (NPC.velocity.Y == 0f && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) { - flag4 = true; + isWalking = true; } - if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)num35) | flag4) + if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)backUpTimer) | isWalking) { NPC.ai[3] += 1f; } @@ -76,7 +76,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] -= 1f; } - if (NPC.ai[3] > (float)(num35 * 10)) + if (NPC.ai[3] > (float)(backUpTimer * 10)) { NPC.ai[3] = 0f; } @@ -84,11 +84,11 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = 0f; } - if (NPC.ai[3] == (float)num35) + if (NPC.ai[3] == (float)backUpTimer) { NPC.netUpdate = true; } - if (NPC.ai[3] < (float)num35) + if (NPC.ai[3] < (float)backUpTimer) { NPC.TargetClosest(true); } @@ -124,81 +124,81 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity.X = 0f; return; } - float num65 = CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2f : 1f; - float num66 = CalamityWorld.death ? 0.28f : CalamityWorld.revenge ? 0.18f : 0.08f; - num65 += (1f - (float)NPC.life / (float)NPC.lifeMax) * 2f; - num66 += (1f - (float)NPC.life / (float)NPC.lifeMax) * 0.2f; - if (NPC.velocity.X < -num65 || NPC.velocity.X > num65) + float maxVelocity = CalamityWorld.death ? 3f : CalamityWorld.revenge ? 2f : 1f; + float acceleration = CalamityWorld.death ? 0.28f : CalamityWorld.revenge ? 0.18f : 0.08f; + maxVelocity += (1f - (float)NPC.life / (float)NPC.lifeMax) * 2f; + acceleration += (1f - (float)NPC.life / (float)NPC.lifeMax) * 0.2f; + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) { if (NPC.velocity.Y == 0f) NPC.velocity *= 0.7f; } - else if (NPC.velocity.X < num65 && NPC.direction == 1) + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) { - NPC.velocity.X = NPC.velocity.X + num66; - if (NPC.velocity.X > num65) - NPC.velocity.X = num65; + NPC.velocity.X = NPC.velocity.X + acceleration; + if (NPC.velocity.X > maxVelocity) + NPC.velocity.X = maxVelocity; } - else if (NPC.velocity.X > -num65 && NPC.direction == -1) + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) { - NPC.velocity.X = NPC.velocity.X - num66; - if (NPC.velocity.X < -num65) - NPC.velocity.X = -num65; + NPC.velocity.X = NPC.velocity.X - acceleration; + if (NPC.velocity.X < -maxVelocity) + NPC.velocity.X = -maxVelocity; } - bool flag22 = false; + bool isOnSolidTile = false; if (NPC.velocity.Y == 0f) { - int num161 = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; - int arg_A8FB_0 = (int)NPC.position.X / 16; - int num162 = (int)(NPC.position.X + (float)NPC.width) / 16; - for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + int yTile = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; + int initialXTile = (int)NPC.position.X / 16; + int maxXTile = (int)(NPC.position.X + (float)NPC.width) / 16; + for (int xTile = initialXTile; xTile <= maxXTile; xTile++) { - if (Main.tile[num163, num161] == null) + if (Main.tile[xTile, yTile] == null) { return; } - if (Main.tile[num163, num161].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num163, num161].TileType]) + if (Main.tile[xTile, yTile].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xTile, yTile].TileType]) { - flag22 = true; + isOnSolidTile = true; break; } } } if (NPC.velocity.Y >= 0f) { - int num164 = 0; + int fallFaceDirection = 0; if (NPC.velocity.X < 0f) { - num164 = -1; + fallFaceDirection = -1; } if (NPC.velocity.X > 0f) { - num164 = 1; + fallFaceDirection = 1; } - Vector2 position2 = NPC.position; - position2.X += NPC.velocity.X; - int num165 = (int)((position2.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * num164)) / 16f); - int num166 = (int)((position2.Y + (float)NPC.height - 1f) / 16f); - if ((float)(num165 * 16) < position2.X + (float)NPC.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].HasUnactuatedTile && !Main.tile[num165, num166].TopSlope && !Main.tile[num165, num166 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num165, num166].TileType] && !Main.tileSolidTop[(int)Main.tile[num165, num166].TileType]) || (Main.tile[num165, num166 - 1].IsHalfBlock && Main.tile[num165, num166 - 1].HasUnactuatedTile)) && (!Main.tile[num165, num166 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].TileType] || (Main.tile[num165, num166 - 1].IsHalfBlock && (!Main.tile[num165, num166 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].TileType]))) && (!Main.tile[num165, num166 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].TileType]) && (!Main.tile[num165, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].TileType]) && (!Main.tile[num165 - num164, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].TileType])) + Vector2 fishePosition = NPC.position; + fishePosition.X += NPC.velocity.X; + int xTileBelow = (int)((fishePosition.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * fallFaceDirection)) / 16f); + int yTileBelow = (int)((fishePosition.Y + (float)NPC.height - 1f) / 16f); + if ((float)(xTileBelow * 16) < fishePosition.X + (float)NPC.width && (float)(xTileBelow * 16 + 16) > fishePosition.X && ((Main.tile[xTileBelow, yTileBelow].HasUnactuatedTile && !Main.tile[xTileBelow, yTileBelow].TopSlope && !Main.tile[xTileBelow, yTileBelow - 1].TopSlope && Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow].TileType] && !Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow].TileType]) || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile)) && (!Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && (!Main.tile[xTileBelow, yTileBelow - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType]))) && (!Main.tile[xTileBelow, yTileBelow - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType]) && (!Main.tile[xTileBelow, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType]) && (!Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].TileType])) { - float num167 = (float)(num166 * 16); - if (Main.tile[num165, num166].IsHalfBlock) + float yPixelDistance = (float)(yTileBelow * 16); + if (Main.tile[xTileBelow, yTileBelow].IsHalfBlock) { - num167 += 8f; + yPixelDistance += 8f; } - if (Main.tile[num165, num166 - 1].IsHalfBlock) + if (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock) { - num167 -= 8f; + yPixelDistance -= 8f; } - if (num167 < position2.Y + (float)NPC.height) + if (yPixelDistance < fishePosition.Y + (float)NPC.height) { - float num168 = position2.Y + (float)NPC.height - num167; - float num169 = 16.1f; - if (num168 <= num169) + float percentageTileRisen = fishePosition.Y + (float)NPC.height - yPixelDistance; + float fullTileAmt = 16.1f; + if (percentageTileRisen <= fullTileAmt) { - NPC.gfxOffY += NPC.position.Y + (float)NPC.height - num167; - NPC.position.Y = num167 - (float)NPC.height; - if (num168 < 9f) + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - yPixelDistance; + NPC.position.Y = yPixelDistance - (float)NPC.height; + if (percentageTileRisen < 9f) { NPC.stepSpeed = 1f; } @@ -210,57 +210,57 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag22) + if (isOnSolidTile) { - int num170 = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); - int num171 = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); - if ((Main.tile[num170, num171 - 1].HasUnactuatedTile && (Main.tile[num170, num171 - 1].TileType == 10 || Main.tile[num170, num171 - 1].TileType == 388)) & flag5) + int doorCheckX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); + int doorCheckY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); + if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10 || Main.tile[doorCheckX, doorCheckY - 1].TileType == 388)) & unusedFlag) { NPC.ai[2] += 1f; NPC.ai[3] = 0f; if (NPC.ai[2] >= 60f) { NPC.velocity.X = 0.5f * (float)-(float)NPC.direction; - int num172 = 5; - if (Main.tile[num170, num171 - 1].TileType == 388) + int doorOpenInc = 5; + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - num172 = 2; + doorOpenInc = 2; } - NPC.ai[1] += (float)num172; + NPC.ai[1] += (float)doorOpenInc; NPC.ai[2] = 0f; - bool flag23 = false; + bool letMeIn = false; if (NPC.ai[1] >= 10f) { - flag23 = true; + letMeIn = true; NPC.ai[1] = 10f; } - WorldGen.KillTile(num170, num171 - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) + WorldGen.KillTile(doorCheckX, doorCheckY - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !letMeIn) && letMeIn && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.tile[num170, num171 - 1].TileType == 10) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10) { - bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, NPC.direction); - if (!flag24) + bool canOpenDoor = WorldGen.OpenDoor(doorCheckX, doorCheckY - 1, NPC.direction); + if (!canOpenDoor) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag24) + if (Main.netMode == NetmodeID.Server & canOpenDoor) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)NPC.direction, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)doorCheckX, (float)(doorCheckY - 1), (float)NPC.direction, 0, 0, 0); } } - if (Main.tile[num170, num171 - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); - if (!flag25) + bool canOpenTallGate = WorldGen.ShiftTallGate(doorCheckX, doorCheckY - 1, false); + if (!canOpenTallGate) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag25) + if (Main.netMode == NetmodeID.Server & canOpenTallGate) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)doorCheckX, (float)(doorCheckY - 1), 0f, 0, 0, 0); } } } @@ -268,12 +268,12 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - int num173 = NPC.spriteDirection; - if ((NPC.velocity.X < 0f && num173 == -1) || (NPC.velocity.X > 0f && num173 == 1)) + int faceDirection = NPC.spriteDirection; + if ((NPC.velocity.X < 0f && faceDirection == -1) || (NPC.velocity.X > 0f && faceDirection == 1)) { - if (NPC.height >= 32 && Main.tile[num170, num171 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 2].TileType]) + if (NPC.height >= 32 && Main.tile[doorCheckX, doorCheckY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 2].TileType]) { - if (Main.tile[num170, num171 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 3].TileType]) + if (Main.tile[doorCheckX, doorCheckY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 3].TileType]) { NPC.velocity.Y = -8f; NPC.netUpdate = true; @@ -284,35 +284,35 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; } } - else if (Main.tile[num170, num171 - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 1].TileType]) + else if (Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 1].TileType]) { NPC.velocity.Y = -6f; NPC.netUpdate = true; } - else if (NPC.position.Y + (float)NPC.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].HasUnactuatedTile && !Main.tile[num170, num171].TopSlope && Main.tileSolid[(int)Main.tile[num170, num171].TileType]) + else if (NPC.position.Y + (float)NPC.height - (float)(doorCheckY * 16) > 20f && Main.tile[doorCheckX, doorCheckY].HasUnactuatedTile && !Main.tile[doorCheckX, doorCheckY].TopSlope && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY].TileType]) { NPC.velocity.Y = -5f; NPC.netUpdate = true; } - else if (NPC.directionY < 0 && (!Main.tile[num170, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].TileType]) && (!Main.tile[num170 + NPC.direction, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170 + NPC.direction, num171 + 1].TileType])) + else if (NPC.directionY < 0 && (!Main.tile[doorCheckX, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY + 1].TileType]) && (!Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].TileType])) { NPC.velocity.Y = -8f; NPC.velocity.X = NPC.velocity.X * 1.5f; NPC.netUpdate = true; } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; } - if ((NPC.velocity.Y == 0f & flag3) && NPC.ai[3] == 1f) + if ((NPC.velocity.Y == 0f & noXMovement) && NPC.ai[3] == 1f) { NPC.velocity.Y = -5f; } } } } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; diff --git a/NPCs/NormalNPCs/Frogfish.cs b/NPCs/NormalNPCs/Frogfish.cs index 5d02a309d8..9519f06eeb 100644 --- a/NPCs/NormalNPCs/Frogfish.cs +++ b/NPCs/NormalNPCs/Frogfish.cs @@ -50,10 +50,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - int num = 200; + int alphaControl = 200; if (NPC.ai[2] == 0f) { - NPC.alpha = num; + NPC.alpha = alphaControl; NPC.TargetClosest(true); if (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 170f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) @@ -70,7 +70,7 @@ namespace CalamityMod.NPCs.NormalNPCs { if (NPC.alpha > 0) { - NPC.alpha -= num / 16; + NPC.alpha -= alphaControl / 16; if (NPC.alpha < 0) { NPC.alpha = 0; diff --git a/NPCs/NormalNPCs/Horse.cs b/NPCs/NormalNPCs/Horse.cs index 8aa442bb97..927c78fb78 100644 --- a/NPCs/NormalNPCs/Horse.cs +++ b/NPCs/NormalNPCs/Horse.cs @@ -127,23 +127,23 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 160; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int earthDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[earthDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[earthDust].scale = 0.5f; + Main.dust[earthDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int earthDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 3f); + Main.dust[earthDust2].noGravity = true; + Main.dust[earthDust2].velocity *= 5f; + earthDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.Torch, 0f, 0f, 100, default, 2f); + Main.dust[earthDust2].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) @@ -238,31 +238,30 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.TargetClosest(); if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float num179 = 4f; - Vector2 value9 = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); - float num180 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - value9.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int num184 = 30; - int num185 = ModContent.ProjectileType(); - value9.X += num180; - value9.Y += num182; - for (int num186 = 0; num186 < 4; num186++) + float rockSpeed = 4f; + Vector2 projPosition = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; + float absoluteTargetX = Math.Abs(targetXDist) * 0.1f; + float targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y - absoluteTargetX; + float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = rockSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + int rockType = ModContent.ProjectileType(); + projPosition.X += targetXDist; + projPosition.Y += targetYDist; + for (int k = 0; k < 4; k++) { - num185 = Main.rand.NextBool(4) ? ModContent.ProjectileType() : ModContent.ProjectileType(); - num180 = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - value9.X; - num182 = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt(num180 * num180 + num182 * num182); - num183 = num179 / num183; - num180 += Main.rand.Next(-40, 41); - num182 += Main.rand.Next(-40, 41); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, num180, num182, num185, num184, 0f, Main.myPlayer, 0f, 0f); + rockType = Main.rand.NextBool(4) ? ModContent.ProjectileType() : ModContent.ProjectileType(); + targetXDist = Main.player[NPC.target].position.X + Main.player[NPC.target].width * 0.5f - projPosition.X; + targetYDist = Main.player[NPC.target].position.Y + Main.player[NPC.target].height * 0.5f - projPosition.Y; + targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); + targetDistance = rockSpeed / targetDistance; + targetXDist += Main.rand.Next(-40, 41); + targetYDist += Main.rand.Next(-40, 41); + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), projPosition.X, projPosition.Y, targetXDist, targetYDist, rockType, 30, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/NormalNPCs/ImpiousImmolator.cs b/NPCs/NormalNPCs/ImpiousImmolator.cs index ce2b86ec15..7278c038d5 100644 --- a/NPCs/NormalNPCs/ImpiousImmolator.cs +++ b/NPCs/NormalNPCs/ImpiousImmolator.cs @@ -87,13 +87,13 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.chaseable = hasBeenHit; if (!NPC.wet) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); - if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -118,7 +118,7 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.2f; @@ -151,19 +151,19 @@ namespace CalamityMod.NPCs.NormalNPCs if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { float speed = 12f; - Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float num6 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); - float num7 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; + Vector2 beamPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - beamPosition.X + (float)Main.rand.Next(-20, 21); + float targetYDist = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - beamPosition.Y + (float)Main.rand.Next(-20, 21); + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = speed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; int damage = 55; if (Main.expertMode) { damage = 42; } - int beam = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, num6, num7, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); + int beam = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, targetXDist, targetYDist, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, 0f, 0f); Main.projectile[beam].tileCollide = true; } } @@ -192,15 +192,15 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount < 128) //problem? + int tileCheckX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int tileCheckY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[tileCheckX, tileCheckY - 1].LiquidAmount < 128) //problem? { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[tileCheckX, tileCheckY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[tileCheckX, tileCheckY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewel.cs index cc5fa62cf0..bc10f7bc3a 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel.cs @@ -189,23 +189,23 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.height = 45; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); - for (int num621 = 0; num621 < 2; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int rubyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int j = 0; j < 10; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int rubyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 3f); + Main.dust[rubyDust2].noGravity = true; + Main.dust[rubyDust2].velocity *= 5f; + rubyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 90, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust2].velocity *= 2f; } } } diff --git a/NPCs/NormalNPCs/MantisShrimp.cs b/NPCs/NormalNPCs/MantisShrimp.cs index 792a20229f..2ccd64a058 100644 --- a/NPCs/NormalNPCs/MantisShrimp.cs +++ b/NPCs/NormalNPCs/MantisShrimp.cs @@ -55,43 +55,43 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1; - float num79 = (Main.player[NPC.target].Center - NPC.Center).Length(); - num79 *= 0.0025f; - if ((double)num79 > 1.5) + float targetDist = (Main.player[NPC.target].Center - NPC.Center).Length(); + targetDist *= 0.0025f; + if ((double)targetDist > 1.5) { - num79 = 1.5f; + targetDist = 1.5f; } - float num78; + float maxSpeed; if (Main.expertMode) { - num78 = 3f - num79; + maxSpeed = 3f - targetDist; } else { - num78 = 2.5f - num79; + maxSpeed = 2.5f - targetDist; } - num78 *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); - if (NPC.velocity.X < -num78 || NPC.velocity.X > num78) + maxSpeed *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); + if (NPC.velocity.X < -maxSpeed || NPC.velocity.X > maxSpeed) { if (NPC.velocity.Y == 0f) { NPC.velocity *= 0.8f; } } - else if (NPC.velocity.X < num78 && NPC.direction == 1) + else if (NPC.velocity.X < maxSpeed && NPC.direction == 1) { NPC.velocity.X = NPC.velocity.X + 1f; - if (NPC.velocity.X > num78) + if (NPC.velocity.X > maxSpeed) { - NPC.velocity.X = num78; + NPC.velocity.X = maxSpeed; } } - else if (NPC.velocity.X > -num78 && NPC.direction == -1) + else if (NPC.velocity.X > -maxSpeed && NPC.direction == -1) { NPC.velocity.X = NPC.velocity.X - 1f; - if (NPC.velocity.X < -num78) + if (NPC.velocity.X < -maxSpeed) { - NPC.velocity.X = -num78; + NPC.velocity.X = -maxSpeed; } } } diff --git a/NPCs/NormalNPCs/OverloadedSoldier.cs b/NPCs/NormalNPCs/OverloadedSoldier.cs index c809377f28..b9911088c5 100644 --- a/NPCs/NormalNPCs/OverloadedSoldier.cs +++ b/NPCs/NormalNPCs/OverloadedSoldier.cs @@ -104,23 +104,23 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.35f, 0f, 0.15f); - bool flag3 = false; + bool noXMovement = false; if (NPC.velocity.X == 0f) { - flag3 = true; + noXMovement = true; } if (NPC.justHit) { - flag3 = false; + noXMovement = false; } - bool flag4 = false; - bool flag5 = false; - int num35 = 60; + bool isWalking = false; + bool unusedFlag = false; + int backUpTimer = 60; if (NPC.velocity.Y == 0f && ((NPC.velocity.X > 0f && NPC.direction < 0) || (NPC.velocity.X < 0f && NPC.direction > 0))) { - flag4 = true; + isWalking = true; } - if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)num35) | flag4) + if ((NPC.position.X == NPC.oldPosition.X || NPC.ai[3] >= (float)backUpTimer) | isWalking) { NPC.ai[3] += 1f; } @@ -128,7 +128,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] -= 1f; } - if (NPC.ai[3] > (float)(num35 * 10)) + if (NPC.ai[3] > (float)(backUpTimer * 10)) { NPC.ai[3] = 0f; } @@ -136,11 +136,11 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[3] = 0f; } - if (NPC.ai[3] == (float)num35) + if (NPC.ai[3] == (float)backUpTimer) { NPC.netUpdate = true; } - if (NPC.ai[3] < (float)num35) + if (NPC.ai[3] < (float)backUpTimer) { NPC.TargetClosest(true); } @@ -168,88 +168,88 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.direction = 1; } } - float num65 = 1.5f; - float num66 = 0.1f; + float maxVelocity = 1.5f; + float acceleration = 0.1f; if (CalamityWorld.death) { - num65 *= 1.5f; - num66 *= 1.5f; + maxVelocity *= 1.5f; + acceleration *= 1.5f; } if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) < 400f) { - num65 += (CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6f : 4f) - ((Main.player[NPC.target].Center - NPC.Center).Length() * 0.01f); + maxVelocity += (CalamityWorld.death ? 8f : CalamityWorld.revenge ? 6f : 4f) - ((Main.player[NPC.target].Center - NPC.Center).Length() * 0.01f); } - if (NPC.velocity.X < -num65 || NPC.velocity.X > num65) + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) { if (NPC.velocity.Y == 0f) NPC.velocity *= 0.7f; } - else if (NPC.velocity.X < num65 && NPC.direction == 1) + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) { - NPC.velocity.X = NPC.velocity.X + num66; - if (NPC.velocity.X > num65) - NPC.velocity.X = num65; + NPC.velocity.X = NPC.velocity.X + acceleration; + if (NPC.velocity.X > maxVelocity) + NPC.velocity.X = maxVelocity; } - else if (NPC.velocity.X > -num65 && NPC.direction == -1) + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) { - NPC.velocity.X = NPC.velocity.X - num66; - if (NPC.velocity.X < -num65) - NPC.velocity.X = -num65; + NPC.velocity.X = NPC.velocity.X - acceleration; + if (NPC.velocity.X < -maxVelocity) + NPC.velocity.X = -maxVelocity; } - bool flag22 = false; + bool isOnSolidTile = false; if (NPC.velocity.Y == 0f) { - int num161 = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; - int arg_A8FB_0 = (int)NPC.position.X / 16; - int num162 = (int)(NPC.position.X + (float)NPC.width) / 16; - for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + int yTile = (int)(NPC.position.Y + (float)NPC.height + 7f) / 16; + int initialXTile = (int)NPC.position.X / 16; + int maxXTile = (int)(NPC.position.X + (float)NPC.width) / 16; + for (int xTile = initialXTile; xTile <= maxXTile; xTile++) { - if (Main.tile[num163, num161] == null) + if (Main.tile[xTile, yTile] == null) { return; } - if (Main.tile[num163, num161].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num163, num161].TileType]) + if (Main.tile[xTile, yTile].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[xTile, yTile].TileType]) { - flag22 = true; + isOnSolidTile = true; break; } } } if (NPC.velocity.Y >= 0f) { - int num164 = 0; + int fallFaceDirection = 0; if (NPC.velocity.X < 0f) { - num164 = -1; + fallFaceDirection = -1; } if (NPC.velocity.X > 0f) { - num164 = 1; + fallFaceDirection = 1; } - Vector2 position2 = NPC.position; - position2.X += NPC.velocity.X; - int num165 = (int)((position2.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * num164)) / 16f); - int num166 = (int)((position2.Y + (float)NPC.height - 1f) / 16f); - if ((float)(num165 * 16) < position2.X + (float)NPC.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].HasUnactuatedTile && !Main.tile[num165, num166].TopSlope && !Main.tile[num165, num166 - 1].TopSlope && Main.tileSolid[(int)Main.tile[num165, num166].TileType] && !Main.tileSolidTop[(int)Main.tile[num165, num166].TileType]) || (Main.tile[num165, num166 - 1].IsHalfBlock && Main.tile[num165, num166 - 1].HasUnactuatedTile)) && (!Main.tile[num165, num166 - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].TileType] || (Main.tile[num165, num166 - 1].IsHalfBlock && (!Main.tile[num165, num166 - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].TileType]))) && (!Main.tile[num165, num166 - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].TileType]) && (!Main.tile[num165, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].TileType] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].TileType]) && (!Main.tile[num165 - num164, num166 - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].TileType])) + Vector2 ghostPosition = NPC.position; + ghostPosition.X += NPC.velocity.X; + int xTileBelow = (int)((ghostPosition.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1) * fallFaceDirection)) / 16f); + int yTileBelow = (int)((ghostPosition.Y + (float)NPC.height - 1f) / 16f); + if ((float)(xTileBelow * 16) < ghostPosition.X + (float)NPC.width && (float)(xTileBelow * 16 + 16) > ghostPosition.X && ((Main.tile[xTileBelow, yTileBelow].HasUnactuatedTile && !Main.tile[xTileBelow, yTileBelow].TopSlope && !Main.tile[xTileBelow, yTileBelow - 1].TopSlope && Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow].TileType] && !Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow].TileType]) || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile)) && (!Main.tile[xTileBelow, yTileBelow - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 1].TileType] || (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock && (!Main.tile[xTileBelow, yTileBelow - 4].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 4].TileType]))) && (!Main.tile[xTileBelow, yTileBelow - 2].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 2].TileType]) && (!Main.tile[xTileBelow, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType] || Main.tileSolidTop[(int)Main.tile[xTileBelow, yTileBelow - 3].TileType]) && (!Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[xTileBelow - fallFaceDirection, yTileBelow - 3].TileType])) { - float num167 = (float)(num166 * 16); - if (Main.tile[num165, num166].IsHalfBlock) + float yPixelDistance = (float)(yTileBelow * 16); + if (Main.tile[xTileBelow, yTileBelow].IsHalfBlock) { - num167 += 8f; + yPixelDistance += 8f; } - if (Main.tile[num165, num166 - 1].IsHalfBlock) + if (Main.tile[xTileBelow, yTileBelow - 1].IsHalfBlock) { - num167 -= 8f; + yPixelDistance -= 8f; } - if (num167 < position2.Y + (float)NPC.height) + if (yPixelDistance < ghostPosition.Y + (float)NPC.height) { - float num168 = position2.Y + (float)NPC.height - num167; - float num169 = 16.1f; - if (num168 <= num169) + float percentageTileRisen = ghostPosition.Y + (float)NPC.height - yPixelDistance; + float fullTileAmt = 16.1f; + if (percentageTileRisen <= fullTileAmt) { - NPC.gfxOffY += NPC.position.Y + (float)NPC.height - num167; - NPC.position.Y = num167 - (float)NPC.height; - if (num168 < 9f) + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - yPixelDistance; + NPC.position.Y = yPixelDistance - (float)NPC.height; + if (percentageTileRisen < 9f) { NPC.stepSpeed = 1f; } @@ -261,57 +261,57 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag22) + if (isOnSolidTile) { - int num170 = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); - int num171 = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); - if ((Main.tile[num170, num171 - 1].HasUnactuatedTile && (Main.tile[num170, num171 - 1].TileType == 10 || Main.tile[num170, num171 - 1].TileType == 388)) & flag5) + int doorCheckX = (int)((NPC.position.X + (float)(NPC.width / 2) + (float)(15 * NPC.direction)) / 16f); + int doorCheckY = (int)((NPC.position.Y + (float)NPC.height - 15f) / 16f); + if ((Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10 || Main.tile[doorCheckX, doorCheckY - 1].TileType == 388)) & unusedFlag) { NPC.ai[2] += 1f; NPC.ai[3] = 0f; if (NPC.ai[2] >= 60f) { NPC.velocity.X = 0.5f * (float)-(float)NPC.direction; - int num172 = 5; - if (Main.tile[num170, num171 - 1].TileType == 388) + int doorOpenInc = 5; + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - num172 = 2; + doorOpenInc = 2; } - NPC.ai[1] += (float)num172; + NPC.ai[1] += (float)doorOpenInc; NPC.ai[2] = 0f; - bool flag23 = false; + bool letMeIn = false; if (NPC.ai[1] >= 10f) { - flag23 = true; + letMeIn = true; NPC.ai[1] = 10f; } - WorldGen.KillTile(num170, num171 - 1, true, false, false); - if ((Main.netMode != NetmodeID.MultiplayerClient || !flag23) && flag23 && Main.netMode != NetmodeID.MultiplayerClient) + WorldGen.KillTile(doorCheckX, doorCheckY - 1, true, false, false); + if ((Main.netMode != NetmodeID.MultiplayerClient || !letMeIn) && letMeIn && Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.tile[num170, num171 - 1].TileType == 10) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 10) { - bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, NPC.direction); - if (!flag24) + bool canOpenDoor = WorldGen.OpenDoor(doorCheckX, doorCheckY - 1, NPC.direction); + if (!canOpenDoor) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag24) + if (Main.netMode == NetmodeID.Server & canOpenDoor) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)NPC.direction, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 0, (float)doorCheckX, (float)(doorCheckY - 1), (float)NPC.direction, 0, 0, 0); } } - if (Main.tile[num170, num171 - 1].TileType == 388) + if (Main.tile[doorCheckX, doorCheckY - 1].TileType == 388) { - bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); - if (!flag25) + bool canOpenTallGate = WorldGen.ShiftTallGate(doorCheckX, doorCheckY - 1, false); + if (!canOpenTallGate) { - NPC.ai[3] = (float)num35; + NPC.ai[3] = (float)backUpTimer; NPC.netUpdate = true; } - if (Main.netMode == NetmodeID.Server & flag25) + if (Main.netMode == NetmodeID.Server & canOpenTallGate) { - NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + NetMessage.SendData(MessageID.ToggleDoorState, -1, -1, null, 4, (float)doorCheckX, (float)(doorCheckY - 1), 0f, 0, 0, 0); } } } @@ -319,12 +319,12 @@ namespace CalamityMod.NPCs.NormalNPCs } else { - int num173 = NPC.spriteDirection; - if ((NPC.velocity.X < 0f && num173 == -1) || (NPC.velocity.X > 0f && num173 == 1)) + int faceDirection = NPC.spriteDirection; + if ((NPC.velocity.X < 0f && faceDirection == -1) || (NPC.velocity.X > 0f && faceDirection == 1)) { - if (NPC.height >= 32 && Main.tile[num170, num171 - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 2].TileType]) + if (NPC.height >= 32 && Main.tile[doorCheckX, doorCheckY - 2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 2].TileType]) { - if (Main.tile[num170, num171 - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 3].TileType]) + if (Main.tile[doorCheckX, doorCheckY - 3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 3].TileType]) { NPC.velocity.Y = -8f; NPC.netUpdate = true; @@ -335,35 +335,35 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; } } - else if (Main.tile[num170, num171 - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num170, num171 - 1].TileType]) + else if (Main.tile[doorCheckX, doorCheckY - 1].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY - 1].TileType]) { NPC.velocity.Y = -6f; NPC.netUpdate = true; } - else if (NPC.position.Y + (float)NPC.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].HasUnactuatedTile && !Main.tile[num170, num171].TopSlope && Main.tileSolid[(int)Main.tile[num170, num171].TileType]) + else if (NPC.position.Y + (float)NPC.height - (float)(doorCheckY * 16) > 20f && Main.tile[doorCheckX, doorCheckY].HasUnactuatedTile && !Main.tile[doorCheckX, doorCheckY].TopSlope && Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY].TileType]) { NPC.velocity.Y = -5f; NPC.netUpdate = true; } - else if (NPC.directionY < 0 && (!Main.tile[num170, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].TileType]) && (!Main.tile[num170 + NPC.direction, num171 + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[num170 + NPC.direction, num171 + 1].TileType])) + else if (NPC.directionY < 0 && (!Main.tile[doorCheckX, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX, doorCheckY + 1].TileType]) && (!Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[doorCheckX + NPC.direction, doorCheckY + 1].TileType])) { NPC.velocity.Y = -8f; NPC.velocity.X = NPC.velocity.X * 1.5f; NPC.netUpdate = true; } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; } - if ((NPC.velocity.Y == 0f & flag3) && NPC.ai[3] == 1f) + if ((NPC.velocity.Y == 0f & noXMovement) && NPC.ai[3] == 1f) { NPC.velocity.Y = -5f; } } } } - else if (flag5) + else if (unusedFlag) { NPC.ai[1] = 0f; NPC.ai[2] = 0f; diff --git a/NPCs/NormalNPCs/PhantomSpirit.cs b/NPCs/NormalNPCs/PhantomSpirit.cs index 10dd45904b..a7e0bf2637 100644 --- a/NPCs/NormalNPCs/PhantomSpirit.cs +++ b/NPCs/NormalNPCs/PhantomSpirit.cs @@ -50,8 +50,8 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = CalamityWorld.death ? 22f : CalamityWorld.revenge ? 19.5f : 17f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; @@ -65,10 +65,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/PhantomSpiritL.cs b/NPCs/NormalNPCs/PhantomSpiritL.cs index 686af1f815..233e0ef259 100644 --- a/NPCs/NormalNPCs/PhantomSpiritL.cs +++ b/NPCs/NormalNPCs/PhantomSpiritL.cs @@ -64,15 +64,15 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 16f : CalamityWorld.revenge ? 14f : 12f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; - Vector2 vector17 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num147 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector17.X; - float num148 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector17.Y; - float num149 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148)); + Vector2 spiritPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - spiritPosition.X; + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - spiritPosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.justHit) NPC.ai[2] = 0f; @@ -81,13 +81,13 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] >= 150f) { NPC.ai[2] = 0f; - float num151 = 10f; + float projSpeed = 10f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - num149 = num151 / num149; - num147 *= num149; - num148 *= num149; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector17.X, vector17.Y, num147, num148, type, damage, 0f, Main.myPlayer, 0f, 0f); + targetDistance = projSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), spiritPosition.X, spiritPosition.Y, targetXDist, targetYDist, type, damage, 0f, Main.myPlayer, 0f, 0f); } } @@ -99,10 +99,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/PhantomSpiritM.cs b/NPCs/NormalNPCs/PhantomSpiritM.cs index d77ab006b9..3c6729f09c 100644 --- a/NPCs/NormalNPCs/PhantomSpiritM.cs +++ b/NPCs/NormalNPCs/PhantomSpiritM.cs @@ -60,8 +60,8 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = CalamityWorld.death ? 18f : CalamityWorld.revenge ? 15.75f : 13.5f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; @@ -76,10 +76,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/PhantomSpiritS.cs b/NPCs/NormalNPCs/PhantomSpiritS.cs index 4397bae9ae..de9a48fb3f 100644 --- a/NPCs/NormalNPCs/PhantomSpiritS.cs +++ b/NPCs/NormalNPCs/PhantomSpiritS.cs @@ -59,8 +59,8 @@ namespace CalamityMod.NPCs.NormalNPCs { float speed = CalamityWorld.death ? 20f : CalamityWorld.revenge ? 17.5f : 15f; CalamityAI.DungeonSpiritAI(NPC, Mod, speed, -MathHelper.PiOver2); - int num822 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; + int polterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, 0f, 0f, 0, default, 1f); + Dust dust = Main.dust[polterDust]; dust.velocity *= 0.1f; dust.scale = 1.3f; dust.noGravity = true; @@ -74,10 +74,10 @@ namespace CalamityMod.NPCs.NormalNPCs } if (NPC.life <= 0) { - for (int num288 = 0; num288 < 50; num288++) + for (int i = 0; i < 50; i++) { - int num289 = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); - Dust dust = Main.dust[num289]; + int hitPolterDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, (int)CalamityDusts.Polterplasm, NPC.velocity.X, NPC.velocity.Y, 0, default, 1f); + Dust dust = Main.dust[hitPolterDust]; dust.velocity *= 2f; dust.noGravity = true; dust.scale = 1.4f; diff --git a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs index 880e72f1db..e68b2d29f5 100644 --- a/NPCs/NormalNPCs/ProfanedEnergyLantern.cs +++ b/NPCs/NormalNPCs/ProfanedEnergyLantern.cs @@ -45,10 +45,10 @@ namespace CalamityMod.NPCs.NormalNPCs return; } - int num750 = CalamityGlobalNPC.energyFlame; + int energyBase = CalamityGlobalNPC.energyFlame; if (NPC.ai[3] > 0f) { - num750 = (int)NPC.ai[3] - 1; + energyBase = (int)NPC.ai[3] - 1; } if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -62,23 +62,23 @@ namespace CalamityMod.NPCs.NormalNPCs } } NPC.TargetClosest(true); - float num751 = 0.1f; - float num752 = 500f; + float lanternAcceleration = 0.1f; + float lanternSpeed = 500f; if ((double)Main.npc[CalamityGlobalNPC.energyFlame].life < (double)Main.npc[CalamityGlobalNPC.energyFlame].lifeMax * 0.25) { - num752 += 50f; + lanternSpeed += 50f; } if ((double)Main.npc[CalamityGlobalNPC.energyFlame].life < (double)Main.npc[CalamityGlobalNPC.energyFlame].lifeMax * 0.1) { - num752 += 50f; + lanternSpeed += 50f; } if (Main.expertMode) { - float num753 = 1f - (float)NPC.life / (float)NPC.lifeMax; - num752 += num753 * 200f; - num751 += 0.15f; + float expertSpeedMult = 1f - (float)NPC.life / (float)NPC.lifeMax; + lanternSpeed += expertSpeedMult * 200f; + lanternAcceleration += 0.15f; } - if (!Main.npc[num750].active || CalamityGlobalNPC.energyFlame < 0) + if (!Main.npc[energyBase].active || CalamityGlobalNPC.energyFlame < 0) { NPC.life = 0; NPC.HitEffect(); @@ -86,49 +86,49 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.netUpdate = true; return; } - Vector2 vector22 = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); - float num189 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - (float)(NPC.width / 2) - vector22.X; - float num190 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - (float)(NPC.height / 2) - vector22.Y; - float num191 = (float)Math.Sqrt((double)(num189 * num189 + num190 * num190)); - float num754 = Main.npc[num750].position.X + (float)(Main.npc[num750].width / 2); - float num755 = Main.npc[num750].position.Y + (float)(Main.npc[num750].height / 2); - Vector2 vector93 = new Vector2(num754, num755); - float num756 = num754 + NPC.ai[0]; - float num757 = num755 + NPC.ai[1]; - float num758 = num756 - vector93.X; - float num759 = num757 - vector93.Y; - float num760 = (float)Math.Sqrt((double)(num758 * num758 + num759 * num759)); - num760 = num752 / num760; - num758 *= num760; - num759 *= num760; - if (NPC.position.X < num754 + num758) + Vector2 lanternRelocation = new Vector2(NPC.ai[0] * 16f + 8f, NPC.ai[1] * 16f + 8f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - (float)(NPC.width / 2) - lanternRelocation.X; + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - (float)(NPC.height / 2) - lanternRelocation.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float baseXPos = Main.npc[energyBase].position.X + (float)(Main.npc[energyBase].width / 2); + float baseYPos = Main.npc[energyBase].position.Y + (float)(Main.npc[energyBase].height / 2); + Vector2 baseCurrentPos = new Vector2(baseXPos, baseYPos); + float basePosition = baseXPos + NPC.ai[0]; + float newLanternPos = baseYPos + NPC.ai[1]; + float baseXDist = basePosition - baseCurrentPos.X; + float baseYDist = newLanternPos - baseCurrentPos.Y; + float baseDistance = (float)Math.Sqrt((double)(baseXDist * baseXDist + baseYDist * baseYDist)); + baseDistance = lanternSpeed / baseDistance; + baseXDist *= baseDistance; + baseYDist *= baseDistance; + if (NPC.position.X < baseXPos + baseXDist) { - NPC.velocity.X = NPC.velocity.X + num751; - if (NPC.velocity.X < 0f && num758 > 0f) + NPC.velocity.X = NPC.velocity.X + lanternAcceleration; + if (NPC.velocity.X < 0f && baseXDist > 0f) { NPC.velocity.X = NPC.velocity.X * 0.9f; } } - else if (NPC.position.X > num754 + num758) + else if (NPC.position.X > baseXPos + baseXDist) { - NPC.velocity.X = NPC.velocity.X - num751; - if (NPC.velocity.X > 0f && num758 < 0f) + NPC.velocity.X = NPC.velocity.X - lanternAcceleration; + if (NPC.velocity.X > 0f && baseXDist < 0f) { NPC.velocity.X = NPC.velocity.X * 0.9f; } } - if (NPC.position.Y < num755 + num759) + if (NPC.position.Y < baseYPos + baseYDist) { - NPC.velocity.Y = NPC.velocity.Y + num751; - if (NPC.velocity.Y < 0f && num759 > 0f) + NPC.velocity.Y = NPC.velocity.Y + lanternAcceleration; + if (NPC.velocity.Y < 0f && baseYDist > 0f) { NPC.velocity.Y = NPC.velocity.Y * 0.9f; } } - else if (NPC.position.Y > num755 + num759) + else if (NPC.position.Y > baseYPos + baseYDist) { - NPC.velocity.Y = NPC.velocity.Y - num751; - if (NPC.velocity.Y > 0f && num759 < 0f) + NPC.velocity.Y = NPC.velocity.Y - lanternAcceleration; + if (NPC.velocity.Y > 0f && baseYDist < 0f) { NPC.velocity.Y = NPC.velocity.Y * 0.9f; } @@ -158,21 +158,20 @@ namespace CalamityMod.NPCs.NormalNPCs { if (!Collision.SolidCollision(NPC.position, NPC.width, NPC.height)) { - float num196 = 11f; - vector22 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num189 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector22.X + (float)Main.rand.Next(-10, 11); - float num197 = Math.Abs(num189 * 0.1f); - if (num190 > 0f) + float projSpeed = 11f; + lanternRelocation = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - lanternRelocation.X + (float)Main.rand.Next(-10, 11); + float absoluteTargetX = Math.Abs(targetXDist * 0.1f); + if (targetYDist > 0f) { - num197 = 0f; + absoluteTargetX = 0f; } - num190 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector22.Y + (float)Main.rand.Next(-10, 11) - num197; - num191 = (float)Math.Sqrt((double)(num189 * num189 + num190 * num190)); - num191 = num196 / num191; - num189 *= num191; - num190 *= num191; - int num9 = ModContent.ProjectileType(); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, num189, num190, num9, 40, 0f, Main.myPlayer, 0f, 0f); + targetYDist = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - lanternRelocation.Y + (float)Main.rand.Next(-10, 11) - absoluteTargetX; + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = projSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, targetXDist, targetYDist, ModContent.ProjectileType(), 40, 0f, Main.myPlayer, 0f, 0f); NPC.localAI[1] = 0f; return; } diff --git a/NPCs/NormalNPCs/ScornEater.cs b/NPCs/NormalNPCs/ScornEater.cs index 8bb616a6ba..830218703a 100644 --- a/NPCs/NormalNPCs/ScornEater.cs +++ b/NPCs/NormalNPCs/ScornEater.cs @@ -76,20 +76,20 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y == 0f) { NPC.ai[2] += 1f; - int num321 = 20; + int decelerationDelay = 20; if (NPC.ai[1] == 0f) { - num321 = 12; + decelerationDelay = 12; } if (CalamityWorld.revenge) { - num321 /= 2; + decelerationDelay /= 2; } if (CalamityWorld.death) { - num321 /= 2; + decelerationDelay /= 2; } - if (NPC.ai[2] < (float)num321) + if (NPC.ai[2] < (float)decelerationDelay) { NPC.velocity.X = NPC.velocity.X * 0.9f; return; diff --git a/NPCs/NormalNPCs/ShockstormShuttle.cs b/NPCs/NormalNPCs/ShockstormShuttle.cs index 4c7016a189..ea56e034a8 100644 --- a/NPCs/NormalNPCs/ShockstormShuttle.cs +++ b/NPCs/NormalNPCs/ShockstormShuttle.cs @@ -88,7 +88,7 @@ namespace CalamityMod.NPCs.NormalNPCs npcPos.X += velocity.X; npcPos.Y += velocity.Y; int spread = Main.getGoodWorld ? 100 : 20; - for (int num186 = 0; num186 < (Main.getGoodWorld ? 10 : 2); num186++) + for (int i = 0; i < (Main.getGoodWorld ? 10 : 2); i++) { velocity = Main.player[NPC.target].Center - npcPos; targetDist = velocity.Length(); @@ -106,15 +106,15 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.localAI[3] = 1f; } - Vector2 center16 = NPC.Center; - Player player8 = Main.player[NPC.target]; - if (NPC.target < 0 || NPC.target == Main.maxPlayers || player8.dead || !player8.active) + Vector2 shuttleCenter = NPC.Center; + Player targetedPlayer = Main.player[NPC.target]; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || targetedPlayer.dead || !targetedPlayer.active) { NPC.TargetClosest(); - player8 = Main.player[NPC.target]; + targetedPlayer = Main.player[NPC.target]; NPC.netUpdate = true; } - if ((player8.dead || Vector2.Distance(player8.Center, center16) > 3200f) && NPC.ai[0] != 1f) + if ((targetedPlayer.dead || Vector2.Distance(targetedPlayer.Center, shuttleCenter) > 3200f) && NPC.ai[0] != 1f) { NPC.ai[0] = -1f; NPC.netUpdate = true; @@ -126,7 +126,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.timeLeft = 10; } - if (!player8.dead) + if (!targetedPlayer.dead) { NPC.timeLeft = 300; NPC.ai[1] = 0f; @@ -138,128 +138,127 @@ namespace CalamityMod.NPCs.NormalNPCs } else if (NPC.ai[0] == 0f) { - int num1580 = 0; + int movementPattern = 0; if (NPC.ai[3] >= 580f) { - num1580 = 0; + movementPattern = 0; } else if (NPC.ai[3] >= 440f) { - num1580 = 5; + movementPattern = 5; } else if (NPC.ai[3] >= 420f) { - num1580 = 4; + movementPattern = 4; } else if (NPC.ai[3] >= 280f) { - num1580 = 3; + movementPattern = 3; } else if (NPC.ai[3] >= 260f) { - num1580 = 2; + movementPattern = 2; } else if (NPC.ai[3] >= 20f) { - num1580 = 1; + movementPattern = 1; } NPC.ai[3] += 1f; if (NPC.ai[3] >= 600f) { NPC.ai[3] = 0f; } - int num1581 = num1580; + int patternCompare = movementPattern; if (NPC.ai[3] >= 580f) { - num1580 = 0; + movementPattern = 0; } else if (NPC.ai[3] >= 440f) { - num1580 = 5; + movementPattern = 5; } else if (NPC.ai[3] >= 420f) { - num1580 = 4; + movementPattern = 4; } else if (NPC.ai[3] >= 280f) { - num1580 = 3; + movementPattern = 3; } else if (NPC.ai[3] >= 260f) { - num1580 = 2; + movementPattern = 2; } else if (NPC.ai[3] >= 20f) { - num1580 = 1; + movementPattern = 1; } - if (num1580 != num1581) + if (movementPattern != patternCompare) { - if (num1580 == 0) + if (movementPattern == 0) { NPC.ai[2] = 0f; } - if (num1580 == 1) + if (movementPattern == 1) { - NPC.ai[2] = (float)((Math.Sign((player8.Center - center16).X) == 1) ? 1 : -1); + NPC.ai[2] = (float)((Math.Sign((targetedPlayer.Center - shuttleCenter).X) == 1) ? 1 : -1); } - if (num1580 == 2) + if (movementPattern == 2) { NPC.ai[2] = 0f; } NPC.netUpdate = true; } - if (num1580 == 0) + if (movementPattern == 0) { if (NPC.ai[2] == 0f) { - NPC.ai[2] = (float)(-600 * Math.Sign((center16 - player8.Center).X)); + NPC.ai[2] = (float)(-600 * Math.Sign((shuttleCenter - targetedPlayer.Center).X)); } - Vector2 vector196 = player8.Center + new Vector2(NPC.ai[2], -250f) - center16; - if (vector196.Length() < 50f) + Vector2 targetingDirection = targetedPlayer.Center + new Vector2(NPC.ai[2], -250f) - shuttleCenter; + if (targetingDirection.Length() < 50f) { NPC.ai[3] = 19f; } else { - vector196.Normalize(); - NPC.velocity = Vector2.Lerp(NPC.velocity, vector196 * 16f, 0.1f); + targetingDirection.Normalize(); + NPC.velocity = Vector2.Lerp(NPC.velocity, targetingDirection * 16f, 0.1f); } } - if (num1580 == 1) + if (movementPattern == 1) { - int num1582 = (int)NPC.Center.X / 16; - int num1583 = (int)(NPC.position.Y + (float)NPC.height) / 16; - int num1584 = 0; - bool flag149 = Main.tile[num1582, num1583].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1582, num1583].TileType] && !Main.tileSolidTop[(int)Main.tile[num1582, num1583].TileType]; - if (flag149) + int npcTileX = (int)NPC.Center.X / 16; + int npcTileY = (int)(NPC.position.Y + (float)NPC.height) / 16; + int upwardMoveAmt = 0; + bool solidTilePresent = Main.tile[npcTileX, npcTileY].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileY].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX, npcTileY].TileType]; + if (solidTilePresent) { - num1584 = 1; + upwardMoveAmt = 1; } else { - while (num1584 < 150 && num1583 + num1584 < Main.maxTilesY) + while (upwardMoveAmt < 150 && npcTileY + upwardMoveAmt < Main.maxTilesY) { - int num1585 = num1583 + num1584; - bool flag150 = Main.tile[num1582, num1585].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1582, num1585].TileType] && !Main.tileSolidTop[(int)Main.tile[num1582, num1585].TileType]; - if (flag150) + int npcTileYUp = npcTileY + upwardMoveAmt; + bool solidTilePresentAgain = Main.tile[npcTileX, npcTileYUp].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX, npcTileYUp].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX, npcTileYUp].TileType]; + if (solidTilePresentAgain) { - num1584--; + upwardMoveAmt--; break; } - num1584++; + upwardMoveAmt++; } } - float num1586 = (float)(num1584 * 16); - float num1587 = 250f; - if (num1586 < num1587) + float pixelsUpAmt = (float)(upwardMoveAmt * 16); + if (pixelsUpAmt < 250f) { - float num1588 = -4f; - if (-num1588 > num1586) + float velocityUpwards = -4f; + if (-velocityUpwards > pixelsUpAmt) { - num1588 = -num1586; + velocityUpwards = -pixelsUpAmt; } - NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, num1588, 0.05f); + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, velocityUpwards, 0.05f); } else { @@ -267,106 +266,104 @@ namespace CalamityMod.NPCs.NormalNPCs } NPC.velocity.X = 3.5f * NPC.ai[2]; } - if (num1580 == 2) + if (movementPattern == 2) { if (NPC.ai[2] == 0f) { - NPC.ai[2] = (float)(300 * Math.Sign((center16 - player8.Center).X)); + NPC.ai[2] = (float)(300 * Math.Sign((shuttleCenter - targetedPlayer.Center).X)); } - Vector2 vector197 = player8.Center + new Vector2(NPC.ai[2], -170f) - center16; - int num1589 = (int)NPC.Center.X / 16; - int num1590 = (int)(NPC.position.Y + (float)NPC.height) / 16; - int num1591 = 0; - bool flag151 = Main.tile[num1589, num1590].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1589, num1590].TileType] && !Main.tileSolidTop[(int)Main.tile[num1589, num1590].TileType]; - if (flag151) + Vector2 targetingCenter2 = targetedPlayer.Center + new Vector2(NPC.ai[2], -170f) - shuttleCenter; + int npcTileX2 = (int)NPC.Center.X / 16; + int npcTileY2 = (int)(NPC.position.Y + (float)NPC.height) / 16; + int upwardsMovement = 0; + bool solidTile = Main.tile[npcTileX2, npcTileY2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX2, npcTileY2].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX2, npcTileY2].TileType]; + if (solidTile) { - num1591 = 1; + upwardsMovement = 1; } else { - while (num1591 < 150 && num1590 + num1591 < Main.maxTilesY) + while (upwardsMovement < 150 && npcTileY2 + upwardsMovement < Main.maxTilesY) { - int num1592 = num1590 + num1591; - bool flag152 = Main.tile[num1589, num1592].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1589, num1592].TileType] && !Main.tileSolidTop[(int)Main.tile[num1589, num1592].TileType]; - if (flag152) + int npcTileYUp2 = npcTileY2 + upwardsMovement; + bool solidTileAgain = Main.tile[npcTileX2, npcTileYUp2].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX2, npcTileYUp2].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX2, npcTileYUp2].TileType]; + if (solidTileAgain) { - num1591--; + upwardsMovement--; break; } - num1591++; + upwardsMovement++; } } - float num1593 = (float)(num1591 * 16); - float num1594 = 170f; - if (num1593 < num1594) + float pixelsUpAmt2 = (float)(upwardsMovement * 16); + if (pixelsUpAmt2 < 170f) { - vector197.Y -= num1594 - num1593; + targetingCenter2.Y -= 170f - pixelsUpAmt2; } - if (vector197.Length() < 70f) + if (targetingCenter2.Length() < 70f) { NPC.ai[3] = 279f; } else { - vector197.Normalize(); - NPC.velocity = Vector2.Lerp(NPC.velocity, vector197 * 20f, 0.1f); + targetingCenter2.Normalize(); + NPC.velocity = Vector2.Lerp(NPC.velocity, targetingCenter2 * 20f, 0.1f); } } - else if (num1580 == 3) + else if (movementPattern == 3) { - float num1595 = 0.85f; - int num1596 = (int)NPC.Center.X / 16; - int num1597 = (int)(NPC.position.Y + (float)NPC.height) / 16; - int num1598 = 0; - bool flag153 = Main.tile[num1596, num1597].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1596, num1597].TileType] && !Main.tileSolidTop[(int)Main.tile[num1596, num1597].TileType]; - if (flag153) + float decelerationMult = 0.85f; + int npcTileX3 = (int)NPC.Center.X / 16; + int npcTileY3 = (int)(NPC.position.Y + (float)NPC.height) / 16; + int upwardsMovement3 = 0; + bool thereIsSolidTile = Main.tile[npcTileX3, npcTileY3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX3, npcTileY3].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX3, npcTileY3].TileType]; + if (thereIsSolidTile) { - num1598 = 1; + upwardsMovement3 = 1; } else { - while (num1598 < 150 && num1597 + num1598 < Main.maxTilesY) + while (upwardsMovement3 < 150 && npcTileY3 + upwardsMovement3 < Main.maxTilesY) { - int num1599 = num1597 + num1598; - bool flag154 = Main.tile[num1596, num1599].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[num1596, num1599].TileType] && !Main.tileSolidTop[(int)Main.tile[num1596, num1599].TileType]; - if (flag154) + int npcTileYUp3 = npcTileY3 + upwardsMovement3; + bool thereIsSolidTileAgain = Main.tile[npcTileX3, npcTileYUp3].HasUnactuatedTile && Main.tileSolid[(int)Main.tile[npcTileX3, npcTileYUp3].TileType] && !Main.tileSolidTop[(int)Main.tile[npcTileX3, npcTileYUp3].TileType]; + if (thereIsSolidTileAgain) { - num1598--; + upwardsMovement3--; break; } - num1598++; + upwardsMovement3++; } } - float num1600 = (float)(num1598 * 16); - float num1601 = 170f; - if (num1600 < num1601) + float pixelUpAmt3 = (float)(upwardsMovement3 * 16); + if (pixelUpAmt3 < 170f) { - float num1602 = -4f; - if (-num1602 > num1600) + float velocityUpwards3 = -4f; + if (-velocityUpwards3 > pixelUpAmt3) { - num1602 = -num1600; + velocityUpwards3 = -pixelUpAmt3; } - NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, num1602, 0.05f); + NPC.velocity.Y = MathHelper.Lerp(NPC.velocity.Y, velocityUpwards3, 0.05f); } else { - NPC.velocity.Y = NPC.velocity.Y * num1595; + NPC.velocity.Y = NPC.velocity.Y * decelerationMult; } - NPC.velocity.X = NPC.velocity.X * num1595; + NPC.velocity.X = NPC.velocity.X * decelerationMult; } - if (num1580 == 4) + if (movementPattern == 4) { - Vector2 vector198 = player8.Center + new Vector2(0f, -250f) - center16; - if (vector198.Length() < 50f) + Vector2 targetingCenter4 = targetedPlayer.Center + new Vector2(0f, -250f) - shuttleCenter; + if (targetingCenter4.Length() < 50f) { NPC.ai[3] = 439f; return; } - vector198.Normalize(); - NPC.velocity = Vector2.Lerp(NPC.velocity, vector198 * 16f, 0.1f); + targetingCenter4.Normalize(); + NPC.velocity = Vector2.Lerp(NPC.velocity, targetingCenter4 * 16f, 0.1f); return; } - else if (num1580 == 5) + else if (movementPattern == 5) { NPC.velocity *= 0.85f; return; diff --git a/NPCs/NormalNPCs/Sunskater.cs b/NPCs/NormalNPCs/Sunskater.cs index 903f9e96ec..ffba1f6bff 100644 --- a/NPCs/NormalNPCs/Sunskater.cs +++ b/NPCs/NormalNPCs/Sunskater.cs @@ -85,13 +85,13 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.chaseable = hasBeenHit; if (!NPC.wet) { - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); - if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((Main.player[NPC.target].wet || Main.player[NPC.target].dead) && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -116,7 +116,7 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * 0.15f; @@ -148,15 +148,15 @@ namespace CalamityMod.NPCs.NormalNPCs } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount < 128) //problem? + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount < 128) //problem? { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/NormalNPCs/WildBumblefuck.cs b/NPCs/NormalNPCs/WildBumblefuck.cs index 050c2b3c1c..0aff5466d9 100644 --- a/NPCs/NormalNPCs/WildBumblefuck.cs +++ b/NPCs/NormalNPCs/WildBumblefuck.cs @@ -122,30 +122,28 @@ namespace CalamityMod.NPCs.NormalNPCs spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); - Color color36 = Color.Gold; - float amount9 = 0.5f; - int num153 = NPC.ai[0] == 2.1f ? 7 : 0; + Vector2 halfSizeTexture = new Vector2(TextureAssets.Npc[NPC.type].Value.Width / 2, TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2); + int afterimageAmt = NPC.ai[0] == 2.1f ? 7 : 0; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; - vector41 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.Gold, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2(texture2D15.Width, texture2D15.Height / Main.npcFrameCount[NPC.type]) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/Other/THELORDE.cs b/NPCs/Other/THELORDE.cs index 8a0631d769..73744b4cd2 100644 --- a/NPCs/Other/THELORDE.cs +++ b/NPCs/Other/THELORDE.cs @@ -201,18 +201,17 @@ namespace CalamityMod.NPCs.Other { NPC.rotation += 5f; NPC.TargetClosest(true); - float num1372 = 69f; - Vector2 vector167 = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); - float num1373 = playerLOL.position.X + (float)playerLOL.width * 0.5f - vector167.X; - float num1374 = playerLOL.Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374)); - float num1376 = num1372 / num1375; - num1373 *= num1376; - num1374 *= num1376; + Vector2 lordePosition = new Vector2(NPC.Center.X + (float)(NPC.direction * 20), NPC.Center.Y + 6f); + float targetXDist = playerLOL.position.X + (float)playerLOL.width * 0.5f - lordePosition.X; + float targetYDist = playerLOL.Center.Y - lordePosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float velocityMult = 69f / targetDistance; + targetXDist *= velocityMult; + targetYDist *= velocityMult; NPC.ai[0] -= 1f; - if (num1375 < 50f || NPC.ai[0] > 0f) + if (targetDistance < 50f || NPC.ai[0] > 0f) { - if (num1375 < 50f) + if (targetDistance < 50f) { NPC.ai[0] = 20f; } @@ -226,17 +225,17 @@ namespace CalamityMod.NPCs.Other } return; } - NPC.velocity.X = (NPC.velocity.X * 50f + num1373) / 51f; - NPC.velocity.Y = (NPC.velocity.Y * 50f + num1374) / 51f; - if (num1375 < 150f) + NPC.velocity.X = (NPC.velocity.X * 50f + targetXDist) / 51f; + NPC.velocity.Y = (NPC.velocity.Y * 50f + targetYDist) / 51f; + if (targetDistance < 150f) { - NPC.velocity.X = (NPC.velocity.X * 10f + num1373) / 11f; - NPC.velocity.Y = (NPC.velocity.Y * 10f + num1374) / 11f; + NPC.velocity.X = (NPC.velocity.X * 10f + targetXDist) / 11f; + NPC.velocity.Y = (NPC.velocity.Y * 10f + targetYDist) / 11f; } - if (num1375 < 100f) + if (targetDistance < 100f) { - NPC.velocity.X = (NPC.velocity.X * 7f + num1373) / 8f; - NPC.velocity.Y = (NPC.velocity.Y * 7f + num1374) / 8f; + NPC.velocity.X = (NPC.velocity.X * 7f + targetXDist) / 8f; + NPC.velocity.Y = (NPC.velocity.Y * 7f + targetYDist) / 8f; } return; } diff --git a/NPCs/PlagueEnemies/PestilentSlime.cs b/NPCs/PlagueEnemies/PestilentSlime.cs index e89ce9e9f1..14511f8d49 100644 --- a/NPCs/PlagueEnemies/PestilentSlime.cs +++ b/NPCs/PlagueEnemies/PestilentSlime.cs @@ -65,11 +65,11 @@ namespace CalamityMod.NPCs.PlagueEnemies } if (!NPC.wet && !Main.player[NPC.target].npcTypeNoAggro[NPC.type]) { - Vector2 vector3 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num14 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector3.X; - float num15 = Main.player[NPC.target].position.Y - vector3.Y; - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.expertMode && num16 < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + Vector2 slimePosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - slimePosition.X; + float targetYDist = Main.player[NPC.target].position.Y - slimePosition.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (Main.expertMode && targetDistance < 120f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -81,17 +81,17 @@ namespace CalamityMod.NPCs.PlagueEnemies SoundEngine.PlaySound(SoundID.Item42, NPC.Center); for (int n = 0; n < 5; n++) { - Vector2 vector4 = new Vector2((float)(n - 2), -4f); - vector4.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; - vector4.Normalize(); - vector4 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, vector4.X, vector4.Y, ModContent.ProjectileType(), 25, 0f, Main.myPlayer, 0f, 0f); + Vector2 spikeVelocity = new Vector2((float)(n - 2), -4f); + spikeVelocity.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeVelocity.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f; + spikeVelocity.Normalize(); + spikeVelocity *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), slimePosition.X, slimePosition.Y, spikeVelocity.X, spikeVelocity.Y, ModContent.ProjectileType(), 25, 0f, Main.myPlayer, 0f, 0f); spikeTimer = 30f; } } } - else if (num16 < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) + else if (targetDistance < 360f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && NPC.velocity.Y == 0f) { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) @@ -101,13 +101,13 @@ namespace CalamityMod.NPCs.PlagueEnemies if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { SoundEngine.PlaySound(SoundID.Item42, NPC.Center); - num15 = Main.player[NPC.target].position.Y - vector3.Y - (float)Main.rand.Next(0, 200); - num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - num16 = 6.5f / num16; - num14 *= num16; - num15 *= num16; + targetYDist = Main.player[NPC.target].position.Y - slimePosition.Y - (float)Main.rand.Next(0, 200); + targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = 6.5f / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; spikeTimer = 50f; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector3.X, vector3.Y, num14, num15, ModContent.ProjectileType(), 22, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), slimePosition.X, slimePosition.Y, targetXDist, targetYDist, ModContent.ProjectileType(), 22, 0f, Main.myPlayer, 0f, 0f); } } } diff --git a/NPCs/PlagueEnemies/PlagueCharger.cs b/NPCs/PlagueEnemies/PlagueCharger.cs index 26bf2995b8..53b533f68b 100644 --- a/NPCs/PlagueEnemies/PlagueCharger.cs +++ b/NPCs/PlagueEnemies/PlagueCharger.cs @@ -63,49 +63,47 @@ namespace CalamityMod.NPCs.PlagueEnemies spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/PlagueEnemies/PlagueChargerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redEyeColor = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color redEyeAfterimageColor = redEyeColor; + redEyeAfterimageColor = Color.Lerp(redEyeAfterimageColor, Color.White, 0.5f); + redEyeAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 redEyeAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + redEyeAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + redEyeAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, redEyeAfterimagePos, NPC.frame, redEyeAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redEyeColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PlagueEnemies/PlagueChargerLarge.cs b/NPCs/PlagueEnemies/PlagueChargerLarge.cs index 30d10b4956..e8342aa68f 100644 --- a/NPCs/PlagueEnemies/PlagueChargerLarge.cs +++ b/NPCs/PlagueEnemies/PlagueChargerLarge.cs @@ -65,49 +65,47 @@ namespace CalamityMod.NPCs.PlagueEnemies spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); texture2D15 = ModContent.Request("CalamityMod/NPCs/PlagueEnemies/PlagueChargerGlow").Value; - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + Color redEyeColor = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) { - for (int num163 = 1; num163 < num153; num163++) + for (int j = 1; j < afterimageAmt; j++) { - Color color41 = color37; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (float)(num153 - num163) / 15f; - Vector2 vector44 = NPC.oldPos[num163] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector44 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector44 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector44, NPC.frame, color41, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color redEyeAfterimageColor = redEyeColor; + redEyeAfterimageColor = Color.Lerp(redEyeAfterimageColor, Color.White, 0.5f); + redEyeAfterimageColor *= (float)(afterimageAmt - j) / 15f; + Vector2 redEyeAfterimagePos = NPC.oldPos[j] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + redEyeAfterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + redEyeAfterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, redEyeAfterimagePos, NPC.frame, redEyeAfterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - spriteBatch.Draw(texture2D15, vector43, NPC.frame, color37, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, redEyeColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } diff --git a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs index e67a0c15b1..78e7b7d9d7 100644 --- a/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs +++ b/NPCs/PlagueEnemies/PlaguebringerMiniboss.cs @@ -76,10 +76,10 @@ namespace CalamityMod.NPCs.PlagueEnemies public override void AI() { Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.1f, 0.3f, 0f); - bool flag113 = false; + bool outsideJungle = false; if (!Main.player[NPC.target].ZoneJungle) { - flag113 = true; + outsideJungle = true; if (NPC.timeLeft > 150) { NPC.timeLeft = 150; @@ -92,12 +92,12 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.timeLeft = 750; } } - int num1038 = 0; - for (int num1039 = 0; num1039 < 255; num1039++) + int playerAmt = 0; + for (int i = 0; i < 255; i++) { - if (Main.player[num1039].active && !Main.player[num1039].dead && (NPC.Center - Main.player[num1039].Center).Length() < 1000f) + if (Main.player[i].active && !Main.player[i].dead && (NPC.Center - Main.player[i].Center).Length() < 1000f) { - num1038++; + playerAmt++; } } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -129,22 +129,22 @@ namespace CalamityMod.NPCs.PlagueEnemies { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1041 = NPC.ai[1]; - int num1042; + float currentAttack = NPC.ai[1]; + int nextAttack; do { - num1042 = Main.rand.Next(3); - if (num1042 == 1) + nextAttack = Main.rand.Next(3); + if (nextAttack == 1) { - num1042 = 2; + nextAttack = 2; } - else if (num1042 == 2) + else if (nextAttack == 2) { - num1042 = 3; + nextAttack = 3; } } - while ((float)num1042 == num1041); - NPC.ai[0] = (float)num1042; + while ((float)nextAttack == currentAttack); + NPC.ai[0] = (float)nextAttack; NPC.ai[1] = 0f; NPC.ai[2] = 0f; return; @@ -152,12 +152,12 @@ namespace CalamityMod.NPCs.PlagueEnemies } else if (NPC.ai[0] == 0f) { - int num1043 = 2; //2 - if (flag113) + int chargeDelay = 2; //2 + if (outsideJungle) { - num1043 += 1; + chargeDelay += 1; } - if (NPC.ai[1] > (float)(2 * num1043) && NPC.ai[1] % 2f == 0f) + if (NPC.ai[1] > (float)(2 * chargeDelay) && NPC.ai[1] % 2f == 0f) { NPC.ai[0] = -1f; NPC.ai[1] = 0f; @@ -173,45 +173,45 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.localAI[0] = 1f; NPC.ai[1] += 1f; NPC.ai[2] = 0f; - float num1044 = 15f; - if (flag113) + float chargeSpeed = 15f; + if (outsideJungle) { - num1044 += 2f; + chargeSpeed += 2f; } - Vector2 vector117 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1045 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector117.X; - float num1046 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector117.Y; - float num1047 = (float)Math.Sqrt((double)(num1045 * num1045 + num1046 * num1046)); - num1047 = num1044 / num1047; - NPC.velocity.X = num1045 * num1047; - NPC.velocity.Y = num1046 * num1047; + Vector2 chargeBeePos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float chargeTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - chargeBeePos.X; + float chargeTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - chargeBeePos.Y; + float chargeTargetDist = (float)Math.Sqrt((double)(chargeTargetX * chargeTargetX + chargeTargetY * chargeTargetY)); + chargeTargetDist = chargeSpeed / chargeTargetDist; + NPC.velocity.X = chargeTargetX * chargeTargetDist; + NPC.velocity.Y = chargeTargetY * chargeTargetDist; NPC.spriteDirection = NPC.direction; SoundEngine.PlaySound(SoundID.Roar, NPC.Center); return; } NPC.localAI[0] = 0f; - float num1048 = 12.25f; - float num1049 = 0.155f; - if (flag113) + float lineUpSpeed = 12.25f; + float lineUpAcceleration = 0.155f; + if (outsideJungle) { - num1048 += 1f; - num1049 += 0.075f; + lineUpSpeed += 1f; + lineUpAcceleration += 0.075f; } if (NPC.position.Y + (float)(NPC.height / 2) < Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2)) { - NPC.velocity.Y = NPC.velocity.Y + num1049; + NPC.velocity.Y = NPC.velocity.Y + lineUpAcceleration; } else { - NPC.velocity.Y = NPC.velocity.Y - num1049; + NPC.velocity.Y = NPC.velocity.Y - lineUpAcceleration; } if (NPC.velocity.Y < -12f) { - NPC.velocity.Y = -num1048; + NPC.velocity.Y = -lineUpSpeed; } if (NPC.velocity.Y > 12f) { - NPC.velocity.Y = num1048; + NPC.velocity.Y = lineUpSpeed; } if (Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) > 600f) { @@ -246,13 +246,12 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.direction = 1; } NPC.spriteDirection = NPC.direction; - int num1050 = 500; - int num1051 = 1; + int chargeDirection = 1; if (NPC.position.X + (float)(NPC.width / 2) < Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2)) { - num1051 = -1; + chargeDirection = -1; } - if (NPC.direction == num1051 && Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) > (float)num1050) + if (NPC.direction == chargeDirection && Math.Abs(NPC.position.X + (float)(NPC.width / 2) - (Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2))) > 500f) { NPC.ai[2] = 1f; } @@ -265,13 +264,13 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.spriteDirection = NPC.direction; NPC.localAI[0] = 0f; NPC.velocity *= 0.9f; - float num1052 = 0.105f; - if (flag113) + float chargeDeceleration = 0.105f; + if (outsideJungle) { NPC.velocity *= 0.9f; - num1052 += 0.075f; + chargeDeceleration += 0.075f; } - if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < num1052) + if (Math.Abs(NPC.velocity.X) + Math.Abs(NPC.velocity.Y) < chargeDeceleration) { NPC.ai[2] = 0f; NPC.ai[1] += 1f; @@ -282,54 +281,54 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.TargetClosest(true); NPC.spriteDirection = NPC.direction; - float num1053 = 12f; - float num1054 = 0.1f; - if (flag113) + float hoverForBeesSpeed = 12f; + float hoverForBeesAccel = 0.1f; + if (outsideJungle) { - num1054 = 0.12f; + hoverForBeesAccel = 0.12f; } - Vector2 vector118 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1055 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector118.X; - float num1056 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 200f - vector118.Y; - float num1057 = (float)Math.Sqrt((double)(num1055 * num1055 + num1056 * num1056)); - if (num1057 < 400f) + Vector2 hoverForBeesPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float hoverForBeesTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - hoverForBeesPosition.X; + float hoverForBeesTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 200f - hoverForBeesPosition.Y; + float hoverForBeesTargetDist = (float)Math.Sqrt((double)(hoverForBeesTargetX * hoverForBeesTargetX + hoverForBeesTargetY * hoverForBeesTargetY)); + if (hoverForBeesTargetDist < 400f) { NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.netUpdate = true; return; } - num1057 = num1053 / num1057; - if (NPC.velocity.X < num1055) + hoverForBeesTargetDist = hoverForBeesSpeed / hoverForBeesTargetDist; + if (NPC.velocity.X < hoverForBeesTargetX) { - NPC.velocity.X = NPC.velocity.X + num1054; - if (NPC.velocity.X < 0f && num1055 > 0f) + NPC.velocity.X = NPC.velocity.X + hoverForBeesAccel; + if (NPC.velocity.X < 0f && hoverForBeesTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1054; + NPC.velocity.X = NPC.velocity.X + hoverForBeesAccel; } } - else if (NPC.velocity.X > num1055) + else if (NPC.velocity.X > hoverForBeesTargetX) { - NPC.velocity.X = NPC.velocity.X - num1054; - if (NPC.velocity.X > 0f && num1055 < 0f) + NPC.velocity.X = NPC.velocity.X - hoverForBeesAccel; + if (NPC.velocity.X > 0f && hoverForBeesTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1054; + NPC.velocity.X = NPC.velocity.X - hoverForBeesAccel; } } - if (NPC.velocity.Y < num1056) + if (NPC.velocity.Y < hoverForBeesTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1054; - if (NPC.velocity.Y < 0f && num1056 > 0f) + NPC.velocity.Y = NPC.velocity.Y + hoverForBeesAccel; + if (NPC.velocity.Y < 0f && hoverForBeesTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1054; + NPC.velocity.Y = NPC.velocity.Y + hoverForBeesAccel; } } - else if (NPC.velocity.Y > num1056) + else if (NPC.velocity.Y > hoverForBeesTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1054; - if (NPC.velocity.Y > 0f && num1056 < 0f) + NPC.velocity.Y = NPC.velocity.Y - hoverForBeesAccel; + if (NPC.velocity.Y > 0f && hoverForBeesTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1054; + NPC.velocity.Y = NPC.velocity.Y - hoverForBeesAccel; } } } @@ -337,83 +336,83 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.localAI[0] = 0f; NPC.TargetClosest(true); - Vector2 vector119 = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); - Vector2 vector120 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1058 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector120.X; - float num1059 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector120.Y; - float num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059)); + Vector2 beeSpawnPosition = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); + Vector2 plaguebringerBeeSpawnPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float beeSpawnTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - plaguebringerBeeSpawnPos.X; + float beeSpawnTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - plaguebringerBeeSpawnPos.Y; + float beeSpawnTargetDist = (float)Math.Sqrt((double)(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY)); NPC.ai[1] += 1f; - NPC.ai[1] += (float)(num1038 / 2); - bool flag103 = false; + NPC.ai[1] += (float)(playerAmt / 2); + bool canSpawnBee = false; if (NPC.ai[1] > 10f) { NPC.ai[1] = 0f; NPC.ai[2] += 1f; - flag103 = true; + canSpawnBee = true; } - if (Collision.CanHit(vector119, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && flag103) + if (Collision.CanHit(beeSpawnPosition, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && canSpawnBee) { SoundEngine.PlaySound(SoundID.NPCHit8, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - int num1061; + int beeType; if (Main.rand.NextBool(4)) { - num1061 = ModContent.NPCType(); + beeType = ModContent.NPCType(); } else { - num1061 = ModContent.NPCType(); + beeType = ModContent.NPCType(); } if (NPC.CountNPCS(ModContent.NPCType()) < 3) { - int num1062 = NPC.NewNPC(NPC.GetSource_FromAI(), (int)vector119.X, (int)vector119.Y, num1061, 0, 0f, 0f, 0f, 0f, 255); - Main.npc[num1062].velocity.X = (float)Main.rand.Next(-200, 201) * 0.005f; - Main.npc[num1062].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.005f; - Main.npc[num1062].localAI[0] = 60f; - Main.npc[num1062].netUpdate = true; + int notTheBees = NPC.NewNPC(NPC.GetSource_FromAI(), (int)beeSpawnPosition.X, (int)beeSpawnPosition.Y, beeType, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[notTheBees].velocity.X = (float)Main.rand.Next(-200, 201) * 0.005f; + Main.npc[notTheBees].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.005f; + Main.npc[notTheBees].localAI[0] = 60f; + Main.npc[notTheBees].netUpdate = true; } } } - if (num1060 > 400f || !Collision.CanHit(new Vector2(vector119.X, vector119.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (beeSpawnTargetDist > 400f || !Collision.CanHit(new Vector2(beeSpawnPosition.X, beeSpawnPosition.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - float num1063 = 14.5f; - float num1064 = 0.105f; - vector120 = vector119; - num1058 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector120.X; - num1059 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector120.Y; - num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059)); - num1060 = num1063 / num1060; - if (NPC.velocity.X < num1058) + float beeSpawnSpeed = 14.5f; + float beeSpawnAcceleration = 0.105f; + plaguebringerBeeSpawnPos = beeSpawnPosition; + beeSpawnTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - plaguebringerBeeSpawnPos.X; + beeSpawnTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - plaguebringerBeeSpawnPos.Y; + beeSpawnTargetDist = (float)Math.Sqrt((double)(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY)); + beeSpawnTargetDist = beeSpawnSpeed / beeSpawnTargetDist; + if (NPC.velocity.X < beeSpawnTargetX) { - NPC.velocity.X = NPC.velocity.X + num1064; - if (NPC.velocity.X < 0f && num1058 > 0f) + NPC.velocity.X = NPC.velocity.X + beeSpawnAcceleration; + if (NPC.velocity.X < 0f && beeSpawnTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1064; + NPC.velocity.X = NPC.velocity.X + beeSpawnAcceleration; } } - else if (NPC.velocity.X > num1058) + else if (NPC.velocity.X > beeSpawnTargetX) { - NPC.velocity.X = NPC.velocity.X - num1064; - if (NPC.velocity.X > 0f && num1058 < 0f) + NPC.velocity.X = NPC.velocity.X - beeSpawnAcceleration; + if (NPC.velocity.X > 0f && beeSpawnTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1064; + NPC.velocity.X = NPC.velocity.X - beeSpawnAcceleration; } } - if (NPC.velocity.Y < num1059) + if (NPC.velocity.Y < beeSpawnTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1064; - if (NPC.velocity.Y < 0f && num1059 > 0f) + NPC.velocity.Y = NPC.velocity.Y + beeSpawnAcceleration; + if (NPC.velocity.Y < 0f && beeSpawnTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1064; + NPC.velocity.Y = NPC.velocity.Y + beeSpawnAcceleration; } } - else if (NPC.velocity.Y > num1059) + else if (NPC.velocity.Y > beeSpawnTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1064; - if (NPC.velocity.Y > 0f && num1059 < 0f) + NPC.velocity.Y = NPC.velocity.Y - beeSpawnAcceleration; + if (NPC.velocity.Y > 0f && beeSpawnTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1064; + NPC.velocity.Y = NPC.velocity.Y - beeSpawnAcceleration; } } } @@ -431,123 +430,123 @@ namespace CalamityMod.NPCs.PlagueEnemies } else if (NPC.ai[0] == 3f) { - float num1065 = 7f; - float num1066 = 0.075f; - if (flag113) + float stingerAttackSpeed = 7f; + float stingerAttackAccel = 0.075f; + if (outsideJungle) { - num1066 = 0.09f; - num1065 = 8f; + stingerAttackAccel = 0.09f; + stingerAttackSpeed = 8f; } - Vector2 vector121 = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); - Vector2 vector122 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num1067 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector122.X; - float num1068 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 300f - vector122.Y; - float num1069 = (float)Math.Sqrt((double)(num1067 * num1067 + num1068 * num1068)); + Vector2 stingerSpawnPos = new Vector2(NPC.position.X + (float)(NPC.width / 2) + (float)(40 * NPC.direction), NPC.position.Y + (float)NPC.height * 0.8f); + Vector2 stingerAttackPos = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float stingerAttackTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - stingerAttackPos.X; + float stingerAttackTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - 300f - stingerAttackPos.Y; + float stingerAttackTargetDist = (float)Math.Sqrt((double)(stingerAttackTargetX * stingerAttackTargetX + stingerAttackTargetY * stingerAttackTargetY)); NPC.ai[1] += 1f; - bool flag104 = false; + bool canFireStinger = false; if (NPC.ai[1] % 35f == 34f) { - flag104 = true; + canFireStinger = true; } - if (flag104 && NPC.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y && Collision.CanHit(vector121, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (canFireStinger && NPC.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y && Collision.CanHit(stingerSpawnPos, 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { SoundEngine.PlaySound(SoundID.Item42, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1070 = 6f; - if (flag113) + float stingerSpeed = 6f; + if (outsideJungle) { - num1070 += 2f; + stingerSpeed += 2f; } - float num1071 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector121.X; - float num1072 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector121.Y; - float num1073 = (float)Math.Sqrt((double)(num1071 * num1071 + num1072 * num1072)); - num1073 = num1070 / num1073; - num1071 *= num1073; - num1072 *= num1073; + float stingerTargetX = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - stingerSpawnPos.X; + float stingerTargetY = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - stingerSpawnPos.Y; + float stingerTargetDist = (float)Math.Sqrt((double)(stingerTargetX * stingerTargetX + stingerTargetY * stingerTargetY)); + stingerTargetDist = stingerSpeed / stingerTargetDist; + stingerTargetX *= stingerTargetDist; + stingerTargetY *= stingerTargetDist; bool fireRocket = Main.rand.NextBool(15); int type = fireRocket ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = fireRocket ? 72 : 52; if (Main.expertMode) damage = fireRocket ? 50 : 35; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vector121.X, vector121.Y, num1071, num1072, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), stingerSpawnPos.X, stingerSpawnPos.Y, stingerTargetX, stingerTargetY, type, damage, 0f, Main.myPlayer, 0f, 0f); } } - if (!Collision.CanHit(new Vector2(vector121.X, vector121.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) + if (!Collision.CanHit(new Vector2(stingerSpawnPos.X, stingerSpawnPos.Y - 30f), 1, 1, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) { - num1066 = 0.105f; - vector122 = vector121; - num1067 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - vector122.X; - num1068 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - vector122.Y; - if (NPC.velocity.X < num1067) + stingerAttackAccel = 0.105f; + stingerAttackPos = stingerSpawnPos; + stingerAttackTargetX = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2) - stingerAttackPos.X; + stingerAttackTargetY = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2) - stingerAttackPos.Y; + if (NPC.velocity.X < stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X + num1066; - if (NPC.velocity.X < 0f && num1067 > 0f) + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel; + if (NPC.velocity.X < 0f && stingerAttackTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1066; + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel; } } - else if (NPC.velocity.X > num1067) + else if (NPC.velocity.X > stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X - num1066; - if (NPC.velocity.X > 0f && num1067 < 0f) + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel; + if (NPC.velocity.X > 0f && stingerAttackTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1066; + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel; } } - if (NPC.velocity.Y < num1068) + if (NPC.velocity.Y < stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1066; - if (NPC.velocity.Y < 0f && num1068 > 0f) + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel; + if (NPC.velocity.Y < 0f && stingerAttackTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1066; + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel; } } - else if (NPC.velocity.Y > num1068) + else if (NPC.velocity.Y > stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1066; - if (NPC.velocity.Y > 0f && num1068 < 0f) + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel; + if (NPC.velocity.Y > 0f && stingerAttackTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1066; + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel; } } } - else if (num1069 > 100f) + else if (stingerAttackTargetDist > 100f) { NPC.TargetClosest(true); NPC.spriteDirection = NPC.direction; - num1069 = num1065 / num1069; - if (NPC.velocity.X < num1067) + stingerAttackTargetDist = stingerAttackSpeed / stingerAttackTargetDist; + if (NPC.velocity.X < stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X + num1066; - if (NPC.velocity.X < 0f && num1067 > 0f) + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel; + if (NPC.velocity.X < 0f && stingerAttackTargetX > 0f) { - NPC.velocity.X = NPC.velocity.X + num1066 * 2f; + NPC.velocity.X = NPC.velocity.X + stingerAttackAccel * 2f; } } - else if (NPC.velocity.X > num1067) + else if (NPC.velocity.X > stingerAttackTargetX) { - NPC.velocity.X = NPC.velocity.X - num1066; - if (NPC.velocity.X > 0f && num1067 < 0f) + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel; + if (NPC.velocity.X > 0f && stingerAttackTargetX < 0f) { - NPC.velocity.X = NPC.velocity.X - num1066 * 2f; + NPC.velocity.X = NPC.velocity.X - stingerAttackAccel * 2f; } } - if (NPC.velocity.Y < num1068) + if (NPC.velocity.Y < stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y + num1066; - if (NPC.velocity.Y < 0f && num1068 > 0f) + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel; + if (NPC.velocity.Y < 0f && stingerAttackTargetY > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num1066 * 2f; + NPC.velocity.Y = NPC.velocity.Y + stingerAttackAccel * 2f; } } - else if (NPC.velocity.Y > num1068) + else if (NPC.velocity.Y > stingerAttackTargetY) { - NPC.velocity.Y = NPC.velocity.Y - num1066; - if (NPC.velocity.Y > 0f && num1068 < 0f) + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel; + if (NPC.velocity.Y > 0f && stingerAttackTargetY < 0f) { - NPC.velocity.Y = NPC.velocity.Y - num1066 * 2f; + NPC.velocity.Y = NPC.velocity.Y - stingerAttackAccel * 2f; } } } @@ -572,32 +571,30 @@ namespace CalamityMod.NPCs.PlagueEnemies spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = TextureAssets.Npc[NPC.type].Value; - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 7; + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + int afterimageAmt = 7; if (NPC.ai[0] != 0f) - num153 = 5; + afterimageAmt = 5; if (CalamityConfig.Instance.Afterimages) { - for (int num155 = 1; num155 < num153; num155 += 2) + for (int i = 1; i < afterimageAmt; i += 2) { - Color color38 = drawColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = NPC.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = NPC.oldPos[num155] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector41 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, NPC.frame, color38, NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Color afterimageColor = drawColor; + afterimageColor = Color.Lerp(afterimageColor, Color.White, 0.5f); + afterimageColor = NPC.GetAlpha(afterimageColor); + afterimageColor *= (float)(afterimageAmt - i) / 15f; + Vector2 afterimagePos = NPC.oldPos[i] + new Vector2((float)NPC.width, (float)NPC.height) / 2f - screenPos; + afterimagePos -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + afterimagePos += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, afterimagePos, NPC.frame, afterimageColor, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); } } - Vector2 vector43 = NPC.Center - screenPos; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; - vector43 += vector11 * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector11, NPC.scale, spriteEffects, 0f); + Vector2 drawLocation = NPC.Center - screenPos; + drawLocation -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[NPC.type])) * NPC.scale / 2f; + drawLocation += halfSizeTexture * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture2D15, drawLocation, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0f); return false; } @@ -628,23 +625,23 @@ namespace CalamityMod.NPCs.PlagueEnemies NPC.height = 100; NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int num621 = 0; num621 < 40; num621++) + for (int i = 0; i < 40; i++) { - int num622 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + int plagueDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[plagueDust].scale = 0.5f; + Main.dust[plagueDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 70; num623++) + for (int j = 0; j < 70; j++) { - int num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + int plagueDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 3f); + Main.dust[plagueDust2].noGravity = true; + Main.dust[plagueDust2].velocity *= 5f; + plagueDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, (int)CalamityDusts.Plague, 0f, 0f, 100, default, 2f); + Main.dust[plagueDust2].velocity *= 2f; } } } diff --git a/NPCs/PlagueEnemies/Viruling.cs b/NPCs/PlagueEnemies/Viruling.cs index d5377f9986..a78dd17c7f 100644 --- a/NPCs/PlagueEnemies/Viruling.cs +++ b/NPCs/PlagueEnemies/Viruling.cs @@ -66,75 +66,75 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.TargetClosest(true); } - float num = 6f; - float num2 = 0.05f; + float maxSpeed = 6f; + float acceleration = 0.05f; if (CalamityWorld.revenge) { - num *= 1.25f; - num2 *= 1.25f; + maxSpeed *= 1.25f; + acceleration *= 1.25f; } if (CalamityWorld.death) { - num *= 1.25f; - num2 *= 1.25f; + maxSpeed *= 1.25f; + acceleration *= 1.25f; } Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num4 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num5 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num4 = (float)((int)(num4 / 8f) * 8); - num5 = (float)((int)(num5 / 8f) * 8); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 8f) * 8); + targetYDist = (float)((int)(targetYDist / 8f) * 8); vector.X = (float)((int)(vector.X / 8f) * 8); vector.Y = (float)((int)(vector.Y / 8f) * 8); - num4 -= vector.X; - num5 -= vector.Y; - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - if (num6 == 0f) + targetXDist -= vector.X; + targetYDist -= vector.Y; + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + if (targetDistance == 0f) { - num4 = NPC.velocity.X; - num5 = NPC.velocity.Y; + targetXDist = NPC.velocity.X; + targetYDist = NPC.velocity.Y; } else { - num6 = num / num6; - num4 *= num6; - num5 *= num6; + targetDistance = maxSpeed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; } if (Main.player[NPC.target].dead) { - num4 = (float)NPC.direction * num / 2f; - num5 = -num / 2f; + targetXDist = (float)NPC.direction * maxSpeed / 2f; + targetYDist = -maxSpeed / 2f; } - if (NPC.velocity.X < num4) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num2; + NPC.velocity.X = NPC.velocity.X + acceleration; } - else if (NPC.velocity.X > num4) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num2; + NPC.velocity.X = NPC.velocity.X - acceleration; } - if (NPC.velocity.Y < num5) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num2; + NPC.velocity.Y = NPC.velocity.Y + acceleration; } - else if (NPC.velocity.Y > num5) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num2; + NPC.velocity.Y = NPC.velocity.Y - acceleration; } - if (num4 > 0f) + if (targetXDist > 0f) { NPC.spriteDirection = 1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4); + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist); } - else if (num4 < 0f) + else if (targetXDist < 0f) { NPC.spriteDirection = -1; - NPC.rotation = (float)Math.Atan2((double)num5, (double)num4) + 3.14f; + NPC.rotation = (float)Math.Atan2((double)targetYDist, (double)targetXDist) + 3.14f; } - float num12 = 0.7f; + float recoilSpeed = 0.7f; if (NPC.collideX) { NPC.netUpdate = true; - NPC.velocity.X = NPC.oldVelocity.X * -num12; + NPC.velocity.X = NPC.oldVelocity.X * -recoilSpeed; if (NPC.direction == -1 && NPC.velocity.X > 0f && NPC.velocity.X < 2f) { NPC.velocity.X = 2f; @@ -147,7 +147,7 @@ namespace CalamityMod.NPCs.PlagueEnemies if (NPC.collideY) { NPC.netUpdate = true; - NPC.velocity.Y = NPC.oldVelocity.Y * -num12; + NPC.velocity.Y = NPC.oldVelocity.Y * -recoilSpeed; if (NPC.velocity.Y > 0f && (double)NPC.velocity.Y < 1.5) { NPC.velocity.Y = 2f; @@ -161,8 +161,8 @@ namespace CalamityMod.NPCs.PlagueEnemies { NPC.netUpdate = true; } - int num13 = Dust.NewDust(new Vector2(NPC.position.X - NPC.velocity.X, NPC.position.Y - NPC.velocity.Y), NPC.width, NPC.height, 46, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default, 2f); - Dust dust = Main.dust[num13]; + int idleDust = Dust.NewDust(new Vector2(NPC.position.X - NPC.velocity.X, NPC.position.Y - NPC.velocity.Y), NPC.width, NPC.height, 46, NPC.velocity.X * 0.2f, NPC.velocity.Y * 0.2f, 100, default, 2f); + Dust dust = Main.dust[idleDust]; dust.noGravity = true; dust.velocity.X *= 0.3f; dust.velocity.Y *= 0.3f; diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index c7b8761c08..896e52d12c 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -1366,14 +1366,14 @@ namespace CalamityMod.NPCs.PrimordialWyrm { for (int num1474 = 0; num1474 < dustAmt; num1474++) { - Vector2 vector171 = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; - vector171 = vector171.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 172, value18.X * 2f, value18.Y * 2f, 100, default, 1.4f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= NPC.velocity; + Vector2 dustRotation = Vector2.Normalize(NPC.velocity) * new Vector2((NPC.width + 50) / 2f, NPC.height) * 0.75f; + dustRotation = dustRotation.RotatedBy((num1474 - (dustAmt / 2 - 1)) * (double)pie / (float)dustAmt) + NPC.Center; + Vector2 dustVelocity = ((float)(Main.rand.NextDouble() * pie) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int chargeDust = Dust.NewDust(dustRotation + dustVelocity, 0, 0, 172, dustVelocity.X * 2f, dustVelocity.Y * 2f, 100, default, 1.4f); + Main.dust[chargeDust].noGravity = true; + Main.dust[chargeDust].noLight = true; + Main.dust[chargeDust].velocity /= 4f; + Main.dust[chargeDust].velocity -= NPC.velocity; } } @@ -1394,18 +1394,18 @@ namespace CalamityMod.NPCs.PrimordialWyrm Rectangle targetHitbox = target.Hitbox; - float dist1 = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); - float dist2 = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); - float dist3 = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); - float dist4 = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); + float hitboxTopLeft = Vector2.Distance(NPC.Center, targetHitbox.TopLeft()); + float hitboxTopRight = Vector2.Distance(NPC.Center, targetHitbox.TopRight()); + float hitboxBotLeft = Vector2.Distance(NPC.Center, targetHitbox.BottomLeft()); + float hitboxBotRight = Vector2.Distance(NPC.Center, targetHitbox.BottomRight()); - float minDist = dist1; - if (dist2 < minDist) - minDist = dist2; - if (dist3 < minDist) - minDist = dist3; - if (dist4 < minDist) - minDist = dist4; + float minDist = hitboxTopLeft; + if (hitboxTopRight < minDist) + minDist = hitboxTopRight; + if (hitboxBotLeft < minDist) + minDist = hitboxBotLeft; + if (hitboxBotRight < minDist) + minDist = hitboxBotRight; return minDist <= 70f && NPC.Opacity == 1f; } diff --git a/NPCs/SulphurousSea/Gnasher.cs b/NPCs/SulphurousSea/Gnasher.cs index 7b7fad8f42..c84311fc14 100644 --- a/NPCs/SulphurousSea/Gnasher.cs +++ b/NPCs/SulphurousSea/Gnasher.cs @@ -56,43 +56,43 @@ namespace CalamityMod.NPCs.SulphurousSea public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1; - float num79 = (Main.player[NPC.target].Center - NPC.Center).Length(); - num79 *= 0.0025f; - if ((double)num79 > 1.5) + float targetDist = (Main.player[NPC.target].Center - NPC.Center).Length(); + targetDist *= 0.0025f; + if ((double)targetDist > 1.5) { - num79 = 1.5f; + targetDist = 1.5f; } - float num78; + float maxVelocity; if (Main.expertMode) { - num78 = 2.5f - num79; + maxVelocity = 2.5f - targetDist; } else { - num78 = 2.25f - num79; + maxVelocity = 2.25f - targetDist; } - num78 *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); - if (NPC.velocity.X < -num78 || NPC.velocity.X > num78) + maxVelocity *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) { if (NPC.velocity.Y == 0f) { NPC.velocity *= 0.8f; } } - else if (NPC.velocity.X < num78 && NPC.direction == 1) + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) { NPC.velocity.X = NPC.velocity.X + 1f; - if (NPC.velocity.X > num78) + if (NPC.velocity.X > maxVelocity) { - NPC.velocity.X = num78; + NPC.velocity.X = maxVelocity; } } - else if (NPC.velocity.X > -num78 && NPC.direction == -1) + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) { NPC.velocity.X = NPC.velocity.X - 1f; - if (NPC.velocity.X < -num78) + if (NPC.velocity.X < -maxVelocity) { - NPC.velocity.X = -num78; + NPC.velocity.X = -maxVelocity; } } } diff --git a/NPCs/SulphurousSea/Sulflounder.cs b/NPCs/SulphurousSea/Sulflounder.cs index 91b8c82b15..d91dcee45e 100644 --- a/NPCs/SulphurousSea/Sulflounder.cs +++ b/NPCs/SulphurousSea/Sulflounder.cs @@ -56,10 +56,10 @@ namespace CalamityMod.NPCs.SulphurousSea public override void AI() { NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; - int num = 200; + int alphaControl = 200; if (NPC.ai[2] == 0f) { - NPC.alpha = num; + NPC.alpha = alphaControl; NPC.TargetClosest(true); if (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 170f && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height)) @@ -76,7 +76,7 @@ namespace CalamityMod.NPCs.SulphurousSea { if (NPC.alpha > 0) { - NPC.alpha -= num / 16; + NPC.alpha -= alphaControl / 16; if (NPC.alpha < 0) { NPC.alpha = 0; diff --git a/NPCs/SulphurousSea/Trasher.cs b/NPCs/SulphurousSea/Trasher.cs index a13569ff75..6dbff3f85d 100644 --- a/NPCs/SulphurousSea/Trasher.cs +++ b/NPCs/SulphurousSea/Trasher.cs @@ -89,19 +89,19 @@ namespace CalamityMod.NPCs.SulphurousSea NPC.TargetClosest(true); } NPC.noTileCollide = false; - bool flag14 = hasBeenHit; + bool canAttack = hasBeenHit; NPC.TargetClosest(false); if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && (Main.player[NPC.target].Center - NPC.Center).Length() < 200f) { - flag14 = true; + canAttack = true; } - if (Main.player[NPC.target].dead && flag14) + if (Main.player[NPC.target].dead && canAttack) { - flag14 = false; + canAttack = false; } - if (!flag14) + if (!canAttack) { if (NPC.collideX) { @@ -126,7 +126,7 @@ namespace CalamityMod.NPCs.SulphurousSea } } } - if (flag14) + if (canAttack) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X + (float)NPC.direction * (CalamityWorld.death ? 0.6f : CalamityWorld.revenge ? 0.45f : 0.3f); @@ -174,15 +174,15 @@ namespace CalamityMod.NPCs.SulphurousSea } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } @@ -201,22 +201,22 @@ namespace CalamityMod.NPCs.SulphurousSea return; } NPC.noTileCollide = true; - float num823 = 1f; + float velocityBoost = 1f; NPC.TargetClosest(true); - bool flag51 = false; + bool closeToTargetX = false; if ((double)NPC.life < (double)NPC.lifeMax * 0.5 || CalamityWorld.death) { - num823 = 1.5f; + velocityBoost = 1.5f; } if ((double)NPC.life < (double)NPC.lifeMax * 0.25 || CalamityWorld.death) { - num823 = 2.5f; + velocityBoost = 2.5f; } if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 20f) { - flag51 = true; + closeToTargetX = true; } - if (flag51) + if (closeToTargetX) { NPC.velocity.X = NPC.velocity.X * 0.9f; if ((double)NPC.velocity.X > -0.1 && (double)NPC.velocity.X < 0.1) @@ -228,26 +228,26 @@ namespace CalamityMod.NPCs.SulphurousSea { if (NPC.direction > 0) { - NPC.velocity.X = (NPC.velocity.X * 20f + num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f + velocityBoost) / 21f; } if (NPC.direction < 0) { - NPC.velocity.X = (NPC.velocity.X * 20f - num823) / 21f; + NPC.velocity.X = (NPC.velocity.X * 20f - velocityBoost) / 21f; } } - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(NPC.Center.X - (float)(num854 / 2), NPC.position.Y + (float)NPC.height - (float)num855); - bool flag52 = false; + int collisionWidth = 80; + int collisionHeight = 20; + Vector2 collisionSize = new Vector2(NPC.Center.X - (float)(collisionWidth / 2), NPC.position.Y + (float)NPC.height - (float)collisionHeight); + bool shouldFallThroughTiles = false; if (NPC.position.X < Main.player[NPC.target].position.X && NPC.position.X + (float)NPC.width > Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width && NPC.position.Y + (float)NPC.height < Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height - 16f) { - flag52 = true; + shouldFallThroughTiles = true; } - if (flag52) + if (shouldFallThroughTiles) { NPC.velocity.Y = NPC.velocity.Y + 0.5f; } - else if (Collision.SolidCollision(position2, num854, num855)) + else if (Collision.SolidCollision(collisionSize, collisionWidth, collisionHeight)) { if (NPC.velocity.Y > 0f) { diff --git a/NPCs/SunkenSea/BabyGhostBell.cs b/NPCs/SunkenSea/BabyGhostBell.cs index 73816facfa..187eec59a4 100644 --- a/NPCs/SunkenSea/BabyGhostBell.cs +++ b/NPCs/SunkenSea/BabyGhostBell.cs @@ -142,13 +142,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/BabyGhostBellGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/SunkenSea/BlindedAngler.cs b/NPCs/SunkenSea/BlindedAngler.cs index 804650ce5b..ccba52a02b 100644 --- a/NPCs/SunkenSea/BlindedAngler.cs +++ b/NPCs/SunkenSea/BlindedAngler.cs @@ -85,13 +85,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/SunkenSea/Clam.cs b/NPCs/SunkenSea/Clam.cs index 12e1ce4a1c..101764fe4a 100644 --- a/NPCs/SunkenSea/Clam.cs +++ b/NPCs/SunkenSea/Clam.cs @@ -121,12 +121,12 @@ namespace CalamityMod.NPCs.SunkenSea else if (NPC.velocity.Y == 0f) { NPC.ai[2] += 1f; - int num321 = 20; + int decelerationTimer = 20; if (NPC.ai[1] == 0f) { - num321 = 12; + decelerationTimer = 12; } - if (NPC.ai[2] < (float)num321) + if (NPC.ai[2] < (float)decelerationTimer) { NPC.velocity.X *= 0.9f; return; diff --git a/NPCs/SunkenSea/EutrophicRay.cs b/NPCs/SunkenSea/EutrophicRay.cs index 00ecd57f2c..2cee708a99 100644 --- a/NPCs/SunkenSea/EutrophicRay.cs +++ b/NPCs/SunkenSea/EutrophicRay.cs @@ -184,13 +184,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/SunkenSea/GhostBell.cs b/NPCs/SunkenSea/GhostBell.cs index 857c2720b1..d01e9196ec 100644 --- a/NPCs/SunkenSea/GhostBell.cs +++ b/NPCs/SunkenSea/GhostBell.cs @@ -139,13 +139,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo) diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index 1d23f095fa..782165556a 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -212,17 +212,17 @@ namespace CalamityMod.NPCs.SunkenSea { if (Main.rand.NextBool()) { - int num5 = Dust.NewDust(NPC.position, NPC.width, NPC.height, 226, 0f, 0f, 200, default, 1.5f); - Main.dust[num5].noGravity = true; - Main.dust[num5].velocity *= 0.75f; - Main.dust[num5].fadeIn = 1.3f; + int attackDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 226, 0f, 0f, 200, default, 1.5f); + Main.dust[attackDust].noGravity = true; + Main.dust[attackDust].velocity *= 0.75f; + Main.dust[attackDust].fadeIn = 1.3f; Vector2 vector = new Vector2((float)Main.rand.Next(-200, 201), (float)Main.rand.Next(-200, 201)); vector.Normalize(); vector *= (float)Main.rand.Next(100, 200) * 0.04f; - Main.dust[num5].velocity = vector; + Main.dust[attackDust].velocity = vector; vector.Normalize(); vector *= 34f; - Main.dust[num5].position = NPC.Center - vector; + Main.dust[attackDust].position = NPC.Center - vector; } NPC.alpha -= Main.hardMode ? 7 : 4; if (NPC.alpha <= 0) @@ -356,7 +356,7 @@ namespace CalamityMod.NPCs.SunkenSea else if (attack == 2) { SoundEngine.PlaySound(SoundID.Item67, NPC.position); - Vector2 value9 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + Vector2 clamPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); float spread = 45f * 0.0174f; double startAngle = Math.Atan2(NPC.velocity.X, NPC.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; @@ -365,18 +365,18 @@ namespace CalamityMod.NPCs.SunkenSea int damage = Main.expertMode ? 28 : 35; float speed = 5f; Vector2 vector = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)(NPC.height / 2)); - float num6 = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); - float num7 = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); - float num8 = (float)Math.Sqrt((double)(num6 * num6 + num7 * num7)); - num8 = speed / num8; - num6 *= num8; - num7 *= num8; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, num6, num7, projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); + float targetXDist = Main.player[NPC.target].position.X + (float)Main.player[NPC.target].width * 0.5f - vector.X + (float)Main.rand.Next(-20, 21); + float targetYDist = Main.player[NPC.target].position.Y + (float)Main.player[NPC.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-20, 21); + float targetDistance = (float)Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + targetDistance = speed / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, targetXDist, targetYDist, projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); for (int i = 0; i < 4; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, (float)(Math.Sin(offsetAngle) * 3f), (float)(Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, (float)(-Math.Sin(offsetAngle) * 3f), (float)(-Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), clamPosition.X, clamPosition.Y, (float)(Math.Sin(offsetAngle) * 3f), (float)(Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), clamPosition.X, clamPosition.Y, (float)(-Math.Sin(offsetAngle) * 3f), (float)(-Math.Cos(offsetAngle) * 3f), projectileShot, damage, 0f, Main.myPlayer, 0f, 0f); } attack = -1; NPC.ai[3] = 0f; @@ -507,12 +507,12 @@ namespace CalamityMod.NPCs.SunkenSea Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/SunkenSea/GiantClamGlow").Value; SpriteEffects spriteEffects = SpriteEffects.None; Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(texture.Width / 2), (float)(texture.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)glowmask.Width, (float)(glowmask.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); - Main.EntitySpriteDraw(glowmask, vector, NPC.frame, color, NPC.rotation, vector11, NPC.scale, spriteEffects, 0); + Main.EntitySpriteDraw(glowmask, vector, NPC.frame, color, NPC.rotation, halfSizeTexture, NPC.scale, spriteEffects, 0); } public override void OnKill() diff --git a/NPCs/SunkenSea/PrismBack.cs b/NPCs/SunkenSea/PrismBack.cs index 3c80c68b70..32cd648cf8 100644 --- a/NPCs/SunkenSea/PrismBack.cs +++ b/NPCs/SunkenSea/PrismBack.cs @@ -130,13 +130,13 @@ namespace CalamityMod.NPCs.SunkenSea spriteEffects = SpriteEffects.FlipHorizontally; } Vector2 center = new Vector2(NPC.Center.X, NPC.Center.Y); - Vector2 vector11 = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); + Vector2 halfSizeTexture = new Vector2((float)(TextureAssets.Npc[NPC.type].Value.Width / 2), (float)(TextureAssets.Npc[NPC.type].Value.Height / Main.npcFrameCount[NPC.type] / 2)); Vector2 vector = center - screenPos; vector -= new Vector2((float)ModContent.Request("CalamityMod/NPCs/SunkenSea/PrismBackGlow").Value.Width, (float)(ModContent.Request("CalamityMod/NPCs/SunkenSea/PrismBackGlow").Value.Height / Main.npcFrameCount[NPC.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 4f + NPC.gfxOffY); + vector += halfSizeTexture * 1f + new Vector2(0f, 4f + NPC.gfxOffY); Color color = new Color(127 - NPC.alpha, 127 - NPC.alpha, 127 - NPC.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Blue); Main.spriteBatch.Draw(ModContent.Request("CalamityMod/NPCs/SunkenSea/PrismBackGlow").Value, vector, - new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, vector11, 1f, spriteEffects, 0f); + new Microsoft.Xna.Framework.Rectangle?(NPC.frame), color, NPC.rotation, halfSizeTexture, 1f, spriteEffects, 0f); } public override bool? CanBeHitByProjectile(Projectile projectile) diff --git a/NPCs/SunkenSea/SeaMinnow.cs b/NPCs/SunkenSea/SeaMinnow.cs index af2f8ea345..0b4a2fa887 100644 --- a/NPCs/SunkenSea/SeaMinnow.cs +++ b/NPCs/SunkenSea/SeaMinnow.cs @@ -51,7 +51,7 @@ namespace CalamityMod.NPCs.SunkenSea CalamityAI.PassiveSwimmingAI(NPC, Mod, 3, 150f, 0.25f, 0.15f, 6f, 6f, 0.05f); NPC.spriteDirection = (NPC.direction > 0) ? 1 : -1; NPC.noGravity = true; - bool flag14 = false; + bool shouldSwimAway = false; if (NPC.direction == 0) { NPC.TargetClosest(true); @@ -62,13 +62,13 @@ namespace CalamityMod.NPCs.SunkenSea if (Main.player[NPC.target].wet && !Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < 150f) { - flag14 = true; + shouldSwimAway = true; } - if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && flag14) + if ((!Main.player[NPC.target].wet || Main.player[NPC.target].dead) && shouldSwimAway) { - flag14 = false; + shouldSwimAway = false; } - if (!flag14) + if (!shouldSwimAway) { if (NPC.collideX || NPC.velocity.X == 0f) { @@ -93,7 +93,7 @@ namespace CalamityMod.NPCs.SunkenSea } } } - if (flag14) + if (shouldSwimAway) { NPC.TargetClosest(true); NPC.velocity.X = NPC.velocity.X - (float)NPC.direction * 0.25f; @@ -140,15 +140,15 @@ namespace CalamityMod.NPCs.SunkenSea } } } - int num258 = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; - int num259 = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; - if (Main.tile[num258, num259 - 1].LiquidAmount > 128) + int npcTileX = (int)(NPC.position.X + (float)(NPC.width / 2)) / 16; + int npcTileY = (int)(NPC.position.Y + (float)(NPC.height / 2)) / 16; + if (Main.tile[npcTileX, npcTileY - 1].LiquidAmount > 128) { - if (Main.tile[num258, num259 + 1].HasTile) + if (Main.tile[npcTileX, npcTileY + 1].HasTile) { NPC.ai[0] = -1f; } - else if (Main.tile[num258, num259 + 2].HasTile) + else if (Main.tile[npcTileX, npcTileY + 2].HasTile) { NPC.ai[0] = -1f; } diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index fa6aa7939c..8a332e4ec3 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -144,149 +144,149 @@ namespace CalamityMod.NPCs.SunkenSea { NPC.active = false; } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + float currentSpeed = speed; + float currentTurnSpeed = turnSpeed; + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); if (NPC.life > NPC.lifeMax * 0.99) { - num192 += 300; + targetYDist += 300; if (Math.Abs(NPC.Center.X - Main.player[NPC.target].Center.X) < 250f) { if (NPC.velocity.X > 0f) { - num191 = Main.player[NPC.target].Center.X + 300f; + targetXDist = Main.player[NPC.target].Center.X + 300f; } else { - num191 = Main.player[NPC.target].Center.X - 300f; + targetXDist = Main.player[NPC.target].Center.X - 300f; } } } else { - num188 *= 1.5f; - num189 *= 1.5f; + currentSpeed *= 1.5f; + currentTurnSpeed *= 1.5f; } - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = NPC.velocity.Length(); - if (num50 > 0f) + float maxCurrentSpeed = currentSpeed * 1.3f; + float minCurrentSpeed = currentSpeed * 0.7f; + float speedCompare = NPC.velocity.Length(); + if (speedCompare > 0f) { - if (num50 > num48) + if (speedCompare > maxCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num48; + NPC.velocity *= maxCurrentSpeed; } - else if (num50 < num49) + else if (speedCompare < minCurrentSpeed) { NPC.velocity.Normalize(); - NPC.velocity *= num49; + NPC.velocity *= minCurrentSpeed; } } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - if ((NPC.velocity.X > 0f && num191 > 0f) || (NPC.velocity.X < 0f && num191 < 0f) || (NPC.velocity.Y > 0f && num192 > 0f) || (NPC.velocity.Y < 0f && num192 < 0f)) + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + float absoluteTargetX = System.Math.Abs(targetXDist); + float absoluteTargetY = System.Math.Abs(targetYDist); + float timeToReachTarget = currentSpeed / targetDistance; + targetXDist *= timeToReachTarget; + targetYDist *= timeToReachTarget; + if ((NPC.velocity.X > 0f && targetXDist > 0f) || (NPC.velocity.X < 0f && targetXDist < 0f) || (NPC.velocity.Y > 0f && targetYDist > 0f) || (NPC.velocity.Y < 0f && targetYDist < 0f)) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - if (NPC.velocity.X > num191) + if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - if (NPC.velocity.Y > num192) + if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((NPC.velocity.X > 0f && num191 < 0f) || (NPC.velocity.X < 0f && num191 > 0f))) + if ((double)System.Math.Abs(targetYDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.X > 0f && targetXDist < 0f) || (NPC.velocity.X < 0f && targetXDist > 0f))) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 2f; } else { - NPC.velocity.Y = NPC.velocity.Y - num189 * 2f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 2f; } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((NPC.velocity.Y > 0f && num192 < 0f) || (NPC.velocity.Y < 0f && num192 > 0f))) + if ((double)System.Math.Abs(targetXDist) < (double)currentSpeed * 0.2 && ((NPC.velocity.Y > 0f && targetYDist < 0f) || (NPC.velocity.Y < 0f && targetYDist > 0f))) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 2f; //changed from 2 } else { - NPC.velocity.X = NPC.velocity.X - num189 * 2f; //changed from 2 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 2f; //changed from 2 } } } else { - if (num196 > num197) + if (absoluteTargetX > absoluteTargetY) { - if (NPC.velocity.X < num191) + if (NPC.velocity.X < targetXDist) { - NPC.velocity.X = NPC.velocity.X + num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed * 1.1f; //changed from 1.1 } - else if (NPC.velocity.X > num191) + else if (NPC.velocity.X > targetXDist) { - NPC.velocity.X = NPC.velocity.X - num189 * 1.1f; //changed from 1.1 + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed * 1.1f; //changed from 1.1 } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.Y > 0f) { - NPC.velocity.Y = NPC.velocity.Y + num189; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed; } else { - NPC.velocity.Y = NPC.velocity.Y - num189; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed; } } } else { - if (NPC.velocity.Y < num192) + if (NPC.velocity.Y < targetYDist) { - NPC.velocity.Y = NPC.velocity.Y + num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y + currentTurnSpeed * 1.1f; } - else if (NPC.velocity.Y > num192) + else if (NPC.velocity.Y > targetYDist) { - NPC.velocity.Y = NPC.velocity.Y - num189 * 1.1f; + NPC.velocity.Y = NPC.velocity.Y - currentTurnSpeed * 1.1f; } - if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)num188 * 0.5) + if ((double)(System.Math.Abs(NPC.velocity.X) + System.Math.Abs(NPC.velocity.Y)) < (double)currentSpeed * 0.5) { if (NPC.velocity.X > 0f) { - NPC.velocity.X = NPC.velocity.X + num189; + NPC.velocity.X = NPC.velocity.X + currentTurnSpeed; } else { - NPC.velocity.X = NPC.velocity.X - num189; + NPC.velocity.X = NPC.velocity.X - currentTurnSpeed; } } } diff --git a/NPCs/SunkenSea/SeaSerpent2.cs b/NPCs/SunkenSea/SeaSerpent2.cs index e631ce019d..fc7e14a9cb 100644 --- a/NPCs/SunkenSea/SeaSerpent2.cs +++ b/NPCs/SunkenSea/SeaSerpent2.cs @@ -87,39 +87,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SunkenSea/SeaSerpent3.cs b/NPCs/SunkenSea/SeaSerpent3.cs index b1c257e61c..7c8873f0fa 100644 --- a/NPCs/SunkenSea/SeaSerpent3.cs +++ b/NPCs/SunkenSea/SeaSerpent3.cs @@ -85,39 +85,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SunkenSea/SeaSerpent4.cs b/NPCs/SunkenSea/SeaSerpent4.cs index 884f30e531..9442d632d8 100644 --- a/NPCs/SunkenSea/SeaSerpent4.cs +++ b/NPCs/SunkenSea/SeaSerpent4.cs @@ -85,39 +85,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/NPCs/SunkenSea/SeaSerpent5.cs b/NPCs/SunkenSea/SeaSerpent5.cs index f5b91b77e3..6728bd8461 100644 --- a/NPCs/SunkenSea/SeaSerpent5.cs +++ b/NPCs/SunkenSea/SeaSerpent5.cs @@ -85,39 +85,39 @@ namespace CalamityMod.NPCs.SunkenSea NPC.alpha = 0; } - Vector2 vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num191 = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); - float num192 = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + float targetXDist = Main.player[NPC.target].position.X + (float)(Main.player[NPC.target].width / 2); + float targetYDist = Main.player[NPC.target].position.Y + (float)(Main.player[NPC.target].height / 2); + targetXDist = (float)((int)(targetXDist / 16f) * 16); + targetYDist = (float)((int)(targetYDist / 16f) * 16); + segmentPosition.X = (float)((int)(segmentPosition.X / 16f) * 16); + segmentPosition.Y = (float)((int)(segmentPosition.Y / 16f) * 16); + targetXDist -= segmentPosition.X; + targetYDist -= segmentPosition.Y; + float targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); if (NPC.ai[1] > 0f && NPC.ai[1] < (float)Main.npc.Length) { try { - vector18 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - num191 = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - vector18.Y; + segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); + targetXDist = Main.npc[(int)NPC.ai[1]].position.X + (float)(Main.npc[(int)NPC.ai[1]].width / 2) - segmentPosition.X; + targetYDist = Main.npc[(int)NPC.ai[1]].position.Y + (float)(Main.npc[(int)NPC.ai[1]].height / 2) - segmentPosition.Y; } catch { } - NPC.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - int num194 = NPC.width; - num193 = (num193 - (float)num194) / num193; - num191 *= num193; - num192 *= num193; + NPC.rotation = (float)System.Math.Atan2((double)targetYDist, (double)targetXDist) + 1.57f; + targetDistance = (float)System.Math.Sqrt((double)(targetXDist * targetXDist + targetYDist * targetYDist)); + int segmentWidth = NPC.width; + targetDistance = (targetDistance - (float)segmentWidth) / targetDistance; + targetXDist *= targetDistance; + targetYDist *= targetDistance; NPC.velocity = Vector2.Zero; - NPC.position.X = NPC.position.X + num191; - NPC.position.Y = NPC.position.Y + num192; + NPC.position.X = NPC.position.X + targetXDist; + NPC.position.Y = NPC.position.Y + targetYDist; - if (num191 < 0f) + if (targetXDist < 0f) NPC.spriteDirection = -1; - else if (num191 > 0f) + else if (targetXDist > 0f) NPC.spriteDirection = 1; } } diff --git a/Particles/AltLineParticle.cs b/Particles/AltLineParticle.cs new file mode 100644 index 0000000000..5dfd32e142 --- /dev/null +++ b/Particles/AltLineParticle.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class AltLineParticle : Particle + { + public Color InitialColor; + public bool AffectedByGravity; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => false; + + public override string Texture => "CalamityMod/Particles/DrainLine"; + + public AltLineParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + { + Position = relativePosition; + Velocity = velocity; + AffectedByGravity = affectedByGravity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + } + + public override void Update() + { + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = new Vector2(0.5f, 1.6f) * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + } + } +} diff --git a/Particles/AltSparkParticle.cs b/Particles/AltSparkParticle.cs new file mode 100644 index 0000000000..24fd3ec6c8 --- /dev/null +++ b/Particles/AltSparkParticle.cs @@ -0,0 +1,51 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class AltSparkParticle : Particle + { + public Color InitialColor; + public bool AffectedByGravity; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => false; + + public override string Texture => "CalamityMod/Projectiles/StarProj"; + + public AltSparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color) + { + Position = relativePosition; + Velocity = velocity; + AffectedByGravity = affectedByGravity; + Scale = scale; + Lifetime = lifetime; + Color = InitialColor = color; + } + + public override void Update() + { + Scale *= 0.95f; + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + Velocity *= 0.95f; + if (Velocity.Length() < 12f && AffectedByGravity) + { + Velocity.X *= 0.94f; + Velocity.Y += 0.25f; + } + Rotation = Velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Vector2 scale = new Vector2(0.5f, 1.6f) * Scale; + Texture2D texture = ModContent.Request(Texture).Value; + + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f); + } + } +} diff --git a/Particles/DetailedExplosion.cs b/Particles/DetailedExplosion.cs new file mode 100644 index 0000000000..cee0d32038 --- /dev/null +++ b/Particles/DetailedExplosion.cs @@ -0,0 +1,57 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Particles +{ + public class DetailedExplosion : Particle + { + public override string Texture => "CalamityMod/Particles/DetailedExplosion"; + public bool UseAltVisual = true; + public override bool UseAdditiveBlend => UseAltVisual; + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + + private float OriginalScale; + private float FinalScale; + private float opacity; + private Vector2 Squish; + private Color BaseColor; + + public DetailedExplosion(Vector2 position, Vector2 velocity, Color color, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true) + { + Position = position; + Velocity = velocity; + BaseColor = color; + OriginalScale = originalScale; + FinalScale = finalScale; + Scale = originalScale; + Lifetime = lifeTime; + Squish = squish; + Rotation = rotation; + UseAltVisual = UseAdditiveBlend; + } + + public override void Update() + { + float pulseProgress = PiecewiseAnimation(LifetimeCompletion, new CurveSegment[] { new CurveSegment(EasingType.PolyOut, 0f, 0f, 1f, 4) }); + Scale = MathHelper.Lerp(OriginalScale, FinalScale, pulseProgress); + + opacity = (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2); + + Color = BaseColor * opacity; + Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + Velocity *= 0.95f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D tex = ModContent.Request(Texture).Value; + spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale * Squish, SpriteEffects.None, 0); + } + + } +} diff --git a/Particles/DetailedExplosion.png b/Particles/DetailedExplosion.png new file mode 100644 index 0000000000..f2b4c369ba Binary files /dev/null and b/Particles/DetailedExplosion.png differ diff --git a/Particles/FlameParticle.cs b/Particles/FlameParticle.cs index 128a7e2286..7acd1586aa 100644 --- a/Particles/FlameParticle.cs +++ b/Particles/FlameParticle.cs @@ -5,10 +5,9 @@ namespace CalamityMod.Particles { public class FlameParticle : Particle { - public override string Texture => "CalamityMod/Particles/Fire"; + public override string Texture => "CalamityMod/Particles/Flames"; public override bool UseAdditiveBlend => true; public override bool SetLifetime => true; - public override int FrameVariants => 3; public float RelativePower; @@ -34,6 +33,7 @@ namespace CalamityMod.Particles { Scale += RelativePower * 0.01f; Position.Y -= RelativePower * 1.25f; + Scale *= 0.97f; Color = Color.Lerp(BrightColor, DarkColor, LifetimeCompletion); Color = Color.Lerp(Color, Color.White, Utils.GetLerpValue(0.1f, 0.25f, LifetimeCompletion, true) * Utils.GetLerpValue(0.4f, 0.25f, LifetimeCompletion, true) * 0.7f); diff --git a/Particles/Flames.png b/Particles/Flames.png new file mode 100644 index 0000000000..4a07c0f9e1 Binary files /dev/null and b/Particles/Flames.png differ diff --git a/Particles/GenericBloom.cs b/Particles/GenericBloom.cs index 9cd4d2b52b..52ca597791 100644 --- a/Particles/GenericBloom.cs +++ b/Particles/GenericBloom.cs @@ -9,14 +9,15 @@ namespace CalamityMod.Particles public class GenericBloom : Particle { public override string Texture => "CalamityMod/Particles/Light"; - public override bool UseAdditiveBlend => true; + public bool UseAltVisual = true; + public override bool UseAdditiveBlend => UseAltVisual; public override bool SetLifetime => true; private float opacity; private Color BaseColor; private bool ProduceLight; - public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, bool produceLight = true) + public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, bool produceLight = true, bool AddativeBlend = true) { Position = position; Velocity = velocity; @@ -25,6 +26,7 @@ namespace CalamityMod.Particles Lifetime = lifeTime; Rotation = Main.rand.NextFloat(MathHelper.TwoPi); ProduceLight = produceLight; + UseAltVisual = AddativeBlend; } public override void Update() diff --git a/Particles/Metaballs/BaseFusableParticleSet.cs b/Particles/Metaballs/BaseFusableParticleSet.cs deleted file mode 100644 index a7ae1e7c6d..0000000000 --- a/Particles/Metaballs/BaseFusableParticleSet.cs +++ /dev/null @@ -1,114 +0,0 @@ -using CalamityMod.Graphics; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; - -namespace CalamityMod.Particles.Metaballs -{ - public abstract class BaseFusableParticleSet - { - public class FusableParticleRenderCollection - { - public BaseFusableParticleSet ParticleSet; - public List BackgroundTargets; - public FusableParticleRenderCollection(BaseFusableParticleSet set, List backgroundTargets) - { - ParticleSet = set; - BackgroundTargets = backgroundTargets; - } - } - - public class FusableParticle - { - public Vector2 Center; - public float Size; - public Vector2 TopLeft => Center + new Vector2(-1f, -1f) * Size * 0.5f; - public Vector2 TopRight => Center + new Vector2(1f, -1f) * Size * 0.5f; - public Vector2 BottomLeft => Center + new Vector2(-1f, 1f) * Size * 0.5f; - public Vector2 BottomRight => Center + new Vector2(1f, 1f) * Size * 0.5f; - - public FusableParticle(Vector2 center, float size) - { - Center = center; - Size = size; - } - } - - public int LayerCount - { - get - { - // Not doing this will result in inevitable crashes down the line as the graphics engine fails. - if (BackgroundShaders.Count != BackgroundTextures.Count) - throw new InvalidOperationException("The number of texture maps and shaders are not equivalent."); - - return BackgroundShaders.Count; - } - } - - internal List DrawDataBuffer = new(); - - public List Particles = new(); - - public FusableParticleRenderCollection RenderCollection => FusableParticleManager.GetParticleRenderCollectionByType(GetType()); - - public List GetBackgroundTargets => RenderCollection.BackgroundTargets; - - public void PrepareSpecialDrawingForNextFrame(params DrawData[] drawContents) => DrawDataBuffer.AddRange(drawContents); - public virtual float BorderSize => 0f; - public virtual bool BorderShouldBeSolid => false; - public virtual Color BorderColor => Color.Transparent; - public virtual void PrepareOptionalShaderData(Effect effect, int index) { } - public abstract List BackgroundShaders { get; } - public abstract List BackgroundTextures { get; } - public abstract FusableParticle SpawnParticle(Vector2 center, float sizeStrength); - public abstract void UpdateBehavior(FusableParticle particle); - public abstract void DrawParticles(); - - /// - /// Temporarily moves from the backbuffer to a specialized render target, draws all particles, and caches the resulting render target for drawing later. - /// - internal void PrepareRenderTargetForDrawing() - { - // Don't bother doing anything if this method is called serverside. - if (Main.netMode == NetmodeID.Server) - return; - - // Don't bother doing anything if the set has no particles to render at the moment, for the sake of optimization. - if (Particles.Count <= 0) - return; - - // Go through each background render target in the set and clear the entire thing to use a base of transparent pixels. - foreach (ManagedRenderTarget backgroundTarget in GetBackgroundTargets) - { - Main.instance.GraphicsDevice.SetRenderTarget(backgroundTarget.Target); - Main.instance.GraphicsDevice.Clear(Color.Transparent); - - // Clear away any particles that shouldn't exist anymore. - Particles.RemoveAll(p => p.Size <= 5f); - - // Prepare the sprite batch for specialized drawing in prepration that the graphics device will draw to new render targets. - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); - - // Draw the surviving particles. - DrawParticles(); - - // Draw all special contents in the draw buffer before clearing it. - foreach (DrawData drawData in DrawDataBuffer) - drawData.Draw(Main.spriteBatch); - - Main.spriteBatch.End(); - } - - // Clear the special draw data buffer. - DrawDataBuffer.Clear(); - - // Return to using the backbuffer after done drawing everything to the background targets. - Main.instance.GraphicsDevice.SetRenderTarget(null); - } - } -} diff --git a/Particles/Metaballs/FusableParticleManager.cs b/Particles/Metaballs/FusableParticleManager.cs deleted file mode 100644 index 738c032a89..0000000000 --- a/Particles/Metaballs/FusableParticleManager.cs +++ /dev/null @@ -1,199 +0,0 @@ -using CalamityMod.Graphics; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using static CalamityMod.Particles.Metaballs.BaseFusableParticleSet; - -namespace CalamityMod.Particles.Metaballs -{ - // NOTE: A lot of the functionalities within this system cannot under really any circumstance be used serverside. - // This system is entirely visual. However, servers do not have drawing capabilities, nor even a proper GraphicsDevice - // instance. This system utilizes many things that require both of these things, such as shaders and render targets. - // As such, it is littered with many netMode checks. While some may be overprotective in their nature it is critical that - // failsafes exist there, as visual failures tend to result in engine crashes, which will kill a lot of MP servers. - // If someone other than me for any reason attempts to notably expand upon this system you must keep this in mind. -Dominic - - // TODO -- This can be made into a ModSystem. Its main thread load dependency with render targets is safe to put in OnModLoad. - public static class FusableParticleManager - { - internal static List ParticleSets = new(); - internal static List ExtraModsToLoadSetsFrom = new(); - internal static List ParticleSetTypes = new(); - internal static bool HasBeenFormallyDefined = false; - - /// - /// Loads all render sets. - /// - internal static void LoadParticleRenderSets() - { - // Don't attempt to prepare anything serverside. - if (Main.netMode == NetmodeID.Server) - return; - - ParticleSets = new(); - ParticleSetTypes = new(); - ExtraModsToLoadSetsFrom = new(); - HasBeenFormallyDefined = true; - - FindParticleSetTypesInMod(CalamityMod.Instance); - foreach (Mod m in ExtraModsToLoadSetsFrom) - FindParticleSetTypesInMod(m); - - foreach (Type t in ParticleSetTypes) - CreateParticleSetOfType(t); - } - - internal static void FindParticleSetTypesInMod(Mod mod) - { - // Look through every type in the mod, and check if it's derived from BaseFusableParticleSet. - // If it is, create a default instance of said particle and save it. - foreach (Type type in mod.Code.GetTypes()) - { - // Don't load abstract classes; they cannot have instances. - if (type.IsAbstract) - continue; - - if (type.IsSubclassOf(typeof(BaseFusableParticleSet))) - ParticleSetTypes.Add(type); - } - } - - internal static void CreateParticleSetOfType(Type t) - { - BaseFusableParticleSet instance = Activator.CreateInstance(t) as BaseFusableParticleSet; - List backgroundTargets = new List(); - - // Only generate render targets to use if this isn't called serverside. - if (Main.netMode != NetmodeID.Server) - { - for (int i = 0; i < instance.LayerCount; i++) - backgroundTargets.Add(new ManagedRenderTarget(true, ManagedRenderTarget.CreateScreenSizedTarget)); - } - - FusableParticleRenderCollection particleRenderCollection = new FusableParticleRenderCollection(instance, backgroundTargets); - ParticleSets.Add(particleRenderCollection); - } - - internal static void CreateParticleSetOfType() where T : BaseFusableParticleSet => - CreateParticleSetOfType(typeof(T)); - - /// - /// Unloads all render sets. - /// - internal static void UnloadParticleRenderSets() - { - foreach (FusableParticleRenderCollection particleRenderSet in ParticleSets) - particleRenderSet.ParticleSet = null; - - HasBeenFormallyDefined = false; - ParticleSets = null; - ExtraModsToLoadSetsFrom = null; - ParticleSetTypes = null; - } - - /// - /// Prepares the render targets of each cached instance in advance. - /// - internal static void PrepareFusableParticleTargets() - { - // Don't attempt to prepare anything serverside, if the particle sets are unloaded, or if on the menu. - if (Main.netMode == NetmodeID.Server || ParticleSets is null || Main.gameMenu) - return; - - // Prepare the render target for all fusable particles. - for (int i = 0; i < ParticleSets.Count; i++) - ParticleSets[i].ParticleSet.PrepareRenderTargetForDrawing(); - } - - /// - /// Renders each cached instance with its connecting shader. - /// - internal static void RenderAllFusableParticles() - { - // Don't attempt to render anything serverside or on the menu. - if (Main.netMode == NetmodeID.Server || Main.gameMenu) - return; - - for (int i = 0; i < ParticleSets.Count; i++) - { - BaseFusableParticleSet particleSet = ParticleSets[i].ParticleSet; - - // Don't bother rendering if the set has no particles to render at the moment, for the sake of optimization. - if (particleSet.Particles.Count <= 0) - continue; - - List backgroundTargets = particleSet.GetBackgroundTargets; - - // Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied. - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - for (int j = 0; j < particleSet.LayerCount; j++) - { - Effect shader = particleSet.BackgroundShaders[j]; - Texture2D backgroundTexture = particleSet.BackgroundTextures[j]; - - // Draw the current target with the specified shader. - shader.Parameters["edgeBorderSize"].SetValue(particleSet.BorderSize); - shader.Parameters["borderShouldBeSolid"].SetValue(particleSet.BorderShouldBeSolid); - shader.Parameters["edgeBorderColor"].SetValue(particleSet.BorderColor.ToVector3()); - shader.Parameters["screenArea"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight) / Main.GameViewMatrix.Zoom); - shader.Parameters["screenMoveOffset"].SetValue(Main.screenPosition - Main.screenLastPosition); - shader.Parameters["uWorldPosition"].SetValue(Main.screenPosition); - shader.Parameters["renderTargetArea"].SetValue(new Vector2(backgroundTargets[j].Width, backgroundTargets[j].Height)); - shader.Parameters["invertedScreen"].SetValue(Main.LocalPlayer.gravDir == -1f); - shader.Parameters["upscaleFactor"].SetValue(Vector2.One); - shader.Parameters["generalBackgroundOffset"].SetValue(Vector2.Zero); - - // Prepare the background texture for loading. - Main.graphics.GraphicsDevice.Textures[1] = backgroundTexture; - shader.Parameters["uImageSize1"].SetValue(backgroundTexture.Size()); - - // Do any optional shader operations prior to applying the shader. - particleSet.PrepareOptionalShaderData(shader, j); - - // Apply the shader. This is what is used to connect separated blobs together. - shader.CurrentTechnique.Passes[0].Apply(); - - // And draw the particle set's render target with said shader. - Main.spriteBatch.Draw(backgroundTargets[j].Target, Vector2.Zero, Color.White); - } - - Main.spriteBatch.End(); - } - } - - /// - /// Obtains the instance from a given if it is a . - /// - /// The type to check. - internal static FusableParticleRenderCollection GetParticleRenderCollectionByType(Type type) - { - if (Main.netMode == NetmodeID.Server) - return null; - - return ParticleSets.First(s => s.ParticleSet.GetType() == type); - } - - /// - /// Obtains the cached singleton instance of a given . - /// - /// The type to check. - public static T GetParticleSetByType() where T : BaseFusableParticleSet - { - if (Main.netMode == NetmodeID.Server) - return null; - - // Reload particle sets if they are completely unloaded for some reason. - if (ParticleSets.Count <= 0) - LoadParticleRenderSets(); - - return ParticleSets.First(s => s.ParticleSet.GetType() == typeof(T)).ParticleSet as T; - } - } -} diff --git a/Particles/Metaballs/GruesomeEminenceParticleSet.cs b/Particles/Metaballs/GruesomeEminenceParticleSet.cs deleted file mode 100644 index f72b74a650..0000000000 --- a/Particles/Metaballs/GruesomeEminenceParticleSet.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class GruesomeEminenceParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Fuchsia, Color.Black, 0.55f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer1").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer2").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer3").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer4").Value, - ModContent.Request("CalamityMod/Particles/Metaballs/GruesomeEminence_Ghost_Layer5").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 2.5f, 0f, 400f) * 0.97f; - } - - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.03f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Gaseous skulls. - case 1: - offset = Vector2.One * (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.041f) * 2f; - offset = offset.RotatedBy((float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.08f) * 0.97f); - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Spooky faces 1. - case 2: - offset = (Main.GlobalTimeWrappedHourly * 2.02f).ToRotationVector2() * 0.036f; - offset.Y += (float)Math.Cos(Main.GlobalTimeWrappedHourly * 0.161f) * 0.5f + 0.5f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Spooky faces 2. - case 3: - offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * -0.04f + (Main.GlobalTimeWrappedHourly * 1.89f).ToRotationVector2() * 0.03f; - offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 466920161) * 0.025f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - - // Spooky faces 3. - case 4: - offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f + (Main.GlobalTimeWrappedHourly * 1.77f).ToRotationVector2() * 0.04725f; - offset.Y += CalamityUtils.PerlinNoise2D(Main.GlobalTimeWrappedHourly * 0.187f, Main.GlobalTimeWrappedHourly * 0.193f, 2, 577215664) * 0.05f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - break; - } - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/PaintParticleSets.cs b/Particles/Metaballs/PaintParticleSets.cs deleted file mode 100644 index bd65882d69..0000000000 --- a/Particles/Metaballs/PaintParticleSets.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class CyanPaint : PaintParticleSet - { - public override Color BorderColor => Color.Cyan * 0.7f; - } - public class BluePaint : PaintParticleSet - { - public override Color BorderColor => Color.Blue * 0.7f; - } - public class MagentaPaint : PaintParticleSet - { - public override Color BorderColor => Color.Magenta * 0.7f; - } - public class LimePaint : PaintParticleSet - { - public override Color BorderColor => Color.Lime * 0.7f; - } - public class YellowPaint : PaintParticleSet - { - public override Color BorderColor => Color.Yellow * 0.7f; - } - - public abstract class PaintParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 12f; - public override bool BorderShouldBeSolid => false; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.1f, 0f, 200f) * 0.997f; - if (particle.Size < 20f) - particle.Size = particle.Size * 0.8f - 1f; - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(50f, 100f, particle.Size, true) * 0.1f) * 1.2f; - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/RancorGroundLavaParticleSet.cs b/Particles/Metaballs/RancorGroundLavaParticleSet.cs deleted file mode 100644 index 0675a3b6c7..0000000000 --- a/Particles/Metaballs/RancorGroundLavaParticleSet.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class RancorGroundLavaParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 18f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.15f, 0f, 200f) * 0.997f; - if (particle.Size < 20f) - particle.Size = particle.Size * 0.95f - 0.9f; - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size() * new Vector2(1f, 0.5f); - Color drawColor = Color.Lerp(BorderColor, new Color(0f, 0f, 1f), Utils.GetLerpValue(120f, 135f, particle.Size, true) * 0.1f) * 1.4f; - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/RancorLavaParticleSet.cs b/Particles/Metaballs/RancorLavaParticleSet.cs deleted file mode 100644 index 9b4431a2e1..0000000000 --- a/Particles/Metaballs/RancorLavaParticleSet.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class RancorLavaParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 18f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Yellow, Color.Red, 0.85f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:AdditiveFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 0.24f, 0f, 200f) * 0.9956f; - if (particle.Size < 15f) - particle.Size = particle.Size * 0.95f - 0.9f; - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, BorderColor * 1.2f, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/StreamGougeLayer.png b/Particles/Metaballs/StreamGougeLayer.png deleted file mode 100644 index 773929e360..0000000000 Binary files a/Particles/Metaballs/StreamGougeLayer.png and /dev/null differ diff --git a/Particles/Metaballs/StreamGougeParticleSet.cs b/Particles/Metaballs/StreamGougeParticleSet.cs deleted file mode 100644 index 08af896b55..0000000000 --- a/Particles/Metaballs/StreamGougeParticleSet.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - public class StreamGougeParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.DarkBlue, Color.Black, 0.75f) * 0.85f; - - public override List BackgroundShaders => new() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new() - { - ModContent.Request("CalamityMod/Particles/Metaballs/StreamGougeLayer").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; - } - - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.045f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); - break; - } - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Particles/Metaballs/VoidGeneratorParticleSet.cs b/Particles/Metaballs/VoidGeneratorParticleSet.cs deleted file mode 100644 index 9e01ec5462..0000000000 --- a/Particles/Metaballs/VoidGeneratorParticleSet.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.Linq; -using Terraria; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; - -namespace CalamityMod.Particles.Metaballs -{ - //This is basically just the Stream Gouge set but purple - public class VoidGeneratorParticleSet : BaseFusableParticleSet - { - public override float BorderSize => 3f; - public override bool BorderShouldBeSolid => false; - public override Color BorderColor => Color.Lerp(Color.Purple, Color.Black, 0.75f) * 0.85f; - - public override List BackgroundShaders => new List() - { - GameShaders.Misc["CalamityMod:BaseFusableParticleEdge"].Shader, - }; - public override List BackgroundTextures => new List() - { - ModContent.Request("CalamityMod/Particles/Metaballs/StreamGougeLayer").Value, - }; - public override FusableParticle SpawnParticle(Vector2 center, float sizeStrength) - { - Particles.Add(new FusableParticle(center, sizeStrength)); - return Particles.Last(); - } - - public override void UpdateBehavior(FusableParticle particle) - { - particle.Size = MathHelper.Clamp(particle.Size - 1f, 0f, 200f) * 0.98f; - } - - public override void PrepareOptionalShaderData(Effect effect, int index) - { - switch (index) - { - // Background. - case 0: - Vector2 offset = Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.045f; - effect.Parameters["generalBackgroundOffset"].SetValue(offset); - effect.Parameters["upscaleFactor"].SetValue(Vector2.One * -0.3f); - break; - } - } - - public override void DrawParticles() - { - Texture2D fusableParticleBase = ModContent.Request("CalamityMod/Particles/Metaballs/FusableParticleBase").Value; - foreach (FusableParticle particle in Particles) - { - Vector2 drawPosition = particle.Center - Main.screenPosition; - Vector2 origin = fusableParticleBase.Size() * 0.5f; - Vector2 scale = Vector2.One * particle.Size / fusableParticleBase.Size(); - Main.spriteBatch.Draw(fusableParticleBase, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f); - } - } - } -} diff --git a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs index f4bbf765b8..40219fe0b0 100644 --- a/Projectiles/BaseProjectiles/BaseSpearProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseSpearProjectile.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; @@ -66,7 +66,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles } // If at the end of the animation, kill the projectile. - if (player.itemAnimation == 0) + //Checking if == 0 is too late, lets the projectile linger into chained item uses. + if (player.itemAnimation <= 1) Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2 + MathHelper.PiOver4; diff --git a/Projectiles/Boss/BrimstoneFire.cs b/Projectiles/Boss/BrimstoneFire.cs index 8cc17235dd..e4f7699ef2 100644 --- a/Projectiles/Boss/BrimstoneFire.cs +++ b/Projectiles/Boss/BrimstoneFire.cs @@ -1,76 +1,153 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class BrimstoneFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 90; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 10; Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; CooldownSlot = ImmunityCooldownID.Bosses; } public override void AI() { - Lighting.AddLight(Projectile.Center, 0.3f, 0f, 0f); - if (Projectile.ai[0] > 7f) + Time++; + if (Time < Fadetime && Main.rand.NextBool(6)) { - float scalar = 1f; - if (Projectile.ai[0] == 8f) + Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, ModContent.DustType(), Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); + if (Main.rand.NextBool(3)) { - scalar = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - scalar = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - scalar = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = (int)CalamityDusts.Brimstone; - if (Main.rand.NextBool()) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f, 100, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - } - else - { - dust.scale *= 1.5f; - } - dust.scale *= scalar; + cinder.scale *= 2f; + cinder.velocity *= 2f; } + cinder.noGravity = true; + cinder.scale *= cinderSize * 1.2f; + cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + if (MistType == -1) + MistType = Main.rand.Next(3); + + Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f); } + // Keeping the flames in place when hitting a block + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + Time++; + Projectile.timeLeft--; + return false; + } + + // Expanding hitbox + // A bit more generous than Havoc's Breath fire because enemy projectiles + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, Fadetime, 8f, 32f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 32f, 0f); + hitbox.Inflate(size, size); + } + + // Anti-wall hacking checks + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; + public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0) return; target.AddBuff(ModContent.BuffType(), 150); + + // Cook you up (still scales with player size in case it's manipulated) + int smokeCount = 4 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); + for (int i = 0; i < smokeCount; i++) + { + Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); + Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-2.4f, -0.8f) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); + Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Main.rand.NextFloat(1f, 2f), 245 - Main.rand.Next(50), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D fire = ModContent.Request(Texture).Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(255, 110, 100, 200); + Color color2 = new Color(255, 50, 50, 70); + Color color3 = new Color(255, 100, 100, 100); + Color color4 = new Color(200, 35, 30, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; } } } diff --git a/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs b/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs index 080e9f6d5b..edf43f9d7e 100644 --- a/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs +++ b/Projectiles/Boss/StormWeaverFrostWaveTelegraph.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - Texture2D pulseTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseAura").Value; + Texture2D pulseTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; // Aura drawing. for (int i = 0; i < 5; i++) diff --git a/Projectiles/CalamityGlobalProjectileTweaks.cs b/Projectiles/CalamityGlobalProjectileTweaks.cs index 89a94b6ce3..8c4f31c9be 100644 --- a/Projectiles/CalamityGlobalProjectileTweaks.cs +++ b/Projectiles/CalamityGlobalProjectileTweaks.cs @@ -139,7 +139,6 @@ namespace CalamityMod.Projectiles { ProjectileID.FairyQueenRangedItemShot, Do(PiercingExact(7), ExtraUpdatesExact(1)) }, // Eventide Convert { ProjectileID.FlaironBubble, Do(ExtraUpdatesExact(1), TimeLeftExact(400)) }, { ProjectileID.Flamarang, Do(ExtraUpdatesExact(2)) }, - { ProjectileID.Flames, Do(IDStaticIFrames(10)) }, // Flamethrower + Elf Melter { ProjectileID.FlamingJack, Do(ExtraUpdatesExact(1)) }, { ProjectileID.FlowerPetal, Do(MaxUpdatesExact(4), LocalIFrames(10)) }, // Orichalcum armor { ProjectileID.FlowerPow, Do(ExtraUpdatesExact(1)) }, diff --git a/Projectiles/DraedonsArsenal/PulseAura.png b/Projectiles/DraedonsArsenal/PulseAura.png deleted file mode 100644 index 8e2d2a871c..0000000000 Binary files a/Projectiles/DraedonsArsenal/PulseAura.png and /dev/null differ diff --git a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs index 82c9c77400..756c4112b3 100644 --- a/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs +++ b/Projectiles/DraedonsArsenal/PulseDragonProjectile.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Player player = Main.player[Projectile.owner]; Texture2D chainTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseDragonChain").Value; - Texture2D pulseTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseAura").Value; + Texture2D pulseTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; Texture2D dragonHeadTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseDragonProjectile").Value; if (ReelingBack) dragonHeadTexture = ModContent.Request("CalamityMod/Projectiles/DraedonsArsenal/PulseDragonHeadClosed").Value; diff --git a/Projectiles/FireProj.png b/Projectiles/FireProj.png new file mode 100644 index 0000000000..49851837be Binary files /dev/null and b/Projectiles/FireProj.png differ diff --git a/Projectiles/Magic/IcicleStaffProj.png b/Projectiles/Magic/IcicleStaffProj.png index 00b1ef9ae1..c1e15cae9a 100644 Binary files a/Projectiles/Magic/IcicleStaffProj.png and b/Projectiles/Magic/IcicleStaffProj.png differ diff --git a/Projectiles/Magic/RancorLargeCinder.cs b/Projectiles/Magic/RancorLargeCinder.cs index 61adef419b..45e9a59036 100644 --- a/Projectiles/Magic/RancorLargeCinder.cs +++ b/Projectiles/Magic/RancorLargeCinder.cs @@ -1,5 +1,4 @@ -using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -45,7 +44,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.velocity.Y += 0.04f; // Create lava particles. - FusableParticleManager.GetParticleSetByType().SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(6f, 6f), Projectile.scale * 36f); + RancorLavaMetaball.SpawnParticle(Projectile.Center + Main.rand.NextVector2Circular(6f, 6f), Projectile.scale * 36f); Time++; } diff --git a/Projectiles/Magic/RancorLaserbeam.cs b/Projectiles/Magic/RancorLaserbeam.cs index e0b5d5cf70..86ab25cc1b 100644 --- a/Projectiles/Magic/RancorLaserbeam.cs +++ b/Projectiles/Magic/RancorLaserbeam.cs @@ -1,6 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -147,7 +146,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectile(Projectile.GetSource_FromThis(), endOfLaser, cinderVelocity, type, damage, 0f, Projectile.owner); } - FusableParticleManager.GetParticleSetByType().SpawnParticle(endOfLaser + Main.rand.NextVector2Circular(10f, 10f) + Projectile.velocity * 40f, 135f); + RancorLavaMetaball.SpawnParticle(endOfLaser + Main.rand.NextVector2Circular(10f, 10f) + Projectile.velocity * 40f, 135f); } private float PrimitiveWidthFunction(float completionRatio) => Projectile.scale * 20f; @@ -163,8 +162,7 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - if (RayDrawer is null) - RayDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]); + RayDrawer ??= new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]); GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin"); diff --git a/Projectiles/Magic/SmallSpirit.cs b/Projectiles/Magic/SmallSpirit.cs index fb9abe07fd..3c24b7b56c 100644 --- a/Projectiles/Magic/SmallSpirit.cs +++ b/Projectiles/Magic/SmallSpirit.cs @@ -1,5 +1,4 @@ -using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using System; using Terraria; @@ -49,7 +48,7 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - float radius = MathHelper.SmoothStep(84f, 44f, (float)Math.Sqrt(1f - Projectile.timeLeft / 360f)); + float radius = MathHelper.SmoothStep(67f, 32f, (float)Math.Sqrt(1f - Projectile.timeLeft / 360f)); // Handle frames. Projectile.frameCounter++; @@ -68,7 +67,7 @@ namespace CalamityMod.Projectiles.Magic { Projectile.hostile = false; - radius += 54f; + radius += 36f; target = ProjectileOwner; flySpeed = 29f; @@ -109,7 +108,7 @@ namespace CalamityMod.Projectiles.Magic // Emit particles. Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, radius); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(6f, 6f), radius); } public override Color? GetAlpha(Color lightColor) => Color.White * Projectile.Opacity; diff --git a/Projectiles/Magic/SpiritCongregation.cs b/Projectiles/Magic/SpiritCongregation.cs index ac81c8ca39..48ffe84e32 100644 --- a/Projectiles/Magic/SpiritCongregation.cs +++ b/Projectiles/Magic/SpiritCongregation.cs @@ -1,15 +1,13 @@ -using CalamityMod.Particles; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; -using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using CalamityMod.Particles.Metaballs; -using Terraria.DataStructures; +using System.Collections.Generic; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Magic { @@ -62,6 +60,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 12; Projectile.timeLeft = 90000; + Projectile.hide = true; } public override void SendExtraAI(BinaryWriter writer) @@ -229,8 +228,8 @@ namespace CalamityMod.Projectiles.Magic particleSize += (Projectile.oldPosition - Projectile.position).Length() * 4.2f; // Place a hard limit on particle sizes. - if (particleSize > 500f) - particleSize = 500f; + if (particleSize > 210f) + particleSize = 210f; // Make particles shrink when dying. particleSize *= MathHelper.Lerp(1f, 0.5f, Utils.GetLerpValue(0f, 35f, DeathCounter, true)); @@ -240,12 +239,15 @@ namespace CalamityMod.Projectiles.Magic { // Summon a base particle. Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(1f, 1f) * particleSize / 26f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, particleSize); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(4.4f, 4.4f), particleSize); // And an "ahead" particle that spawns based on current movement. // This causes the "head" of the overall thing to have bumps when moving. spawnPosition += Projectile.velocity.RotatedByRandom(1.38f) * particleSize / 105f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, particleSize * 0.4f); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(i * 1.5f + 7f, i * 1.5f + 7f), particleSize * 0.3f); + + // Make particle sizes exponentially decrease across loop iterations. + particleSize *= 0.9f; } // Release gas projectiles randomly. This does not happen when dying. @@ -263,41 +265,56 @@ namespace CalamityMod.Projectiles.Magic Projectile.frame = Projectile.frameCounter / 5 % maxFrame; } + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + // Ensure that the teeth draw over the metaballs. + overPlayers.Add(index); + } + public override bool PreDraw(ref Color lightColor) { - int maxFrame = CurrentPower <= LargeMouthPowerLowerBound ? 6 : 9; Texture2D texture = ModContent.Request(Texture).Value; - Texture2D backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBack").Value; - Texture2D auraTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationAura").Value; if (CurrentPower > LargeMouthPowerLowerBound) - { texture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBig").Value; - backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBackBig").Value; - auraTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationAuraBig").Value; - } - - float offsetFactor = Projectile.scale * ((CongregationDiameter - 54f) / 90f + 1.5f); - offsetFactor *= texture.Width / 90f; - Vector2 drawPosition = Projectile.Center - Main.screenPosition + Projectile.rotation.ToRotationVector2() * offsetFactor * 15f; - Rectangle frame = texture.Frame(1, maxFrame, 0, Projectile.frame); - Vector2 origin = frame.Size() * 0.5f; - SpriteEffects direction = Math.Cos(Projectile.rotation) > 0f ? SpriteEffects.None : SpriteEffects.FlipVertically; - DrawData backTextureDraw = new(backTexture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, direction, 0); - DrawData auraTextureDraw = new(auraTexture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, direction, 0); - FusableParticleManager.GetParticleSetByType()?.PrepareSpecialDrawingForNextFrame(backTextureDraw, auraTextureDraw); - Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, direction, 0); + DrawHead(texture); return false; } - // Damage scales up over time as it grows + public void DrawHead(Texture2D texture, float scaleFactor = 1f) + { + int maxFrame = CurrentPower <= LargeMouthPowerLowerBound ? 6 : 9; + float offsetFactor = Projectile.scale * ((CongregationDiameter - 54f) / 90f + 1.5f); + offsetFactor *= texture.Width / 90f; + + Vector2 drawPosition = Projectile.Center - Main.screenPosition + Projectile.rotation.ToRotationVector2() * offsetFactor * 15f; + Rectangle frame = texture.Frame(1, maxFrame, 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects direction = MathF.Cos(Projectile.rotation) > 0f ? SpriteEffects.None : SpriteEffects.FlipVertically; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale * scaleFactor, direction, 0); + } + + public void DrawHeadForMetaball() + { + Texture2D backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBack").Value; + if (CurrentPower > LargeMouthPowerLowerBound) + backTexture = ModContent.Request("CalamityMod/Projectiles/Magic/SpiritCongregationBackBig").Value; + + DrawHead(backTexture, 1.04f); + } + + // Damage scales up over time as it grows. public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) { float damageFactor = 0.25f + 0.75f * CurrentPower; int fullPowerDamage; - if (Main.masterMode) fullPowerDamage = 540; - else if (Main.expertMode) fullPowerDamage = 450; - else fullPowerDamage = 360; + if (Main.masterMode) + fullPowerDamage = 540; + else if (Main.expertMode) + fullPowerDamage = 450; + else + fullPowerDamage = 360; modifiers.SourceDamage *= 0f; modifiers.SourceDamage.Flat += (int)(damageFactor * fullPowerDamage); diff --git a/Projectiles/Magic/SpiritDust.cs b/Projectiles/Magic/SpiritDust.cs index 97a8ee4f20..0d01bdc4b7 100644 --- a/Projectiles/Magic/SpiritDust.cs +++ b/Projectiles/Magic/SpiritDust.cs @@ -1,4 +1,4 @@ -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -8,6 +8,7 @@ namespace CalamityMod.Projectiles.Magic public class SpiritDust : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() @@ -24,7 +25,7 @@ namespace CalamityMod.Projectiles.Magic { float radius = MathHelper.SmoothStep(80f, 48f, 1f - Projectile.timeLeft / 90f); Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Circular(5f, 5f) * radius / 130f; - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, radius); + GruesomeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(3f, 3f), radius); } } } diff --git a/Projectiles/Melee/Orbacle.cs b/Projectiles/Melee/Orbacle.cs index 45e1a73cce..afb422575d 100644 --- a/Projectiles/Melee/Orbacle.cs +++ b/Projectiles/Melee/Orbacle.cs @@ -7,6 +7,7 @@ namespace CalamityMod.Projectiles.Melee public class Orbacle : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; private static int Lifetime = 40; public override void SetDefaults() diff --git a/Projectiles/Melee/StreamGougePortal.cs b/Projectiles/Melee/StreamGougePortal.cs index 3312c33872..b7b02a5d1c 100644 --- a/Projectiles/Melee/StreamGougePortal.cs +++ b/Projectiles/Melee/StreamGougePortal.cs @@ -7,14 +7,15 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using CalamityMod.Particles.Metaballs; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Melee { public class StreamGougePortal : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public static readonly SoundStyle SpawnSound = new SoundStyle("CalamityMod/Sounds/Custom/SwiftSlice") + + public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/SwiftSlice") { PitchVariance = 0.1f }; @@ -43,7 +44,8 @@ namespace CalamityMod.Projectiles.Melee // Play a slice sound when spawning. if (Projectile.localAI[0] == 0f) { - SoundEngine.PlaySound(SpawnSound, Projectile.Center); + float volume = Utils.Remap(Main.LocalPlayer.Distance(Projectile.Center), 600f, 100f, 0.12f, 0.5f); + SoundEngine.PlaySound(SpawnSound with { Volume = volume }, Projectile.Center); Projectile.localAI[0] = 1f; } @@ -106,11 +108,12 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 20; i++) { Vector2 spawnPosition = target.Center + Main.rand.NextVector2Circular(30f, 30f); - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, 60f); + StreamGougeMetaball.SpawnParticle(spawnPosition, Main.rand.NextVector2Circular(3f, 3f), 60f); float scale = MathHelper.Lerp(24f, 64f, CalamityUtils.Convert01To010(i / 19f)); spawnPosition = target.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * MathHelper.Lerp(-40f, 90f, i / 19f); - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(spawnPosition, scale); + Vector2 particleVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.23f) * Main.rand.NextFloat(2.5f, 9f); + StreamGougeMetaball.SpawnParticle(spawnPosition, particleVelocity, scale); } } diff --git a/Projectiles/Ranged/AuroraFire.cs b/Projectiles/Ranged/AuroraFire.cs index 5c5018021a..28da085bbc 100644 --- a/Projectiles/Ranged/AuroraFire.cs +++ b/Projectiles/Ranged/AuroraFire.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ModLoader; @@ -10,77 +11,110 @@ namespace CalamityMod.Projectiles.Ranged public class AuroraFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/Magic/RancorFog"; - private const int framesBeforeTurning = 70; - private bool initialized = false; - private int radianAmt = 0; + public static int Lifetime => 450; + public static int Fadetime => 420; + public ref float Time => ref Projectile.ai[0]; + public ref float LightPower => ref Projectile.ai[1]; + + // The Fog is Coming + public Color OrangeFogColor = new Color(255, 160, 100); + public float OrangeFogRot = 0f; + public float OrangeFogScale = 1f; + public Color BlueFogColor = new Color(150, 120, 255); + public float BlueFogRot = 0f; + public float BlueFogScale = 1f; public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = Projectile.height = 64; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.tileCollide = false; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 8; } public override void AI() { - if (Projectile.ai[0] % 2 == 0) - Projectile.ai[0]++; - - if (!initialized) + // Initialize random fog scale/rotation/color + if (Time == 0f) { - int pointCount = (int)Projectile.ai[0]; - radianAmt = 180 + (int)(360 / (pointCount * 2)); - Projectile.timeLeft = framesBeforeTurning * pointCount - 1; - initialized = true; + OrangeFogColor.B = (byte)Main.rand.Next(100, 180 + 1); + OrangeFogScale = Main.rand.NextFloat(0.8f, 1f); + OrangeFogRot = Main.rand.NextFloat(MathHelper.TwoPi); + BlueFogColor.G = (byte)Main.rand.Next(120, 250 + 1); + BlueFogScale = OrangeFogScale * Main.rand.NextFloat(0.9f, 1.1f); + BlueFogRot = OrangeFogRot + MathHelper.ToRadians(Main.rand.NextFloat(30f, 330f)); + } + Time++; + + // Turns around every once in a while + int TurnRate = Lifetime / 5; + if (Time % TurnRate == TurnRate - 1) + Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(-216f)); + Projectile.rotation = Projectile.velocity.ToRotation(); + + // Determines particle size as well as hitbox + if (Time >= Fadetime) + { + Projectile.scale = Utils.GetLerpValue(MathHelper.Lerp(Fadetime, Lifetime, 0.5f), Fadetime, Time, true); + if (Projectile.scale <= 0.01f) + Projectile.Kill(); + } + else if (Time >= 6f) + Projectile.scale = Utils.GetLerpValue(6f, 36f, Time, true); + else + return; // Helps position it at the tip + + // Draw smokes over the whole thing + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + Color smokeColor = Color.Lerp(OrangeFogColor, BlueFogColor, 0.6f + 0.4f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f)); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 8, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.8f, smokeRot, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, which is on the brighter side + if (Main.rand.NextBool(8)) + { + Color glowColor = Color.Lerp(smokeColor, Color.White, 0.25f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 6, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.6f, smokeRot, true, 0.005f, true); + GeneralParticleHandler.SpawnParticle(smokeGlow); } - //Velocity movement - Projectile.localAI[1]++; - if (Projectile.localAI[1] % framesBeforeTurning == 0) - { - Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.ToRadians(radianAmt)); - } - - //Dust behavior - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - ModContent.DustType(), - ModContent.DustType() - }); - for (int i = 0; i < 5; i++) - { - int astral = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 0.8f); - Dust dust = Main.dust[astral]; - dust.noGravity = true; - dust.velocity *= 0f; - dust.scale *= Main.rand.NextFloat(); - } - } - - //rotation code for when sproot - Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; + // Lighting and fog + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale); + OrangeFogRot += MathHelper.ToRadians(1f); + BlueFogRot -= MathHelper.ToRadians(1f); + Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Time, true) * Utils.GetLerpValue(450f, 360f, Time, true); + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); - public override void OnHitPlayer(Player target, Player.HurtInfo info) + public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 240); + + // Circular hitbox adjusted for the size of the smoke particles (rough estimate minimally accounting for fog) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * Projectile.scale * 0.5f, targetHitbox); + + public override bool PreDraw(ref Color lightColor) { - target.AddBuff(ModContent.BuffType(), 240); + Main.spriteBatch.SetBlendState(BlendState.Additive); + Texture2D fog = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.3f; + Main.EntitySpriteDraw(fog, drawPosition, null, OrangeFogColor * opacity, Projectile.rotation + OrangeFogRot, fog.Size() * 0.5f, Projectile.scale * OrangeFogScale, SpriteEffects.None); + Main.EntitySpriteDraw(fog, drawPosition, null, BlueFogColor * opacity, Projectile.rotation + BlueFogRot, fog.Size() * 0.5f, Projectile.scale * BlueFogScale, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Ranged/BlightFlames.cs b/Projectiles/Ranged/BlightFlames.cs new file mode 100644 index 0000000000..0afebe9849 --- /dev/null +++ b/Projectiles/Ranged/BlightFlames.cs @@ -0,0 +1,172 @@ +using System; +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using CalamityMod.Particles; +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Items.Weapons.Ranged; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Ranged +{ + public class BlightFlames : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/BlightFlames"; + + public ref float ScaleFactor => ref Projectile.ai[0]; + public ref float LightPower => ref Projectile.ai[1]; + + public int Time = 0; + public bool postTileHit = false; + public bool postEnemyHit = false; + + public Color FogColor = new Color(30, 255, 30); + public override void SetDefaults() + { + Projectile.width = 14; + Projectile.height = 14; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = -1; + Projectile.extraUpdates = 5; + Projectile.timeLeft = 400; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 55; + } + public override void AI() + { + Time++; + Projectile.rotation += Main.rand.NextFloat(0.2f, 0.9f); + if (Time > 6 && Time < 540 && Main.rand.NextBool(2 + Time / 7)) + { + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(10 + Time * 0.5f, 10 + Time * 0.5f), Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.03f, 0.09f) + Time * 0.00055f, 0f, 25); + GeneralParticleHandler.SpawnParticle(pulse); + } + if (Time > 6 && Time < 150 && !postTileHit && !postEnemyHit && Main.rand.NextBool(3 + Time / 7)) + { + MediumMistParticle smoke = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.2f, 5 + Time * 0.2f), -Projectile.velocity * 0.05f, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Lime, Color.Black, Main.rand.NextFloat(0.3f, 0.8f) + Time * 0.013f, 160); + GeneralParticleHandler.SpawnParticle(smoke); + } + if (Time == 8) + { + for (int i = 0; i <= 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 91, Projectile.velocity * 0.6f); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); + dust.noGravity = true; + dust.color = Main.rand.NextBool() ? Color.Chartreuse : Color.LimeGreen; + dust.noLight = true; + dust.alpha = 90; + } + } + if (Time == 10) + { + for (int i = 0; i <= 3; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, 220, Projectile.velocity * 0.6f); + dust.scale = Main.rand.NextFloat(0.4f, 1.2f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); + dust.noGravity = false; + } + } + if (Main.rand.NextBool(4) && Time > 135 && !postTileHit && !postEnemyHit) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), 220, Vector2.Zero); + dust.scale = Main.rand.NextFloat(0.2f, 0.4f); + dust.noGravity = true; + } + if (Main.rand.NextBool(20) && (postTileHit || postEnemyHit)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(145, 145), 220, Vector2.Zero); + dust.scale = Main.rand.NextFloat(0.4f, 1.2f); + dust.noGravity = true; + } + // Add some degree of variation to the fog with rotation/color + + if (Main.rand.NextBool(3)) + FogColor.G = (byte)Main.rand.Next(160, 230 + 1); + ScaleFactor += 0.0061f; + ScaleFactor = MathHelper.Clamp(ScaleFactor, 0f, Projectile.scale); + Lighting.AddLight(Projectile.Center, new Vector3(1f, 1f, 0.25f) * ScaleFactor); + + Projectile.velocity *= 0.99f; + Projectile.Opacity = Utils.GetLerpValue(30f, 50f, Projectile.timeLeft, true) * Utils.GetLerpValue(0f, 130f, Projectile.timeLeft, true); + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); + + if (postEnemyHit && !postTileHit) + { + CalamityUtils.HomeInOnNPC(Projectile, true, 300f, 25f, 35f); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (!postTileHit) + Projectile.Center = Projectile.Center + Main.rand.NextVector2Circular(20, 20); + target.AddBuff(ModContent.BuffType(), 420); + + for (int i = 0; i <= 3; i++) + { + MediumMistParticle smoke = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.2f, 5 + Time * 0.2f), new Vector2(Main.rand.NextFloat(2, 6), Main.rand.NextFloat(2, 6)).RotatedByRandom(60), Main.rand.NextBool(3) ? Color.LimeGreen : Color.Lime, Color.Black, Main.rand.NextFloat(1.2f, 2.3f), 140); + GeneralParticleHandler.SpawnParticle(smoke); + } + if (!postTileHit && !postEnemyHit) + { + SoundEngine.PlaySound(BlightSpewer.Nanomachines, Projectile.Center); + Projectile.velocity = Vector2.Zero; + Projectile.timeLeft = 300; + postEnemyHit = true; + } + + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Projectile.damage = (int)(Projectile.damage * 0.95f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (!postEnemyHit) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + if (!postTileHit) + { + Projectile.timeLeft = 800; + postTileHit = true; + } + } + return false; + } + + // Expanding hitbox + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, 90, 10f, 95f); + hitbox.Inflate(size, size); + } + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.65f; + Color drawColor = FogColor * opacity; + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, Projectile.rotation, texture.Size() * 0.5f, ScaleFactor, SpriteEffects.None); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; + } + } +} diff --git a/Projectiles/Ranged/BlightFlames.png b/Projectiles/Ranged/BlightFlames.png new file mode 100644 index 0000000000..5bdf23b09a Binary files /dev/null and b/Projectiles/Ranged/BlightFlames.png differ diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index 3616ee50d4..9696e970b2 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -1,10 +1,12 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Particles; using Microsoft.Xna.Framework; -using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -14,94 +16,117 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; private bool playedSound = false; - + public int Time = 0; + public float particleSize = 15; + public Vector2 bloodCloudReturn; + public bool improvedHeal = false; + public bool setHomingVelocity = false; + public float HomingVelocity = 0.18f; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; - Projectile.scale = 2f; + Projectile.width = 43; + Projectile.height = 43; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; Projectile.penetrate = -1; - Projectile.extraUpdates = 1; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 5; + Projectile.extraUpdates = 4; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; Projectile.timeLeft = 300; } - public override void AI() { + if (Projectile.timeLeft > 220) // Main visual size changes + particleSize += 0.5f; + else + particleSize -= 1f; + + Time++; + + if (Projectile.timeLeft == 295) // Blood produced from the muzzle when firing the weapon + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Main.rand.NextBool() ? Color.Firebrick : Color.Red; + + float randomSpeedMultiplier = Main.rand.NextFloat(0.8f, 1.55f); + Vector2 bloodVelocity = Projectile.velocity.RotatedByRandom(0.5) * randomSpeedMultiplier + new Vector2 (0, -3); + BloodParticle blood = new BloodParticle(Projectile.Center, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + if (Projectile.timeLeft < 296) // The main visual of the projectile and the blood mist it produces before turning around + { + BloodBoilerMetaball2.SpawnParticle(Projectile.Center, particleSize * 2.3f); + BloodBoilerMetaball.SpawnParticle(Projectile.Center, particleSize * 1.7f); + + if (Main.rand.NextBool(6) && Projectile.ai[1] == 0f) + { + Color smokeColor = Main.rand.NextBool() ? Color.Red : Color.Firebrick; + Vector2 smokePosition = Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.3f, 5 + Time * 0.3f); + float smokeScale = Main.rand.NextFloat(0.5f, 1.6f); + float smokeOpacity = 170 + -Time * 0.6f; + Particle smoke = new MediumMistParticle(smokePosition, Vector2.Zero, smokeColor, Color.Black, smokeScale, smokeOpacity, Main.rand.NextFloat(0.2f, -0.2f)); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + if (Projectile.ai[1] == 0f) // Blood pulses on the projectile before it turns around + { + if (Main.rand.NextBool(9)) + { + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(7 + Time * 0.4f, 7 + Time * 0.4f), Vector2.Zero, Main.rand.NextBool(3) ? Color.Red : Color.Firebrick, new Vector2(1, 1), 0, Main.rand.NextFloat(0.02f, 0.07f) + Time * 0.0006f, 0f, 35); + GeneralParticleHandler.SpawnParticle(pulse); + } + } if (!playedSound) { SoundEngine.PlaySound(SoundID.Item34, Projectile.position); playedSound = true; } - if (Projectile.scale <= 3f) - Projectile.scale *= 1.01f; - Lighting.AddLight(Projectile.Center, 1f, 0f, 0f); - if (Projectile.ai[0] > 7f) + // A bunch of small things mostly for visuals when the projectile starts turning around before it homes on the player + if (Projectile.timeLeft == 235) + bloodCloudReturn = Projectile.velocity; + if (Projectile.timeLeft <= 235 && Projectile.ai[1] == 0f) + Projectile.velocity *= 0.98f; + if (Projectile.timeLeft == 220) { - float num296 = 1f; - if (Projectile.ai[0] == 8f) + Projectile.velocity = -bloodCloudReturn.RotatedBy(Projectile.ai[2] == 5 ? -0.7f : 0.7f) * 1.2f; + for (int i = 0; i <= 5; i++) { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 5; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(0.5f)) * Main.rand.NextFloat(1.7f, 3.2f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 2f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.7f)); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(1.2f, 2f); } } - else + if (Projectile.timeLeft == 209) // Begin returning to player { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - - if (Projectile.timeLeft == 160) Projectile.ai[1] = 1f; + } - if (Projectile.ai[1] == 1f) + if (Projectile.ai[1] == 1f) // Dusts as the projectile homes back in on the player { - Projectile.tileCollide = false; - - Projectile.extraUpdates = 2; + if (!setHomingVelocity) + { + HomingVelocity = Main.rand.NextFloat(0.29f, 0.32f); + setHomingVelocity = true; + } + Projectile.extraUpdates = 5; + bool dustEffect = Main.rand.NextBool(3) ? false : true; + int dustColor = dustEffect ? 296 : 60; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(dustEffect ? 0 : 5, dustEffect ? 0 : 5), dustColor); + dust.scale = dustEffect ? Main.rand.NextFloat(1.1f, 1.45f) : Main.rand.NextFloat(0.9f, 1.2f); + dust.velocity = dustEffect ? Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f) : Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.7f, 1.2f); + dust.alpha = 100; + dust.noLight = true; + dust.noGravity = true; Player player = Main.player[Projectile.owner]; @@ -120,38 +145,40 @@ namespace CalamityMod.Projectiles.Ranged // Home back in on the player. if (Projectile.velocity.X < xDist) { - Projectile.velocity.X = Projectile.velocity.X + 5f; + Projectile.velocity.X = Projectile.velocity.X + HomingVelocity; if (Projectile.velocity.X < 0f && xDist > 0f) - Projectile.velocity.X += 5f; + Projectile.velocity.X += HomingVelocity; } else if (Projectile.velocity.X > xDist) { - Projectile.velocity.X = Projectile.velocity.X - 5f; + Projectile.velocity.X = Projectile.velocity.X - HomingVelocity; if (Projectile.velocity.X > 0f && xDist < 0f) - Projectile.velocity.X -= 5f; + Projectile.velocity.X -= HomingVelocity; } if (Projectile.velocity.Y < yDist) { - Projectile.velocity.Y = Projectile.velocity.Y + 5f; + Projectile.velocity.Y = Projectile.velocity.Y + HomingVelocity; if (Projectile.velocity.Y < 0f && yDist > 0f) - Projectile.velocity.Y += 5f; + Projectile.velocity.Y += HomingVelocity; } else if (Projectile.velocity.Y > yDist) { - Projectile.velocity.Y = Projectile.velocity.Y - 5f; + Projectile.velocity.Y = Projectile.velocity.Y - HomingVelocity; if (Projectile.velocity.Y > 0f && yDist < 0f) - Projectile.velocity.Y -= 5f; + Projectile.velocity.Y -= HomingVelocity; } - + if (Projectile.timeLeft == 5) // Absolutely make sure the player gets the chance to heal + Projectile.Center = playerCenter; // Delete the projectile if it touches its owner. Has a chance to heal the player again if (Main.myPlayer == Projectile.owner) { if (Projectile.Hitbox.Intersects(player.Hitbox)) { - if (Main.rand.NextBool(3) && !Main.player[Projectile.owner].moonLeech) + if (Main.rand.NextBool(4) && !Main.player[Projectile.owner].moonLeech) { - player.statLife += 1; - player.HealEffect(1); + int bonusHeal = Main.rand.NextBool(3) ? 3 : 2; + player.statLife += improvedHeal ? bonusHeal : 1; + player.HealEffect(improvedHeal ? bonusHeal : 1); } Projectile.Kill(); } @@ -161,18 +188,14 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); - - if (!target.canGhostHeal || Main.player[Projectile.owner].moonLeech) - return; - - Player player = Main.player[Projectile.owner]; - if (Main.rand.NextBool()) - { - int healAmt = Main.rand.Next(1, 4); - player.statLife += healAmt; - player.HealEffect(healAmt); - } + target.AddBuff(ModContent.BuffType(), 600); + improvedHeal = true; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Projectile.damage = (int)(Projectile.damage * 0.88f); // 12% damage nerf for every enemy hit + if (Projectile.damage < 1) + Projectile.damage = 1; } } } diff --git a/Projectiles/Ranged/BrimstoneFireFriendly.cs b/Projectiles/Ranged/BrimstoneFireFriendly.cs index 93ba70a87e..8271e32a81 100644 --- a/Projectiles/Ranged/BrimstoneFireFriendly.cs +++ b/Projectiles/Ranged/BrimstoneFireFriendly.cs @@ -1,86 +1,153 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class BrimstoneFireFriendly : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 60; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 6; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - if (Projectile.timeLeft > 90) + Time++; + if (Time < Fadetime && Main.rand.NextBool(6)) { - Projectile.timeLeft = 90; + Vector2 cinderPos = Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Lifetime, 0.5f, 1f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(cinderPos, 4, 4, ModContent.DustType(), Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f); + if (Main.rand.NextBool(3)) + { + cinder.scale *= 2f; + cinder.velocity *= 2f; + } + cinder.noGravity = true; + cinder.scale *= cinderSize * 1.2f; + cinder.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); } - if (Projectile.ai[0] > 7f) - { - float dustScale = 1f; - if (Projectile.ai[0] == 8f) - { - dustScale = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScale = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScale = 0.75f; - } - Projectile.ai[0] += 1f; - if (Main.rand.NextBool()) - { - for (int i = 0; i < 1; i++) - { - int theDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 235, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[theDust].noGravity = true; - Main.dust[theDust].scale *= 3f; - Dust expr_DBEF_cp_0 = Main.dust[theDust]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[theDust]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[theDust].scale *= 1.5f; - } - Dust expr_DC74_cp_0 = Main.dust[theDust]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[theDust]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[theDust].scale *= dustScale; - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + if (MistType == -1) + MistType = Main.rand.Next(3); + + Lighting.AddLight(Projectile.Center, 0.75f, 0.15f, 0.15f); } + // Keeping the flames in place when hitting a block + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + Time++; + Projectile.timeLeft--; + return false; + } + + // Expanding hitbox + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + int size = (int)Utils.Remap(Time, 0f, Fadetime, 10f, 40f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 40f, 0f); + hitbox.Inflate(size, size); + } + + // Anti-wall hacking checks + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projHitbox.Intersects(targetHitbox) && Collision.CanHit(Projectile.Center, 0, 0, targetHitbox.Center.ToVector2(), 0, 0) ? null : false; + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.immune[Projectile.owner] = 7; target.AddBuff(ModContent.BuffType(), 240); + + // Gas up the enemy + int smokeCount = 3 + (int)MathHelper.Clamp(target.width * 0.1f, 0f, 20f); + for (int i = 0; i < smokeCount; i++) + { + bool Smoketype = Main.rand.NextBool(); + Vector2 smokePos = target.Center + Main.rand.NextVector2Circular(target.width * 0.5f, target.height * 0.5f); + Vector2 smokeVel = Vector2.UnitY * (Smoketype ? Main.rand.NextFloat(-0.8f, -2f) : Main.rand.NextFloat(-1.2f, -0.2f)) * MathHelper.Clamp(target.height * 0.1f, 1f, 10f); + Particle smoke = new MediumMistParticle(smokePos, smokeVel, new Color(255, 50, 50), Color.DimGray, Smoketype ? Main.rand.NextFloat(0.4f, 0.75f) : Main.rand.NextFloat(1.5f, 2f), 220 - Main.rand.Next(50), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D fire = ModContent.Request(Texture).Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(255, 110, 100, 200); + Color color2 = new Color(255, 50, 50, 70); + Color color3 = new Color(255, 100, 100, 100); + Color color4 = new Color(200, 35, 30, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + Color innerColor = Color.Lerp(fireColor, Color.Black, 0.3f); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = -j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length; + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, innerColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, innerColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + if (MistType > 2 || MistType < 0) + return false; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; } } } diff --git a/Projectiles/Ranged/CorossiveFlames.cs b/Projectiles/Ranged/CorossiveFlames.cs deleted file mode 100644 index ce12110be3..0000000000 --- a/Projectiles/Ranged/CorossiveFlames.cs +++ /dev/null @@ -1,87 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class CorossiveFlames : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, 0f, 0.25f, 0f); - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 89; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 2.5f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - if (Main.rand.NextBool(6)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 2f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.immune[Projectile.owner] = 4; - target.AddBuff(ModContent.BuffType(), 240); - } - } -} diff --git a/Projectiles/Ranged/CosmicFire.cs b/Projectiles/Ranged/CosmicFire.cs index 7b9ca8f127..3f2b021786 100644 --- a/Projectiles/Ranged/CosmicFire.cs +++ b/Projectiles/Ranged/CosmicFire.cs @@ -1,5 +1,11 @@ -using Terraria; +using CalamityMod.Buffs.DamageOverTime; +using Terraria; using Terraria.ModLoader; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.Typeless; namespace CalamityMod.Projectiles.Ranged { @@ -7,78 +13,129 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref int HitCount => ref Main.player[Projectile.owner].Calamity().deadSunCounter; + public ref float Time => ref Projectile.ai[0]; + public ref float BounceHits => ref Projectile.ai[1]; + + public Color InnerColor = Color.LightGreen; public override void SetDefaults() { - Projectile.width = 10; - Projectile.height = 10; + Projectile.width = Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 100; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 10; + Projectile.timeLeft = 15 * Projectile.MaxUpdates; } public override void AI() { - if (Projectile.scale <= 1.5f) + Time++; + Lighting.AddLight(Projectile.Center, InnerColor.ToVector3() * 0.2f); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen since it makes a fuck load of particles + if (Projectile.timeLeft % 3 == 0 && Time > 12f && targetDist < 1400f) { - Projectile.scale *= 1.01f; + AltSparkParticle spark = new AltSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 2.3f, Color.Black); + GeneralParticleHandler.SpawnParticle(spark); } - Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0.1f); - if (Projectile.ai[0] > 7f) + if (Main.rand.NextBool(3) && Time > 12f && targetDist < 1400f) { - float scalar = 1f; - if (Projectile.ai[0] == 8f) + Particle orb = new GenericBloom(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Projectile.velocity * Main.rand.NextFloat(0.05f, 0.5f), Color.Black, Main.rand.NextFloat(0.2f, 0.45f), Main.rand.Next(9, 12), true, false); + GeneralParticleHandler.SpawnParticle(orb); + } + + if (Projectile.timeLeft % 3 == 0 && Time > 12f && targetDist < 1400f) + { + LineParticle spark2 = new LineParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 1.7f, InnerColor); + GeneralParticleHandler.SpawnParticle(spark2); + } + if (Main.rand.NextBool(3) && Time > 12f && targetDist < 1400f) + { + Particle orb2 = new GenericBloom(Projectile.Center + Main.rand.NextVector2Circular(5, 5), Projectile.velocity * Main.rand.NextFloat(0.05f, 0.5f), InnerColor, Main.rand.NextFloat(0.05f, 0.3f), Main.rand.Next(9, 12), true); + GeneralParticleHandler.SpawnParticle(orb2); + } + + if (Time == 7f) + { + for (int i = 0; i <= 18; i++) { - scalar = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - scalar = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - scalar = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = Main.rand.NextBool(4) ? 61 : 62; - if (Main.rand.NextBool()) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= scalar; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + int dustStyle = Main.rand.NextBool() ? 66 : 263; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 191 : dustStyle, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.5f, 2.3f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 2.1f); + dust.noGravity = true; + dust.color = dust.type == dustStyle ? InnerColor : default; } } - else + if (BounceHits > 0f) { - Projectile.ai[0] += 1f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(6) ? 278 : 263, -Projectile.velocity); + dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.3f, 0.6f) : Main.rand.NextFloat(0.6f, 1.4f); + dust.velocity = -Projectile.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.3f, 1.7f); + dust.noGravity = true; + dust.color = InnerColor; + + CalamityUtils.HomeInOnNPC(Projectile, false, 600f, 12f, 20f); } - Projectile.rotation += 0.3f * (float)Projectile.direction; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.immune[Projectile.owner] = 3; + SoundEngine.PlaySound(DeadSunsWind.Explosion with { Pitch = HitCount * 0.05f }, Projectile.Center); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 2, 4f, Projectile.owner, HitCount * 10, BounceHits > 0f ? 5 : 0); + if (HitCount >= 15) + HitCount = 6; + else + HitCount++; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.timeLeft = 15 * Projectile.MaxUpdates; + float numberOflines = 5; + float rotFactorlines = 360f / numberOflines; + for (int i = 0; i < numberOflines; i++) + { + float rot = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + AltSparkParticle spark = new AltSparkParticle(Projectile.Center + offset, velOffset, false, 20, Main.rand.NextFloat(1.9f, 2.3f), Color.Black); + GeneralParticleHandler.SpawnParticle(spark); + } + float numberOfDusts = 25; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 156 : 191, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.noLight = dust.type == 191 ? true : false; + dust.velocity = dust.type == 191 ? velOffset * 2.5f : velOffset; + dust.scale = dust.type == 191 ? Main.rand.NextFloat(0.9f, 1.9f) : Main.rand.NextFloat(2.6f, 3.2f); + } + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, InnerColor, new Vector2(1f, 1f), Main.rand.NextFloat(5, -5), 0.1f, 0.9f - (BounceHits * 0.25f), 25); + GeneralParticleHandler.SpawnParticle(pulse); + + if (BounceHits == 0f) + SoundEngine.PlaySound(DeadSunsWind.Ricochet, Projectile.Center); + + BounceHits++; + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + if (BounceHits >= 4f) + Projectile.Kill(); + return false; } } } diff --git a/Projectiles/Ranged/DeadSunExplosion.cs b/Projectiles/Ranged/DeadSunExplosion.cs new file mode 100644 index 0000000000..9b8f99b9ea --- /dev/null +++ b/Projectiles/Ranged/DeadSunExplosion.cs @@ -0,0 +1,63 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class DeadSunExplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Player Owner => Main.player[Projectile.owner]; + public ref float ExplosionRadius => ref Projectile.ai[0]; + public Color color1 = Color.LightGreen; + public Color color2 = Color.Black; + public override void SetDefaults() + { + //These shouldn't matter because its circular + Projectile.width = 100; + Projectile.height = 100; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + } + public override void AI() + { + Particle explosion = new DetailedExplosion(Projectile.Center, Vector2.Zero, color1, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, ExplosionRadius * 0.0065f + 0.1f, Main.rand.Next(15, 22)); + GeneralParticleHandler.SpawnParticle(explosion); + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Black, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, ExplosionRadius * 0.0045f + 0.1f, Main.rand.Next(15, 22), false); + GeneralParticleHandler.SpawnParticle(explosion2); + Particle explosion3 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.Black, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, ExplosionRadius * 0.0030f + 0.1f, Main.rand.Next(15, 22), false); + GeneralParticleHandler.SpawnParticle(explosion3); + Particle orb = new GenericBloom(Projectile.Center, Projectile.velocity, color1, ExplosionRadius * 0.0085f + 0.05f, 10, true); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new GenericBloom(Projectile.Center, Projectile.velocity, color2, ExplosionRadius * 0.006f + 0.05f, 10, true, true); + GeneralParticleHandler.SpawnParticle(orb2); + float numberOfDusts = ExplosionRadius * 0.1f + 10; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = (Vector2.UnitX * Main.rand.NextFloat(ExplosionRadius * 0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = (Vector2.UnitX * Main.rand.NextFloat(ExplosionRadius * 0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(4) ? 263 : Projectile.ai[1] == 5 ? 278 : 66, velOffset); + dust.noGravity = dust.type == 278? false : true; + dust.color = color1; + dust.velocity = velOffset; + dust.scale = dust.type == 278 ? Main.rand.NextFloat(0.7f, 1.3f) : Main.rand.NextFloat(1.6f, 2.2f); + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius + 20, targetHitbox); + } +} diff --git a/Projectiles/Ranged/DragonsBreathFlames.cs b/Projectiles/Ranged/DragonsBreathFlames.cs new file mode 100644 index 0000000000..8317d628c5 --- /dev/null +++ b/Projectiles/Ranged/DragonsBreathFlames.cs @@ -0,0 +1,194 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class DragonsBreathFlames : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public int Time = 0; + public float beamWidth = 1.1f; + public bool beamsize = false; + public float bbbBONUSbeamSizeWOAHH = 50; + public bool postHit = false; + public int beamWeldBloomReduction = 0; + public ref int audioCooldown => ref Main.player[Projectile.owner].Calamity().DragonsBreathAudioCooldown; + + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.extraUpdates = 6; + Projectile.penetrate = -1; + Projectile.timeLeft = 500; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void AI() + { + Vector3 Light = Projectile.ai[0] == 1 ? new Vector3(0.255f, 0.080f, 0.080f) : new Vector3(0.255f, 0.060f, 0.000f); + Lighting.AddLight(Projectile.Center, Light * (Projectile.ai[0] == 1 ? 5 : 3)); + + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen + if (beamWidth <= 0.9f) + { + beamsize = true; + } + if (beamWidth >= 1.1f) + { + beamsize = false; + } + beamWidth += (beamsize ? 0.02f : -0.02f); + Time++; + if (Projectile.ai[0] == 0) //Fireball Mode + { + if (Time == 16) + { + for (int i = 0; i <= 7; i++) + { + int DustType1 = 259; + Vector2 dustyVelocity = Projectile.velocity * 4f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? DustType1 : 174); + dust.scale = dust.type == DustType1 ? Main.rand.NextFloat(0.9f, 1.9f) : Main.rand.NextFloat(0.8f, 1.7f); + dust.velocity = dustyVelocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.3f, 0.8f); + dust.noGravity = true; + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? DustType1 : 174); + dust2.scale = dust.type == DustType1 ? Main.rand.NextFloat(0.85f, 1.8f) : Main.rand.NextFloat(0.75f, 1.6f); + dust2.velocity = dustyVelocity.RotatedByRandom(0.15f) * Main.rand.NextFloat(0.8f, 2.1f); + dust2.noGravity = true; + } + for (int i = 0; i <= 5; i++) + { + Vector2 smokeVel = Projectile.velocity * 4.2f; + float rotationAngle = Main.rand.NextFloat(-0.15f, 0.15f); + smokeVel = smokeVel.RotatedBy(rotationAngle) * Main.rand.NextFloat(0.45f, 1.3f); + + float smokeScale = Main.rand.NextFloat(0.4f, 1.2f); + + SmallSmokeParticle smoke = new SmallSmokeParticle(Projectile.Center, smokeVel, Color.DimGray, Main.rand.NextBool() ? Color.SlateGray : Color.Black, smokeScale, 100); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + if (Time % 5 == 0 && Time > 35f && targetDist < 1400f) + { + SparkParticle spark = new SparkParticle(Projectile.Center + Main.rand.NextVector2Circular(1 + (Time * 0.3f), 1 + (Time * 0.3f)), -Projectile.velocity * 0.5f, false, 15, Main.rand.NextFloat(0.4f, 0.7f), Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark); + } + if (targetDist < 1400f) + { + ModContent.GetInstance().SpawnParticle(Projectile.Center, Time * 0.9f); + ModContent.GetInstance().SpawnParticle(Projectile.Center + Projectile.velocity, Time * 0.85f); + } + Projectile.velocity *= 1.01f; + } + if (Projectile.ai[0] == 1) //Welding Mode + { + if (bbbBONUSbeamSizeWOAHH > 0) + bbbBONUSbeamSizeWOAHH -= 0.65f; + Projectile.extraUpdates = 170; + + if (Time > 13) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), Main.rand.NextBool(3) ? 162 : 259); + dust2.scale = Main.rand.NextFloat(0.3f, 0.5f); + dust2.noGravity = true; + if (Main.rand.NextBool(6)) + { + dust2.velocity = new Vector2(0, Main.rand.NextFloat(-1, -13)); + } + if (targetDist < 1400f) + { + ModContent.GetInstance().SpawnParticle(Projectile.Center, beamWidth * 46 + bbbBONUSbeamSizeWOAHH); + ModContent.GetInstance().SpawnParticle(Projectile.Center, beamWidth * 45 + bbbBONUSbeamSizeWOAHH); + } + } + if (Time == 13) + { + for (int i = 0; i <= 4; i++) + { + Vector2 sparkVelocity = Projectile.velocity * 6; + + float sparkScale1 = Main.rand.NextFloat(0.3f, 0.8f); + Vector2 sparkvelocity1 = sparkVelocity.RotatedByRandom(0.45f) * Main.rand.NextFloat(0.4f, 0.95f); + SparkParticle spark1 = new SparkParticle(Projectile.Center, sparkvelocity1, false, 6, sparkScale1, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark1); + + float sparkScale2 = Main.rand.NextFloat(0.4f, 1f); + Vector2 sparkvelocity2 = sparkVelocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(1.1f, 3.1f); + SparkParticle spark2 = new SparkParticle(Projectile.Center, sparkvelocity2, false, 6, sparkScale2, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark2); + } + } + } + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.ai[0] == 1) + { + if (beamWeldBloomReduction < 3) + { + if (audioCooldown == 0) + { + SoundEngine.PlaySound(DragonsBreath.WeldingBurn, Projectile.Center); + audioCooldown = 12; + } + float OrbSize = Main.rand.NextFloat(0.5f, 0.8f) - beamWeldBloomReduction * 0.14f; + Particle orb = new GenericBloom(target.Center, Vector2.Zero, Color.OrangeRed, OrbSize + 0.6f, 8, true); + GeneralParticleHandler.SpawnParticle(orb); + Particle orb2 = new GenericBloom(target.Center, Vector2.Zero, Color.White, OrbSize + 0.2f, 8, true); + GeneralParticleHandler.SpawnParticle(orb2); + if (!postHit) + { + for (int i = 0; i < 3; i++) + { + Vector2 SpawnPosition = target.Center + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; + Vector2 splatterDirection = (Projectile.Center - SpawnPosition).SafeNormalize(Vector2.UnitY); + int sparkLifetime = Main.rand.Next(22, 36); + float sparkScale = Main.rand.NextFloat(0.8f, 1.3f); + Color sparkColor = Main.rand.NextBool(4) ? Color.OrangeRed : Color.Orange; + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + SparkParticle spark = new SparkParticle(target.Center, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + postHit = true; + } + beamWeldBloomReduction++; + } + target.AddBuff(ModContent.BuffType(), 420); + } + else if (!postHit) + { + for (int i = 0; i <= 6; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.position - Projectile.velocity * 0.5f, Main.rand.NextBool(3) ? 293 : 174, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.5f, 3.5f), 0, default, Main.rand.NextFloat(1.6f, 2.3f)); + dust.noGravity = true; + Dust dust2 = Dust.NewDustPerfect(Projectile.position - Projectile.velocity * 0.5f, Main.rand.NextBool(3) ? 293 : 174, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(5f)) * Main.rand.NextFloat(0.8f, 5.8f), 0, default, Main.rand.NextFloat(1.6f, 2.3f)); + dust2.noGravity = true; + } + postHit = true; + } + target.AddBuff(ModContent.BuffType(), 240); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.ai[1] == 1 ? 4 : Projectile.width + Time * 0.1f, targetHitbox); + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + Projectile.damage = (int)(Projectile.damage * 0.89f); // 11% damage nerf for every enemy hit + if (Projectile.damage < 1) + Projectile.damage = 1; + } + } +} diff --git a/Projectiles/Ranged/DragonsBreathMag.cs b/Projectiles/Ranged/DragonsBreathMag.cs new file mode 100644 index 0000000000..0908d58da1 --- /dev/null +++ b/Projectiles/Ranged/DragonsBreathMag.cs @@ -0,0 +1,81 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static Humanizer.In; + +namespace CalamityMod.Projectiles.Ranged +{ + public class DragonsBreathMag : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/Ranged/DragonsBreathMag"; + public int Time = 0; + public bool TouchedGrass = false; + + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.ignoreWater = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.aiStyle = ProjAIStyleID.GroundProjectile; + Projectile.penetrate = -1; + Projectile.timeLeft = 700; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + public override void SetStaticDefaults() + { + // Unsure if it will look good with these + //ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + //ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } + public override bool PreDraw(ref Color lightColor) + { + //CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DragonsBreathMag").Value); + return true; + } + public override void AI() + { + Projectile.extraUpdates = 0; + Time++; + Player Owner = Main.player[Projectile.owner]; + if (!TouchedGrass) + { + Projectile.rotation += 0.5f * (float)Projectile.direction; + } + Projectile.velocity.Y -= 0.055f; + Projectile.velocity.X *= 0.992f; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + Projectile.damage = 0; + TouchedGrass = true; + Projectile.velocity *= 0.98f; + return false; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Main.zenithWorld) + { + for (int i = 0; i <= 30; i++) + { + SparkParticle spark1 = new SparkParticle(Projectile.Center, new Vector2(4, 4).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 2.8f), false, 45, 1.4f, Main.rand.NextBool(4) ? Color.Orange : Color.OrangeRed); + GeneralParticleHandler.SpawnParticle(spark1); + } + Particle explosion = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.DarkOrange, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 2.8f, 33); + GeneralParticleHandler.SpawnParticle(explosion); + Particle explosion2 = new DetailedExplosion(Projectile.Center, Vector2.Zero, Color.OrangeRed, Vector2.One, Main.rand.NextFloat(-5, 5), 0f, 3f, 33, false); + GeneralParticleHandler.SpawnParticle(explosion2); + } + target.AddBuff(ModContent.BuffType(), 20); + } + } +} diff --git a/Projectiles/Ranged/DragonsBreathMag.png b/Projectiles/Ranged/DragonsBreathMag.png new file mode 100644 index 0000000000..e17cb6edf4 Binary files /dev/null and b/Projectiles/Ranged/DragonsBreathMag.png differ diff --git a/Projectiles/Ranged/DragonsBreathRound.cs b/Projectiles/Ranged/DragonsBreathRound.cs deleted file mode 100644 index 7f1b358ae6..0000000000 --- a/Projectiles/Ranged/DragonsBreathRound.cs +++ /dev/null @@ -1,82 +0,0 @@ -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using CalamityMod.Buffs.DamageOverTime; - -namespace CalamityMod.Projectiles.Ranged -{ - public class DragonsBreathRound : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 4; - Projectile.height = 4; - Projectile.friendly = true; - Projectile.extraUpdates = 10; - Projectile.penetrate = 1; - Projectile.timeLeft = 180; - Projectile.DamageType = DamageClass.Ranged; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - //Rotation - Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) +MathHelper.ToRadians(90) * Projectile.direction; - - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) - { - float num93 = Projectile.velocity.X / 3f; - float num94 = Projectile.velocity.Y / 3f; - int num95 = 4; - int idx = Dust.NewDust(new Vector2(Projectile.position.X + (float)num95, Projectile.position.Y + (float)num95), Projectile.width - num95 * 2, Projectile.height - num95 * 2, 127, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[idx]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= num93; - dust.position.Y -= num94; - - if (Main.rand.NextBool(20)) - { - int num97 = 4; - int num98 = Dust.NewDust(new Vector2(Projectile.position.X + (float)num97, Projectile.position.Y + (float)num97), Projectile.width - num97 * 2, Projectile.height - num97 * 2, 127, 0f, 0f, 100, default, 0.6f); - Main.dust[num98].velocity *= 0.25f; - Main.dust[num98].velocity += Projectile.velocity * 0.5f; - } - } - } - - public override void OnKill(int timeLeft) - { - if (Projectile.owner == Main.myPlayer) - { - int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].DamageType = DamageClass.Ranged; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor); - return false; - } - } -} diff --git a/Projectiles/Ranged/DragonsBreathRound.png b/Projectiles/Ranged/DragonsBreathRound.png deleted file mode 100644 index 2599eb14ac..0000000000 Binary files a/Projectiles/Ranged/DragonsBreathRound.png and /dev/null differ diff --git a/Projectiles/Ranged/DrizzlefishFire.cs b/Projectiles/Ranged/DrizzlefishFire.cs index 74defbd5af..f86cce2045 100644 --- a/Projectiles/Ranged/DrizzlefishFire.cs +++ b/Projectiles/Ranged/DrizzlefishFire.cs @@ -1,4 +1,5 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Fishing.BrimstoneCragCatches; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -9,7 +10,8 @@ namespace CalamityMod.Projectiles.Ranged public class DrizzlefishFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - private int splitTimer = 30; + private int splitTimer = 45; + public int Time = 0; public override void SetDefaults() { @@ -18,15 +20,28 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; + Projectile.penetrate = -1; Projectile.extraUpdates = 1; Projectile.timeLeft = 90; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } - + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } public override bool PreDraw(ref Color lightColor) { + if (Time < 7) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value); + else + { + if (Projectile.ai[1] == 1f) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value); + else + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire").Value); + } //Changes the texture of the projectile if (Projectile.ai[1] == 1f) { @@ -39,21 +54,79 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + Player Owner = Main.player[Projectile.owner]; + if (Main.zenithWorld && Time == 1 && Owner.Calamity().dragoonDrizzlefishGelBoost > 1) + Projectile.damage = (int)(Projectile.damage * Owner.Calamity().dragoonDrizzlefishGelBoost); + Projectile.scale = 1.5f; int dustType = 235; + int dustType2 = 235; if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool()) { - dustType = 35; + dustType = 174; } else { - dustType = 55; + dustType = 162; } } else { - dustType = 235; + if (Main.rand.NextBool()) + { + dustType = 183; + } + else + { + dustType = 90; + } + } + if (Time > 7) + { + Projectile.alpha = 0; + for (int i = 0; i < 5; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) - Projectile.velocity * 1.5f, dustType, -Projectile.velocity); + dust.noGravity = true; + dust.velocity *= 0f; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0.7f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 1.4f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(1.2f, 1.9f); + } + } + else + Projectile.alpha = 255; + if (Time == 4) + { + for (int i = 0; i <= 16; i++) + { + if (Projectile.ai[1] == 1f) + { + if (Main.rand.NextBool()) + { + dustType2 = 174; + } + else + { + dustType2 = 162; + } + } + else + { + if (Main.rand.NextBool()) + { + dustType2 = 183; + } + else + { + dustType2 = 90; + } + } + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType2, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.8f, 2.3f); + dust.velocity = Projectile.velocity.RotatedByRandom(1.1f) * Main.rand.NextFloat(0.6f, 1.9f); + dust.noGravity = true; + } } splitTimer--; if (splitTimer <= 0) @@ -86,57 +159,14 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.timeLeft = 90; } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 2.5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 2f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + Projectile.rotation += 0.5f * (float)Projectile.direction; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.ai[1] == 1f) { - target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.OnFire3, 120); } else { diff --git a/Projectiles/Ranged/DrizzlefishFireSplit.cs b/Projectiles/Ranged/DrizzlefishFireSplit.cs index 1cdd80e6ed..8ab731eafa 100644 --- a/Projectiles/Ranged/DrizzlefishFireSplit.cs +++ b/Projectiles/Ranged/DrizzlefishFireSplit.cs @@ -1,15 +1,20 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static Humanizer.In; + namespace CalamityMod.Projectiles.Ranged { public class DrizzlefishFireSplit : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/Ranged/DrizzlefishFire"; + public int Time = 0; public override void SetDefaults() { @@ -18,14 +23,20 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; + Projectile.penetrate = 1; Projectile.timeLeft = 90; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 15; } - + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } public override bool PreDraw(ref Color lightColor) { + if (Projectile.ai[1] == 1f) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value); + else + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire").Value); //Changes the texture of the projectile if (Projectile.ai[1] == 1f) { @@ -38,70 +49,47 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Time++; + Player Owner = Main.player[Projectile.owner]; + if (Main.zenithWorld && Time == 1 && Owner.Calamity().dragoonDrizzlefishGelBoost > 1) + Projectile.damage = (int)(Projectile.damage * Owner.Calamity().dragoonDrizzlefishGelBoost); + Projectile.velocity.X *= 0.98f; + Projectile.velocity.Y += 0.5f; int dustType = 235; if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool()) { - dustType = 35; + dustType = 174; } else { - dustType = 55; + dustType = 162; } } else { - dustType = 235; + if (Main.rand.NextBool()) + { + dustType = 183; + } + else + { + dustType = 90; + } + } + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(4, 4) - Projectile.velocity * 1.5f, dustType, -Projectile.velocity); + dust.noGravity = true; + dust.velocity *= 0f; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 0.3f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.4f, 0.8f); } Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); if (Projectile.timeLeft > 90) { Projectile.timeLeft = 90; } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 2.5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 2f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } - } - else - { - Projectile.ai[0] += 1f; - } Projectile.rotation += 0.3f * (float)Projectile.direction; } @@ -109,12 +97,48 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[1] == 1f) { - target.AddBuff(BuffID.OnFire, 120); + target.AddBuff(BuffID.OnFire3, 60); } else { target.AddBuff(ModContent.BuffType(), 30); } } + public override void OnKill(int timeLeft) + { + Player Owner = Main.player[Projectile.owner]; + int dustType = 235; + for (int i = 0; i <= 9; i++) + { + if (Projectile.ai[1] == 1f) + { + if (Main.rand.NextBool()) + { + dustType = 174; + } + else + { + dustType = 162; + } + } + else + { + if (Main.rand.NextBool()) + { + dustType = 183; + } + else + { + dustType = 90; + } + } + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, new Vector2(0, -5).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 1.9f)); + dust.noGravity = false; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 0.6f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.4f, 1.1f); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, dustType, new Vector2(0, -3).RotatedByRandom(MathHelper.ToRadians(25f)) * Main.rand.NextFloat(0.1f, 1.9f)); + dust2.noGravity = false; + dust2.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 0.6f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.4f, 1.1f); + } + } } } diff --git a/Projectiles/Ranged/DrizzlefishFireball.cs b/Projectiles/Ranged/DrizzlefishFireball.cs index 60f9d30381..864bcdaa33 100644 --- a/Projectiles/Ranged/DrizzlefishFireball.cs +++ b/Projectiles/Ranged/DrizzlefishFireball.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,8 +9,8 @@ namespace CalamityMod.Projectiles.Ranged public class DrizzlefishFireball : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - + public override string Texture => "CalamityMod/Projectiles/Ranged/DrizzlefishFire"; + public int Time = 0; public override void SetDefaults() { Projectile.width = 10; @@ -22,34 +23,87 @@ namespace CalamityMod.Projectiles.Ranged Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } - + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 8; + ProjectileID.Sets.TrailingMode[Projectile.type] = 0; + } public override void AI() { + Time++; + Player Owner = Main.player[Projectile.owner]; + if (Main.zenithWorld && Time == 1 && Owner.Calamity().dragoonDrizzlefishGelBoost > 1) + Projectile.damage = (int)(Projectile.damage * Owner.Calamity().dragoonDrizzlefishGelBoost); + Projectile.velocity.X *= 0.995f; + Projectile.velocity.Y -= 0.065f; Lighting.AddLight(Projectile.Center, 0.25f, 0f, 0f); int dustType = 235; + int dustType2 = 235; if (Projectile.ai[1] == 1f) { if (Main.rand.NextBool()) { - dustType = 35; + dustType = 174; } else { - dustType = 55; + dustType = 162; } } else { - dustType = 235; - } - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 4f) - { - for (int num468 = 0; num468 < 5; num468++) + if (Main.rand.NextBool()) { - int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, 2f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; + dustType = 183; + } + else + { + dustType = 90; + } + } + if (Time > 7) + { + Projectile.alpha = 0; + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(5, 5) - Projectile.velocity * 1.5f, dustType, -Projectile.velocity); + dust.noGravity = true; + dust.velocity *= 0f; + dust.scale = Owner.Calamity().dragoonDrizzlefishGelBoost > 1 ? Main.rand.NextFloat(0.4f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f, 1f + Owner.Calamity().dragoonDrizzlefishGelBoost * 0.5f) : Main.rand.NextFloat(0.9f, 1.5f); + } + } + else + Projectile.alpha = 255; + if (Time == 4) + { + for (int i = 0; i <= 8; i++) + { + if (Projectile.ai[1] == 1f) + { + if (Main.rand.NextBool()) + { + dustType2 = 174; + } + else + { + dustType2 = 162; + } + } + else + { + if (Main.rand.NextBool()) + { + dustType2 = 183; + } + else + { + dustType2 = 90; + } + } + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType2, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.8f) * Main.rand.NextFloat(0.3f, 1.3f); + dust.noGravity = true; } } } @@ -60,15 +114,35 @@ namespace CalamityMod.Projectiles.Ranged return false; } + public override bool PreDraw(ref Color lightColor) + { + if (Time < 7) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/InvisibleProj").Value); + else + { + if (Projectile.ai[1] == 1f) + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value); + else + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1, ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire").Value); + } + //Changes the texture of the projectile + if (Projectile.ai[1] == 1f) + { + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Ranged/DrizzlefishFire2").Value; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, new Rectangle?(new Rectangle(0, 0, 16, 16)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, 20 / 2f), Projectile.scale, SpriteEffects.None, 0); + return false; + } + return true; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.ai[1] == 1f) { - target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.OnFire3, 40); } else { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 20); } } } diff --git a/Projectiles/Ranged/ElementalEruptionHouldout.cs b/Projectiles/Ranged/ElementalEruptionHouldout.cs new file mode 100644 index 0000000000..4ad18da7a5 --- /dev/null +++ b/Projectiles/Ranged/ElementalEruptionHouldout.cs @@ -0,0 +1,141 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using log4net.Core; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ElementalEruptionHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/ElementalEruption"; + private Player Owner => Main.player[Projectile.owner]; + private ref float ShotsFired => ref Projectile.ai[1]; + private ref float ShootTimer => ref Projectile.ai[2]; + private ref int ShotDelay => ref Owner.ActiveItem().useTime; // 6 + public int ShotCooldown; + public int FireBlobs = 0; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + + public override void SetDefaults() + { + Projectile.width = 64; + Projectile.height = 34; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (Owner.dead || ShotsFired >= 24) // destroy the holdout if the player dies or is out of shots + { + Projectile.Kill(); + return; + } + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.8f; + + // Kill if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + Projectile.Kill(); + } + else + { + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + + ShootTimer++; + if (ShootTimer >= 60) + { + if (ShotCooldown == 0) + { + SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() < 0.70f); + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + } + ShotsFired++; + ShotCooldown = ShotDelay; + if (FireBlobs == 0) + { + Vector2 newVel = (Projectile.velocity * 9); + Vector2 newPos = tipPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 36f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), newPos, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner, newVel.Length(), -1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), newPos, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner, newVel.Length(), 1f); + FireBlobs = 3; + } + else + FireBlobs--; + } + else + ShotCooldown--; + } + else + { + if (ShootTimer == 1) + SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f}, Projectile.Center); + ShotsFired = 0; + for (int i = 0; i < 2; i++) + { + int dustType = Main.rand.NextBool() ? 66 : 247; + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust = Dust.NewDustPerfect(tipPosition, dustType); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f) * (ShootTimer * 0.025f) - rotMulti * 0.1f; + dust.noGravity = true; + dust.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 3.2f) - rotMulti) * (ShootTimer * 0.025f); + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + Vector2 oldVelocity = Projectile.velocity; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + } + Projectile.Center = armPosition + Projectile.velocity * 20; + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Projectile.spriteDirection = Projectile.direction; + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/ElementalFire.cs b/Projectiles/Ranged/ElementalFire.cs index 22f851a0e5..3e99af8777 100644 --- a/Projectiles/Ranged/ElementalFire.cs +++ b/Projectiles/Ranged/ElementalFire.cs @@ -1,8 +1,11 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class ElementalFire : ModProjectile, ILocalizedModType @@ -10,74 +13,90 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int Lifetime => 96; + public ref float ColorType => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = Projectile.height = 12; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 2; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 90; + Projectile.penetrate = 5; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = Lifetime; // 24 effectively Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 9; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Lighting.AddLight(Projectile.Center, 0.15f, 0.45f, 0f); - if (Projectile.ai[0] > 7f) + var effectcolor = Main.rand.Next(4) switch { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 66; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 0.75f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - } - } - } + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + + Time++; + ColorType += 0.02f; + + // Determines particle size as well as hitbox + if (Time >= 1f) + Projectile.scale = 1.8f * Utils.GetLerpValue(5f, 30f, Time, true); else + return; // Helps position it at the tip + + if (Time == 1) { - Projectile.ai[0] += 1f; + for (int i = 0; i < 12; i++) + { + float rotMulti = Main.rand.NextFloat(0.7f, 1.1f); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType); + dust.scale = Main.rand.NextFloat(1.8f, 2.5f) - rotMulti; + dust.noGravity = true; + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f * rotMulti) * Main.rand.NextFloat(0.5f, 1.8f) * rotMulti; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 540); + + if (Time > 9) + { + float dustArea = Main.rand.NextFloat(0.1f, 1.7f); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) + Projectile.velocity * Main.rand.NextFloat(-1.8f, 1.8f), dustType); + dust.scale = (1.8f - dustArea) * 0.65f; + dust.noGravity = true; + dust.velocity = new Vector2(4, 4).RotatedByRandom(100) * dustArea; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + + // Rainbow smokes of increasing opacity + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + float hue = 0.5f * (ColorType % 1f) + 0.5f * Utils.GetLerpValue(30f, Lifetime, Time, true) * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color smokeColor = Main.hslToRgb(hue, 1f, 0.7f); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.45f, smokeRot, true, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, which is on the brighter side + if (Main.rand.NextBool(5)) + { + Color glowColor = Color.Lerp(smokeColor, Color.White, 0.3f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 9, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.2f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); + } + + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale * 0.3f); } + + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 540); } } diff --git a/Projectiles/Ranged/ElementalFlare.cs b/Projectiles/Ranged/ElementalFlare.cs new file mode 100644 index 0000000000..5adc2f48d7 --- /dev/null +++ b/Projectiles/Ranged/ElementalFlare.cs @@ -0,0 +1,152 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ElementalFlare : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/SmallGreyscaleCircle"; + + // Stats for both + public static int Lifetime = 90; // effective, 1.5 seconds + + // Homing Flare stats + public static float MinimumSpeed => 4f; + public static float MaximumSpeed => 24f; + public static float HomingRange => 720f; // 45 tiles + public static float HomingSpeedMult => 1.6f; + + // Sticky Flare stats + public static int StickDuration => 2; // already in seconds + public static int MaxStick => 6; + public static float StickyDamageFalloff => 0.5f; + + public bool StickToEnemies => Projectile.ai[2] == 1f; + public bool StickToTiles => Projectile.ai[2] == 2f; + public ref float StoredVelocity => ref Projectile.ai[0]; + public ref float Direction => ref Projectile.ai[1]; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 18; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = Lifetime * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + if (StickToTiles) + return; + + if (StickToEnemies) + { + Projectile.ai[2] = 1f; + Projectile.StickyProjAI(StickDuration * Projectile.MaxUpdates); + return; + } + + float effectiveVelocity = MathHelper.Clamp(StoredVelocity, MinimumSpeed, MaximumSpeed); + int targetNPC = Projectile.FindTargetWithLineOfSight(HomingRange); + if (targetNPC != -1 && Projectile.timeLeft < (Lifetime - 20) * Projectile.MaxUpdates) + { + Vector2 destination = Main.npc[targetNPC].Center; + Projectile.velocity = Projectile.SafeDirectionTo(destination) * effectiveVelocity * HomingSpeedMult; + + // If close enough, don't do the sine movement + if (Projectile.Distance(destination) <= 160f) + return; + } + + // Sine-like movement + Projectile.position += (Vector2.UnitY * MathF.Sin(Projectile.timeLeft * MathHelper.Pi * 0.05f) * effectiveVelocity * Direction).RotatedBy(Projectile.velocity.ToRotation()); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 540); + + // Lose a bit of damage from repeated hits + if ((StickToEnemies || StickToTiles) && Projectile.damage > 1) + Projectile.damage = (int)(Projectile.damage * StickyDamageFalloff); + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (StickToEnemies) + Projectile.ModifyHitNPCSticky(MaxStick); + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (StickToTiles || StickToEnemies) + { + Projectile.velocity = oldVelocity * 0.95f; + Projectile.position -= Projectile.velocity; + + // No more enemy sticking + reset duration + if (StickToEnemies) + { + Projectile.ai[2] = 2f; + Projectile.timeLeft = StickDuration * 60 * Projectile.MaxUpdates; + } + return false; + } + return true; + } + + public override void OnKill(int timeLeft) + { + // Circular spread of clouds + for (int i = 0; i < 8; i++) + { + Vector2 smokeVel = Main.rand.NextVector2Circular(16f, 16f); + Color smokeColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.6f, 1.6f), 200 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D lightTexture = ModContent.Request(Texture).Value; + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float hue = 0.5f + 0.5f * i / (float)Projectile.oldPos.Length * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color color = Main.hslToRgb(hue, 1f, 0.6f); + Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); + Color outerColor = color * 2f; + Color innerColor = Color.Lerp(color, Color.White, 0.2f) * 0.5f; + float intensity = 0.9f + 0.15f * MathF.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + + // Become smaller the futher along the old positions we are. + intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + + Vector2 outerScale = new Vector2(1.25f) * intensity; + Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f; + outerColor *= intensity * Projectile.scale; + innerColor *= intensity * Projectile.scale; + Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/EssenceFire.cs b/Projectiles/Ranged/EssenceFire.cs index 42b2bf6bde..9d2781a92e 100644 --- a/Projectiles/Ranged/EssenceFire.cs +++ b/Projectiles/Ranged/EssenceFire.cs @@ -1,93 +1,143 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class EssenceFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/FireProj"; + + public static int Lifetime => 96; + public static int Fadetime => 80; + public ref float Time => ref Projectile.ai[0]; + public int MistType = -1; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 10; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 65; + Projectile.MaxUpdates = 4; + Projectile.timeLeft = Lifetime; // 24 effectively + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 3; } public override void AI() { - if (Projectile.scale <= 1.5f) - { - Projectile.scale *= 1.01f; - } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - if (Projectile.timeLeft > 65) - Projectile.timeLeft = 65; + Time++; - if (Projectile.ai[0] > 5f) + if (MistType == -1) + MistType = Main.rand.Next(3); + + if (Time > Fadetime) + Projectile.velocity *= 0.95f; + + if (Time > 6f && Time < Fadetime) { - float num296 = 1f; - if (Projectile.ai[0] == 6f) + if (Main.rand.NextBool(16)) { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 7f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 8f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = (int)CalamityDusts.PurpleCosmilite; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) + Dust dust = Dust.NewDustDirect(Projectile.Center + Main.rand.NextVector2Circular(60f, 60f) * Utils.Remap(Time, 0f, Fadetime, 0.5f, 1f), 4, 4, 295, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100); + if (Main.rand.NextBool(5)) { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + dust.noGravity = true; + dust.scale *= 2f; + dust.velocity *= 0.8f; } + dust.velocity *= 1.1f; + dust.velocity += Projectile.velocity * Utils.Remap(Time, 0f, Fadetime * 0.75f, 1f, 0.1f) * Utils.Remap(Time, 0f, Fadetime * 0.1f, 0.1f, 1f); + } + + if (Main.rand.NextBool(17)) + { + bool LowVel = Main.rand.NextBool() ? false : true; + FlameParticle fire = new FlameParticle(Projectile.Center, 20, MathHelper.Clamp(Time * 0.05f, 0.15f, 1.75f), 0.05f, Color.BlueViolet * (LowVel ? 1.2f : 0.5f), Color.DarkBlue * (LowVel ? 1.2f : 0.5f)); + fire.Velocity = new Vector2(Projectile.velocity.X * 0.8f, -10).RotatedByRandom(0.005f) * (LowVel ? Main.rand.NextFloat(0.4f, 0.65f) : Main.rand.NextFloat(0.8f, 1f)); + GeneralParticleHandler.SpawnParticle(fire); } } - else + else if (Time == 5f) { - Projectile.ai[0] += 1f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 295 : 181, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(0.5f, 1f)); + dust.scale = Main.rand.NextFloat(0.8f, 1.8f); + dust.noGravity = true; + dust.fadeIn = 0.5f; } - Projectile.rotation += 0.3f * Projectile.direction; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + // Expanding hitbox + public override void ModifyDamageHitbox(ref Rectangle hitbox) { - target.AddBuff(ModContent.BuffType(), 240); - target.immune[Projectile.owner] = 1; + int size = (int)Utils.Remap(Time, 0f, Fadetime, 10f, 40f); + + // Shrinks again after fading + if (Time > Fadetime) + size = (int)Utils.Remap(Time, Fadetime, Lifetime, 40f, 0f); + hitbox.Inflate(size, size); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 360); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D fire = ModContent.Request(Texture).Value; + Texture2D mist = ModContent.Request("CalamityMod/Particles/MediumMist").Value; + + // The conga line of colors to sift through + Color color1 = new Color(160, 100, 255, 200); + Color color2 = new Color(160, 50, 255, 70); + Color color3 = new Color(120, 100, 255, 100); + Color color4 = new Color(30, 50, 200, 100); + float length = ((Time > Fadetime - 10f) ? 0.1f : 0.15f); + float vOffset = Math.Min(Time, 20f); + float timeRatio = Utils.GetLerpValue(0f, Lifetime, Time); + float fireSize = Utils.Remap(timeRatio, 0.2f, 0.5f, 0.25f, 1f); + + if (timeRatio >= 1f) + return false; + + for (float j = 1f; j >= 0f; j -= length) + { + // Color + Color fireColor = ((timeRatio < 0.1f) ? Color.Lerp(Color.Transparent, color1, Utils.GetLerpValue(0f, 0.1f, timeRatio)) : + ((timeRatio < 0.2f) ? Color.Lerp(color1, color2, Utils.GetLerpValue(0.1f, 0.2f, timeRatio)) : + ((timeRatio < 0.35f) ? color2 : + ((timeRatio < 0.7f) ? Color.Lerp(color2, color3, Utils.GetLerpValue(0.35f, 0.7f, timeRatio)) : + ((timeRatio < 0.85f) ? Color.Lerp(color3, color4, Utils.GetLerpValue(0.7f, 0.85f, timeRatio)) : + Color.Lerp(color4, Color.Transparent, Utils.GetLerpValue(0.85f, 1f, timeRatio))))))); + fireColor *= (1f - j) * Utils.GetLerpValue(0f, 0.2f, timeRatio, true); + + // Positions and rotations + Vector2 firePos = Projectile.Center - Main.screenPosition - Projectile.velocity * vOffset * j; + float mainRot = (-j * MathHelper.PiOver2 - Main.GlobalTimeWrappedHourly * (j + 1f) * 2f / length) * Math.Sign(Projectile.velocity.X); + float trailRot = MathHelper.PiOver4 - mainRot; + + // Draw one backtrail + Vector2 trailOffset = Projectile.velocity * vOffset * length * 0.5f; + Main.EntitySpriteDraw(fire, firePos - trailOffset, null, fireColor * 0.25f, trailRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the main fire + Main.EntitySpriteDraw(fire, firePos, null, fireColor, mainRot, fire.Size() * 0.5f, fireSize, SpriteEffects.None); + + // Draw the masking smoke + if (MistType > 2 || MistType < 0) + return false; + Main.spriteBatch.SetBlendState(BlendState.Additive); + Rectangle frame = mist.Frame(1, 3, 0, MistType); + Main.EntitySpriteDraw(mist, firePos, frame, Color.Lerp(fireColor, Color.White, 0.3f), mainRot, frame.Size() * 0.5f, fireSize, SpriteEffects.None); + Main.EntitySpriteDraw(mist, firePos, frame, fireColor, mainRot, frame.Size() * 0.5f, fireSize * 3f, SpriteEffects.None); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + return false; } } } diff --git a/Projectiles/Ranged/ExoFire.cs b/Projectiles/Ranged/ExoFire.cs index 10224416b8..132847db21 100644 --- a/Projectiles/Ranged/ExoFire.cs +++ b/Projectiles/Ranged/ExoFire.cs @@ -1,5 +1,12 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +using Terraria.Audio; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -9,72 +16,68 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float LightPower => ref Projectile.ai[2]; - public bool ProducedAcceleration = false; + public Color sparkColor; + public int Time = 0; + public ref int audioCooldown => ref Main.player[Projectile.owner].Calamity().PhotoAudioCooldown; + public ref int PhotoTimer => ref Main.player[Projectile.owner].Calamity().PhotoTimer; public override void SetDefaults() { - Projectile.width = 24; - Projectile.height = 24; + Projectile.width = Projectile.height = 30; Projectile.friendly = true; Projectile.ignoreWater = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.MaxUpdates = 3; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 5; - Projectile.timeLeft = 180; + Projectile.MaxUpdates = 180; + Projectile.timeLeft = 240; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Projectile.ai[0] += 1f; - if (Projectile.ai[0] <= 3f) - return; - - float dustScale = 1f; - if (Projectile.ai[0] == 8f) + sparkColor = Main.rand.Next(4) switch { - dustScale = 0.25f; + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + Time++; + Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 0.2f); + Player Owner = Main.player[Projectile.owner]; + float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); //used for some drawing prevention for when it's offscreen since it makes a fuck load of particles + if (targetDist < 1400f) + { + if (PhotoTimer == 0) + PhotoMetaball3.SpawnParticle(Projectile.Center + Owner.velocity, 42 - Time * 0.165f); + if (PhotoTimer == 1) + PhotoMetaball3.SpawnParticle(Projectile.Center + Owner.velocity, (37 - Time * (PhotoTimer == 0 ? 0.165f : 0.088f)) - PhotoTimer * 0.2f + (PhotoTimer == 1 ? 20 : 0)); ; + + PhotoMetaball4.SpawnParticle(Projectile.Center + Owner.velocity, (37 - Time * (PhotoTimer == 0 ? 0.165f : 0.088f)) - PhotoTimer * 0.2f + (PhotoTimer == 1 ? 20 : 0)); } - else if (Projectile.ai[0] == 9f) + if ( Main.rand.NextBool(35) && targetDist < 1400f && Time > 5) { - dustScale = 0.5f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, 263, new Vector2(0, -5).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.3f, 1f); + dust.color = sparkColor; } - else if (Projectile.ai[0] == 10f) + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(ModContent.BuffType(), 300); + if (audioCooldown == 0) { - dustScale = 0.75f; - } - - int dustID = Main.rand.NextBool() ? 107 : 234; - if (Main.rand.NextBool(4)) - dustID = 269; - - if (Main.rand.NextBool()) - { - for (int i = 0; i < 2; i++) - { - Dust d = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, dustID, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 0.6f); - if (Main.rand.NextBool(3)) - { - d.scale *= 1.5f; - d.velocity.X *= 1.2f; - d.velocity.Y *= 1.2f; - } - else - d.scale *= 0.75f; - - d.noGravity = true; - d.velocity.X *= 0.8f; - d.velocity.Y *= 0.8f; - d.scale *= dustScale; - d.velocity += Projectile.velocity; - } + SoundEngine.PlaySound(Photoviscerator.HitSound, target.Center); + audioCooldown = 6; } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 300); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 300); + } } diff --git a/Projectiles/Ranged/ExoFlare.cs b/Projectiles/Ranged/ExoFlare.cs deleted file mode 100644 index cc2ada2684..0000000000 --- a/Projectiles/Ranged/ExoFlare.cs +++ /dev/null @@ -1,103 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - // Photoviscerator right click split projectile (attached flares to the flare cluster) - public class ExoFlare : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public float OffsetSpeed - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public float OffsetRotation - { - get => Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 20; - } - - public override void SetDefaults() - { - Projectile.width = Projectile.height = 24; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 16; - Projectile.timeLeft = 160; - } - public override void AI() - { - if (Projectile.localAI[0] == 0f) - { - OffsetRotation = Main.rand.NextFloat(MathHelper.TwoPi); - OffsetSpeed = Main.rand.NextFloat(MathHelper.ToRadians(2.5f), MathHelper.ToRadians(4f)) * Main.rand.NextBool().ToDirectionInt(); - Projectile.localAI[0] = 1f; - } - - // Ensure that the owner projectile index is a valid one. - if (!Main.projectile.IndexInRange((int)Projectile.localAI[1])) - { - Projectile.Kill(); - return; - } - - Projectile owner = Main.projectile[(int)Projectile.localAI[1]]; - - // Ensure the owner is the correct projectile. - if (owner.type != ModContent.ProjectileType()) - Projectile.Kill(); - - // Movement around the owner. - Projectile.Center = owner.Center + OffsetRotation.ToRotationVector2() * (float)Math.Cos(OffsetRotation * 0.3f) * owner.Size * 0.5f; - Projectile.rotation = (Projectile.position - Projectile.oldPos[1]).ToRotation(); - OffsetRotation += OffsetSpeed; - } - - public override bool PreDraw(ref Color lightColor) - { - Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - float colorInterpolation = (float)Math.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; - Color color = Color.Lerp(Color.LightGreen, Color.LightPink, colorInterpolation) * 0.4f; - color.A = 0; - Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-25f, -25f); - Color outerColor = color; - Color innerColor = color * 0.5f; - float intensity = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); - - // Become smaller the futher along the old positions we are. - intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); - - Vector2 outerScale = new Vector2(1.65f) * intensity; - Vector2 innerScale = new Vector2(1.65f) * intensity * 0.7f; - outerColor *= intensity; - innerColor *= intensity; - Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); - } - return false; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 600); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 600); - } -} diff --git a/Projectiles/Ranged/ExoFlareCluster.cs b/Projectiles/Ranged/ExoFlareCluster.cs index c6489e9582..516b68c5a6 100644 --- a/Projectiles/Ranged/ExoFlareCluster.cs +++ b/Projectiles/Ranged/ExoFlareCluster.cs @@ -1,8 +1,12 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CalamityMod.Graphics.Metaballs; +using CalamityMod.Items.Weapons.Ranged; +using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -12,8 +16,10 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public const float MinDistanceFromTarget = 45f; - public const float MaxDistanceFromTarget = 350f; + public int Time = 0; + public Color sparkColor; + public bool PostTileHit = false; + public ref int audioCooldown => ref Main.player[Projectile.owner].Calamity().PhotoAudioCooldown; public override void SetStaticDefaults() { ProjectileID.Sets.NeedsUUID[Projectile.type] = true; @@ -24,61 +30,92 @@ namespace CalamityMod.Projectiles.Ranged Projectile.width = Projectile.height = 50; Projectile.friendly = true; Projectile.ignoreWater = true; - Projectile.tileCollide = false; + Projectile.tileCollide = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; + Projectile.penetrate = 20; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; - Projectile.timeLeft = 180; + Projectile.localNPCHitCooldown = 6; + Projectile.extraUpdates = 1; + Projectile.timeLeft = 300; } public override void AI() { - // localAI[0] is used by the sticky AI method, so use localAI[1] to spawn the flares. - if (Projectile.localAI[1] == 0f) + Time++; + sparkColor = Main.rand.Next(4) switch { - if (Main.netMode != NetmodeID.Server) - { - int projID = ModContent.ProjectileType(); - int flareDamage = (int)(0.6f * Projectile.damage); - float flareKB = Projectile.knockBack; - for (int i = 0; i < 4; i++) - { - Projectile p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, projID, flareDamage, flareKB, Projectile.owner); - p.localAI[1] = Projectile.GetByUUID(Projectile.owner, Projectile.whoAmI); - } - } - Projectile.localAI[1] = 1f; - } - - if (Projectile.ai[0] == 0f) - { - NPC potentialTarget = Projectile.Center.ClosestNPCAt(MaxDistanceFromTarget, true, true); - if (potentialTarget != null) - { - if (Projectile.Distance(potentialTarget.Center) > MinDistanceFromTarget) - { - float angleOffset = Projectile.AngleTo(potentialTarget.Center) - Projectile.velocity.ToRotation(); - angleOffset = MathHelper.WrapAngle(angleOffset); - Projectile.velocity = Projectile.velocity.RotatedBy(MathHelper.Clamp(angleOffset, -0.1f, 0.1f)); - } - } - } - Projectile.StickyProjAI(5); + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + PhotoMetaball.SpawnParticle(Projectile.Center, 90); + PhotoMetaball2.SpawnParticle(Projectile.Center, 85); + CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 12f, 20f); } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => Projectile.ModifyHitNPCSticky(4); - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Projectile.width == 50) - { - int width = (int)MathHelper.Min(target.Hitbox.Width, 60); - int height = (int)MathHelper.Min(target.Hitbox.Height, 60); - Projectile.ExpandHitboxBy(width, height); - } target.AddBuff(ModContent.BuffType(), 600); - } + float numberOflines = 2; + float rotFactorlines = 360f / numberOflines; + for (int i = 0; i < numberOflines; i++) + { + float rot = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot + Main.rand.NextFloat(0.1f, 5.1f)); + Vector2 velOffset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot + Main.rand.NextFloat(0.1f, 5.1f)); + SparkParticle spark = new SparkParticle(Projectile.Center + offset, velOffset * Main.rand.NextFloat(3.5f, 6.5f), true, 95, Main.rand.NextFloat(0.3f, 0.8f), Color.White); + GeneralParticleHandler.SpawnParticle(spark); + float rot2 = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 + Main.rand.NextFloat(0.1f, 5.1f)); + Vector2 velOffset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 + Main.rand.NextFloat(0.1f, 5.1f)); + + SquishyLightParticle exoEnergy = new(Projectile.Center + offset2, velOffset2 * Main.rand.NextFloat(0.5f, 2.5f), 0.5f, sparkColor, 35); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + if (audioCooldown == 0) + { + SoundEngine.PlaySound(Photoviscerator.HitSound, target.Center); + audioCooldown = 6; + } + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (!PostTileHit) + { + SoundEngine.PlaySound(DeadSunsWind.Ricochet with { Volume = 1.2f }, Projectile.Center); + float numberOflines = 25; + float rotFactorlines = 360f / numberOflines; + for (int i = 0; i < numberOflines; i++) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + + float rot2 = MathHelper.ToRadians(i * rotFactorlines); + Vector2 offset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset2 = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot2 * Main.rand.NextFloat(1.1f, 9.1f)); + + SquishyLightParticle exoEnergy = new(Projectile.Center + offset2, velOffset2 * Main.rand.NextFloat(0.2f, 1.9f), 0.5f, sparkColor, 40); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + PostTileHit = true; + } + + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + return false; + } public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(ModContent.BuffType(), 600); diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index bf4d7586d4..a3af7aece4 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -1,4 +1,6 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.IO; @@ -6,7 +8,8 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Ranged { @@ -18,166 +21,132 @@ namespace CalamityMod.Projectiles.Ranged public Vector2 InitialCenter; public Vector2 Destination; + public Vector2 NPCDestination; public const float MaxRadius = 90f; - public float Time - { - get => Projectile.ai[0]; - set => Projectile.ai[0] = value; - } - public int DustType - { - get => (int)Projectile.ai[1]; - set => Projectile.ai[1] = value; - } - public float YDirection - { - get => Projectile.localAI[1]; - set => Projectile.localAI[1] = value; - } + public ref float YDirection => ref Projectile.ai[0]; + public ref float Time => ref Projectile.ai[1]; + public Color sparkColor; public override void SetStaticDefaults() { ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 15; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36; } public override void SetDefaults() { - Projectile.width = Projectile.height = 40; + Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 210; Projectile.alpha = 127; + Projectile.extraUpdates = 1; + Projectile.tileCollide = false; } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(YDirection); writer.WriteVector2(Destination); } + public override void ReceiveExtraAI(BinaryReader reader) { - YDirection = reader.ReadSingle(); Destination = reader.ReadVector2(); } public override void AI() { + PhotoMetaball.SpawnParticle(Projectile.Center, 54); + PhotoMetaball2.SpawnParticle(Projectile.Center, 50); + + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + Lighting.AddLight(Projectile.Center, Color.DarkSlateGray.ToVector3()); - Projectile.alpha = (int)MathHelper.Lerp(255, 127, Utils.GetLerpValue(0f, 25f, Time, true)); Projectile.scale = MathHelper.Lerp(0.001f, 1f, Utils.GetLerpValue(0f, 25f, Time, true)); if (Projectile.localAI[0] == 0f) { + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].CanBeChasedBy(Projectile.GetSource_FromThis(), false)) + NPCDestination = Main.npc[i].Center + Main.npc[i].velocity * 5f; + } InitialCenter = Projectile.Center; + Projectile.localAI[0] = 1f; if (Main.myPlayer == Projectile.owner) { - Destination = Main.MouseWorld; + Destination = NPCDestination; Projectile.netUpdate = true; } - DustType = Main.rand.NextBool() ? 107 : 234; - if (Main.rand.NextBool(4)) - { - DustType = 269; - } - Projectile.localAI[0] = 1f; } if (Destination == Vector2.Zero) return; - if (Time <= 90f) + if (Time <= 60f) { - Projectile.position = Vector2.Lerp(InitialCenter, Destination, Time / 90f); - Projectile.position.Y += (float)Math.Sin(Time / 90f * MathHelper.TwoPi) * 75f; + Projectile.Center = Vector2.Lerp(InitialCenter, Destination, Time / 60f); + Projectile.Center += (Vector2.UnitY * MathF.Sin(Time / 70f * MathHelper.TwoPi) * 75f * YDirection).RotatedBy(Projectile.velocity.ToRotation()); } - else if (Time < 180f) + else if (Time < 120f) { // For those who haven't seen this yet (namely in the 1.4 source), this allows you to achieve a // fade-in and fade-out effect with relative ease. At 90, multiply by 0, and somewhere in-between until 115, where you multiply by 1. // And then do the same for the fade-out effect of 180f-165. These inverse linear interpolations cannot overlap by definition because // their ranges do not overlap. Overall a really cool trick. - float radius = MaxRadius * Utils.GetLerpValue(90f, 115f, Time, true) * Utils.GetLerpValue(180f, 165f, Time, true); - radius *= 1f + (float)Math.Cos(Main.GlobalTimeWrappedHourly / 24f) * 0.25f; + float radius = MaxRadius * Utils.GetLerpValue(60f, 75f, Time, true) * Utils.GetLerpValue(120f, 105f, Time, true); + radius *= 1f + MathF.Cos(Main.GlobalTimeWrappedHourly / 24f) * 0.25f; if (radius < 5f) radius = 5f; - Projectile.Center = Destination + ((Time - 90) / 90f * MathHelper.ToRadians(720f) + (YDirection == -1).ToInt() * MathHelper.Pi).ToRotationVector2() * radius; + Projectile.Center = Destination + ((Time - 60) / 60f * MathHelper.ToRadians(720f) + (YDirection == -1).ToInt() * MathHelper.Pi).ToRotationVector2() * radius; } - else if (Time == 180f) + else if (Time == 120f) Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; Time++; } - public void GenerateRotationalDust() - { - for (int i = 0; i < 9; i++) - { - float angle = Time / 45f + i / 9f * MathHelper.TwoPi; - Vector2 offsetSpan = angle.ToRotationVector2() * Projectile.Size * 0.65f * Projectile.scale; - Vector2 edgePosition = Projectile.Center + offsetSpan.RotatedBy(Projectile.rotation); - Dust dust = Dust.NewDustPerfect(edgePosition + Main.rand.NextVector2Circular(4f, 4f), DustType); - dust.velocity = Vector2.Zero; - dust.noGravity = true; - dust.scale = 0.65f; - } - } - - public override Color? GetAlpha(Color lightColor) - { - return CalamityUtils.MulticolorLerp(Time / 60f % 1f, new Color[] - { - Color.PaleGreen, - Color.Violet, - Color.SlateGray - }) * Projectile.Opacity; - } - public override bool PreDraw(ref Color lightColor) - { - Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; - for (int i = 0; i < Projectile.oldPos.Length; i++) - { - float colorInterpolation = (float)Math.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; - Color color = CalamityUtils.MulticolorLerp(MathHelper.Clamp(colorInterpolation, 0f, 0.99f), new Color[] - { - Color.PaleGreen, - Color.Violet, - Color.SlateGray - }) * Projectile.Opacity; - color.A = 0; - Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); - Color outerColor = color; - Color innerColor = color * 0.5f; - float intensity = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); - - // Become smaller the futher along the old positions we are. - intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); - - Vector2 outerScale = new Vector2(1.25f) * intensity; - Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f; - outerColor *= intensity * Projectile.scale; - innerColor *= intensity * Projectile.scale; - Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); - } - return false; - } - public override void OnKill(int timeLeft) { - SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + float scaleBonus = Time >= 120f ? Main.rand.NextFloat(3.4f, 4.2f) : Main.rand.NextFloat(0.8f, 1.6f); + SoundEngine.PlaySound(DeadSunsWind.Explosion with { Volume = 0.7f}, Projectile.Center); + float numberOfDusts = Time >= 120f ? 30 : 20; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) { - int projID = ModContent.ProjectileType(); - for (int i = 0; i < 3; i++) + sparkColor = Main.rand.Next(4) switch { - Vector2 vel = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * 16f; - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, projID, Projectile.damage, Projectile.knockBack * 0.3f, Projectile.owner); - } + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + Vector2 velOffset = (Vector2.UnitX * Main.rand.NextFloat(0.2f, 3.1f)).RotatedBy(rot * Main.rand.NextFloat(1.1f, 9.1f)); + + SquishyLightParticle exoEnergy = new(Projectile.Center + offset, velOffset * (Main.rand.NextFloat(0.5f, 3.5f) + scaleBonus * 0.65f), Time >= 120f ? 0.7f : 0.5f, sparkColor, Time >= 120f ? 50 : 35); + GeneralParticleHandler.SpawnParticle(exoEnergy); } + Projectile.scale = 6.5f * scaleBonus; + // we should probably have a generic util to do this whole thing + Projectile.maxPenetrate = -1; + Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.Damage(); } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * Projectile.scale * 0.5f, targetHitbox); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 360); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 360); diff --git a/Projectiles/Ranged/ExoSpark.cs b/Projectiles/Ranged/ExoSpark.cs deleted file mode 100644 index 7abdaa0efe..0000000000 --- a/Projectiles/Ranged/ExoSpark.cs +++ /dev/null @@ -1,72 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - // Photoviscerator left click splitting homing projectile - public class ExoSpark : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public static readonly int[] FrameToDustIDTable = new int[] - { - 107, - 234, - 269, - }; - public const float HomingInertia = 10f; - public const float MaxTargetDistance = 750f; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 3; - } - - public override void SetDefaults() - { - Projectile.width = 28; - Projectile.height = 14; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.timeLeft = 600; - } - - public override void AI() - { - if (Projectile.localAI[0] == 0f) - { - Projectile.frame = Main.rand.Next(3); - Projectile.localAI[0] = 1f; - Projectile.netUpdate = true; - } - NPC potentialTarget = Projectile.Center.ClosestNPCAt(MaxTargetDistance); - if (potentialTarget != null) - Projectile.velocity = (Projectile.velocity * (HomingInertia - 1) + Projectile.SafeDirectionTo(potentialTarget.Center) * 16f) / HomingInertia; - - Projectile.rotation = Projectile.velocity.ToRotation(); - if (!Main.dedServ) - { - GenerateCircularDust(); - } - } - - public void GenerateCircularDust() - { - for (int i = 0; i < 12; i++) - { - float angle = i / 12f * MathHelper.TwoPi; - Vector2 spawnPosition = Projectile.Center + angle.ToRotationVector2().RotatedBy(Projectile.rotation) * new Vector2(10f, 6f); - Dust dust = Dust.NewDustPerfect(spawnPosition, FrameToDustIDTable[Projectile.frame]); - dust.velocity = Vector2.Zero; - dust.scale = 0.5f; - dust.noGravity = true; - } - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); - } -} diff --git a/Projectiles/Ranged/ExoSpark.png b/Projectiles/Ranged/ExoSpark.png deleted file mode 100644 index eb696c6909..0000000000 Binary files a/Projectiles/Ranged/ExoSpark.png and /dev/null differ diff --git a/Projectiles/Ranged/HalleysComet.cs b/Projectiles/Ranged/HalleysComet.cs index bdb9e589ee..4d867a5b71 100644 --- a/Projectiles/Ranged/HalleysComet.cs +++ b/Projectiles/Ranged/HalleysComet.cs @@ -1,6 +1,11 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using Terraria; using Terraria.ModLoader; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Ranged; + namespace CalamityMod.Projectiles.Ranged { public class HalleysComet : ModProjectile, ILocalizedModType @@ -8,80 +13,70 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { Projectile.width = Projectile.height = 12; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 4; - Projectile.extraUpdates = 10; - Projectile.timeLeft = 600; + Projectile.penetrate = 5; + Projectile.MaxUpdates = 10; + Projectile.timeLeft = 15 * Projectile.MaxUpdates; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - if (Projectile.scale <= 1.5f) + Projectile.rotation = Projectile.velocity.ToRotation(); + Time++; + if (Time > 6f) { - Projectile.scale *= 1.01f; + SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity, false, 11, 1.9f, Color.MediumBlue); + GeneralParticleHandler.SpawnParticle(spark); + SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity, false, 11, 1f, Color.Aqua); + GeneralParticleHandler.SpawnParticle(spark2); } - - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - - if (Projectile.ai[0]++ > 5f) + else if (Time == 5f) { - float dustScaleSize = 1f; - if (Projectile.ai[0] == 6f) + Particle pulse = new DirectionalPulseRing(Projectile.Center, Projectile.velocity * 0.75f, Color.Aqua, new Vector2(1f, 2.5f), Projectile.rotation, 0.2f, 0.03f, 20); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Projectile.velocity * 0.4f, Color.DodgerBlue, new Vector2(1f, 2.5f), Projectile.rotation, 0.1f, 0.025f, 35); + GeneralParticleHandler.SpawnParticle(pulse2); + for (int i = 0; i <= 25; i++) { - dustScaleSize = 0.25f; - } - else if (Projectile.ai[0] == 7f) - { - dustScaleSize = 0.5f; - } - else if (Projectile.ai[0] == 8f) - { - dustScaleSize = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = 176; - for (int i = 0; i < 3; i++) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 1, default, 1f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScaleSize; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.6f, 2.5f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.4f) * Main.rand.NextFloat(0.3f, 1.6f); + dust.noGravity = true; + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust2.scale = Main.rand.NextFloat(1.35f, 2.1f); + dust2.velocity = Projectile.velocity.RotatedByRandom(0.06f) * Main.rand.NextFloat(0.8f, 3.1f); + dust2.noGravity = true; } } - Projectile.rotation += 0.3f * (float)Projectile.direction; + Lighting.AddLight(Projectile.Center, Color.MediumBlue.ToVector3() * 0.4f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 450); + SoundEngine.PlaySound(HalleysInferno.Hit, Projectile.Center); + for (int i = 0; i <= 13; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 172 : 206, Projectile.velocity); + dust.scale = Main.rand.NextFloat(1.1f, 1.9f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f) * Main.rand.NextFloat(0.2f, 2.1f); + dust.noGravity = true; + } } public override void OnHitPlayer(Player target, Player.HurtInfo info) { - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 450); } } } diff --git a/Projectiles/Ranged/MeowCreature.cs b/Projectiles/Ranged/MeowCreature.cs new file mode 100644 index 0000000000..94a6ac41c4 --- /dev/null +++ b/Projectiles/Ranged/MeowCreature.cs @@ -0,0 +1,75 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Linq; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class MeowCreature : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + + internal PrimitiveTrail TrailDrawer; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 24; + Projectile.friendly = true; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 90 * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + CalamityUtils.HomeInOnNPC(Projectile, false, 400f, 15f, 20f); + Projectile.rotation = Projectile.velocity.ToRotation(); + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(Main.rand.NextBool() ? SoundID.Item58 : SoundID.Item57, Projectile.Center); + + // Circular spread of clouds + for (int i = 0; i < 12; i++) + { + Vector2 smokeVel = Main.rand.NextVector2Circular(16f, 16f); + Color smokeColor = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.8f); + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.6f, 1.6f), 220 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + internal float WidthFunction(float completionRatio) => (1f - completionRatio) * Projectile.scale * 9f; + internal Color ColorFunction(float completionRatio) + { + float hue = 0.5f + 0.5f * completionRatio * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); + Color trailColor = Main.hslToRgb(hue, 1f, 0.8f); + return trailColor * Projectile.Opacity; + } + + // The creature glows + public override void PostDraw(Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction); + + TrailDrawer.Draw(Projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), Projectile.Size * 0.5f - Main.screenPosition, 30); + + Texture2D glow = ModContent.Request(Texture).Value; + Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None); + } + } +} diff --git a/Projectiles/Ranged/MeowCreature.png b/Projectiles/Ranged/MeowCreature.png new file mode 100644 index 0000000000..a6634592f8 Binary files /dev/null and b/Projectiles/Ranged/MeowCreature.png differ diff --git a/Projectiles/Ranged/MeowFire.cs b/Projectiles/Ranged/MeowFire.cs index e8dadea34d..263bd0705e 100644 --- a/Projectiles/Ranged/MeowFire.cs +++ b/Projectiles/Ranged/MeowFire.cs @@ -1,8 +1,10 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { @@ -11,97 +13,51 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int Lifetime => 72; + public bool PinkFire => Projectile.ai[0] == 1f; + public ref float Time => ref Projectile.ai[1]; + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 6; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 5; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 95; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; // 24 effectively Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.idStaticNPCHitCooldown = 8; } public override void AI() { - if (Projectile.ai[0] > 7f) - { - float dustScale = 1f; - if (Projectile.ai[0] == 8f) - { - dustScale = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScale = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScale = 0.75f; - } - Projectile.ai[0] += 1f; - for (int i = 0; i < 2; i++) - { - int blueDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[blueDust]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScale; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } + Time++; + + // Determines particle size as well as hitbox + if (Time >= 6f) + Projectile.scale = 1.5f * Utils.GetLerpValue(6f, 30f, Time, true); else + return; // Helps position it at the tip + + // Main smokes composing of blue or pink + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + Color smokeColor = Color.Lerp(PinkFire ? Color.DeepPink : Color.DodgerBlue, PinkFire ? Color.Pink : Color.PowderBlue, 0.5f + 0.3f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f)); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.25f, smokeRot, true, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, a bit brighter + if (Main.rand.NextBool(8)) { - Projectile.ai[0] += 1f; + Color glowColor = Color.Lerp(smokeColor, Color.White, 0.2f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 8, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.15f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); } - Projectile.rotation += 0.3f * (float)Projectile.direction; + + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale * 0.2f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - SoundEngine.PlaySound(SoundID.Item57, Projectile.position); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 10; - Projectile.height = 10; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int j = 0; j < 10; j++) - { - int dustHit = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); - Main.dust[dustHit].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[dustHit].scale = 0.5f; - Main.dust[dustHit].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int k = 0; k < 20; k++) - { - int dustHit2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1.5f); - Main.dust[dustHit2].noGravity = true; - Main.dust[dustHit2].velocity *= 5f; - dustHit2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 56, 0f, 0f, 100, default, 1f); - Main.dust[dustHit2].velocity *= 2f; - } - } + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); } } diff --git a/Projectiles/Ranged/MeowFire2.cs b/Projectiles/Ranged/MeowFire2.cs deleted file mode 100644 index 5d4fab83d3..0000000000 --- a/Projectiles/Ranged/MeowFire2.cs +++ /dev/null @@ -1,107 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria.Audio; - -namespace CalamityMod.Projectiles.Ranged -{ - public class MeowFire2 : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 6; - Projectile.height = 6; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 5; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 95; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; - } - - public override void AI() - { - if (Projectile.ai[0] > 7f) - { - float dustScale = 1f; - if (Projectile.ai[0] == 8f) - { - dustScale = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScale = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScale = 0.75f; - } - Projectile.ai[0] += 1f; - for (int i = 0; i < 2; i++) - { - int pinkDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[pinkDust]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScale; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - SoundEngine.PlaySound(SoundID.Item58, Projectile.position); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 10; - Projectile.height = 10; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int j = 0; j < 10; j++) - { - int dustHit = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1f); - Main.dust[dustHit].velocity *= 3f; - if (Main.rand.NextBool()) - { - Main.dust[dustHit].scale = 0.5f; - Main.dust[dustHit].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int k = 0; k < 20; k++) - { - int dustHit2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1.5f); - Main.dust[dustHit2].noGravity = true; - Main.dust[dustHit2].velocity *= 5f; - dustHit2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 73, 0f, 0f, 100, default, 1f); - Main.dust[dustHit2].velocity *= 2f; - } - } - } -} diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.cs b/Projectiles/Ranged/PhotovisceratorHoldout.cs new file mode 100644 index 0000000000..05976bce42 --- /dev/null +++ b/Projectiles/Ranged/PhotovisceratorHoldout.cs @@ -0,0 +1,269 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Ranged.Photoviscerator; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PhotovisceratorHoldout : ModProjectile + { + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public Player Owner => Main.player[Projectile.owner]; + public bool OwnerCanShoot => (Owner.channel || Owner.Calamity().mouseRight) && !Owner.noItems && !Owner.CCed; + public ref float ShootTimer => ref Projectile.ai[0]; + public ref float ForcedLifespan => ref Projectile.ai[1]; + public Color sparkColor; + public int Time = 0; + public ref int PhotoTimer => ref Main.player[Projectile.owner].Calamity().PhotoTimer; + public SlotId PhotoUseSound; + + public override void SetDefaults() + { + Projectile.width = 170; + Projectile.height = 66; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + } + + public override void AI() + { + Time++; + if (PhotoTimer > 0) + PhotoTimer--; + + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + + if (Owner.Calamity().mouseRight) + { + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound2)) + Sound2?.Stop(); + } + + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound) && Sound.IsPlaying) + Sound.Position = Projectile.Center; + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + + // Orange exo energy as the back "flames" + Color energyColor = Color.Orange; + Vector2 flamePosition = armPosition + Projectile.velocity * Projectile.width * 0.12f; + Vector2 verticalOffset = Vector2.UnitY.RotatedBy(Projectile.rotation); + if (Math.Cos(Projectile.rotation) < 0f) + verticalOffset *= -1f; + + if (Main.rand.NextBool(4)) + { + Vector2 flameAngle = -Vector2.UnitY.RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(270f, 300f) * Projectile.spriteDirection)); + SquishyLightParticle exoEnergy = new(flamePosition - verticalOffset * 26f, flameAngle * Main.rand.NextFloat(0.8f, 3.6f), 0.25f, energyColor, 20); + GeneralParticleHandler.SpawnParticle(exoEnergy); + SquishyLightParticle exoEnergy2 = new(armPosition - verticalOffset * 22f, flameAngle * Main.rand.NextFloat(0.7f, 3.2f), 0.2f, energyColor, 12); + GeneralParticleHandler.SpawnParticle(exoEnergy2); + } + + // Create light around the crystal + Lighting.AddLight(armPosition + Projectile.velocity * 42f - verticalOffset * 10f, 0.8f, 0.8f, 0.8f); + Lighting.AddLight(armPosition + Projectile.velocity * 96f + verticalOffset * 6f, 0.4f, 0.4f, 0.4f); + + // Despawn the projectile if the player can't shoot + // Any forced lifespan (triggered by attacking right click to prevent click spamming) will have priority + if (!OwnerCanShoot) + { + ForcedLifespan--; + if (ForcedLifespan <= 0f) + Projectile.Kill(); + return; + } + + // Don't try to perform attacks if it's not the holder + if (Projectile.owner != Main.myPlayer) + return; + + // Immediately killed if ammo is out + if (!Owner.HasAmmo(Owner.ActiveItem())) + { + Projectile.Kill(); + return; + } + + // Right-click attacks + if (Owner.Calamity().mouseRight && !Owner.channel) + { + // Can't shoot on frame 1 as it can't use ammo yet + if (ShootTimer < 0f) + RightClickAttack(armPosition, verticalOffset); + + ShootTimer--; + } + else if (!Owner.Calamity().mouseRight && Owner.channel) + { + ShootTimer++; + LeftClickAttack(armPosition, verticalOffset); + } + } + + public void LeftClickAttack(Vector2 armPosition, Vector2 verticalOffset) + { + if (Time == 1 || Time % 55 == 0) + { + PhotoUseSound = SoundEngine.PlaySound(Photoviscerator.UseSound, Projectile.Center); + } + + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound3)) + Sound3.Pitch = 0 - (PhotoTimer * 0.002f); + + // Consume ammo and retrieve projectile stats; has a chance to not consume ammo + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() <= AmmoNotConsumeChance); + + var source = Projectile.GetSource_FromThis(); + Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f; + Vector2 velocity = Projectile.velocity * shootSpeed; + + if (PhotoTimer == 1) + { + for (int i = 0; i < 30; i++) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + SquishyLightParticle exoEnergy = new(position, (Projectile.velocity * 3).RotatedByRandom(0.4f) * Main.rand.NextFloat(0.3f, 1.6f), 0.9f, sparkColor, 60); + GeneralParticleHandler.SpawnParticle(exoEnergy); + } + SoundEngine.PlaySound(DeadSunsWind.Shoot with { Volume = 1.9f}, Owner.MountedCenter); + } + + Dust dust = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.3f, 1.8f) - PhotoTimer * 0.02f; + dust.color = sparkColor; + Dust dust2 = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 15).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust2.noGravity = true; + dust2.scale = Main.rand.NextFloat(1.3f, 1.8f) - PhotoTimer * 0.02f; + dust2.color = sparkColor; + if (Main.rand.NextBool()) + { + MediumMistParticle smoke = new MediumMistParticle(position + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 15).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.5f, 2.1f), sparkColor, Color.White, Main.rand.NextFloat(1.8f, 2.9f) - PhotoTimer * 0.026f, 160, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke); + MediumMistParticle smoke2 = new MediumMistParticle(position + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 18).RotatedByRandom(0.05f) * Main.rand.NextFloat(1.8f, 3.1f), sparkColor, Color.White, Main.rand.NextFloat(0.8f, 1.9f) - PhotoTimer * 0.02f, 160, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke2); + } + + // Main fire stream + Projectile.NewProjectile(source, position, velocity.RotatedByRandom(0.005f), ProjectileType(), (int)(damage * (1 - PhotoTimer / 59.9f)), knockback, Projectile.owner, Main.rand.NextFloat(0f, 3f)); + + // Shoots light bombs every once in a while, rate of which equals to the item's use time + if (ShootTimer >= Owner.ActiveItem().useTime * 10 && PhotoTimer == 0) + { + ShootTimer = 0f; + + for (int i = 0; i < 2; i++) + { + Vector2 bombPos = armPosition + Projectile.velocity * 108f + verticalOffset * 6f; + int yDirection = (i == 0).ToDirectionInt(); + Vector2 bombVel = velocity.RotatedBy(0.2f * yDirection); + + Projectile.NewProjectile(source, bombPos, bombVel, ProjectileType(), damage, knockback, Projectile.owner, yDirection); + } + SoundEngine.PlaySound(HalleysInferno.Hit, Owner.MountedCenter); + } + } + + public void RightClickAttack(Vector2 armPosition, Vector2 verticalOffset) + { + + // Multiplied by the ratio of attack speed gained from modifiers + ShootTimer = (RightClickCooldown * Owner.ActiveItem().useTime / (float)LightBombCooldown) - 1f; + ForcedLifespan = ShootTimer; + + // Consume ammo and retrieve projectile stats + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _); + + var source = Projectile.GetSource_FromThis(); + Vector2 position = armPosition + Projectile.velocity * 55f - verticalOffset * 10f; + Vector2 velocity = Projectile.velocity * shootSpeed * RightClickVelocityMult; + for (int i = 0; i <= 15; i++) + { + sparkColor = Main.rand.Next(4) switch + { + 0 => Color.Red, + 1 => Color.MediumTurquoise, + 2 => Color.Orange, + _ => Color.LawnGreen, + }; + DirectionalPulseRing pulse = new DirectionalPulseRing(position, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f), sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.2f, 0.35f), 0f, 40); + GeneralParticleHandler.SpawnParticle(pulse); + DirectionalPulseRing pulse2 = new DirectionalPulseRing(position, (Projectile.velocity * 10).RotatedByRandom(0.1f) * Main.rand.NextFloat(0.8f, 3.1f), sparkColor, new Vector2(1, 1), 0, Main.rand.NextFloat(0.2f, 0.35f), 0f, 40); + GeneralParticleHandler.SpawnParticle(pulse2); + Dust dust = Dust.NewDustPerfect(position, 263, (Projectile.velocity * 10).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.3f, 1.6f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.3f, 1.8f); + dust.color = sparkColor; + } + SoundEngine.PlaySound(HalleysInferno.Shoot, Owner.MountedCenter); + Projectile.NewProjectile(source, position, velocity, ProjectileType(), (int)(damage * 1.2f), knockback, Projectile.owner); + } + + public void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + Vector2 oldVelocity = Projectile.velocity; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + if (Projectile.velocity != oldVelocity) + { + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } + } + + Projectile.position = armPosition - Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.UnitY) * 28f; + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Projectile.spriteDirection == -1) + Projectile.rotation += MathHelper.Pi; + Projectile.spriteDirection = Projectile.direction; + Projectile.timeLeft = 2; + } + + public void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + + public override bool ShouldUpdatePosition() => false; + + public override bool? CanDamage() => false; + public override void OnKill(int timeLeft) + { + if (SoundEngine.TryGetActiveSound(PhotoUseSound, out var Sound)) + Sound?.Stop(); + PhotoTimer = 90; + } + } +} diff --git a/Projectiles/Ranged/PhotovisceratorHoldout.png b/Projectiles/Ranged/PhotovisceratorHoldout.png new file mode 100644 index 0000000000..403e234758 Binary files /dev/null and b/Projectiles/Ranged/PhotovisceratorHoldout.png differ diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.png b/Projectiles/Ranged/PrismaticEnergyBlast.png deleted file mode 100644 index 8e2d2a871c..0000000000 Binary files a/Projectiles/Ranged/PrismaticEnergyBlast.png and /dev/null differ diff --git a/Projectiles/Ranged/PristineFire.cs b/Projectiles/Ranged/PristineFire.cs index a12e433ba6..66e34181a0 100644 --- a/Projectiles/Ranged/PristineFire.cs +++ b/Projectiles/Ranged/PristineFire.cs @@ -1,7 +1,12 @@ -using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged @@ -9,137 +14,104 @@ namespace CalamityMod.Projectiles.Ranged public class PristineFire : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Particles/MediumMist"; - private int dust1 = (int)CalamityDusts.ProfanedFire; - private int dust2 = ModContent.DustType(); + // Helix trail thing + public PrimitiveTrail HelixTrail = null; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 20; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public float smokeOpa = 0.25f; public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 6; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 4; Projectile.timeLeft = 120; } public override void AI() { - if (Projectile.scale <= 1.5f) + if (Projectile.timeLeft < 118) { - Projectile.scale *= 1.01f; - } - Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f); - if (Projectile.timeLeft > 90) - { - Projectile.timeLeft = 120; - } + if (smokeOpa > 0) + smokeOpa -= 0.02f; - int dustTypeOnTimer = dust1; + Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f); - Projectile.localAI[0] += 1f; - if (Projectile.localAI[0] > 5f) - { - for (int num447 = 0; num447 < 2; num447++) - { - Vector2 vector33 = Projectile.position; - vector33 -= Projectile.velocity * ((float)num447 * 0.25f); - Projectile.alpha = 255; - int num448 = Dust.NewDust(vector33, 1, 1, dustTypeOnTimer, 0f, 0f, 0, default, 1f); - Main.dust[num448].noGravity = true; - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.2f; - Main.dust[num448].noLight = true; - Main.dust[num448].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - } - Projectile.ai[0] += 1f; - if (Projectile.ai[0] == 48f) - { - Projectile.ai[0] = 0f; - - if (dustTypeOnTimer == dust1) - dustTypeOnTimer = dust2; - else - dustTypeOnTimer = dust1; - } - else - { - Vector2 value7 = new Vector2(5f, 10f); - - for (int num41 = 0; num41 < 2; num41++) - { - int dustType = num41 == 0 ? dust1 : dust2; - Vector2 value8 = Vector2.UnitX * -12f; - value8 = -Vector2.UnitY.RotatedBy((double)(Projectile.ai[0] * 0.1308997f + (float)num41 * 3.14159274f), default) * value7 * 1.5f; - int num42 = Dust.NewDust(Projectile.Center, 0, 0, dustType, 0f, 0f, 160, default, 1f); - Main.dust[num42].scale = 0.75f; - Main.dust[num42].noGravity = true; - Main.dust[num42].position = Projectile.Center + value8; - Main.dust[num42].velocity = Projectile.velocity; - Main.dust[num42].noLight = true; - Main.dust[num42].color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - } - } + // Light smoke + Color smokeColor = new Color(255, Main.rand.Next(160, 230 + 1), 100, 100); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity.RotatedByRandom(smokeOpa * 10) * (Main.rand.NextFloat(0.4f, 0.65f) - smokeOpa), smokeColor, 16, Main.rand.NextFloat(0.6f, 1.2f), 0.2f + smokeOpa, glowing: true); + GeneralParticleHandler.SpawnParticle(smoke); } + Projectile.rotation = Projectile.velocity.ToRotation(); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 240); - } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); public override void OnKill(int timeLeft) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - dust1, - dust2 - }); - int height = 50; - float num50 = 1.7f; - float num51 = 0.8f; - float num52 = 2f; - Vector2 value3 = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); - Vector2 value4 = value3 * Projectile.velocity.Length() * (float)Projectile.MaxUpdates; - Projectile.position = Projectile.Center; - Projectile.width = Projectile.height = height; - Projectile.Center = Projectile.position; + Projectile.ExpandHitboxBy(50); Projectile.maxPenetrate = -1; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); - for (int num53 = 0; num53 < 40; num53++) + + LineParticle spark = new LineParticle(Projectile.Center, -Projectile.velocity.RotatedBy(Main.rand.NextFloat(0.23f, 0.56f)) * Main.rand.NextFloat(0.4f, 2.5f), false, 8, 1.2f, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange); + GeneralParticleHandler.SpawnParticle(spark); + LineParticle spark2 = new LineParticle(Projectile.Center, -Projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.23f, -0.56f)) * Main.rand.NextFloat(0.4f, 2.5f), false, 8, 1.2f, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange); + GeneralParticleHandler.SpawnParticle(spark2); + + for (int i = 0; i <= 3; i++) { - int num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 200, default, num50); - Dust dust = Main.dust[num54]; - dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 169 : 158, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(1.6f, 2.2f)); dust.noGravity = true; - dust.velocity *= 3f; - dust.velocity += value4 * Main.rand.NextFloat(); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - num54 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 100, default, num51); - dust.position = Projectile.Center + Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * (float)Main.rand.NextDouble() * (float)Projectile.width / 2f; - dust.velocity *= 2f; - dust.noGravity = true; - dust.fadeIn = 1f; - dust.velocity += value4 * Main.rand.NextFloat(); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + dust.fadeIn = 0.5f; } - for (int num55 = 0; num55 < 20; num55++) + // Big poofy column + for (int i = 0; i < 7; i++) { - int num56 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, 0f, 0f, 0, default, num52); - Dust dust = Main.dust[num56]; - dust.position = Projectile.Center + Vector2.UnitX.RotatedByRandom(MathHelper.Pi).RotatedBy((double)Projectile.velocity.ToRotation(), default) * (float)Projectile.width / 3f; - dust.noGravity = true; - dust.velocity *= 0.5f; - dust.velocity += value4 * (0.6f + 0.6f * Main.rand.NextFloat()); - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); + float velMulti = Main.rand.NextFloat(0.1f, 1.8f); + Vector2 smokePos = Projectile.Center + Main.rand.NextVector2Circular(32f, 32f); + Vector2 smokeVel = Vector2.UnitY * Main.rand.NextFloat(-12f, -8f) * velMulti; + Particle smoke = new MediumMistParticle(smokePos, smokeVel, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange, Color.Black, Main.rand.NextFloat(0.7f, 1.9f) - velMulti, 225 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); } } + + public float HelixTrailWidthFunction(float completionRatio) => Utils.GetLerpValue(1f, 0.4f, completionRatio, true) * 1.5f; + public Color HelixTrailColorFunction(float completionRatio) => Projectile.timeLeft < 105 ? Projectile.ai[0] == 1 ? Color.DarkOrange * (1f - completionRatio) : Color.Orange * (1f - completionRatio) : Color.Transparent; + + public override bool PreDraw(ref Color lightColor) + { + if (HelixTrail is null) + HelixTrail = new PrimitiveTrail(HelixTrailWidthFunction, HelixTrailColorFunction); + + // Draw a double helix trail + for (int direction = -1; direction <= 1; direction += 2) + { + List trailPositions = new List(); + int trailPoints = ProjectileID.Sets.TrailCacheLength[Type]; + // Add points adjusted for sine + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + if (Projectile.oldPos[i] == Vector2.Zero) + break; + + Vector2 sinOffset = (Vector2.UnitY * direction * MathF.Sin(i * MathHelper.Pi * 0.125f) * 24f).RotatedBy(Projectile.oldRot[i]); + trailPositions.Add(Projectile.oldPos[i] + sinOffset); + } + HelixTrail.Draw(trailPositions, Projectile.Size * 0.5f- Main.screenPosition, 60); + } + return false; + } } } diff --git a/Projectiles/Ranged/PristineSecondary.cs b/Projectiles/Ranged/PristineSecondary.cs index 8aa6e000ea..47f609e474 100644 --- a/Projectiles/Ranged/PristineSecondary.cs +++ b/Projectiles/Ranged/PristineSecondary.cs @@ -1,6 +1,7 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; @@ -9,92 +10,65 @@ namespace CalamityMod.Projectiles.Ranged public class PristineSecondary : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override string Texture => "CalamityMod/Projectiles/Magic/RancorFog"; - private int dust1 = (int)CalamityDusts.ProfanedFire; - private int dust2 = ModContent.DustType(); + public ref float ScaleFactor => ref Projectile.ai[0]; + public ref float LightPower => ref Projectile.ai[1]; + + public Color FogColor = new Color(255, 220, 100); public override void SetDefaults() { - Projectile.width = 50; - Projectile.height = 50; + Projectile.width = Projectile.height = 150; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; + Projectile.timeLeft = 150; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 3; - Projectile.timeLeft = 150; } public override void AI() { + // Add some degree of variation to the fog with scale/rotation/color + if (Projectile.ai[2] == 0f) + { + Projectile.scale = Main.rand.NextFloat(0.15f, 0.75f); + Projectile.ai[2] = Main.rand.NextFloat(MathHelper.TwoPi); + FogColor.G = (byte)Main.rand.Next(160, 230 + 1); + } + ScaleFactor += 0.01f; + ScaleFactor = MathHelper.Clamp(ScaleFactor, 0f, Projectile.scale); + Lighting.AddLight(Projectile.Center, new Vector3(1f, 1f, 0.25f) * ScaleFactor); + Projectile.rotation = Projectile.velocity.ToRotation() + Projectile.ai[2]; + Projectile.velocity *= 0.98f; - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - dust1, - dust2 - }); - Lighting.AddLight(Projectile.Center, 1f, 1f, 0.25f); - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 1; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.25f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - if (Main.rand.NextBool(6)) - { - dust.noGravity = true; - dust.scale *= 1.5f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 1f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.noLight = true; - dust.color = CalamityUtils.ColorSwap(new Color(255, 168, 53), new Color(255, 249, 0), 2f); - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; + Projectile.Opacity = Utils.GetLerpValue(150f, 135f, Projectile.timeLeft, true) * Utils.GetLerpValue(0f, 90f, Projectile.timeLeft, true); + + // Calculate light power. This checks below the position of the fog to check if this fog is underground. + // Without this, it may render over the fullblack that the game renders for obscured tiles. + float lightPowerBelow = Lighting.GetColor((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16 + 6).ToVector3().Length() / (float)Math.Sqrt(3D); + LightPower = MathHelper.Lerp(LightPower, lightPowerBelow, 0.15f); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * ScaleFactor * 0.5f, targetHitbox); + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); + + public override bool PreDraw(ref Color lightColor) { - target.AddBuff(ModContent.BuffType(), 240); + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float opacity = Utils.GetLerpValue(0f, 0.08f, LightPower, true) * Projectile.Opacity * 0.5f; + Color drawColor = FogColor * opacity; + Main.EntitySpriteDraw(texture, drawPosition, null, drawColor, Projectile.rotation, texture.Size() * 0.5f, ScaleFactor, SpriteEffects.None); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Ranged/ShadeFire.cs b/Projectiles/Ranged/ShadeFire.cs index 92d0297eb4..027b90d925 100644 --- a/Projectiles/Ranged/ShadeFire.cs +++ b/Projectiles/Ranged/ShadeFire.cs @@ -1,8 +1,11 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class ShadeFire : ModProjectile, ILocalizedModType @@ -10,79 +13,50 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public static int Lifetime => 60; + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; + Projectile.width = Projectile.height = 6; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 80; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; // 20 effectively + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 10; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.25f / 255f, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f); - if (Projectile.timeLeft > 80) - { - Projectile.timeLeft = 80; - } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 14; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 3; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } - } + Time++; + + // Determines particle size as well as hitbox + if (Time >= 6f) + Projectile.scale = 1.5f * Utils.GetLerpValue(6f, 36f, Time, true); else + return; // Helps position it at the tip + + // Draw shadow smokes over the whole thing + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + Color smokeColor = Color.Lerp(Color.BlueViolet, Color.Black, 0.7f + 0.2f * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f)); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 20, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.8f, smokeRot, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + // Overlay the glow on top, which is on the brighter side + if (Main.rand.NextBool(5)) { - Projectile.ai[0] += 1f; + Color glowColor = Color.Lerp(smokeColor, Color.MidnightBlue, 0.25f); + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 15, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.8f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.AddBuff(ModContent.BuffType(), 300); } + + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 300); } } diff --git a/Projectiles/Ranged/SlimeBolt.cs b/Projectiles/Ranged/SlimeBolt.cs index 01542fa863..bb1125def5 100644 --- a/Projectiles/Ranged/SlimeBolt.cs +++ b/Projectiles/Ranged/SlimeBolt.cs @@ -1,4 +1,7 @@ +using CalamityMod.Particles; +using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -8,59 +11,155 @@ namespace CalamityMod.Projectiles.Ranged public class SlimeBolt : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/TinyGreyscaleCircle"; + + public static int Lifetime => 270; + public static float Fadetime => 225f; + public static float EmpowerTime => 135f; + public static Color SlimeColor => new Color (133, 133, 224); + + public ref float Time => ref Projectile.ai[0]; + public bool Empowered => Projectile.ai[0] >= EmpowerTime; + public ref float BloomPower => ref Projectile.ai[1]; + public bool Bounced => Projectile.ai[2] >= 1f; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + public override void SetDefaults() { - Projectile.width = 6; - Projectile.height = 6; - Projectile.aiStyle = ProjAIStyleID.Beam; + Projectile.width = Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 2; - Projectile.timeLeft = 400; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 3; + Projectile.timeLeft = Lifetime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.25f / 255f); - if (Main.rand.NextBool(5)) + Time++; + if (Time == EmpowerTime) { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 20, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); + Projectile.penetrate = 1; + Projectile.damage *= 2; + Projectile.velocity *= 0f; + Projectile.rotation = Main.rand.NextFloat(0f, MathHelper.TwoPi); + + float numberOfDusts = 10; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(3, 3.1f), 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(3, 3.1f), 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 59 : 20, new Vector2(velOffset.X, velOffset.Y)); + dust.noGravity = true; + dust.velocity = velOffset; + dust.scale = Main.rand.NextFloat(1.2f, 1.9f); + } } + else if (Time >= 90f) + Projectile.velocity *= 0.97f; + + if (Empowered) + { + Projectile.rotation += MathHelper.ToRadians(2f); + if (Time >= Fadetime) + BloomPower = Utils.Remap(Time, Fadetime, Lifetime, 1.5f, 0f); + else + BloomPower = Utils.Remap(Time, EmpowerTime, Fadetime, 0f, 1.5f); + } + else if (Main.rand.NextBool(Bounced ? 2 : 7)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(10, 10), Main.rand.NextBool(3) ? 16 : 20); + dust.scale = Main.rand.NextFloat(0.3f, 0.7f); + dust.velocity = -Projectile.velocity * 0.7f; + } + + Lighting.AddLight(Projectile.Center, 0.3f, 0.3f, 0.5f); } public override bool OnTileCollide(Vector2 oldVelocity) { - Projectile.penetrate--; - if (Projectile.penetrate <= 0) + if (Projectile.velocity.X != oldVelocity.X) { - Projectile.Kill(); + Projectile.velocity.X = -oldVelocity.X * (Bounced ? 1f : Utils.Remap(Time, 0f, EmpowerTime, 1.5f, 4f)); } - else + if (Projectile.velocity.Y != oldVelocity.Y) { - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } - Projectile.velocity *= 0.75f; + Projectile.velocity.Y = -oldVelocity.Y * (Bounced ? 1f : Utils.Remap(Time, 0f, EmpowerTime, 1.5f, 4f)); } + Projectile.ai[2]++; return false; } public override void OnKill(int timeLeft) { - for (int k = 0; k < 5; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 20, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } + Particle pulse = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, SlimeColor, Vector2.One, 0f, 0f, 0.4f, 25); + GeneralParticleHandler.SpawnParticle(pulse); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.Slimed, 180); + target.AddBuff(BuffID.Slimed, Empowered ? 480 : 180); + if (Empowered) + { + Particle pulse2 = new DirectionalPulseRing(Projectile.Center, Vector2.Zero, SlimeColor, Vector2.One, 0f, 0f, 0.65f, 35); + GeneralParticleHandler.SpawnParticle(pulse2); + float numberOfDusts = 12; + float rotFactor = 360f / numberOfDusts; + for (int i = 0; i < numberOfDusts; i++) + { + float rot = MathHelper.ToRadians(i * rotFactor); + Vector2 offset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot); + Vector2 velOffset = new Vector2(Main.rand.NextFloat(1, 3.1f), 0).RotatedBy(rot); + Dust dust = Dust.NewDustPerfect(Projectile.Center + offset, Main.rand.NextBool(3) ? 34 : 59, velOffset); + dust.noGravity = false; + dust.alpha = 130; + dust.velocity = velOffset; + dust.scale = dust.type == 20 ? Main.rand.NextFloat(0.9f, 1.9f) : Main.rand.NextFloat(1.6f, 2.2f); + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Texture2D texture = ModContent.Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Main.EntitySpriteDraw(texture, drawPosition, null, SlimeColor, Projectile.rotation, texture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + + if (Empowered) + { + Texture2D shineTex = ModContent.Request("CalamityMod/Particles/Sparkle").Value; + Texture2D bloomTex = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Main.EntitySpriteDraw(bloomTex, drawPosition, null, SlimeColor * 0.5f, Projectile.rotation, bloomTex.Size() * 0.5f, BloomPower * Projectile.scale * 0.3f, SpriteEffects.None); + Main.EntitySpriteDraw(shineTex, drawPosition, null, SlimeColor, Projectile.rotation, shineTex.Size() * 0.5f, BloomPower * Projectile.scale, SpriteEffects.None); + } + else + { + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float completionRatio = i / (float)Projectile.oldPos.Length; + Vector2 trailPos = Projectile.oldPos[i] + texture.Size() * 0.5f - Main.screenPosition; + + // The further the smaller + Color trailColor = Color.Lerp(SlimeColor, Color.Black, completionRatio); + float trailScale = MathHelper.Lerp(0.15f, 1f, 1f - completionRatio); + + Main.EntitySpriteDraw(texture, trailPos, null, trailColor, 0f, texture.Size() * 0.5f, Projectile.scale * trailScale, SpriteEffects.None, 0); + } + } + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + return false; } } } diff --git a/Projectiles/Ranged/SlimeBolt.png b/Projectiles/Ranged/SlimeBolt.png deleted file mode 100644 index f603916ffa..0000000000 Binary files a/Projectiles/Ranged/SlimeBolt.png and /dev/null differ diff --git a/Projectiles/Ranged/SparkSpreaderFire.cs b/Projectiles/Ranged/SparkSpreaderFire.cs index 473a849407..fa7385a9ee 100644 --- a/Projectiles/Ranged/SparkSpreaderFire.cs +++ b/Projectiles/Ranged/SparkSpreaderFire.cs @@ -1,4 +1,7 @@ -using Terraria; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,78 +12,83 @@ namespace CalamityMod.Projectiles.Ranged public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref Projectile.ai[0]; + public override void SetDefaults() { Projectile.width = Projectile.height = 12; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 3; - Projectile.extraUpdates = 1; - Projectile.timeLeft = 60; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 42 * Projectile.MaxUpdates; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 30; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.05f / 255f, (255 - Projectile.alpha) * 0.45f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - + // Krill the fire when the water if (Projectile.wet && !Projectile.lavaWet) { Projectile.Kill(); return; } - if (Main.rand.NextBool(3)) + Time++; + Projectile.rotation = Projectile.velocity.ToRotation(); + if (Time >= 8f) { - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 35, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 80, default, 0.75f); - Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 55, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 50, default, 0.75f); + float cinderSize = Utils.GetLerpValue(6f, 12f, Time, true); + Dust cinder = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 10, default, 0.75f); + if (Main.rand.NextBool(3)) + { + cinder.scale *= 3f; + cinder.velocity *= 1.5f; + } + cinder.noGravity = true; + cinder.scale *= cinderSize * 0.8f; + cinder.velocity += Projectile.velocity; } - - if (Projectile.ai[0]++ > 7f) - { - float dustScaleSize = 1f; - if (Projectile.ai[0] == 8f) - { - dustScaleSize = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - dustScaleSize = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - dustScaleSize = 0.75f; - } - Projectile.ai[0] += 1f; - int dustType = 6; - for (int i = 0; i < 2; i++) - { - int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 10, default, 0.75f); - Dust dust = Main.dust[fire]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 1.75f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.noGravity = true; - dust.scale *= 0.5f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= dustScaleSize; - dust.velocity += Projectile.velocity; - } - } - - Projectile.rotation += 0.3f * Projectile.direction; + else if (Time == 7f && !Main.rand.NextBool(4)) // Create short sparks around the tip at a pretty high chance + SpawnSparks(3, true); } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); - public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + // On-impact sparks + public override bool OnTileCollide(Vector2 oldVelocity) + { + SpawnSparks(8); + return true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + SpawnSparks(5); + } + + public override void OnHitPlayer(Player target, Player.HurtInfo info) + { + target.AddBuff(BuffID.OnFire, 60 * Main.rand.Next(1, 4)); + SpawnSparks(5); + } + + public void SpawnSparks(int count, bool shorts = false) + { + for (int i = 0; i < count; i++) + { + int sparkLifetime = Main.rand.Next(9, 16); + float sparkScale = Main.rand.NextFloat(0.2f, 0.4f); + Color sparkColor = Color.Lerp(Color.Gold, Color.OrangeRed, Main.rand.NextFloat(0.1f, 1f)); + + if (Main.rand.NextBool(6)) + sparkScale *= 1.5f; + + Vector2 sparkVelocity = Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(1.5f, 3f); + sparkVelocity.Y -= Main.rand.NextFloat(6f, 8f); + SparkParticle spark = new SparkParticle(Projectile.Center, (sparkVelocity * (shorts ? 0.75f : 1f)), true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + } } } diff --git a/Projectiles/Ranged/SpeedBlasterShot.cs b/Projectiles/Ranged/SpeedBlasterShot.cs index 712f695693..40755b24cf 100644 --- a/Projectiles/Ranged/SpeedBlasterShot.cs +++ b/Projectiles/Ranged/SpeedBlasterShot.cs @@ -1,9 +1,6 @@ -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Graphics.Metaballs; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; using System.Linq; using Terraria; using Terraria.Audio; @@ -140,7 +137,7 @@ namespace CalamityMod.Projectiles.Ranged { if (!DashShot) SoundEngine.PlaySound(ShotImpact, Projectile.position); - + for (int i = 0; i <= 8; i++) { Dust dust = Dust.NewDustPerfect(Projectile.position, 192, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.05f, 0.3f), 0, default, Main.rand.NextFloat(0.6f, 1.2f)); @@ -154,23 +151,23 @@ namespace CalamityMod.Projectiles.Ranged { Vector2 paintPos = Projectile.Center + Main.rand.NextVector2Circular(12f, 12f) + (Projectile.velocity.SafeNormalize(Vector2.UnitY)).RotatedByRandom(MathHelper.ToRadians(30f)) * Main.rand.NextFloat(4f, 20f); float paintSize = Main.rand.NextFloat(60f, 100f); - switch(Projectile.ai[0]) + switch (Projectile.ai[0]) { case 0: default: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 1: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 2: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 3: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; case 4: - FusableParticleManager.GetParticleSetByType()?.SpawnParticle(paintPos, paintSize); + ModContent.GetInstance().SpawnParticle(paintPos, paintSize); break; } } diff --git a/Projectiles/Ranged/TerraFire.cs b/Projectiles/Ranged/TerraFire.cs new file mode 100644 index 0000000000..ea49e162a7 --- /dev/null +++ b/Projectiles/Ranged/TerraFire.cs @@ -0,0 +1,89 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFire : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public static int Lifetime => 96; + public bool BlueFire => Projectile.ai[0] == 1f; + public ref float Time => ref Projectile.ai[1]; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 12; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.DamageType = DamageClass.Ranged; + Projectile.penetrate = 4; + Projectile.MaxUpdates = 5; + Projectile.timeLeft = Lifetime; // 24 effectively + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + } + + public override void AI() + { + Time++; + + if (Time == 1) + { + MediumMistParticle smoke2 = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 1f).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.2f, 2.1f), Color.Lime, Color.Turquoise, Main.rand.NextFloat(0.8f, 1.9f), 180, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke2); + MediumMistParticle smoke3 = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 2).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.2f, 2.1f), Color.Lime, Color.Turquoise, Main.rand.NextFloat(0.4f, 1.1f), 180, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke3); + for (int i = 0; i < 9; i++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 135 : 107); + dust2.noGravity = true; + dust2.velocity = Projectile.velocity.RotatedByRandom(0.7f) * Main.rand.NextFloat(0.3f, 2.9f); + dust2.scale = Main.rand.NextFloat(1.3f, 2.1f); + } + } + // Determines particle size as well as hitbox + if (Time >= 1f) + Projectile.scale = 1.8f * Utils.GetLerpValue(6f, 30f, Time, true); + else + return; // Helps position it at the tip + + // Main smokes shifting between green to green-blue and back + float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation + float colorValue = CalamityUtils.Convert01To010(Utils.GetLerpValue(30f, Lifetime, Time, true)); + Color smokeColor = Color.Lerp(Color.Lime, Color.Turquoise, colorValue); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 18, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.4f, smokeRot, true, required: true); + GeneralParticleHandler.SpawnParticle(smoke); + + if (Time > 4) + { + for (int i = 0; i < 2; i++) + { + float dustArea = Main.rand.NextFloat(0.1f, 1.7f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) + Projectile.velocity * Main.rand.NextFloat(-1.8f, 1.8f), Main.rand.NextBool(5) ? 135 : 107); + dust.noGravity = true; + dust.velocity = new Vector2(6, 6).RotatedByRandom(100) * dustArea; + dust.scale = (1.8f - dustArea) * 0.65f; + } + } + + // Overlay a gold glow on top + if (Main.rand.NextBool(5)) + { + Color glowColor = Color.Gold; + Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, glowColor, 9, Projectile.scale * Main.rand.NextFloat(0.4f, 0.7f), 0.2f, smokeRot, true, 0.005f); + GeneralParticleHandler.SpawnParticle(smokeGlow); + } + + Lighting.AddLight(Projectile.Center, smokeColor.ToVector3() * Projectile.scale * 0.3f); + } + + // Circular hitbox adjusted for the size of the smoke particles (which is 52 here) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, 52 * Projectile.scale * 0.5f, targetHitbox); + } +} diff --git a/Projectiles/Ranged/TerraFireGreen.cs b/Projectiles/Ranged/TerraFireGreen.cs deleted file mode 100644 index cd8c65b926..0000000000 --- a/Projectiles/Ranged/TerraFireGreen.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Ranged -{ - public class TerraFireGreen : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetDefaults() - { - Projectile.width = 12; - Projectile.height = 12; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.extraUpdates = 3; - Projectile.timeLeft = 120; - } - - public override void AI() - { - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.15f / 255f, (255 - Projectile.alpha) * 0.45f / 255f, (255 - Projectile.alpha) * 0.05f / 255f); - if (Projectile.timeLeft > 120) - { - Projectile.timeLeft = 120; - } - if (Projectile.ai[0] > 7f) - { - float num296 = 1f; - if (Projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (Projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (Projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - Projectile.ai[0] += 1f; - int num297 = 107; - if (Main.rand.NextBool()) - { - for (int num298 = 0; num298 < 3; num298++) - { - int num299 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num297, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100, default, 0.75f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 0.75f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - dust.velocity += Projectile.velocity; - if (!dust.noGravity) - { - dust.velocity *= 0.5f; - } - } - } - } - else - { - Projectile.ai[0] += 1f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - target.immune[Projectile.owner] = 5; - target.AddBuff(BuffID.CursedInferno, 90); - } - } -} diff --git a/Projectiles/Ranged/TerraFlamebursterHouldout.cs b/Projectiles/Ranged/TerraFlamebursterHouldout.cs new file mode 100644 index 0000000000..68ba520f27 --- /dev/null +++ b/Projectiles/Ranged/TerraFlamebursterHouldout.cs @@ -0,0 +1,128 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using log4net.Core; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFlamebursterHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/TerraFlameburster"; + private Player Owner => Main.player[Projectile.owner]; + private ref float ShotsFired => ref Projectile.ai[1]; + private ref float ShootTimer => ref Projectile.ai[2]; + private ref int ShotDelay => ref Owner.ActiveItem().useTime; // 8 + public int ShotCooldown; + public int FireBlobs = 0; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + + public override void SetDefaults() + { + Projectile.width = 68; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (Owner.dead || ShotsFired >= 16) // destroy the holdout if the player dies or is out of shots + { + Projectile.Kill(); + return; + } + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.8f; + + // Kill if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + Projectile.Kill(); + } + else + { + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + + ShootTimer++; + if (ShootTimer >= 60) + { + if (ShotCooldown == 0) + { + SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextBool(2) ? true : false); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + ShotsFired++; + ShotCooldown = ShotDelay; + if (FireBlobs == 0) + { + float randAngle = Main.rand.NextFloat(8f, 15f); + Vector2 newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(randAngle)) * 2f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner); + newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(-randAngle)) * 2f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner); + FireBlobs = 3; + } + else + FireBlobs--; + } + else + ShotCooldown--; + } + else + { + if (ShootTimer == 1) + SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f}, Projectile.Center); + ShotsFired = 0; + for (int i = 0; i < 2; i++) + { + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust2 = Dust.NewDustPerfect(tipPosition, Main.rand.NextBool(5) ? 135 : 107); + dust2.noGravity = true; + dust2.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 2.9f) - rotMulti); + dust2.scale = Main.rand.NextFloat(1.2f, 1.8f) * (ShootTimer * 0.015f); + } + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + Vector2 oldVelocity = Projectile.velocity; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + } + Projectile.Center = armPosition + Projectile.velocity * 20; + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Projectile.spriteDirection = Projectile.direction; + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/TerraFlare.cs b/Projectiles/Ranged/TerraFlare.cs new file mode 100644 index 0000000000..9bbfe20c28 --- /dev/null +++ b/Projectiles/Ranged/TerraFlare.cs @@ -0,0 +1,74 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFlare : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/SmallGreyscaleCircle"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 18; + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 40; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.penetrate = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 90 * Projectile.MaxUpdates; + Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; + } + + public override void AI() => CalamityUtils.HomeInOnNPC(Projectile, true, 640f, 15f, 20f); + + public override void OnKill(int timeLeft) + { + // Circular spread of clouds + for (int i = 0; i < 8; i++) + { + Vector2 smokeVel = Main.rand.NextVector2Circular(8f, 8f); + Color smokeColor = Main.rand.NextBool() ? Color.Lime : Color.Turquoise; + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.4f, 0.8f), 200 - Main.rand.Next(60), 0.1f); + GeneralParticleHandler.SpawnParticle(smoke); + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D lightTexture = ModContent.Request(Texture).Value; + for (int i = 0; i < Projectile.oldPos.Length; i++) + { + float colorInterpolation = MathF.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; + Color color = Color.Lerp(Color.Lime, Color.Turquoise, colorInterpolation); + Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); + Color outerColor = color; + Color innerColor = Color.Lerp(color, Color.Gold, 0.8f) * 0.5f; + float intensity = 0.9f + 0.15f * MathF.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + + // Become smaller the futher along the old positions we are. + intensity *= MathHelper.Lerp(0.15f, 1f, 1f - i / (float)Projectile.oldPos.Length); + + Vector2 outerScale = new Vector2(1.25f) * intensity; + Vector2 innerScale = new Vector2(1.25f) * intensity * 0.7f; + outerColor *= intensity * Projectile.scale; + innerColor *= intensity * Projectile.scale; + Main.EntitySpriteDraw(lightTexture, drawPosition, null, outerColor, 0f, lightTexture.Size() * 0.5f, outerScale * 0.6f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(lightTexture, drawPosition, null, innerColor, 0f, lightTexture.Size() * 0.5f, innerScale * 0.6f, SpriteEffects.None, 0); + } + return false; + } + } +} diff --git a/Projectiles/Ranged/TheMaelstromExplosion.cs b/Projectiles/Ranged/TheMaelstromExplosion.cs index 1c19bf8c20..a55b68bdd5 100644 --- a/Projectiles/Ranged/TheMaelstromExplosion.cs +++ b/Projectiles/Ranged/TheMaelstromExplosion.cs @@ -11,6 +11,8 @@ namespace CalamityMod.Projectiles.Ranged public class TheMaelstromExplosion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; + public override string Texture => "CalamityMod/ExtraTextures/SmallGreyscaleCircle"; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailingMode[Projectile.type] = 0; diff --git a/Projectiles/Ranged/TheMaelstromExplosion.png b/Projectiles/Ranged/TheMaelstromExplosion.png deleted file mode 100644 index c6b3592c9f..0000000000 Binary files a/Projectiles/Ranged/TheMaelstromExplosion.png and /dev/null differ diff --git a/Projectiles/Summon/HauntedDishes.cs b/Projectiles/Summon/HauntedDishes.cs index 35ddc8de60..8660460405 100644 --- a/Projectiles/Summon/HauntedDishes.cs +++ b/Projectiles/Summon/HauntedDishes.cs @@ -69,10 +69,10 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; } } - bool flag1 = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; + bool minionMovingLeft = false; + bool minionMovingRight = false; + bool minionBelowPlayer = false; + bool minionShouldJump = false; if (Projectile.lavaWet) { Projectile.ai[0] = 1f; @@ -80,9 +80,9 @@ namespace CalamityMod.Projectiles.Summon } int idlePos = 40 * (Projectile.minionPos + 1) * player.direction; if (player.position.X + (float) (player.width / 2) < Projectile.position.X + (float) (Projectile.width / 2) - 10f + (float) idlePos) - flag1 = true; + minionMovingLeft = true; else if (player.position.X + (float) (player.width / 2) > Projectile.position.X + (float) (Projectile.width / 2) + 10f + (float) idlePos) - flag2 = true; + minionMovingRight = true; if (Projectile.ai[1] == 0f) { @@ -90,9 +90,9 @@ namespace CalamityMod.Projectiles.Summon conflict1 += 40 * Projectile.minionPos; if (Projectile.localAI[0] > 0f) conflict1 += 500; - Vector2 vector2 = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); - float playerX = player.position.X + (float) (player.width / 2) - vector2.X; - float playerY = player.position.Y + (float) (player.height / 2) - vector2.Y; + Vector2 idleMinionPos = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); + float playerX = player.position.X + (float) (player.width / 2) - idleMinionPos.X; + float playerY = player.position.Y + (float) (player.height / 2) - idleMinionPos.Y; float playerDist = (float)Math.Sqrt(playerX * playerX + playerY * playerY); if (playerDist > 1500f) { @@ -109,7 +109,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.tileCollide = false; float npcDetectRange = 1200f; bool npcFound = false; - int num6 = -1; + int targetIndex = -1; for (int index = 0; index < Main.maxNPCs; ++index) { NPC npc2 = Main.npc[index]; @@ -121,7 +121,7 @@ namespace CalamityMod.Projectiles.Summon if (npcDist < npcDetectRange) { if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, npc2.position, npc2.width, npc2.height)) - num6 = index; + targetIndex = index; npcFound = true; break; } @@ -129,22 +129,22 @@ namespace CalamityMod.Projectiles.Summon } //return to normal if npc found - if (npcFound && num6 >= 0) + if (npcFound && targetIndex >= 0) Projectile.ai[0] = 0f; - Vector2 vector2 = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); - float xDist = player.position.X + (float) (player.width / 2) - vector2.X; + Vector2 returningMinionPos = new Vector2(Projectile.position.X + (float) Projectile.width * 0.5f, Projectile.position.Y + (float) Projectile.height * 0.5f); + float xDist = player.position.X + (float) (player.width / 2) - returningMinionPos.X; xDist -= (float) (40 * player.direction); if (!npcFound) xDist -= (float) (40 * Projectile.minionPos * player.direction); - float yDist = player.position.Y + (float) (player.height / 2) - vector2.Y; + float yDist = player.position.Y + (float) (player.height / 2) - returningMinionPos.Y; yDist -= 60f; float playerDist2 = (float) Math.Sqrt(xDist * xDist + yDist * yDist); - float num11 = 12f; - float num12 = playerDist2; - float conflict2 = 0.4f; - if (num11 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) - num11 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + float currentReturnSpeed = 12f; + float minionReturnSpeed = playerDist2; + float minionReturnAccel = 0.4f; + if (currentReturnSpeed < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + currentReturnSpeed = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); //if close enough to the player and has tile to stand on, return to normal if (playerDist2 < 100f && player.velocity.Y == 0f && (Projectile.position.Y + (float) Projectile.height <= player.position.Y + (float) player.height && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height))) @@ -165,52 +165,52 @@ namespace CalamityMod.Projectiles.Summon { Projectile.velocity *= 0.99f; } - conflict2 = 0.01f; + minionReturnAccel = 0.01f; } else { if (playerDist2 < 100f) { - conflict2 = 0.1f; + minionReturnAccel = 0.1f; } if (playerDist2 > 300f) { - conflict2 = 1f; + minionReturnAccel = 1f; } - playerDist2 = num12 / playerDist2; + playerDist2 = minionReturnSpeed / playerDist2; xDist *= playerDist2; yDist *= playerDist2; } if (Projectile.velocity.X < xDist) { - Projectile.velocity.X = Projectile.velocity.X + conflict2; - if (conflict2 > 0.05f && Projectile.velocity.X < 0f) + Projectile.velocity.X = Projectile.velocity.X + minionReturnAccel; + if (minionReturnAccel > 0.05f && Projectile.velocity.X < 0f) { - Projectile.velocity.X = Projectile.velocity.X + conflict2; + Projectile.velocity.X = Projectile.velocity.X + minionReturnAccel; } } if (Projectile.velocity.X > xDist) { - Projectile.velocity.X = Projectile.velocity.X - conflict2; - if (conflict2 > 0.05f && Projectile.velocity.X > 0f) + Projectile.velocity.X = Projectile.velocity.X - minionReturnAccel; + if (minionReturnAccel > 0.05f && Projectile.velocity.X > 0f) { - Projectile.velocity.X = Projectile.velocity.X - conflict2; + Projectile.velocity.X = Projectile.velocity.X - minionReturnAccel; } } if (Projectile.velocity.Y < yDist) { - Projectile.velocity.Y = Projectile.velocity.Y + conflict2; - if (conflict2> 0.05f && Projectile.velocity.Y < 0f) + Projectile.velocity.Y = Projectile.velocity.Y + minionReturnAccel; + if (minionReturnAccel> 0.05f && Projectile.velocity.Y < 0f) { - Projectile.velocity.Y = Projectile.velocity.Y + conflict2 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y + minionReturnAccel * 2f; } } if (Projectile.velocity.Y > yDist) { - Projectile.velocity.Y = Projectile.velocity.Y - conflict2; - if (conflict2 > 0.05f && Projectile.velocity.Y > 0f) + Projectile.velocity.Y = Projectile.velocity.Y - minionReturnAccel; + if (minionReturnAccel > 0.05f && Projectile.velocity.Y > 0f) { - Projectile.velocity.Y = Projectile.velocity.Y - conflict2 * 2f; + Projectile.velocity.Y = Projectile.velocity.Y - minionReturnAccel * 2f; } } if (Projectile.frame < 15) @@ -238,9 +238,8 @@ namespace CalamityMod.Projectiles.Summon } else { - float conflict3 = (float) (40 * Projectile.minionPos); + float exaggeratedMinionPos = (float) (40 * Projectile.minionPos); float attackCooldown = 30f; - int num4 = 60; --Projectile.localAI[0]; if (Projectile.localAI[0] < 0f) Projectile.localAI[0] = 0f; @@ -250,113 +249,113 @@ namespace CalamityMod.Projectiles.Summon } else { - float num5 = Projectile.position.X; - float num6 = Projectile.position.Y; - float num7 = 100000f; - float num8 = num7; - int num9 = -1; + float minionXTarget = Projectile.position.X; + float minionYTarget = Projectile.position.Y; + float minionAttackMaxDist = 100000f; + float minionAttackDistance = minionAttackMaxDist; + int minionAttackIndex = -1; NPC minionAttackTargetNpc = Projectile.OwnerMinionAttackTargetNPC; if (minionAttackTargetNpc != null && minionAttackTargetNpc.CanBeChasedBy((object) Projectile, false)) { - float num10 = minionAttackTargetNpc.position.X + (float) (minionAttackTargetNpc.width / 2); - float num11 = minionAttackTargetNpc.position.Y + (float) (minionAttackTargetNpc.height / 2); - float num12 = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - num10) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - num11); - if (num12 < num7) + float minionTargetXDist = minionAttackTargetNpc.position.X + (float) (minionAttackTargetNpc.width / 2); + float minionTargetYDist = minionAttackTargetNpc.position.Y + (float) (minionAttackTargetNpc.height / 2); + float minionTargetDist = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - minionTargetXDist) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - minionTargetYDist); + if (minionTargetDist < minionAttackMaxDist) { - if (num9 == -1 && num12 <= num8) + if (minionAttackIndex == -1 && minionTargetDist <= minionAttackDistance) { - num8 = num12; - num5 = num10; - num6 = num11; + minionAttackDistance = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; } if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, minionAttackTargetNpc.position, minionAttackTargetNpc.width, minionAttackTargetNpc.height)) { - num7 = num12; - num5 = num10; - num6 = num11; - num9 = minionAttackTargetNpc.whoAmI; + minionAttackMaxDist = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; + minionAttackIndex = minionAttackTargetNpc.whoAmI; } } } - if (num9 == -1) + if (minionAttackIndex == -1) { for (int index = 0; index < Main.maxNPCs; ++index) { if (Main.npc[index].CanBeChasedBy((object) Projectile, false)) { - float num10 = Main.npc[index].position.X + (float) (Main.npc[index].width / 2); - float num11 = Main.npc[index].position.Y + (float) (Main.npc[index].height / 2); - float num12 = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - num10) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - num11); - if (num12 < num7) + float minionTargetXDist = Main.npc[index].position.X + (float) (Main.npc[index].width / 2); + float minionTargetYDist = Main.npc[index].position.Y + (float) (Main.npc[index].height / 2); + float minionTargetDist = Math.Abs(Projectile.position.X + (float) (Projectile.width / 2) - minionTargetXDist) + Math.Abs(Projectile.position.Y + (float) (Projectile.height / 2) - minionTargetYDist); + if (minionTargetDist < minionAttackMaxDist) { - if (num9 == -1 && num12 <= num8) + if (minionAttackIndex == -1 && minionTargetDist <= minionAttackDistance) { - num8 = num12; - num5 = num10; - num6 = num11; + minionAttackDistance = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; } if (Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height)) { - num7 = num12; - num5 = num10; - num6 = num11; - num9 = index; + minionAttackMaxDist = minionTargetDist; + minionXTarget = minionTargetXDist; + minionYTarget = minionTargetYDist; + minionAttackIndex = index; } } } } } - if (num9 == -1 && num8 < num7) - num7 = num8; - float num13 = 400f; + if (minionAttackIndex == -1 && minionAttackDistance < minionAttackMaxDist) + minionAttackMaxDist = minionAttackDistance; + float yDependentTargeting = 400f; if ((double) Projectile.position.Y > Main.worldSurface * 16.0) - num13 = 200f; - if (num7 < num13 + conflict3 && num9 == -1) + yDependentTargeting = 200f; + if (minionAttackMaxDist < yDependentTargeting + exaggeratedMinionPos && minionAttackIndex == -1) { - float num10 = num5 - (Projectile.position.X + (float) (Projectile.width / 2)); - if (num10 < -5f) + float minionTargetXDist = minionXTarget - (Projectile.position.X + (float) (Projectile.width / 2)); + if (minionTargetXDist < -5f) { - flag1 = true; - flag2 = false; + minionMovingLeft = true; + minionMovingRight = false; } - else if (num10 > 5f) + else if (minionTargetXDist > 5f) { - flag2 = true; - flag1 = false; + minionMovingRight = true; + minionMovingLeft = false; } } - else if (num9 >= 0 && num7 < 800f + conflict3) + else if (minionAttackIndex >= 0 && minionAttackMaxDist < 800f + exaggeratedMinionPos) { - Projectile.localAI[0] = (float) num4; - float num10 = num5 - (Projectile.position.X + (float) (Projectile.width / 2)); - if (num10 > 300f || num10 < -300f) + Projectile.localAI[0] = 60f; + float minionTargetXDist = minionXTarget - (Projectile.position.X + (float) (Projectile.width / 2)); + if (minionTargetXDist > 300f || minionTargetXDist < -300f) { - if (num10 < -50f) + if (minionTargetXDist < -50f) { - flag1 = true; - flag2 = false; + minionMovingLeft = true; + minionMovingRight = false; } - else if (num10 > 50f) + else if (minionTargetXDist > 50f) { - flag2 = true; - flag1 = false; + minionMovingRight = true; + minionMovingLeft = false; } } else if (Projectile.owner == Main.myPlayer) { Projectile.ai[1] = attackCooldown; - double num11 = 12.0; - Vector2 vector2 = new Vector2(Projectile.Center.X, Projectile.Center.Y - 8f); - float num12 = num5 - vector2.X + Main.rand.NextFloat(-6f, 6f); - float num14 = (float) ((double) (Math.Abs(num12) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); - float num15 = num6 - vector2.Y + Main.rand.NextFloat(-6f, 6f) - num14; - double num16 = Math.Sqrt((double) num12 * (double) num12 + (double) num15 * (double) num15); - float num17 = (float) (num11 / num16); - float SpeedX = num12 * num17; - float SpeedY = num15 * num17; + double plateSpeed = 12.0; + Vector2 projMinionPos = new Vector2(Projectile.Center.X, Projectile.Center.Y - 8f); + float plateTargetX = minionXTarget - projMinionPos.X + Main.rand.NextFloat(-6f, 6f); + float randomPlateYOffset = (float) ((double) (Math.Abs(plateTargetX) * 0.1f) * (double) Main.rand.Next(0, 100) * (1.0 / 1000.0)); + float plateTargetY = minionYTarget - projMinionPos.Y + Main.rand.NextFloat(-6f, 6f) - randomPlateYOffset; + double plateTargetDist = Math.Sqrt((double) plateTargetX * (double) plateTargetX + (double) plateTargetY * (double) plateTargetY); + float plateVelocity = (float) (plateSpeed / plateTargetDist); + float SpeedX = plateTargetX * plateVelocity; + float SpeedY = plateTargetY * plateVelocity; int damage = Projectile.damage; int Type = ModContent.ProjectileType(); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), vector2.X, vector2.Y, SpeedX * 2f, SpeedY * 2f, Type, damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), projMinionPos.X, projMinionPos.Y, SpeedX * 2f, SpeedY * 2f, Type, damage, Projectile.knockBack, Projectile.owner); if (SpeedX < 0f) Projectile.direction = -1; if (SpeedX > 0f) @@ -365,74 +364,71 @@ namespace CalamityMod.Projectiles.Summon } } } - Vector2 vector2_1 = Vector2.Zero; - bool flag7 = false; if (Projectile.ai[1] != 0f) { - flag1 = false; - flag2 = false; + minionMovingLeft = false; + minionMovingRight = false; } else if (Projectile.localAI[0] == 0f) Projectile.direction = player.direction; - if (!flag7) - Projectile.rotation = 0f; + Projectile.rotation = 0f; Projectile.tileCollide = true; - float num18 = 0.08f; - float num19 = 6.5f; - num19 = 6f; - num18 = 0.2f; - if (num19 < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) + float groundMinionAccel = 0.08f; + float groundMinionMaxVel = 6.5f; + groundMinionMaxVel = 6f; + groundMinionAccel = 0.2f; + if (groundMinionMaxVel < Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y)) { - num19 = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); - num18 = 0.3f; + groundMinionMaxVel = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y); + groundMinionAccel = 0.3f; } - if (flag1) + if (minionMovingLeft) { if (Projectile.velocity.X > -3.5f) - Projectile.velocity.X -= num18; + Projectile.velocity.X -= groundMinionAccel; else - Projectile.velocity.X -= num18 * 0.25f; + Projectile.velocity.X -= groundMinionAccel * 0.25f; } - else if (flag2) + else if (minionMovingRight) { if (Projectile.velocity.X < 3.5f) - Projectile.velocity.X += num18; + Projectile.velocity.X += groundMinionAccel; else - Projectile.velocity.X += num18 * 0.25f; + Projectile.velocity.X += groundMinionAccel * 0.25f; } else { Projectile.velocity.X *= 0.9f; - if (Projectile.velocity.X >= -num18 && Projectile.velocity.X <= num18) + if (Projectile.velocity.X >= -groundMinionAccel && Projectile.velocity.X <= groundMinionAccel) Projectile.velocity.X = 0f; } - if (flag1 | flag2) + if (minionMovingLeft | minionMovingRight) { - int conflict4 = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; + int minionTileX = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; int j = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16; - if (flag1) - --conflict4; - if (flag2) - ++conflict4; - if (WorldGen.SolidTile(conflict4 + (int) Projectile.velocity.X, j)) - flag4 = true; + if (minionMovingLeft) + --minionTileX; + if (minionMovingRight) + ++minionTileX; + if (WorldGen.SolidTile(minionTileX + (int) Projectile.velocity.X, j)) + minionShouldJump = true; } if (player.position.Y + player.height - 8f > Projectile.position.Y + Projectile.height) - flag3 = true; + minionBelowPlayer = true; Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY, 1, false, 0); if (Projectile.velocity.Y == 0f) { - if (!flag3 && ((double) Projectile.velocity.X < 0.0 || (double) Projectile.velocity.X > 0.0)) + if (!minionBelowPlayer && ((double) Projectile.velocity.X < 0.0 || (double) Projectile.velocity.X > 0.0)) { int i = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; int j = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16 + 1; - if (flag1) + if (minionMovingLeft) --i; - if (flag2) + if (minionMovingRight) ++i; WorldGen.SolidTile(i, j); } - if (flag4) + if (minionShouldJump) { int i1 = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; int j = (int) ((double) Projectile.position.Y + (double) Projectile.height) / 16 + 1; @@ -446,20 +442,20 @@ namespace CalamityMod.Projectiles.Summon { try { - int conflict5 = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; - int conflict7 = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16; - if (flag1) - --conflict5; - if (flag2) - ++conflict5; - int i2 = conflict5 + (int) Projectile.velocity.X; - if (!WorldGen.SolidTile(i2, conflict7 - 1) && !WorldGen.SolidTile(i2, conflict7 - 2)) + int minionJumpTileX = (int) ((double) Projectile.position.X + (double) (Projectile.width / 2)) / 16; + int minionJumpTileY = (int) ((double) Projectile.position.Y + (double) (Projectile.height / 2)) / 16; + if (minionMovingLeft) + --minionJumpTileX; + if (minionMovingRight) + ++minionJumpTileX; + int i2 = minionJumpTileX + (int) Projectile.velocity.X; + if (!WorldGen.SolidTile(i2, minionJumpTileY - 1) && !WorldGen.SolidTile(i2, minionJumpTileY - 2)) Projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(i2, conflict7 - 2)) + else if (!WorldGen.SolidTile(i2, minionJumpTileY - 2)) Projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(i2, conflict7 - 5)) + else if (WorldGen.SolidTile(i2, minionJumpTileY - 5)) Projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(i2, conflict7 - 4)) + else if (WorldGen.SolidTile(i2, minionJumpTileY - 4)) Projectile.velocity.Y = -10.1f; else Projectile.velocity.Y = -9.1f; @@ -471,20 +467,20 @@ namespace CalamityMod.Projectiles.Summon } } } - else if (Projectile.type == 266 && flag1 | flag2) + else if (Projectile.type == 266 && minionMovingLeft | minionMovingRight) Projectile.velocity.Y -= 6f; } - if (Projectile.velocity.X > num19) - Projectile.velocity.X = num19; - if (Projectile.velocity.X < -num19) - Projectile.velocity.X = -num19; + if (Projectile.velocity.X > groundMinionMaxVel) + Projectile.velocity.X = groundMinionMaxVel; + if (Projectile.velocity.X < -groundMinionMaxVel) + Projectile.velocity.X = -groundMinionMaxVel; if (Projectile.velocity.X < 0f) Projectile.direction = -1; if (Projectile.velocity.X > 0f) Projectile.direction = 1; - if (Projectile.velocity.X > num18 & flag2) + if (Projectile.velocity.X > groundMinionAccel & minionMovingRight) Projectile.direction = 1; - if (Projectile.velocity.X < -num18 & flag1) + if (Projectile.velocity.X < -groundMinionAccel & minionMovingLeft) Projectile.direction = -1; if (Projectile.direction == -1) Projectile.spriteDirection = -1; diff --git a/Projectiles/Typeless/LeviAmberDash.cs b/Projectiles/Typeless/LeviAmberDash.cs index 5ea69efa18..af40656994 100644 --- a/Projectiles/Typeless/LeviAmberDash.cs +++ b/Projectiles/Typeless/LeviAmberDash.cs @@ -40,8 +40,8 @@ namespace CalamityMod.Projectiles.Typeless target.velocity.X += 4.2f * Owner.direction; } target.AddBuff(BuffID.Wet, 300); - target.AddBuff(ModContent.BuffType(), 60); - SoundEngine.PlaySound(SoundID.Item85 with { Volume = 0.6f, PitchVariance = 0.4f }, Projectile.Center); + target.AddBuff(ModContent.BuffType(), 180); + SoundEngine.PlaySound(SoundID.Item85 with { Volume = 0.4f, PitchVariance = 0.4f }, Projectile.Center); for (int i = 0; i < 3; ++i) { int bloodLifetime = Main.rand.Next(20, 26); diff --git a/Projectiles/Typeless/PauldronDash.cs b/Projectiles/Typeless/PauldronDash.cs index 6ea9a1883e..6a17b3d5f8 100644 --- a/Projectiles/Typeless/PauldronDash.cs +++ b/Projectiles/Typeless/PauldronDash.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.OnFire3, 240); - target.AddBuff(ModContent.BuffType(), 240); + target.AddBuff(ModContent.BuffType(), 300); SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode with { Volume = 0.6f, PitchVariance = 0.4f }, Projectile.Center); for (int i = 0; i <= 8; i++) diff --git a/Projectiles/Typeless/VoidFieldGenerator.cs b/Projectiles/Typeless/VoidFieldGenerator.cs index 50350b04b1..caa0c96e8e 100644 --- a/Projectiles/Typeless/VoidFieldGenerator.cs +++ b/Projectiles/Typeless/VoidFieldGenerator.cs @@ -1,10 +1,10 @@ using CalamityMod.CalPlayer; -using CalamityMod.Particles.Metaballs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; +using CalamityMod.Graphics.Metaballs; namespace CalamityMod.Projectiles.Typeless { @@ -12,7 +12,7 @@ namespace CalamityMod.Projectiles.Typeless { public new string LocalizationCategory => "Projectiles.Typeless"; public bool start = true; - public BaseFusableParticleSet.FusableParticle voidaura; + public StreamGougeMetaball.CosmicParticle VoidAura; public override void SetDefaults() { @@ -78,14 +78,14 @@ namespace CalamityMod.Projectiles.Typeless } } - if (voidaura == null) + if (VoidAura == null) { - voidaura = FusableParticleManager.GetParticleSetByType()?.SpawnParticle(Projectile.Center, 500); + VoidAura = VoidGeneratorMetaball.SpawnParticle(Projectile.Center, Vector2.Zero, 120f); } else { - voidaura.Center = Projectile.Center; - voidaura.Size = 500; + VoidAura.Center = Projectile.Center; + VoidAura.Size = 120f; } } public override bool? CanCutTiles() => false; diff --git a/Sounds/Item/DeadSunExplosion.ogg b/Sounds/Item/DeadSunExplosion.ogg new file mode 100644 index 0000000000..5ffd7660ce Binary files /dev/null and b/Sounds/Item/DeadSunExplosion.ogg differ diff --git a/Sounds/Item/DeadSunRicochet.ogg b/Sounds/Item/DeadSunRicochet.ogg new file mode 100644 index 0000000000..31162a2442 Binary files /dev/null and b/Sounds/Item/DeadSunRicochet.ogg differ diff --git a/Sounds/Item/DeadSunShot.ogg b/Sounds/Item/DeadSunShot.ogg new file mode 100644 index 0000000000..d551c9d68f Binary files /dev/null and b/Sounds/Item/DeadSunShot.ogg differ diff --git a/Sounds/Item/HalleysInfernoHit.ogg b/Sounds/Item/HalleysInfernoHit.ogg new file mode 100644 index 0000000000..6cb43e1cd9 Binary files /dev/null and b/Sounds/Item/HalleysInfernoHit.ogg differ diff --git a/Sounds/Item/HalleysInfernoShoot.ogg b/Sounds/Item/HalleysInfernoShoot.ogg new file mode 100644 index 0000000000..00ef951e9a Binary files /dev/null and b/Sounds/Item/HalleysInfernoShoot.ogg differ diff --git a/Sounds/Item/Heartbeat.ogg b/Sounds/Item/Heartbeat.ogg new file mode 100644 index 0000000000..b0121df73c Binary files /dev/null and b/Sounds/Item/Heartbeat.ogg differ diff --git a/Sounds/Item/NanoSwarm.ogg b/Sounds/Item/NanoSwarm.ogg new file mode 100644 index 0000000000..ad6f079194 Binary files /dev/null and b/Sounds/Item/NanoSwarm.ogg differ diff --git a/Sounds/Item/PhotoHitSound.ogg b/Sounds/Item/PhotoHitSound.ogg new file mode 100644 index 0000000000..97f0ff847c Binary files /dev/null and b/Sounds/Item/PhotoHitSound.ogg differ diff --git a/Sounds/Item/PhotoUseSound.ogg b/Sounds/Item/PhotoUseSound.ogg new file mode 100644 index 0000000000..7085134694 Binary files /dev/null and b/Sounds/Item/PhotoUseSound.ogg differ diff --git a/Sounds/Item/WeldingBurn.ogg b/Sounds/Item/WeldingBurn.ogg new file mode 100644 index 0000000000..07b57418b6 Binary files /dev/null and b/Sounds/Item/WeldingBurn.ogg differ diff --git a/Sounds/Item/WeldingShoot.ogg b/Sounds/Item/WeldingShoot.ogg new file mode 100644 index 0000000000..9befb3eb4e Binary files /dev/null and b/Sounds/Item/WeldingShoot.ogg differ diff --git a/Systems/EntityUpdateInterceptionSystem.cs b/Systems/EntityUpdateInterceptionSystem.cs index f3634046bc..98a14899e8 100644 --- a/Systems/EntityUpdateInterceptionSystem.cs +++ b/Systems/EntityUpdateInterceptionSystem.cs @@ -1,6 +1,5 @@ using CalamityMod.NPCs; using CalamityMod.Particles; -using CalamityMod.Particles.Metaballs; using CalamityMod.TileEntities; using Terraria; using Terraria.ModLoader; @@ -9,19 +8,6 @@ namespace CalamityMod.Systems { public class EntityUpdateInterceptionSystem : ModSystem { - #region Fusable Particle Updating - public override void PostUpdateProjectiles() - { - // Update all fusable particles. - // These are really only visual and as such don't really need any complex netcode. - foreach (BaseFusableParticleSet.FusableParticleRenderCollection particleSet in FusableParticleManager.ParticleSets) - { - foreach (BaseFusableParticleSet.FusableParticle particle in particleSet.ParticleSet.Particles) - particleSet.ParticleSet.UpdateBehavior(particle); - } - } - #endregion - #region Ash Drawing public override void PostUpdateDusts() => DeathAshParticle.UpdateAll(); #endregion Ash Drawing diff --git a/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs b/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs index de8a52d827..6d4267dfa0 100644 --- a/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs +++ b/Tiles/Abyss/AbyssAmbient/MassiveRarePearl.cs @@ -1,14 +1,9 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; using Terraria.DataStructures; -using Terraria.Enums; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { @@ -20,8 +15,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102)); DustType = 33; @@ -30,9 +25,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { + { if (Main.rand.NextBool(5)) - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.PinkPearl); + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.PinkPearl); else Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.WhitePearl); } diff --git a/Tiles/Abyss/AbyssAmbient/PirateCrate.cs b/Tiles/Abyss/AbyssAmbient/PirateCrate.cs index 65c3282f0c..23d9edf593 100644 --- a/Tiles/Abyss/AbyssAmbient/PirateCrate.cs +++ b/Tiles/Abyss/AbyssAmbient/PirateCrate.cs @@ -1,15 +1,11 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.DataStructures; -using Terraria.Enums; -using Terraria.Localization; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.Abyss.AbyssAmbient { @@ -22,8 +18,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(97, 69, 52), CalamityUtils.GetText("Tiles.PirateCrate")); DustType = DustID.WoodFurniture; @@ -33,11 +29,11 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { + { //explode when broken (troll!) //also instakill players in for the worthy Vector2 spawnPosition = new(i * 16f + 24f, j * 16f - 4f); - Projectile.NewProjectile(new EntitySource_WorldEvent(), spawnPosition.X, spawnPosition.Y, 0, 0, ProjectileID.Explosives, Main.getGoodWorld ? 99999 : 130, 0f); + Projectile.NewProjectile(new EntitySource_WorldEvent(), spawnPosition.X, spawnPosition.Y, 0, 0, ProjectileID.Explosives, Main.getGoodWorld ? 99999 : 130, 0f); } public override void NumDust(int i, int j, bool fail, ref int num) @@ -48,10 +44,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Framing.GetTileSafely(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate1Glow").Value; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); + spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); } } @@ -60,10 +56,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Framing.GetTileSafely(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate2Glow").Value; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); + spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); } } @@ -72,10 +68,10 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { Tile tile = Framing.GetTileSafely(i, j); - Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow").Value; - Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); + Texture2D tex = ModContent.Request("CalamityMod/Tiles/Abyss/AbyssAmbient/PirateCrate3Glow").Value; + Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange, Main.offScreenRange); - spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); + spriteBatch.Draw(tex, new Vector2(i * 16, j * 16 + 2) - Main.screenPosition + zero, new Rectangle(tile.TileFrameX, tile.TileFrameY, 16, 16), Color.White); } } @@ -88,8 +84,8 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(97, 69, 52), CalamityUtils.GetText("Tiles.PirateCrate")); DustType = DustID.WoodFurniture; @@ -99,9 +95,9 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient } public override void KillMultiTile(int i, int j, int frameX, int frameY) - { + { if (Main.rand.NextBool()) - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.GoldCoin, Main.rand.Next(1, 2)); + Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.GoldCoin, Main.rand.Next(1, 2)); Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 32, ItemID.SilverCoin, Main.rand.Next(45, 75)); } diff --git a/Tiles/Abyss/AbyssalPots.cs b/Tiles/Abyss/AbyssalPots.cs index 15ad3b67e2..5b54a5cdf0 100644 --- a/Tiles/Abyss/AbyssalPots.cs +++ b/Tiles/Abyss/AbyssalPots.cs @@ -1,6 +1,6 @@ -using CalamityMod.Items.TreasureBags.MiscGrabBags; +using System.Collections.Generic; +using CalamityMod.Items.TreasureBags.MiscGrabBags; using Microsoft.Xna.Framework; -using System.Collections.Generic; using Terraria; using Terraria.DataStructures; using Terraria.ID; @@ -21,8 +21,8 @@ namespace CalamityMod.Tiles.Abyss Main.tileSpelunker[Type] = true; Main.tileCut[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(47, 79, 79), Language.GetText("MapObject.Pot")); // dark slate gray DustType = 29; @@ -35,28 +35,28 @@ namespace CalamityMod.Tiles.Abyss if (tileAtPosition.TileFrameX % 36 == 0 && tileAtPosition.TileFrameY % 36 == 0) { if (Main.netMode != NetmodeID.Server) - { - int goreAmt = Main.rand.Next(1, 2 + 1); - for (int k = 0; k < goreAmt; k++) - { - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore1").Type); - Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore2").Type); - } - } + { + int goreAmt = Main.rand.Next(1, 2 + 1); + for (int k = 0; k < goreAmt; k++) + { + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore1").Type); + Gore.NewGore(new EntitySource_TileBreak(i, j), new Vector2(i, j) * 16, Main.rand.NextVector2CircularEdge(3f, 3f), Mod.Find("AbyssPotGore2").Type); + } + } - // 1 in 400 for a Coin Portal - if (Player.GetClosestRollLuck(i, j, 400) == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 16, 0f, -12f, ProjectileID.CoinPortal, 0, 0f, Main.myPlayer); - } - // Followed by a 1 in 4 for a bomb in For The Worthy worlds - else if (Main.getGoodWorld && Main.rand.NextBool(4)) - Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 8, (float)Main.rand.Next(-100, 101) * 0.002f, 0f, ProjectileID.Bomb, 0, 0f, Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)); - else - yield return new Item(ModContent.ItemType()); - } - } + // 1 in 400 for a Coin Portal + if (Player.GetClosestRollLuck(i, j, 400) == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 16, 0f, -12f, ProjectileID.CoinPortal, 0, 0f, Main.myPlayer); + } + // Followed by a 1 in 4 for a bomb in For The Worthy worlds + else if (Main.getGoodWorld && Main.rand.NextBool(4)) + Projectile.NewProjectile(new EntitySource_TileBreak(i, j), i * 16 + 16, j * 16 + 8, (float)Main.rand.Next(-100, 101) * 0.002f, 0f, ProjectileID.Bomb, 0, 0f, Player.FindClosest(new Vector2(i * 16, j * 16), 16, 16)); + else + yield return new Item(ModContent.ItemType()); + } + } public override bool CreateDust(int i, int j, ref int type) { diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index 7710a7396f..c8becd91c8 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Tiles.Abyss public override void RandomUpdate(int i, int j) { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -84,29 +84,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (CalamityUtils.ParanoidTileRetrieval(i, num52).BottomSlope) + if (CalamityUtils.ParanoidTileRetrieval(i, k).BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } } Main.tile[i, j].Get().Slope = SlopeType.Solid; diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index d883642617..ee518f5266 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -162,7 +162,7 @@ namespace CalamityMod.Tiles.Abyss NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); } - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); if (Main.tile[i, j + 1] != null) { if (!Main.tile[i, j + 1].HasTile && Main.tile[i, j + 1].TileType != (ushort)ModContent.TileType()) @@ -171,29 +171,29 @@ namespace CalamityMod.Tiles.Abyss Main.tile[i, j + 1].WallType == (ushort)ModContent.WallType() && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } } } diff --git a/Tiles/Abyss/SteamGeyser.cs b/Tiles/Abyss/SteamGeyser.cs index 62dd12742a..c745770cd0 100644 --- a/Tiles/Abyss/SteamGeyser.cs +++ b/Tiles/Abyss/SteamGeyser.cs @@ -4,7 +4,6 @@ using CalamityMod.Projectiles.Environment; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; -using Terraria.Localization; using Terraria.ModLoader; using Terraria.ObjectData; @@ -19,8 +18,8 @@ namespace CalamityMod.Tiles.Abyss { Main.tileFrameImportant[Type] = true; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(103, 65, 64), CalamityUtils.GetText($"{LocalizationCategory}.SteamGeyser.MapEntry")); DustType = (int)CalamityDusts.SulfurousSeaAcid; diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index 21129d9a32..5d35963b13 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -74,18 +74,18 @@ namespace CalamityMod.Tiles.Abyss { if (Main.tile[i, tileLocationY].LiquidAmount == 255) { - int num13 = 7; - int num14 = 6; - int num15 = 0; - for (int l = i - num13; l <= i + num13; l++) + int ambientObjectDetectRadius = 7; + int ambientObjectMax = 6; + int ambientObjectAmt = 0; + for (int l = i - ambientObjectDetectRadius; l <= i + ambientObjectDetectRadius; l++) { - for (int m = tileLocationY - num13; m <= tileLocationY + num13; m++) + for (int m = tileLocationY - ambientObjectDetectRadius; m <= tileLocationY + ambientObjectDetectRadius; m++) { if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == 81) - num15++; + ambientObjectAmt++; } } - if (num15 < num14 && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && + if (ambientObjectAmt < ambientObjectMax && Main.tile[i, tileLocationY - 1].LiquidAmount == 255 && Main.tile[i, tileLocationY - 2].LiquidAmount == 255 && Main.tile[i, tileLocationY - 3].LiquidAmount == 255 && Main.tile[i, tileLocationY - 4].LiquidAmount == 255) { @@ -96,18 +96,18 @@ namespace CalamityMod.Tiles.Abyss } else if (Main.tile[i, tileLocationY].LiquidAmount == 0) { - int num13 = 7; - int num14 = 6; - int num15 = 0; - for (int l = i - num13; l <= i + num13; l++) + int ambientObjectDetectRadius = 7; + int ambientObjectMax = 6; + int ambientObjectAmt = 0; + for (int l = i - ambientObjectDetectRadius; l <= i + ambientObjectDetectRadius; l++) { - for (int m = tileLocationY - num13; m <= tileLocationY + num13; m++) + for (int m = tileLocationY - ambientObjectDetectRadius; m <= tileLocationY + ambientObjectDetectRadius; m++) { if (Main.tile[l, m].HasTile && Main.tile[l, m].TileType == 324) - num15++; + ambientObjectAmt++; } } - if (num15 < num14) + if (ambientObjectAmt < ambientObjectMax) { WorldGen.PlaceTile(i, tileLocationY, 324, true, false, -1, Main.rand.Next(2)); if (Main.netMode == NetmodeID.Server && Main.tile[i, tileLocationY].HasTile) @@ -119,7 +119,7 @@ namespace CalamityMod.Tiles.Abyss } } - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -143,29 +143,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } Main.tile[i, j].Get().Slope = SlopeType.Solid; Main.tile[i, j].Get().IsHalfBlock = false; diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index c536be437c..a619209223 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Tiles.Abyss public override void RandomUpdate(int i, int j) { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -85,29 +85,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } Main.tile[i, j].Get().Slope = SlopeType.Solid; Main.tile[i, j].Get().IsHalfBlock = false; diff --git a/Tiles/Abyss/SulphurousShale.cs b/Tiles/Abyss/SulphurousShale.cs index a1558e1156..87887f78e1 100644 --- a/Tiles/Abyss/SulphurousShale.cs +++ b/Tiles/Abyss/SulphurousShale.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Tiles.Abyss public override void RandomUpdate(int i, int j) { - int num8 = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); + int vineLength = WorldGen.genRand.Next((int)Main.rockLayer, (int)(Main.rockLayer + (double)Main.maxTilesY * 0.143)); int nearbyVineCount = 0; for (int x = i - 15; x <= i + 15; x++) { @@ -77,29 +77,29 @@ namespace CalamityMod.Tiles.Abyss if (Main.tile[i, j + 1].LiquidAmount == 255 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = num8; num52 > num8 - 10; num52--) + bool canGrowVine = false; + for (int k = vineLength; k > vineLength - 10; k--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); } Main.tile[i, j].Get().Slope = SlopeType.Solid; Main.tile[i, j].Get().IsHalfBlock = false; diff --git a/Tiles/Abyss/ViperVines.cs b/Tiles/Abyss/ViperVines.cs index 318b6590f7..3f491fe5fe 100644 --- a/Tiles/Abyss/ViperVines.cs +++ b/Tiles/Abyss/ViperVines.cs @@ -67,36 +67,36 @@ namespace CalamityMod.Tiles.Abyss { if (Main.tile[i, j + 1].LiquidAmount >= 128 && Main.tile[i, j + 1].LiquidType != LiquidID.Lava) { - bool flag13 = false; - for (int num52 = j; num52 > j - 10; j--) + bool canGrowVine = false; + for (int k = j; k > j - 10; j--) { - if (Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].BottomSlope) { - flag13 = false; + canGrowVine = false; break; } - if (Main.tile[i, num52].HasTile && !Main.tile[i, num52].BottomSlope) + if (Main.tile[i, k].HasTile && !Main.tile[i, k].BottomSlope) { - flag13 = true; + canGrowVine = true; break; } } - if (flag13) + if (canGrowVine) { - int num53 = i; - int num54 = j + 1; - Main.tile[num53, num54].TileType = (ushort)ModContent.TileType(); - Main.tile[num53, num54].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); - Main.tile[num53, num54].TileFrameY = (short)(4 * 18); - Main.tile[num53, num54 - 1].TileFrameX = (short)(WorldGen.genRand.Next(12) * 18); - Main.tile[num53, num54 - 1].TileFrameY = (short)(WorldGen.genRand.Next(4) * 18); - Main.tile[num53, num54].Get().HasTile = true; - WorldGen.SquareTileFrame(num53, num54, true); - WorldGen.SquareTileFrame(num53, num54 - 1, true); + int vineX = i; + int vineY = j + 1; + Main.tile[vineX, vineY].TileType = (ushort)ModContent.TileType(); + Main.tile[vineX, vineY].TileFrameX = (short)(WorldGen.genRand.Next(8) * 18); + Main.tile[vineX, vineY].TileFrameY = (short)(4 * 18); + Main.tile[vineX, vineY - 1].TileFrameX = (short)(WorldGen.genRand.Next(12) * 18); + Main.tile[vineX, vineY - 1].TileFrameY = (short)(WorldGen.genRand.Next(4) * 18); + Main.tile[vineX, vineY].Get().HasTile = true; + WorldGen.SquareTileFrame(vineX, vineY, true); + WorldGen.SquareTileFrame(vineX, vineY - 1, true); if (Main.netMode == NetmodeID.Server) { - NetMessage.SendTileSquare(-1, num53, num54, 3, TileChangeType.None); - NetMessage.SendTileSquare(-1, num53, num54 - 1, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY, 3, TileChangeType.None); + NetMessage.SendTileSquare(-1, vineX, vineY - 1, 3, TileChangeType.None); } } } diff --git a/Tiles/AstralBrick.cs b/Tiles/AstralBrick.cs index af42d9246f..5c2f42bb3f 100644 --- a/Tiles/AstralBrick.cs +++ b/Tiles/AstralBrick.cs @@ -62,7 +62,6 @@ namespace CalamityMod.Tiles Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(50, 50, 50, 50)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 0ccb6b579b..66982b5582 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -383,8 +383,8 @@ namespace CalamityMod.Tiles foreach (Item item in itemDrops) { item.Prefix(-1); // You're twisted if you have a prefixable item inside ores but fuck it - int num = Item.NewItem(source, pos, item); - Main.item[num].TryCombiningIntoNearbyItems(num); + int moddedOre = Item.NewItem(source, pos, item); + Main.item[moddedOre].TryCombiningIntoNearbyItems(moddedOre); } } else // Fetch normal tile-item relationships (all vanilla ores are normal thankfully) @@ -476,19 +476,19 @@ namespace CalamityMod.Tiles return; } - int num = tileSafely.TileFrameX / 22; - int num2 = tileSafely.TileFrameY / 22; - if (num == 3 && num2 <= 2) + int treeTileX = tileSafely.TileFrameX / 22; + int treeTileY = tileSafely.TileFrameY / 22; + if (treeTileX == 3 && treeTileY <= 2) x++; - else if (num == 4 && num2 >= 3 && num2 <= 5) + else if (treeTileX == 4 && treeTileY >= 3 && treeTileY <= 5) x--; - else if (num == 1 && num2 >= 6 && num2 <= 8) + else if (treeTileX == 1 && treeTileY >= 6 && treeTileY <= 8) x--; - else if (num == 2 && num2 >= 6 && num2 <= 8) + else if (treeTileX == 2 && treeTileY >= 6 && treeTileY <= 8) x++; - else if (num == 2 && num2 >= 9) + else if (treeTileX == 2 && treeTileY >= 9) x++; - else if (num == 3 && num2 >= 9) + else if (treeTileX == 3 && treeTileY >= 9) x--; tileSafely = Framing.GetTileSafely(x, y); diff --git a/Tiles/Furniture/BlueCandle.cs b/Tiles/Furniture/BlueCandle.cs index d9a694883b..e174008003 100644 --- a/Tiles/Furniture/BlueCandle.cs +++ b/Tiles/Furniture/BlueCandle.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/BlueCandle.png b/Tiles/Furniture/BlueCandle.png index db4aea46c8..5fe20f8f8b 100644 Binary files a/Tiles/Furniture/BlueCandle.png and b/Tiles/Furniture/BlueCandle.png differ diff --git a/Tiles/Furniture/PinkCandle.cs b/Tiles/Furniture/PinkCandle.cs index 7c7c674b71..fd4a947066 100644 --- a/Tiles/Furniture/PinkCandle.cs +++ b/Tiles/Furniture/PinkCandle.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/PinkCandle.png b/Tiles/Furniture/PinkCandle.png index a74d8acee8..e22cef9737 100644 Binary files a/Tiles/Furniture/PinkCandle.png and b/Tiles/Furniture/PinkCandle.png differ diff --git a/Tiles/Furniture/PurpleCandle.cs b/Tiles/Furniture/PurpleCandle.cs index 99e312788f..232603c410 100644 --- a/Tiles/Furniture/PurpleCandle.cs +++ b/Tiles/Furniture/PurpleCandle.cs @@ -17,12 +17,12 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AdjTiles = new int[] { TileID.Candles }; AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -30,7 +30,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/PurpleCandle.png b/Tiles/Furniture/PurpleCandle.png index e8c72dee6d..41e2f749a3 100644 Binary files a/Tiles/Furniture/PurpleCandle.png and b/Tiles/Furniture/PurpleCandle.png differ diff --git a/Tiles/Furniture/YellowCandle.cs b/Tiles/Furniture/YellowCandle.cs index 1df561d340..54779eadf4 100644 --- a/Tiles/Furniture/YellowCandle.cs +++ b/Tiles/Furniture/YellowCandle.cs @@ -15,11 +15,11 @@ namespace CalamityMod.Tiles.Furniture Main.tileLighted[Type] = true; Main.tileFrameImportant[Type] = true; Main.tileLavaDeath[Type] = true; - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2); + TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); TileObjectData.addTile(Type); AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch); AddMapEntry(new Color(238, 145, 105), CalamityUtils.GetItemName()); - AnimationFrameHeight = 34; + AnimationFrameHeight = 18; } public override void AnimateTile(ref int frame, ref int frameCounter) @@ -27,7 +27,7 @@ namespace CalamityMod.Tiles.Furniture frameCounter++; if (frameCounter >= 6) { - frame = (frame + 1) % 6; + frame = (frame + 1) % 5; frameCounter = 0; } } diff --git a/Tiles/Furniture/YellowCandle.png b/Tiles/Furniture/YellowCandle.png index 3bc79d5a42..74f2a263aa 100644 Binary files a/Tiles/Furniture/YellowCandle.png and b/Tiles/Furniture/YellowCandle.png differ diff --git a/Tiles/FurnitureAshen/AshenAccentSlab.cs b/Tiles/FurnitureAshen/AshenAccentSlab.cs index 5b213032b4..3c49bc54f5 100644 --- a/Tiles/FurnitureAshen/AshenAccentSlab.cs +++ b/Tiles/FurnitureAshen/AshenAccentSlab.cs @@ -514,7 +514,6 @@ namespace CalamityMod.Tiles.FurnitureAshen Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow").Value; Color drawColour = GetDrawColour(i, j, new Color(64, 64, 64, 64)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) { Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xDrawPos, yDrawPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); diff --git a/Tiles/FurnitureAshen/AshenSlab.cs b/Tiles/FurnitureAshen/AshenSlab.cs index 9c3713b9fd..21e695cc16 100644 --- a/Tiles/FurnitureAshen/AshenSlab.cs +++ b/Tiles/FurnitureAshen/AshenSlab.cs @@ -514,7 +514,6 @@ namespace CalamityMod.Tiles.FurnitureAshen Texture2D glowmask = ModContent.Request("CalamityMod/Tiles/FurnitureAshen/AshenSlabGlow").Value; Color drawColour = GetDrawColour(i, j, new Color(64, 64, 64, 64)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) { Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xDrawPos, yDrawPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); diff --git a/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs b/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs index 9e26729104..22bb415dbe 100644 --- a/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs +++ b/Tiles/FurniturePlaguedPlate/PlaguedPlate.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Tiles.FurniturePlaguedPlate Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(128, 128, 128, 128)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureProfaned/ProfanedRock.cs b/Tiles/FurnitureProfaned/ProfanedRock.cs index e955be3677..5ee5413580 100644 --- a/Tiles/FurnitureProfaned/ProfanedRock.cs +++ b/Tiles/FurnitureProfaned/ProfanedRock.cs @@ -222,7 +222,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(25, 25, 25, 25)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureProfaned/RunicProfanedBrick.cs b/Tiles/FurnitureProfaned/RunicProfanedBrick.cs index f861257602..c19ece8e26 100644 --- a/Tiles/FurnitureProfaned/RunicProfanedBrick.cs +++ b/Tiles/FurnitureProfaned/RunicProfanedBrick.cs @@ -54,7 +54,6 @@ namespace CalamityMod.Tiles.FurnitureProfaned Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(128, 128, 128, 128)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureStratus/StratusBricks.cs b/Tiles/FurnitureStratus/StratusBricks.cs index 27a94841bb..93062b4dc7 100644 --- a/Tiles/FurnitureStratus/StratusBricks.cs +++ b/Tiles/FurnitureStratus/StratusBricks.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Tiles.FurnitureStratus Vector2 zero = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureVoid/SmoothVoidstone.cs b/Tiles/FurnitureVoid/SmoothVoidstone.cs index 09c3a0cba8..0f58958ee4 100644 --- a/Tiles/FurnitureVoid/SmoothVoidstone.cs +++ b/Tiles/FurnitureVoid/SmoothVoidstone.cs @@ -228,7 +228,6 @@ namespace CalamityMod.Tiles.FurnitureVoid brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); drawColour *= brightness; - double num6 = Main.time * 0.08; TileFraming.SlopedGlowmask(i, j, 0, glowmask, drawOffset, null, GetDrawColour(i, j, drawColour), default); } diff --git a/Tiles/FurnitureVoid/VoidstoneSlab.cs b/Tiles/FurnitureVoid/VoidstoneSlab.cs index 3e104ec428..a225d5eb71 100644 --- a/Tiles/FurnitureVoid/VoidstoneSlab.cs +++ b/Tiles/FurnitureVoid/VoidstoneSlab.cs @@ -159,7 +159,6 @@ namespace CalamityMod.Tiles.FurnitureVoid Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + zero; Color drawColour = GetDrawColour(i, j, new Color(75, 75, 75, 75)); Tile trackTile = Main.tile[i, j]; - double num6 = Main.time * 0.08; if (!trackTile.IsHalfBlock && trackTile.Slope == 0) { Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColour, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f); diff --git a/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs b/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs index cc9bb319fe..9a12c0cc2e 100644 --- a/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs +++ b/Tiles/Rubblemaker/Abyss/MassiveRarePearlEcho.cs @@ -1,9 +1,8 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.ID; -using Terraria.DataStructures; -using Terraria.ModLoader; using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; using Terraria.ObjectData; namespace CalamityMod.Tiles.Rubblemaker.Abyss @@ -17,8 +16,8 @@ namespace CalamityMod.Tiles.Rubblemaker.Abyss Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(106, 80, 102)); DustType = 33; diff --git a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs index cd95f01c3f..2583c0c2f7 100644 --- a/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/MediumCoralEcho.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -17,8 +16,8 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(233, 132, 58)); DustType = DustID.Coralstone; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs index 5ee30cd7be..61a47c4125 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallWideCoralEcho.cs @@ -1,15 +1,9 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.DataStructures; -using Terraria.Enums; using Terraria.GameContent; +using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.Rubblemaker.SunkenSea { @@ -22,8 +16,8 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(137, 154, 71)); DustType = DustID.Coralstone; diff --git a/Tiles/SunkenSea/MediumCoral.cs b/Tiles/SunkenSea/MediumCoral.cs index 90399e6c3f..0b81d79d94 100644 --- a/Tiles/SunkenSea/MediumCoral.cs +++ b/Tiles/SunkenSea/MediumCoral.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; using Terraria.ObjectData; @@ -15,8 +14,8 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(233, 132, 58)); DustType = DustID.Coralstone; diff --git a/Tiles/SunkenSea/SmallWideCoral.cs b/Tiles/SunkenSea/SmallWideCoral.cs index 45408576e0..f0c524f145 100644 --- a/Tiles/SunkenSea/SmallWideCoral.cs +++ b/Tiles/SunkenSea/SmallWideCoral.cs @@ -1,14 +1,8 @@ -using CalamityMod.Projectiles.Environment; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; using Terraria; -using Terraria.Audio; using Terraria.ID; -using Terraria.DataStructures; -using Terraria.Enums; using Terraria.ModLoader; using Terraria.ObjectData; -using System; namespace CalamityMod.Tiles.SunkenSea { @@ -20,8 +14,8 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileLavaDeath[Type] = true; Main.tileWaterDeath[Type] = false; Main.tileNoAttach[Type] = true; - TileObjectData.newTile.DrawYOffset = 2; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x1); + TileObjectData.newTile.DrawYOffset = 2; TileObjectData.addTile(Type); AddMapEntry(new Color(137, 154, 71)); DustType = DustID.Coralstone; diff --git a/Utilities/FurnitureSetupUtils.cs b/Utilities/FurnitureSetupUtils.cs index 73ae83f344..093fbf5073 100644 --- a/Utilities/FurnitureSetupUtils.cs +++ b/Utilities/FurnitureSetupUtils.cs @@ -406,19 +406,19 @@ namespace CalamityMod { player.piggyBankProjTracker.Clear(); player.voidLensChest.Clear(); - int num213 = Chest.FindChest(left, top); - if (num213 != -1) + int dresserChestID = Chest.FindChest(left, top); + if (dresserChestID != -1) { Main.stackSplit = 600; - if (num213 == player.chest) + if (dresserChestID == player.chest) { player.chest = -1; Recipe.FindRecipes(); SoundEngine.PlaySound(SoundID.MenuClose); } - else if (num213 != player.chest && player.chest == -1) + else if (dresserChestID != player.chest && player.chest == -1) { - player.chest = num213; + player.chest = dresserChestID; Main.playerInventory = true; Main.recBigList = false; SoundEngine.PlaySound(SoundID.MenuOpen); @@ -427,7 +427,7 @@ namespace CalamityMod } else { - player.chest = num213; + player.chest = dresserChestID; Main.playerInventory = true; Main.recBigList = false; SoundEngine.PlaySound(SoundID.MenuTick); diff --git a/Utilities/GenericAIUtils.cs b/Utilities/GenericAIUtils.cs index 3743965ad5..fc86528c32 100644 --- a/Utilities/GenericAIUtils.cs +++ b/Utilities/GenericAIUtils.cs @@ -480,11 +480,11 @@ namespace CalamityMod if (npc.type == NPCID.SolarCrawltipedeTail) { Rectangle rect = npc.Hitbox; - int num5 = 8; - rect.X -= num5; - rect.Y -= num5; - rect.Width += num5 * 2; - rect.Height += num5 * 2; + int crawltipedeHitboxMod = 8; + rect.X -= crawltipedeHitboxMod; + rect.Y -= crawltipedeHitboxMod; + rect.Width += crawltipedeHitboxMod * 2; + rect.Height += crawltipedeHitboxMod * 2; stickingToNPC = projectile.Colliding(myRect, rect); } else @@ -526,15 +526,15 @@ namespace CalamityMod } if (projCount >= array2.Length) { - int num30 = 0; + int stuckProjAmt = 0; for (int m = 1; m < array2.Length; m++) { - if (array2[m].Y < array2[num30].Y) + if (array2[m].Y < array2[stuckProjAmt].Y) { - num30 = m; + stuckProjAmt = m; } } - Main.projectile[array2[num30].X].Kill(); + Main.projectile[array2[stuckProjAmt].X].Kill(); } } } diff --git a/Utilities/MiscUtils.cs b/Utilities/MiscUtils.cs index 6a294a5d54..dd81e33cd4 100644 --- a/Utilities/MiscUtils.cs +++ b/Utilities/MiscUtils.cs @@ -197,51 +197,51 @@ namespace CalamityMod public static void StartRain(bool torrentialTear = false, bool maxSeverity = false) { - int num = 86400; - int num2 = num / 24; - Main.rainTime = Main.rand.Next(num2 * 8, num); + int framesInDay = 86400; + int framesInHour = framesInDay / 24; + Main.rainTime = Main.rand.Next(framesInHour * 8, framesInDay); if (Main.rand.NextBool(3)) { - Main.rainTime += Main.rand.Next(0, num2); + Main.rainTime += Main.rand.Next(0, framesInHour); } if (Main.rand.NextBool(4)) { - Main.rainTime += Main.rand.Next(0, num2 * 2); + Main.rainTime += Main.rand.Next(0, framesInHour * 2); } if (Main.rand.NextBool(5)) { - Main.rainTime += Main.rand.Next(0, num2 * 2); + Main.rainTime += Main.rand.Next(0, framesInHour * 2); } if (Main.rand.NextBool(6)) { - Main.rainTime += Main.rand.Next(0, num2 * 3); + Main.rainTime += Main.rand.Next(0, framesInHour * 3); } if (Main.rand.NextBool(7)) { - Main.rainTime += Main.rand.Next(0, num2 * 4); + Main.rainTime += Main.rand.Next(0, framesInHour * 4); } if (Main.rand.NextBool(8)) { - Main.rainTime += Main.rand.Next(0, num2 * 5); + Main.rainTime += Main.rand.Next(0, framesInHour * 5); } - float num3 = 1f; + float randRainExtender = 1f; if (Main.rand.NextBool()) { - num3 += 0.05f; + randRainExtender += 0.05f; } if (Main.rand.NextBool(3)) { - num3 += 0.1f; + randRainExtender += 0.1f; } if (Main.rand.NextBool(4)) { - num3 += 0.15f; + randRainExtender += 0.15f; } if (Main.rand.NextBool(5)) { - num3 += 0.2f; + randRainExtender += 0.2f; } - Main.rainTime = (int)(Main.rainTime * num3); + Main.rainTime = (int)(Main.rainTime * randRainExtender); Main.raining = true; if (torrentialTear) TorrentialTear.AdjustRainSeverity(maxSeverity); diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 46a8140139..53a6444f8c 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee.Yoyos; -using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; @@ -19,7 +18,36 @@ namespace CalamityMod { public static partial class CalamityUtils { - public static int CountProjectiles(int Type) => Main.projectile.Count(proj => proj.type == Type && proj.active); + public static bool AnyProjectiles(int projectileID) + { + // Efficiently loop through all projectiles, using a specially designed continue continue that attempts to minimize the amount of OR + // checks per iteration. + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.type != projectileID || !p.active) + continue; + + return true; + } + + return false; + } + + public static IEnumerable AllProjectilesByID(int projectileID) + { + // This uses the same efficient loop idea as AnyProjectiles. + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p.type != projectileID || !p.active) + continue; + + yield return p; + } + } + + public static int CountProjectiles(int projectileID) => Main.projectile.Count(proj => proj.type == projectileID && proj.active); public static int CountHookProj() => Main.projectile.Count(proj => Main.projHook[proj.type] && proj.ai[0] == 2f && proj.active && proj.owner == Main.myPlayer); @@ -157,7 +185,7 @@ namespace CalamityMod public static Vector2 SuperhomeTowardsTarget(this Projectile projectile, NPC target, float homingSpeed, float inertia, float predictionStrength = 1f) { if (predictionStrength < 0.01f) { predictionStrength = 0.01f; } - Vector2 idealVelocity = CalculatePredictiveAimToTarget(projectile.Center, target, homingSpeed/predictionStrength) * predictionStrength; + Vector2 idealVelocity = CalculatePredictiveAimToTarget(projectile.Center, target, homingSpeed / predictionStrength) * predictionStrength; return (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; } #endregion diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index baf1b2f64b..981e12cdeb 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -114,13 +114,13 @@ namespace CalamityMod int height = 16; int yOffset = TileObjectData.GetTileData(tile).DrawYOffset; - ulong num190 = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); + ulong randShakeEffect = Main.TileFrameSeed ^ (ulong)((long)j << 32 | (long)(uint)i); float drawPositionX = i * 16 - (int)Main.screenPosition.X - (width - 16f) / 2f; float drawPositionY = j * 16 - (int)Main.screenPosition.Y; for (int c = 0; c < 7; c++) { - float shakeX = Utils.RandomInt(ref num190, -10, 11) * 0.15f; - float shakeY = Utils.RandomInt(ref num190, -10, 1) * 0.35f; + float shakeX = Utils.RandomInt(ref randShakeEffect, -10, 11) * 0.15f; + float shakeY = Utils.RandomInt(ref randShakeEffect, -10, 1) * 0.35f; Main.spriteBatch.Draw(flameTexture, new Vector2(drawPositionX + shakeX, drawPositionY + shakeY + yOffset) + zero, new Rectangle(tile.TileFrameX + offsetX, tile.TileFrameY + offsetY, width, height), new Color(100, 100, 100, 0), 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } } diff --git a/World/Abyss.cs b/World/Abyss.cs index 7cdca25089..92679c590e 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -810,29 +810,29 @@ namespace CalamityMod.World int islandTopY = Math.Clamp((int)(islandOrigin.Y - islandWidth * 0.5), 0, Main.maxTilesY); int islandBottomY = Math.Clamp((int)(islandOrigin.Y + islandWidth * 0.5), 0, Main.maxTilesY); - double num11 = islandWidth * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 - float num12 = islandOrigin.Y + 1f; + double extraIslandWidth = islandWidth * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 + float islandYOffset = islandOrigin.Y + 1f; for (int k = islandLeftX; k < islandRightX; k++) { if (WorldGen.genRand.NextBool(2)) { - num12 += (float)WorldGen.genRand.Next(-1, 2); + islandYOffset += (float)WorldGen.genRand.Next(-1, 2); } - if (num12 < islandOrigin.Y) + if (islandYOffset < islandOrigin.Y) { - num12 = islandOrigin.Y; + islandYOffset = islandOrigin.Y; } - if (num12 > islandOrigin.Y + 2f) + if (islandYOffset > islandOrigin.Y + 2f) { - num12 = islandOrigin.Y + 2f; + islandYOffset = islandOrigin.Y + 2f; } for (int l = islandTopY; l < islandBottomY; l++) { - if ((float)l > num12) + if ((float)l > islandYOffset) { - float arg_218_0 = Math.Abs((float)k - islandOrigin.X); - float num13 = Math.Abs((float)l - islandOrigin.Y) * 3f; - if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) + float tileCheckXDist = Math.Abs((float)k - islandOrigin.X); + float tileCheckYDist = Math.Abs((float)l - islandOrigin.Y) * 3f; + if (Math.Sqrt((double)(tileCheckXDist * tileCheckXDist + tileCheckYDist * tileCheckYDist)) < extraIslandWidth * 0.4) { if (k < islandPositionX) { @@ -879,17 +879,17 @@ namespace CalamityMod.World } } int m = islandPositionX; - int num15; - for (m += WorldGen.genRand.Next(5); m < islandPositionXAgain; m += WorldGen.genRand.Next(num15, (int)(num15 * 1.5))) + int randMinMaxValues; + for (m += WorldGen.genRand.Next(5); m < islandPositionXAgain; m += WorldGen.genRand.Next(randMinMaxValues, (int)(randMinMaxValues * 1.5))) { - int num14 = islandPositionY; - while (!Main.tile[m, num14].HasTile) + int islandTileY = islandPositionY; + while (!Main.tile[m, islandTileY].HasTile) { - num14--; + islandTileY--; } - num14 += WorldGen.genRand.Next(-3, 4); - num15 = WorldGen.genRand.Next(4, 8); - int num16 = tileType; + islandTileY += WorldGen.genRand.Next(-3, 4); + randMinMaxValues = WorldGen.genRand.Next(4, 8); + int placedTile = tileType; //chance to place clumps of whatever defined block if (hasClumps && WorldGen.genRand.NextBool(3)) @@ -898,30 +898,30 @@ namespace CalamityMod.World if (tileType != ModContent.TileType()) { //if scoria is enabled, then place it, otherwise place planty mush clumps - num16 = hasScoria ? ModContent.TileType() : ModContent.TileType(); + placedTile = hasScoria ? ModContent.TileType() : ModContent.TileType(); } //if the tile is pyre mantle then always place scoria else { //place molten pyre mantle and scorcia ore - num16 = hasScoria ? ModContent.TileType() : ModContent.TileType(); + placedTile = hasScoria ? ModContent.TileType() : ModContent.TileType(); } } - for (int n = m - num15; n <= m + num15; n++) + for (int n = m - randMinMaxValues; n <= m + randMinMaxValues; n++) { - for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) + for (int p = islandTileY - randMinMaxValues; p <= islandTileY + randMinMaxValues; p++) { - if (num17 > islandPositionYAgain) + if (p > islandPositionYAgain) { - float arg_409_0 = (float)Math.Abs(n - m); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) + float islandTileXDist = (float)Math.Abs(n - m); + float islandTileYDist = (float)(Math.Abs(p - islandTileY) * 2); + if (Math.Sqrt((double)(islandTileXDist * islandTileXDist + islandTileYDist * islandTileYDist)) < (double)(randMinMaxValues + WorldGen.genRand.Next(2))) { - Main.tile[n, num17].Get().HasTile = true; + Main.tile[n, p].Get().HasTile = true; - Main.tile[n, num17].TileType = (ushort)num16; - CalamityUtils.SafeSquareTileFrame(n, num17, true); + Main.tile[n, p].TileType = (ushort)placedTile; + CalamityUtils.SafeSquareTileFrame(n, p, true); } } } @@ -963,43 +963,43 @@ namespace CalamityMod.World vector2.Y = -0.2f; } } - int num23 = islandPositionX; - num23 += WorldGen.genRand.Next(5); - while (num23 < islandPositionXAgain) + int islandXOffsetPos = islandPositionX; + islandXOffsetPos += WorldGen.genRand.Next(5); + while (islandXOffsetPos < islandPositionXAgain) { - int num24 = islandPositionY; - while ((!Main.tile[num23, num24].HasTile || Main.tile[num23, num24].TileType != 0) && num23 < islandPositionXAgain) + int islandYOffsetPos = islandPositionY; + while ((!Main.tile[islandXOffsetPos, islandYOffsetPos].HasTile || Main.tile[islandXOffsetPos, islandYOffsetPos].TileType != 0) && islandXOffsetPos < islandPositionXAgain) { - num24--; - if (num24 < islandPositionYAgain) + islandYOffsetPos--; + if (islandYOffsetPos < islandPositionYAgain) { - num24 = islandPositionY; - num23 += WorldGen.genRand.Next(1, 4); + islandYOffsetPos = islandPositionY; + islandXOffsetPos += WorldGen.genRand.Next(1, 4); } } - if (num23 < islandPositionXAgain) + if (islandXOffsetPos < islandPositionXAgain) { - num24 += WorldGen.genRand.Next(0, 4); - int num25 = WorldGen.genRand.Next(2, 5); - int num26 = tileType; - for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) + islandYOffsetPos += WorldGen.genRand.Next(0, 4); + int islandOffsetRandValues = WorldGen.genRand.Next(2, 5); + int placeTile = tileType; + for (int r = islandXOffsetPos - islandOffsetRandValues; r <= islandXOffsetPos + islandOffsetRandValues; r++) { - for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) + for (int s = islandYOffsetPos - islandOffsetRandValues; s <= islandYOffsetPos + islandOffsetRandValues; s++) { - if (num28 > islandPositionYAgain) + if (s > islandPositionYAgain) { - float arg_890_0 = Math.Abs(num27 - num23); - float num29 = (Math.Abs(num28 - num24) * 2); - if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < num25) + float islandOffsetXDist = Math.Abs(r - islandXOffsetPos); + float islandOffsetYDist = (Math.Abs(s - islandYOffsetPos) * 2); + if (Math.Sqrt((double)(islandOffsetXDist * islandOffsetXDist + islandOffsetYDist * islandOffsetYDist)) < islandOffsetRandValues) { - Main.tile[num27, num28].TileType = (ushort)num26; - CalamityUtils.SafeSquareTileFrame(num27, num28, true); + Main.tile[r, s].TileType = (ushort)placeTile; + CalamityUtils.SafeSquareTileFrame(r, s, true); } } } } - num23 += WorldGen.genRand.Next(num25, (int)(num25 * 1.5)); + islandXOffsetPos += WorldGen.genRand.Next(islandOffsetRandValues, (int)(islandOffsetRandValues * 1.5)); } } } diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index d43940cfeb..68a534ad96 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -255,8 +255,8 @@ namespace CalamityMod.World { return false; } - int num = 35; - Rectangle rectangle = new Rectangle((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16); + int avoidRectangleSize = 35; + Rectangle rectangle = new Rectangle((i - avoidRectangleSize) * 16, (j - avoidRectangleSize) * 16, avoidRectangleSize * 2 * 16, avoidRectangleSize * 2 * 16); for (int k = 0; k < Main.maxPlayers; k++) { if (Main.player[k].active) @@ -279,9 +279,9 @@ namespace CalamityMod.World } } } - for (int m = i - num; m < i + num; m++) + for (int m = i - avoidRectangleSize; m < i + avoidRectangleSize; m++) { - for (int n = j - num; n < j + num; n++) + for (int n = j - avoidRectangleSize; n < j + avoidRectangleSize; n++) { if (Main.tile[m, n].HasTile && Main.tile[m, n].TileType == 21) { @@ -289,130 +289,130 @@ namespace CalamityMod.World } } } - num = rand.Next(17, 23); - for (int num2 = i - num; num2 < i + num; num2++) + avoidRectangleSize = rand.Next(17, 23); + for (int inc = i - avoidRectangleSize; inc < i + avoidRectangleSize; inc++) { - for (int num3 = j - num; num3 < j + num; num3++) + for (int doubleinc = j - avoidRectangleSize; doubleinc < j + avoidRectangleSize; doubleinc++) { - if (num3 > j + rand.Next(-2, 3) - 5) + if (doubleinc > j + rand.Next(-2, 3) - 5) { - float num4 = (float)Math.Abs(i - num2); - float num5 = (float)Math.Abs(j - num3); - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - if ((double)num6 < (double)num * 0.9 + (double)rand.Next(-4, 5)) + float tileXDist = (float)Math.Abs(i - inc); + float tileYDist = (float)Math.Abs(j - doubleinc); + float tileDistance = (float)Math.Sqrt((double)(tileXDist * tileXDist + tileYDist * tileYDist)); + if ((double)tileDistance < (double)avoidRectangleSize * 0.9 + (double)rand.Next(-4, 5)) { - if (Main.tile[num2, num3] != null) + if (Main.tile[inc, doubleinc] != null) { - if (!Main.tileSolid[(int)Main.tile[num2, num3].TileType]) + if (!Main.tileSolid[(int)Main.tile[inc, doubleinc].TileType]) { - Main.tile[num2, num3].Get().HasTile = false; + Main.tile[inc, doubleinc].Get().HasTile = false; } - Main.tile[num2, num3].TileType = (ushort)ModContent.TileType(); + Main.tile[inc, doubleinc].TileType = (ushort)ModContent.TileType(); } } } } } - num = WorldGen.genRand.Next(8, 14); - for (int num7 = i - num; num7 < i + num; num7++) + avoidRectangleSize = WorldGen.genRand.Next(8, 14); + for (int inc2 = i - avoidRectangleSize; inc2 < i + avoidRectangleSize; inc2++) { - for (int num8 = j - num; num8 < j + num; num8++) + for (int doubleinc2 = j - avoidRectangleSize; doubleinc2 < j + avoidRectangleSize; doubleinc2++) { - if (num8 > j + rand.Next(-2, 3) - 4) + if (doubleinc2 > j + rand.Next(-2, 3) - 4) { - float num9 = (float)Math.Abs(i - num7); - float num10 = (float)Math.Abs(j - num8); - float num11 = (float)Math.Sqrt((double)(num9 * num9 + num10 * num10)); - if ((double)num11 < (double)num * 0.8 + (double)rand.Next(-3, 4)) + float tileXDist2 = (float)Math.Abs(i - inc2); + float tileYDist2 = (float)Math.Abs(j - doubleinc2); + float tileDistance2 = (float)Math.Sqrt((double)(tileXDist2 * tileXDist2 + tileYDist2 * tileYDist2)); + if ((double)tileDistance2 < (double)avoidRectangleSize * 0.8 + (double)rand.Next(-3, 4)) { - if (Main.tile[num7, num8] != null) - Main.tile[num7, num8].Get().HasTile = false; + if (Main.tile[inc2, doubleinc2] != null) + Main.tile[inc2, doubleinc2].Get().HasTile = false; } } } } - num = WorldGen.genRand.Next(25, 35); - for (int num12 = i - num; num12 < i + num; num12++) + avoidRectangleSize = WorldGen.genRand.Next(25, 35); + for (int inc3 = i - avoidRectangleSize; inc3 < i + avoidRectangleSize; inc3++) { - for (int num13 = j - num; num13 < j + num; num13++) + for (int doubleinc3 = j - avoidRectangleSize; doubleinc3 < j + avoidRectangleSize; doubleinc3++) { - float num14 = (float)Math.Abs(i - num12); - float num15 = (float)Math.Abs(j - num13); - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.tile[num12, num13] != null) + float tileXDist3 = (float)Math.Abs(i - inc3); + float tileYDist3 = (float)Math.Abs(j - doubleinc3); + float tileDistance3 = (float)Math.Sqrt((double)(tileXDist3 * tileXDist3 + tileYDist3 * tileYDist3)); + if (Main.tile[inc3, doubleinc3] != null) { - if ((double)num16 < (double)num * 0.7) + if ((double)tileDistance3 < (double)avoidRectangleSize * 0.7) { - if (Main.tile[num12, num13].TileType == 5 || Main.tile[num12, num13].TileType == 32 || Main.tile[num12, num13].TileType == 352) + if (Main.tile[inc3, doubleinc3].TileType == 5 || Main.tile[inc3, doubleinc3].TileType == 32 || Main.tile[inc3, doubleinc3].TileType == 352) { try - { WorldGen.KillTile(num12, num13, false, false, true); } + { WorldGen.KillTile(inc3, doubleinc3, false, false, true); } catch (NullReferenceException) { } } - Main.tile[num12, num13].LiquidAmount = 0; + Main.tile[inc3, doubleinc3].LiquidAmount = 0; } - if (Main.tile[num12, num13].TileType == (ushort)ModContent.TileType()) + if (Main.tile[inc3, doubleinc3].TileType == (ushort)ModContent.TileType()) { - if (!WorldGen.SolidTile(num12 - 1, num13) && !WorldGen.SolidTile(num12 + 1, num13) && !WorldGen.SolidTile(num12, num13 - 1) && !WorldGen.SolidTile(num12, num13 + 1)) + if (!WorldGen.SolidTile(inc3 - 1, doubleinc3) && !WorldGen.SolidTile(inc3 + 1, doubleinc3) && !WorldGen.SolidTile(inc3, doubleinc3 - 1) && !WorldGen.SolidTile(inc3, doubleinc3 + 1)) { - Main.tile[num12, num13].Get().HasTile = false; + Main.tile[inc3, doubleinc3].Get().HasTile = false; } - else if ((Main.tile[num12, num13].IsHalfBlock || Main.tile[num12 - 1, num13].TopSlope) && !WorldGen.SolidTile(num12, num13 + 1)) + else if ((Main.tile[inc3, doubleinc3].IsHalfBlock || Main.tile[inc3 - 1, doubleinc3].TopSlope) && !WorldGen.SolidTile(inc3, doubleinc3 + 1)) { - Main.tile[num12, num13].Get().HasTile = false; + Main.tile[inc3, doubleinc3].Get().HasTile = false; } } - WorldGen.SquareTileFrame(num12, num13, true); - WorldGen.SquareWallFrame(num12, num13, true); + WorldGen.SquareTileFrame(inc3, doubleinc3, true); + WorldGen.SquareWallFrame(inc3, doubleinc3, true); } } } - num = WorldGen.genRand.Next(23, 32); - for (int num17 = i - num; num17 < i + num; num17++) + avoidRectangleSize = WorldGen.genRand.Next(23, 32); + for (int inc4 = i - avoidRectangleSize; inc4 < i + avoidRectangleSize; inc4++) { - for (int num18 = j - num; num18 < j + num; num18++) + for (int doubleinc4 = j - avoidRectangleSize; doubleinc4 < j + avoidRectangleSize; doubleinc4++) { - if (num18 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[num17, num18].HasTile && rand.NextBool(10)) + if (doubleinc4 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[inc4, doubleinc4].HasTile && rand.NextBool(10)) { - float num19 = (float)Math.Abs(i - num17); - float num20 = (float)Math.Abs(j - num18); - float num21 = (float)Math.Sqrt((double)(num19 * num19 + num20 * num20)); - if ((double)num21 < (double)num * 0.8) + float tileXDist4 = (float)Math.Abs(i - inc4); + float tileYDist4 = (float)Math.Abs(j - doubleinc4); + float tileDistance4 = (float)Math.Sqrt((double)(tileXDist4 * tileXDist4 + tileYDist4 * tileYDist4)); + if ((double)tileDistance4 < (double)avoidRectangleSize * 0.8) { - if (Main.tile[num17, num18] != null) + if (Main.tile[inc4, doubleinc4] != null) { - if (Main.tile[num17, num18].TileType == 5 || Main.tile[num17, num18].TileType == 32 || Main.tile[num17, num18].TileType == 352) + if (Main.tile[inc4, doubleinc4].TileType == 5 || Main.tile[inc4, doubleinc4].TileType == 32 || Main.tile[inc4, doubleinc4].TileType == 352) { - WorldGen.KillTile(num17, num18, false, false, false); + WorldGen.KillTile(inc4, doubleinc4, false, false, false); } - Main.tile[num17, num18].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(num17, num18, true); + Main.tile[inc4, doubleinc4].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(inc4, doubleinc4, true); } } } } } - num = WorldGen.genRand.Next(30, 38); - for (int num22 = i - num; num22 < i + num; num22++) + avoidRectangleSize = WorldGen.genRand.Next(30, 38); + for (int inc5 = i - avoidRectangleSize; inc5 < i + avoidRectangleSize; inc5++) { - for (int num23 = j - num; num23 < j + num; num23++) + for (int doubleinc5 = j - avoidRectangleSize; doubleinc5 < j + avoidRectangleSize; doubleinc5++) { - if (num23 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[num22, num23].HasTile && rand.NextBool(20)) + if (doubleinc5 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[inc5, doubleinc5].HasTile && rand.NextBool(20)) { - float num24 = (float)Math.Abs(i - num22); - float num25 = (float)Math.Abs(j - num23); - float num26 = (float)Math.Sqrt((double)(num24 * num24 + num25 * num25)); - if ((double)num26 < (double)num * 0.85) + float tileXDist5 = (float)Math.Abs(i - inc5); + float tileYDist5 = (float)Math.Abs(j - doubleinc5); + float tileDistance5 = (float)Math.Sqrt((double)(tileXDist5 * tileXDist5 + tileYDist5 * tileYDist5)); + if ((double)tileDistance5 < (double)avoidRectangleSize * 0.85) { - if (Main.tile[num22, num23] != null) + if (Main.tile[inc5, doubleinc5] != null) { - if (Main.tile[num22, num23].TileType == 5 || Main.tile[num22, num23].TileType == 32 || Main.tile[num22, num23].TileType == 352) + if (Main.tile[inc5, doubleinc5].TileType == 5 || Main.tile[inc5, doubleinc5].TileType == 32 || Main.tile[inc5, doubleinc5].TileType == 352) { - WorldGen.KillTile(num22, num23, false, false, false); + WorldGen.KillTile(inc5, doubleinc5, false, false, false); } - Main.tile[num22, num23].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(num22, num23, true); + Main.tile[inc5, doubleinc5].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(inc5, doubleinc5, true); } } } diff --git a/World/CustomDungeon.cs b/World/CustomDungeon.cs index fbfc39bf4f..553be3097f 100644 --- a/World/CustomDungeon.cs +++ b/World/CustomDungeon.cs @@ -54,28 +54,28 @@ namespace CalamityMod.World GenVars.numDRooms = 0; GenVars.numDDoors = 0; GenVars.numDungeonPlatforms = 0; - int num = WorldGen.genRand.Next(3); + int dungeonColor = WorldGen.genRand.Next(3); WorldGen.genRand.Next(3); if (WorldGen.remixWorldGen) - num = (WorldGen.crimson ? 2 : 0); + dungeonColor = (WorldGen.crimson ? 2 : 0); - ushort num2; - int num3; - switch (num) + ushort brickType; + int wallType; + switch (dungeonColor) { case 0: - num2 = 41; - num3 = 7; + brickType = 41; + wallType = 7; GenVars.crackedType = 481; break; case 1: - num2 = 43; - num3 = 8; + brickType = 43; + wallType = 8; GenVars.crackedType = 482; break; default: - num2 = 44; - num3 = 9; + brickType = 44; + wallType = 9; GenVars.crackedType = 483; break; } @@ -107,7 +107,7 @@ namespace CalamityMod.World num4 += (double)WorldGen.genRand.Next(0, (int)(num4 / 3.0)); double num5 = num4; int num6 = 5; - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); while (num4 > 0.0) { if (GenVars.dungeonX < GenVars.dMinX) @@ -131,26 +131,26 @@ namespace CalamityMod.World { int dungeonX = GenVars.dungeonX; int dungeonY = GenVars.dungeonY; - GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); if (WorldGen.genRand.NextBool()) - GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); GenVars.dungeonX = dungeonX; GenVars.dungeonY = dungeonY; } else { - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); } } else { - WorldGen.DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonHalls(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); } } - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); int num7 = GenVars.dRoomX[0]; int num8 = GenVars.dRoomY[0]; for (int i = 0; i < GenVars.numDRooms; i++) @@ -180,16 +180,16 @@ namespace CalamityMod.World num6 = 10; int dungeonX2 = GenVars.dungeonX; int dungeonY2 = GenVars.dungeonY; - GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, num2, num3, forceX: true); - WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + GenNewDungeonHalls(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType, forceX: true); + WorldGen.DungeonRoom(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); GenVars.dungeonX = dungeonX2; GenVars.dungeonY = dungeonY2; } - WorldGen.DungeonStairs(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonStairs(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); } - WorldGen.DungeonEnt(GenVars.dungeonX, GenVars.dungeonY, num2, num3); + WorldGen.DungeonEnt(GenVars.dungeonX, GenVars.dungeonY, brickType, wallType); Main.statusText = Lang.gen[58].Value + " 65%"; int num9 = Main.maxTilesX * 2; int num10; @@ -201,7 +201,7 @@ namespace CalamityMod.World num11 = (int)Main.worldSurface; int j = WorldGen.genRand.Next(num11, GenVars.dMaxY); - num10 = ((!WorldGen.DungeonPitTrap(i2, j, num2, num3)) ? (num10 + 1) : (num10 + 1500)); + num10 = ((!WorldGen.DungeonPitTrap(i2, j, brickType, wallType)) ? (num10 + 1) : (num10 + 1500)); } for (int k = 0; k < GenVars.numDRooms; k++) @@ -272,7 +272,7 @@ namespace CalamityMod.World num18 = WorldGen.genRand.Next(GenVars.dungeonY + 25, GenVars.dMaxY); int num19 = num17; - if (Main.tile[num17, num18].WallType == num3 && !Main.tile[num17, num18].Get().HasTile) + if (Main.tile[num17, num18].WallType == wallType && !Main.tile[num17, num18].Get().HasTile) { int num20 = 1; if (WorldGen.genRand.NextBool()) @@ -341,7 +341,7 @@ namespace CalamityMod.World int num22 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); int num23 = WorldGen.genRand.Next((int)Main.worldSurface + 25, GenVars.dMaxY); int num24 = num23; - if (Main.tile[num22, num23].WallType == num3 && !Main.tile[num22, num23].Get().HasTile) + if (Main.tile[num22, num23].WallType == wallType && !Main.tile[num22, num23].Get().HasTile) { int num25 = 1; if (WorldGen.genRand.NextBool()) @@ -506,40 +506,40 @@ namespace CalamityMod.World { Main.tile[num44, num47].Clear(TileDataType.Slope); Main.tile[num44, num47].Get().HasTile = true; - Main.tile[num44, num47].TileType = num2; - if (Main.tile[num44 - 1, num47].TileType == num2) + Main.tile[num44, num47].TileType = brickType; + if (Main.tile[num44 - 1, num47].TileType == brickType) { Main.tile[num44 - 1, num47].Get().HasTile = false; Main.tile[num44 - 1, num47].ClearEverything(); - Main.tile[num44 - 1, num47].WallType = (ushort)num3; + Main.tile[num44 - 1, num47].WallType = (ushort)wallType; } - if (Main.tile[num44 - 2, num47].TileType == num2) + if (Main.tile[num44 - 2, num47].TileType == brickType) { Main.tile[num44 - 2, num47].Get().HasTile = false; Main.tile[num44 - 2, num47].ClearEverything(); - Main.tile[num44 - 2, num47].WallType = (ushort)num3; + Main.tile[num44 - 2, num47].WallType = (ushort)wallType; } - if (Main.tile[num44 + 1, num47].TileType == num2) + if (Main.tile[num44 + 1, num47].TileType == brickType) { Main.tile[num44 + 1, num47].Get().HasTile = false; Main.tile[num44 + 1, num47].ClearEverything(); - Main.tile[num44 + 1, num47].WallType = (ushort)num3; + Main.tile[num44 + 1, num47].WallType = (ushort)wallType; } - if (Main.tile[num44 + 2, num47].TileType == num2) + if (Main.tile[num44 + 2, num47].TileType == brickType) { Main.tile[num44 + 2, num47].Get().HasTile = false; Main.tile[num44 + 2, num47].ClearEverything(); - Main.tile[num44 + 2, num47].WallType = (ushort)num3; + Main.tile[num44 + 2, num47].WallType = (ushort)wallType; } } int style = 13; if (WorldGen.genRand.NextBool(3)) { - switch (num3) + switch (wallType) { case 7: style = 16; @@ -567,19 +567,19 @@ namespace CalamityMod.World { Main.tile[num44, num49].Clear(TileDataType.Slope); Main.tile[num44, num49].Get().HasTile = true; - Main.tile[num44, num49].TileType = num2; - if (Main.tile[num44 - 1, num49].TileType == num2) + Main.tile[num44, num49].TileType = brickType; + if (Main.tile[num44 - 1, num49].TileType == brickType) { Main.tile[num44 - 1, num49].Get().HasTile = false; Main.tile[num44 - 1, num49].ClearEverything(); - Main.tile[num44 - 1, num49].WallType = (ushort)num3; + Main.tile[num44 - 1, num49].WallType = (ushort)wallType; } - if (Main.tile[num44 - 2, num49].TileType == num2) + if (Main.tile[num44 - 2, num49].TileType == brickType) { Main.tile[num44 - 2, num49].Get().HasTile = false; Main.tile[num44 - 2, num49].ClearEverything(); - Main.tile[num44 - 2, num49].WallType = (ushort)num3; + Main.tile[num44 - 2, num49].WallType = (ushort)wallType; } } } @@ -597,19 +597,19 @@ namespace CalamityMod.World { Main.tile[num44, num50].Get().HasTile = true; Main.tile[num44, num50].Clear(TileDataType.Slope); - Main.tile[num44, num50].TileType = num2; - if (Main.tile[num44 + 1, num50].TileType == num2) + Main.tile[num44, num50].TileType = brickType; + if (Main.tile[num44 + 1, num50].TileType == brickType) { Main.tile[num44 + 1, num50].Get().HasTile = false; Main.tile[num44 + 1, num50].ClearEverything(); - Main.tile[num44 + 1, num50].WallType = (ushort)num3; + Main.tile[num44 + 1, num50].WallType = (ushort)wallType; } - if (Main.tile[num44 + 2, num50].TileType == num2) + if (Main.tile[num44 + 2, num50].TileType == brickType) { Main.tile[num44 + 2, num50].Get().HasTile = false; Main.tile[num44 + 2, num50].ClearEverything(); - Main.tile[num44 + 2, num50].WallType = (ushort)num3; + Main.tile[num44 + 2, num50].WallType = (ushort)wallType; } } } @@ -618,45 +618,45 @@ namespace CalamityMod.World num44--; for (int num51 = num45 - 8; num51 < num45; num51++) { - if (Main.tile[num44 + 2, num51].TileType == num2) + if (Main.tile[num44 + 2, num51].TileType == brickType) { Main.tile[num44 + 2, num51].Get().HasTile = false; Main.tile[num44 + 2, num51].ClearEverything(); - Main.tile[num44 + 2, num51].WallType = (ushort)num3; + Main.tile[num44 + 2, num51].WallType = (ushort)wallType; } - if (Main.tile[num44 + 3, num51].TileType == num2) + if (Main.tile[num44 + 3, num51].TileType == brickType) { Main.tile[num44 + 3, num51].Get().HasTile = false; Main.tile[num44 + 3, num51].ClearEverything(); - Main.tile[num44 + 3, num51].WallType = (ushort)num3; + Main.tile[num44 + 3, num51].WallType = (ushort)wallType; } - if (Main.tile[num44 - 2, num51].TileType == num2) + if (Main.tile[num44 - 2, num51].TileType == brickType) { Main.tile[num44 - 2, num51].Get().HasTile = false; Main.tile[num44 - 2, num51].ClearEverything(); - Main.tile[num44 - 2, num51].WallType = (ushort)num3; + Main.tile[num44 - 2, num51].WallType = (ushort)wallType; } - if (Main.tile[num44 - 3, num51].TileType == num2) + if (Main.tile[num44 - 3, num51].TileType == brickType) { Main.tile[num44 - 3, num51].Get().HasTile = false; Main.tile[num44 - 3, num51].ClearEverything(); - Main.tile[num44 - 3, num51].WallType = (ushort)num3; + Main.tile[num44 - 3, num51].WallType = (ushort)wallType; } } Main.tile[num44 - 1, num45].Get().HasTile = true; - Main.tile[num44 - 1, num45].TileType = num2; + Main.tile[num44 - 1, num45].TileType = brickType; Main.tile[num44 - 1, num45].Clear(TileDataType.Slope); Main.tile[num44 + 1, num45].Get().HasTile = true; - Main.tile[num44 + 1, num45].TileType = num2; + Main.tile[num44 + 1, num45].TileType = brickType; Main.tile[num44 + 1, num45].Clear(TileDataType.Slope); } int[] array = new int[3]; - switch (num3) + switch (wallType) { case 7: array[0] = 7; @@ -787,7 +787,7 @@ namespace CalamityMod.World Main.tile[num76, num77].Get().HasTile = true; Main.tile[num76, num77].TileType = 19; Main.tile[num76, num77].Clear(TileDataType.Slope); - switch (num3) + switch (wallType) { case 7: Main.tile[num76, num77].TileFrameY = 108; @@ -809,7 +809,7 @@ namespace CalamityMod.World Main.tile[num78, num77].Get().HasTile = true; Main.tile[num78, num77].TileType = 19; Main.tile[num78, num77].Clear(TileDataType.Slope); - switch (num3) + switch (wallType) { case 7: Main.tile[num78, num77].TileFrameY = 108; @@ -1115,12 +1115,12 @@ namespace CalamityMod.World num13 = 0; num14 = 1000; num15 = 0; - MakeDungeon_Lights(num2, ref num13, num14, ref num15, array); + MakeDungeon_Lights(brickType, ref num13, num14, ref num15, array); num13 = 0; num14 = 1000; num15 = 0; MakeDungeon_Traps(ref num13, num14, ref num15); - double count = MakeDungeon_GroundFurniture(num3); + double count = MakeDungeon_GroundFurniture(wallType); count = MakeDungeon_Pictures(array, count); count = MakeDungeon_Banners(array, count); @@ -1164,13 +1164,13 @@ namespace CalamityMod.World { failCount++; int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - while ((double)num2 < Main.worldSurface) + int brickType = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); + while ((double)brickType < Main.worldSurface) { - num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); + brickType = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); } - if (Main.wallDungeon[Main.tile[num, num2].WallType] && WorldGen.placeTrap(num, num2, 0)) + if (Main.wallDungeon[Main.tile[num, brickType].WallType] && WorldGen.placeTrap(num, brickType, 0)) failCount = failMax; if (failCount > failMax) @@ -1205,17 +1205,17 @@ namespace CalamityMod.World { failCount++; int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - if (Main.wallDungeon[Main.tile[num, num2].WallType]) + int brickType = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); + if (Main.wallDungeon[Main.tile[num, brickType].WallType]) { - for (int num3 = num2; num3 > GenVars.dMinY; num3--) + for (int wallType = brickType; wallType > GenVars.dMinY; wallType--) { - if (Main.tile[num, num3 - 1].HasTile && Main.tile[num, num3 - 1].TileType == tileType) + if (Main.tile[num, wallType - 1].HasTile && Main.tile[num, wallType - 1].TileType == tileType) { bool flag = false; for (int i = num - 15; i < num + 15; i++) { - for (int j = num3 - 15; j < num3 + 15; j++) + for (int j = wallType - 15; j < wallType + 15; j++) { if (i > 0 && i < Main.maxTilesX && j > 0 && j < Main.maxTilesY && (Main.tile[i, j].TileType == 42 || Main.tile[i, j].TileType == 34)) { @@ -1225,7 +1225,7 @@ namespace CalamityMod.World } } - if (Main.tile[num - 1, num3].HasTile || Main.tile[num + 1, num3].HasTile || Main.tile[num - 1, num3 + 1].HasTile || Main.tile[num + 1, num3 + 1].HasTile || Main.tile[num, num3 + 2].HasTile) + if (Main.tile[num - 1, wallType].HasTile || Main.tile[num + 1, wallType].HasTile || Main.tile[num - 1, wallType + 1].HasTile || Main.tile[num + 1, wallType + 1].HasTile || Main.tile[num, wallType + 2].HasTile) flag = true; if (flag) @@ -1251,7 +1251,7 @@ namespace CalamityMod.World bool flag3 = false; for (int k = 0; k < 15; k++) { - if (WorldGen.SolidTile(num, num3 + k)) + if (WorldGen.SolidTile(num, wallType + k)) { flag3 = true; break; @@ -1259,9 +1259,9 @@ namespace CalamityMod.World } if (!flag3) - WorldGen.PlaceChand(num, num3, 34, style); + WorldGen.PlaceChand(num, wallType, 34, style); - if (Main.tile[num, num3].TileType == 34) + if (Main.tile[num, wallType].TileType == 34) { flag2 = true; failCount = 0; @@ -1269,8 +1269,8 @@ namespace CalamityMod.World for (int l = 0; l < 1000; l++) { int num4 = num + WorldGen.genRand.Next(-12, 13); - int num5 = num3 + WorldGen.genRand.Next(3, 21); - if (Main.tile[num4, num5].HasTile || Main.tile[num4, num5 + 1].HasTile || !Main.tileDungeon[Main.tile[num4 - 1, num5].TileType] || !Main.tileDungeon[Main.tile[num4 + 1, num5].TileType] || !Collision.CanHit(new Point(num4 * 16, num5 * 16), 16, 16, new Point(num * 16, num3 * 16 + 1), 16, 16)) + int num5 = wallType + WorldGen.genRand.Next(3, 21); + if (Main.tile[num4, num5].HasTile || Main.tile[num4, num5 + 1].HasTile || !Main.tileDungeon[Main.tile[num4 - 1, num5].TileType] || !Main.tileDungeon[Main.tile[num4 + 1, num5].TileType] || !Collision.CanHit(new Point(num4 * 16, num5 * 16), 16, 16, new Point(num * 16, wallType * 16 + 1), 16, 16)) continue; if (((WorldGen.SolidTile(num4 - 1, num5) && Main.tile[num4 - 1, num5].TileType != 10) || (WorldGen.SolidTile(num4 + 1, num5) && Main.tile[num4 + 1, num5].TileType != 10) || WorldGen.SolidTile(num4, num5 + 1)) && Main.wallDungeon[Main.tile[num4, num5].WallType] && (Main.tileDungeon[Main.tile[num4 - 1, num5].TileType] || Main.tileDungeon[Main.tile[num4 + 1, num5].TileType])) @@ -1279,7 +1279,7 @@ namespace CalamityMod.World if (!Main.tile[num4, num5].HasTile) continue; - while (num4 != num || num5 != num3) + while (num4 != num || num5 != wallType) { Main.tile[num4, num5].Get().RedWire = true; if (num4 > num) @@ -1289,10 +1289,10 @@ namespace CalamityMod.World num4++; Main.tile[num4, num5].Get().RedWire = true; - if (num5 > num3) + if (num5 > wallType) num5--; - if (num5 < num3) + if (num5 < wallType) num5++; Main.tile[num4, num5].Get().RedWire = true; @@ -1300,8 +1300,8 @@ namespace CalamityMod.World if (WorldGen.genRand.Next(3) > 0) { - Main.tile[num, num3].TileFrameX = 18; - Main.tile[num, num3 + 1].TileFrameX = 18; + Main.tile[num, wallType].TileFrameX = 18; + Main.tile[num, wallType + 1].TileFrameX = 18; } break; @@ -1313,14 +1313,14 @@ namespace CalamityMod.World break; int style2 = array[0]; - if (Main.tile[num, num3].WallType == roomWall[1]) + if (Main.tile[num, wallType].WallType == roomWall[1]) style2 = array[1]; - if (Main.tile[num, num3].WallType == roomWall[2]) + if (Main.tile[num, wallType].WallType == roomWall[2]) style2 = array[2]; - WorldGen.Place1x2Top(num, num3, 42, style2); - if (Main.tile[num, num3].TileType != 42) + WorldGen.Place1x2Top(num, wallType, 42, style2); + if (Main.tile[num, wallType].TileType != 42) break; flag2 = true; @@ -1329,8 +1329,8 @@ namespace CalamityMod.World for (int m = 0; m < 1000; m++) { int num6 = num + WorldGen.genRand.Next(-12, 13); - int num7 = num3 + WorldGen.genRand.Next(3, 21); - if (Main.tile[num6, num7].HasTile || Main.tile[num6, num7 + 1].HasTile || Main.tile[num6 - 1, num7].TileType == 48 || Main.tile[num6 + 1, num7].TileType == 48 || !Collision.CanHit(new Point(num6 * 16, num7 * 16), 16, 16, new Point(num * 16, num3 * 16 + 1), 16, 16)) + int num7 = wallType + WorldGen.genRand.Next(3, 21); + if (Main.tile[num6, num7].HasTile || Main.tile[num6, num7 + 1].HasTile || Main.tile[num6 - 1, num7].TileType == 48 || Main.tile[num6 + 1, num7].TileType == 48 || !Collision.CanHit(new Point(num6 * 16, num7 * 16), 16, 16, new Point(num * 16, wallType * 16 + 1), 16, 16)) continue; if ((WorldGen.SolidTile(num6 - 1, num7) && Main.tile[num6 - 1, num7].TileType != 10) || (WorldGen.SolidTile(num6 + 1, num7) && Main.tile[num6 + 1, num7].TileType != 10) || WorldGen.SolidTile(num6, num7 + 1)) @@ -1339,7 +1339,7 @@ namespace CalamityMod.World if (!Main.tile[num6, num7].HasTile) continue; - while (num6 != num || num7 != num3) + while (num6 != num || num7 != wallType) { Main.tile[num6, num7].Get().RedWire = true; if (num6 > num) @@ -1349,10 +1349,10 @@ namespace CalamityMod.World num6++; Main.tile[num6, num7].Get().RedWire = true; - if (num7 > num3) + if (num7 > wallType) num7--; - if (num7 < num3) + if (num7 < wallType) num7++; Main.tile[num6, num7].Get().RedWire = true; @@ -1360,8 +1360,8 @@ namespace CalamityMod.World if (WorldGen.genRand.Next(3) > 0) { - Main.tile[num, num3].TileFrameX = 18; - Main.tile[num, num3 + 1].TileFrameX = 18; + Main.tile[num, wallType].TileFrameX = 18; + Main.tile[num, wallType + 1].TileFrameX = 18; } break; @@ -1386,26 +1386,26 @@ namespace CalamityMod.World for (int i = 0; (double)i < count; i++) { int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); - while (!Main.wallDungeon[Main.tile[num, num2].WallType] || Main.tile[num, num2].HasTile) + int brickType = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); + while (!Main.wallDungeon[Main.tile[num, brickType].WallType] || Main.tile[num, brickType].HasTile) { num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - num2 = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); + brickType = WorldGen.genRand.Next(GenVars.dMinY, GenVars.dMaxY); } - while (!WorldGen.SolidTile(num, num2) && num2 > 10) + while (!WorldGen.SolidTile(num, brickType) && brickType > 10) { - num2--; + brickType--; } - num2++; - if (!Main.wallDungeon[Main.tile[num, num2].WallType] || Main.tile[num, num2 - 1].TileType == 48 || Main.tile[num, num2].HasTile || Main.tile[num, num2 + 1].HasTile || Main.tile[num, num2 + 2].HasTile || Main.tile[num, num2 + 3].HasTile) + brickType++; + if (!Main.wallDungeon[Main.tile[num, brickType].WallType] || Main.tile[num, brickType - 1].TileType == 48 || Main.tile[num, brickType].HasTile || Main.tile[num, brickType + 1].HasTile || Main.tile[num, brickType + 2].HasTile || Main.tile[num, brickType + 3].HasTile) continue; bool flag = true; for (int j = num - 1; j <= num + 1; j++) { - for (int k = num2; k <= num2 + 3; k++) + for (int k = brickType; k <= brickType + 3; k++) { if (Main.tile[j, k].HasTile && (Main.tile[j, k].TileType == 10 || Main.tile[j, k].TileType == 11 || Main.tile[j, k].TileType == 91)) flag = false; @@ -1414,15 +1414,15 @@ namespace CalamityMod.World if (flag) { - int num3 = 10; - if (Main.tile[num, num2].WallType == roomWall[1]) - num3 = 12; + int wallType = 10; + if (Main.tile[num, brickType].WallType == roomWall[1]) + wallType = 12; - if (Main.tile[num, num2].WallType == roomWall[2]) - num3 = 14; + if (Main.tile[num, brickType].WallType == roomWall[2]) + wallType = 14; - num3 += WorldGen.genRand.Next(2); - WorldGen.PlaceTile(num, num2, 91, mute: true, forced: false, -1, num3); + wallType += WorldGen.genRand.Next(2); + WorldGen.PlaceTile(num, brickType, 91, mute: true, forced: false, -1, wallType); } } @@ -1435,37 +1435,37 @@ namespace CalamityMod.World for (int i = 0; (double)i < count; i++) { int num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - int num2 = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); - while (!Main.wallDungeon[Main.tile[num, num2].WallType] || Main.tile[num, num2].HasTile) + int brickType = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); + while (!Main.wallDungeon[Main.tile[num, brickType].WallType] || Main.tile[num, brickType].HasTile) { num = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); - num2 = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); + brickType = WorldGen.genRand.Next((int)Main.worldSurface, GenVars.dMaxY); } - int num3 = num; + int wallType = num; int num4 = num; - int num5 = num2; - int num6 = num2; + int num5 = brickType; + int num6 = brickType; int num7 = 0; int num8 = 0; for (int j = 0; j < 2; j++) { - num3 = num; + wallType = num; num4 = num; - while (!Main.tile[num3, num2].HasTile && Main.wallDungeon[Main.tile[num3, num2].WallType]) + while (!Main.tile[wallType, brickType].HasTile && Main.wallDungeon[Main.tile[wallType, brickType].WallType]) { - num3--; + wallType--; } - num3++; - for (; !Main.tile[num4, num2].HasTile && Main.wallDungeon[Main.tile[num4, num2].WallType]; num4++) + wallType++; + for (; !Main.tile[num4, brickType].HasTile && Main.wallDungeon[Main.tile[num4, brickType].WallType]; num4++) { } num4--; - num = (num3 + num4) / 2; - num5 = num2; - num6 = num2; + num = (wallType + num4) / 2; + num5 = brickType; + num6 = brickType; while (!Main.tile[num, num5].HasTile && Main.wallDungeon[Main.tile[num, num5].WallType]) { num5--; @@ -1477,24 +1477,24 @@ namespace CalamityMod.World } num6--; - num2 = (num5 + num6) / 2; + brickType = (num5 + num6) / 2; } - num3 = num; + wallType = num; num4 = num; - while (!Main.tile[num3, num2].HasTile && !Main.tile[num3, num2 - 1].HasTile && !Main.tile[num3, num2 + 1].HasTile) + while (!Main.tile[wallType, brickType].HasTile && !Main.tile[wallType, brickType - 1].HasTile && !Main.tile[wallType, brickType + 1].HasTile) { - num3--; + wallType--; } - num3++; - for (; !Main.tile[num4, num2].HasTile && !Main.tile[num4, num2 - 1].HasTile && !Main.tile[num4, num2 + 1].HasTile; num4++) + wallType++; + for (; !Main.tile[num4, brickType].HasTile && !Main.tile[num4, brickType - 1].HasTile && !Main.tile[num4, brickType + 1].HasTile; num4++) { } num4--; - num5 = num2; - num6 = num2; + num5 = brickType; + num6 = brickType; while (!Main.tile[num, num5].HasTile && !Main.tile[num - 1, num5].HasTile && !Main.tile[num + 1, num5].HasTile) { num5--; @@ -1506,9 +1506,9 @@ namespace CalamityMod.World } num6--; - num = (num3 + num4) / 2; - num2 = (num5 + num6) / 2; - num7 = num4 - num3; + num = (wallType + num4) / 2; + brickType = (num5 + num6) / 2; + num7 = num4 - wallType; num8 = num6 - num5; if (num7 <= 7 || num8 <= 5) continue; @@ -1527,7 +1527,7 @@ namespace CalamityMod.World array[2] = true; int num9 = WorldGen.genRand.Next(3); - if (Main.tile[num, num2].WallType == roomWall[0]) + if (Main.tile[num, brickType].WallType == roomWall[0]) num9 = 0; while (!array[num9]) @@ -1535,7 +1535,7 @@ namespace CalamityMod.World num9 = WorldGen.genRand.Next(3); } - if (WorldGen.nearPicture2(num, num2)) + if (WorldGen.nearPicture2(num, brickType)) num9 = -1; switch (num9) @@ -1543,26 +1543,26 @@ namespace CalamityMod.World case 0: { PaintingEntry paintingEntry2 = WorldGen.RandPictureTile(); - if (Main.tile[num, num2].WallType != roomWall[0]) + if (Main.tile[num, brickType].WallType != roomWall[0]) paintingEntry2 = WorldGen.RandBonePicture(); - if (!WorldGen.nearPicture(num, num2)) - WorldGen.PlaceTile(num, num2, paintingEntry2.tileType, mute: true, forced: false, -1, paintingEntry2.style); + if (!WorldGen.nearPicture(num, brickType)) + WorldGen.PlaceTile(num, brickType, paintingEntry2.tileType, mute: true, forced: false, -1, paintingEntry2.style); break; } case 1: { PaintingEntry paintingEntry3 = WorldGen.RandPictureTile(); - if (Main.tile[num, num2].WallType != roomWall[0]) + if (Main.tile[num, brickType].WallType != roomWall[0]) paintingEntry3 = WorldGen.RandBonePicture(); - if (!Main.tile[num, num2].HasTile) - WorldGen.PlaceTile(num, num2, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style); + if (!Main.tile[num, brickType].HasTile) + WorldGen.PlaceTile(num, brickType, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style); int num13 = num; - int num14 = num2; - int num15 = num2; + int num14 = brickType; + int num15 = brickType; for (int m = 0; m < 2; m++) { num += 7; @@ -1590,7 +1590,7 @@ namespace CalamityMod.World WorldGen.PlaceTile(num, num15, paintingEntry3.tileType, mute: true, forced: false, -1, paintingEntry3.style); } - num15 = num2; + num15 = brickType; num = num13; for (int n = 0; n < 2; n++) { @@ -1624,69 +1624,69 @@ namespace CalamityMod.World case 2: { PaintingEntry paintingEntry = WorldGen.RandPictureTile(); - if (Main.tile[num, num2].WallType != roomWall[0]) + if (Main.tile[num, brickType].WallType != roomWall[0]) paintingEntry = WorldGen.RandBonePicture(); - if (!Main.tile[num, num2].HasTile) - WorldGen.PlaceTile(num, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); + if (!Main.tile[num, brickType].HasTile) + WorldGen.PlaceTile(num, brickType, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); - int num10 = num2; + int num10 = brickType; int num11 = num; int num12 = num; for (int k = 0; k < 3; k++) { - num2 += 7; - num3 = num12; + brickType += 7; + wallType = num12; num4 = num12; - while (!Main.tile[num3, num2].HasTile && !Main.tile[num3, num2 - 1].HasTile && !Main.tile[num3, num2 + 1].HasTile) + while (!Main.tile[wallType, brickType].HasTile && !Main.tile[wallType, brickType - 1].HasTile && !Main.tile[wallType, brickType + 1].HasTile) { - num3--; + wallType--; } - num3++; - for (; !Main.tile[num4, num2].HasTile && !Main.tile[num4, num2 - 1].HasTile && !Main.tile[num4, num2 + 1].HasTile; num4++) + wallType++; + for (; !Main.tile[num4, brickType].HasTile && !Main.tile[num4, brickType - 1].HasTile && !Main.tile[num4, brickType + 1].HasTile; num4++) { } num4--; - num12 = (num3 + num4) / 2; + num12 = (wallType + num4) / 2; paintingEntry = WorldGen.RandPictureTile(); - if (Main.tile[num12, num2].WallType != roomWall[0]) + if (Main.tile[num12, brickType].WallType != roomWall[0]) paintingEntry = WorldGen.RandBonePicture(); - if (Math.Abs(num11 - num12) >= 4 || WorldGen.nearPicture(num12, num2)) + if (Math.Abs(num11 - num12) >= 4 || WorldGen.nearPicture(num12, brickType)) break; - WorldGen.PlaceTile(num12, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); + WorldGen.PlaceTile(num12, brickType, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); } num12 = num; - num2 = num10; + brickType = num10; for (int l = 0; l < 3; l++) { - num2 -= 7; - num3 = num12; + brickType -= 7; + wallType = num12; num4 = num12; - while (!Main.tile[num3, num2].HasTile && !Main.tile[num3, num2 - 1].HasTile && !Main.tile[num3, num2 + 1].HasTile) + while (!Main.tile[wallType, brickType].HasTile && !Main.tile[wallType, brickType - 1].HasTile && !Main.tile[wallType, brickType + 1].HasTile) { - num3--; + wallType--; } - num3++; - for (; !Main.tile[num4, num2].HasTile && !Main.tile[num4, num2 - 1].HasTile && !Main.tile[num4, num2 + 1].HasTile; num4++) + wallType++; + for (; !Main.tile[num4, brickType].HasTile && !Main.tile[num4, brickType - 1].HasTile && !Main.tile[num4, brickType + 1].HasTile; num4++) { } num4--; - num12 = (num3 + num4) / 2; + num12 = (wallType + num4) / 2; paintingEntry = WorldGen.RandPictureTile(); - if (Main.tile[num12, num2].WallType != roomWall[0]) + if (Main.tile[num12, brickType].WallType != roomWall[0]) paintingEntry = WorldGen.RandBonePicture(); - if (Math.Abs(num11 - num12) >= 4 || WorldGen.nearPicture(num12, num2)) + if (Math.Abs(num11 - num12) >= 4 || WorldGen.nearPicture(num12, brickType)) break; - WorldGen.PlaceTile(num12, num2, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); + WorldGen.PlaceTile(num12, brickType, paintingEntry.tileType, mute: true, forced: false, -1, paintingEntry.style); } break; @@ -1700,11 +1700,11 @@ namespace CalamityMod.World public static double MakeDungeon_GroundFurniture(int wallType) { double num = (double)(2000 * Main.maxTilesX) / 4200.0; - int num2 = 1 + (int)((double)Main.maxTilesX / 4200.0); - int num3 = 1 + (int)((double)Main.maxTilesX / 4200.0); + int brickType = 1 + (int)((double)Main.maxTilesX / 4200.0); + int backWallType = 1 + (int)((double)Main.maxTilesX / 4200.0); for (int i = 0; (double)i < num; i++) { - if (num2 > 0 || num3 > 0) + if (brickType > 0 || backWallType > 0) i--; int num4 = WorldGen.genRand.Next(GenVars.dMinX, GenVars.dMaxX); @@ -1755,7 +1755,7 @@ namespace CalamityMod.World int num15 = 22; int num16 = 24; int num17 = 30; - switch (wallType) + switch (backWallType) { case 8: style = 14; @@ -1913,19 +1913,19 @@ namespace CalamityMod.World if ((double)num6 < (double)num19 * 1.75) num18 = -1; - if (num2 > 0 || num3 > 0) + if (brickType > 0 || backWallType > 0) { - if (num2 > 0) + if (brickType > 0) { WorldGen.PlaceTile(num7, j, 355, mute: true); if (Main.tile[num7, j].TileType == 355) - num2--; + brickType--; } - else if (num3 > 0) + else if (backWallType > 0) { WorldGen.PlaceTile(num7, j, 354, mute: true); if (Main.tile[num7, j].TileType == 354) - num3--; + backWallType--; } continue; @@ -2075,10 +2075,10 @@ namespace CalamityMod.World { Vector2D zero = Vector2D.Zero; double num = WorldGen.genRand.Next(4, 6); - double num2 = num; + double brickType = num; Vector2D zero2 = Vector2D.Zero; Vector2D zero3 = Vector2D.Zero; - int num3 = 1; + int newWallType = 1; Vector2D vector2D = default(Vector2D); vector2D.X = i; @@ -2119,7 +2119,7 @@ namespace CalamityMod.World bool flag10 = false; for (int num6 = j; num6 > j - num5; num6--) { - if (Main.tile[i, num6].WallType == wallType) + if (Main.tile[i, num6].WallType == newWallType) { if (flag10) { @@ -2136,7 +2136,7 @@ namespace CalamityMod.World flag10 = false; for (int k = j; k < j + num5; k++) { - if (Main.tile[i, k].WallType == wallType) + if (Main.tile[i, k].WallType == newWallType) { if (flag10) { @@ -2153,7 +2153,7 @@ namespace CalamityMod.World flag10 = false; for (int num7 = i; num7 > i - num5; num7--) { - if (Main.tile[num7, j].WallType == wallType) + if (Main.tile[num7, j].WallType == newWallType) { if (flag10) { @@ -2170,7 +2170,7 @@ namespace CalamityMod.World flag10 = false; for (int l = i; l < i + num5; l++) { - if (Main.tile[l, j].WallType == wallType) + if (Main.tile[l, j].WallType == newWallType) { if (flag10) { @@ -2186,7 +2186,7 @@ namespace CalamityMod.World if (!flag8 && !flag9 && !flag6 && !flag7) { - num3 = (WorldGen.genRand.NextBool() ? 1 : (-1)); + newWallType = (WorldGen.genRand.NextBool() ? 1 : (-1)); if (WorldGen.genRand.NextBool()) flag5 = true; } @@ -2201,21 +2201,21 @@ namespace CalamityMod.World switch (num8) { case 0: - num3 = -1; + newWallType = -1; break; case 1: - num3 = 1; + newWallType = 1; break; default: flag5 = true; - num3 = ((num8 != 2) ? 1 : (-1)); + newWallType = ((num8 != 2) ? 1 : (-1)); break; } } } else { - num3 = (WorldGen.genRand.NextBool() ? 1 : (-1)); + newWallType = (WorldGen.genRand.NextBool() ? 1 : (-1)); if (WorldGen.genRand.NextBool()) flag5 = true; } @@ -2227,11 +2227,11 @@ namespace CalamityMod.World if (flag5) { zero2.Y = 0.0; - zero2.X = num3; + zero2.X = newWallType; zero3.Y = 0.0; - zero3.X = -num3; + zero3.X = -newWallType; zero.Y = 0.0; - zero.X = num3; + zero.X = newWallType; if (WorldGen.genRand.Next(3) == 0) { if (WorldGen.genRand.NextBool()) @@ -2243,12 +2243,12 @@ namespace CalamityMod.World else { num += 1.0; - zero.Y = num3; + zero.Y = newWallType; zero.X = 0.0; zero2.X = 0.0; - zero2.Y = num3; + zero2.Y = newWallType; zero3.X = 0.0; - zero3.Y = -num3; + zero3.Y = -newWallType; if (WorldGen.genRand.Next(3) != 0) { flag3 = true; @@ -2287,11 +2287,11 @@ namespace CalamityMod.World { if (vector2D.X > (double)(LastMaxTilesX - 200)) { - num3 = -1; + newWallType = -1; zero2.Y = 0.0; - zero2.X = num3; + zero2.X = newWallType; zero.Y = 0.0; - zero.X = num3; + zero.X = newWallType; if (WorldGen.genRand.Next(3) == 0) { if (WorldGen.genRand.NextBool()) @@ -2302,11 +2302,11 @@ namespace CalamityMod.World } else if (vector2D.X < 200.0) { - num3 = 1; + newWallType = 1; zero2.Y = 0.0; - zero2.X = num3; + zero2.X = newWallType; zero.Y = 0.0; - zero.X = num3; + zero.X = newWallType; if (WorldGen.genRand.Next(3) == 0) { if (WorldGen.genRand.NextBool()) @@ -2317,12 +2317,12 @@ namespace CalamityMod.World } else if (vector2D.Y > (double)(LastMaxTilesY - 300)) { - num3 = -1; + newWallType = -1; num += 1.0; - zero.Y = num3; + zero.Y = newWallType; zero.X = 0.0; zero2.X = 0.0; - zero2.Y = num3; + zero2.Y = newWallType; if (WorldGen.genRand.NextBool()) { if (WorldGen.genRand.NextBool()) @@ -2333,12 +2333,12 @@ namespace CalamityMod.World } else if (flag11) { - num3 = 1; + newWallType = 1; num += 1.0; - zero.Y = num3; + zero.Y = newWallType; zero.X = 0.0; zero2.X = 0.0; - zero2.Y = num3; + zero2.Y = newWallType; if (WorldGen.genRand.Next(3) != 0) { flag3 = true; @@ -2357,11 +2357,11 @@ namespace CalamityMod.World } else if (vector2D.X < (double)(Main.maxTilesX / 2) && vector2D.X > (double)Main.maxTilesX * 0.25) { - num3 = -1; + newWallType = -1; zero2.Y = 0.0; - zero2.X = num3; + zero2.X = newWallType; zero.Y = 0.0; - zero.X = num3; + zero.X = newWallType; if (WorldGen.genRand.Next(3) == 0) { if (WorldGen.genRand.NextBool()) @@ -2372,11 +2372,11 @@ namespace CalamityMod.World } else if (vector2D.X > (double)(Main.maxTilesX / 2) && vector2D.X < (double)Main.maxTilesX * 0.75) { - num3 = 1; + newWallType = 1; zero2.Y = 0.0; - zero2.X = num3; + zero2.X = newWallType; zero.Y = 0.0; - zero.X = num3; + zero.X = newWallType; if (WorldGen.genRand.Next(3) == 0) { if (WorldGen.genRand.NextBool()) @@ -2403,7 +2403,7 @@ namespace CalamityMod.World GenVars.lastDungeonHall = zero2; if (Math.Abs(zero.X) > Math.Abs(zero.Y) && WorldGen.genRand.Next(3) != 0) - num = (int)(num2 * ((double)WorldGen.genRand.Next(110, 150) * 0.01)); + num = (int)(brickType * ((double)WorldGen.genRand.Next(110, 150) * 0.01)); while (num4 > 0) { @@ -2463,7 +2463,7 @@ namespace CalamityMod.World { for (int num15 = num12 + 1; num15 < num13 - 1; num15++) { - Main.tile[num14, num15].WallType = (ushort)wallType; + Main.tile[num14, num15].WallType = (ushort)newWallType; } } @@ -2498,7 +2498,7 @@ namespace CalamityMod.World Main.tile[num17, num18].Clear(TileDataType.Slope); if (flag) { - if (Main.tile[num17, num18].HasTile || Main.tile[num17, num18].WallType != wallType) + if (Main.tile[num17, num18].HasTile || Main.tile[num17, num18].WallType != newWallType) { Main.tile[num17, num18].Get().HasTile = true; Main.tile[num17, num18].TileType = GenVars.crackedType; @@ -2510,7 +2510,7 @@ namespace CalamityMod.World } Main.tile[num17, num18].Clear(TileDataType.Slope); - Main.tile[num17, num18].WallType = (ushort)wallType; + Main.tile[num17, num18].WallType = (ushort)newWallType; } } diff --git a/World/GiantHive.cs b/World/GiantHive.cs index b63a1fcb8b..57adc27ea4 100644 --- a/World/GiantHive.cs +++ b/World/GiantHive.cs @@ -161,7 +161,7 @@ namespace CalamityMod.World if (ref2.Value / (float)ref1.Value < 0.75f || ref3.Value < 2) return false; - int num = 0; + int arrayInc = 0; int[] array = new int[1000]; int[] array2 = new int[1000]; Vector2 larvaLocation = origin.ToVector2(); @@ -169,32 +169,32 @@ namespace CalamityMod.World for (int i = 0; i < numHiveTunnels; i++) { - Vector2 vector2 = larvaLocation; - int num3 = WorldGen.genRand.Next(2, 5); - for (int j = 0; j < num3; j++) - vector2 = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); + Vector2 movingLarvaLocation = larvaLocation; + int hiveTunnelTries = WorldGen.genRand.Next(2, 5); + for (int j = 0; j < hiveTunnelTries; j++) + movingLarvaLocation = CreateHiveTunnel((int)larvaLocation.X, (int)larvaLocation.Y, WorldGen.genRand); - larvaLocation = vector2; - array[num] = (int)larvaLocation.X; - array2[num] = (int)larvaLocation.Y; - num++; + larvaLocation = movingLarvaLocation; + array[arrayInc] = (int)larvaLocation.X; + array2[arrayInc] = (int)larvaLocation.Y; + arrayInc++; } FrameOutAllHiveContents(origin, 50); - for (int k = 0; k < num; k++) + for (int k = 0; k < arrayInc; k++) { - int num4 = array[k]; + int x = array[k]; int y = array2[k]; - int num5 = 1; + int treeIndentDirection = 1; if (WorldGen.genRand.NextBool()) - num5 = -1; + treeIndentDirection = -1; bool flag = false; - while (WorldGen.InWorld(num4, y, 10) && BadSpotForHoneyFall(num4, y)) + while (WorldGen.InWorld(x, y, 10) && BadSpotForHoneyFall(x, y)) { - num4 += num5; - if (Math.Abs(num4 - array[k]) > 50) + x += treeIndentDirection; + if (Math.Abs(x - array[k]) > 50) { flag = true; break; @@ -203,11 +203,11 @@ namespace CalamityMod.World if (!flag) { - num4 += num5; - if (!SpotActuallyNotInHive(num4, y)) + x += treeIndentDirection; + if (!SpotActuallyNotInHive(x, y)) { - CreateBlockedHoneyCube(num4, y); - CreateDentForHoneyFall(num4, y, num5); + CreateBlockedHoneyCube(x, y); + CreateDentForHoneyFall(x, y, treeIndentDirection); } } } @@ -221,13 +221,13 @@ namespace CalamityMod.World int maxAttempts = 1000; for (int l = 0; l < maxAttempts; l++) { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-50, 51); - vector3.Y += WorldGen.genRand.Next(-50, 51); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + Vector2 newStructureLocation = larvaLocation; + newStructureLocation.X += WorldGen.genRand.Next(-50, 51); + newStructureLocation.Y += WorldGen.genRand.Next(-50, 51); + if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) { - secondLarvaLocation = vector3; - CreateStandForLarva(vector3); + secondLarvaLocation = newStructureLocation; + CreateStandForLarva(newStructureLocation); break; } } @@ -236,24 +236,24 @@ namespace CalamityMod.World Vector2 honeyChestLocation = default; for (int l = 0; l < maxAttempts; l++) { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-100, 101); - vector3.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + Vector2 newStructureLocation = larvaLocation; + newStructureLocation.X += WorldGen.genRand.Next(-100, 101); + newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); + if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) { - honeyChestLocation = vector3; - CreateStandAndPlaceHoneyChest(vector3); + honeyChestLocation = newStructureLocation; + CreateStandAndPlaceHoneyChest(newStructureLocation); break; } } for (int l = 0; l < maxAttempts; l++) { - Vector2 vector3 = larvaLocation; - vector3.X += WorldGen.genRand.Next(-100, 101); - vector3.Y += WorldGen.genRand.Next(-100, 101); - if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(larvaLocation, vector3) > 10f && Vector2.Distance(secondLarvaLocation, vector3) > 10f && Vector2.Distance(honeyChestLocation, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].HasTile && Main.tile[(int)vector3.X, (int)vector3.Y].WallType == WallID.HiveUnsafe) + Vector2 newStructureLocation = larvaLocation; + newStructureLocation.X += WorldGen.genRand.Next(-100, 101); + newStructureLocation.Y += WorldGen.genRand.Next(-100, 101); + if (WorldGen.InWorld((int)newStructureLocation.X, (int)newStructureLocation.Y) && Vector2.Distance(larvaLocation, newStructureLocation) > 10f && Vector2.Distance(secondLarvaLocation, newStructureLocation) > 10f && Vector2.Distance(honeyChestLocation, newStructureLocation) > 10f && !Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].HasTile && Main.tile[(int)newStructureLocation.X, (int)newStructureLocation.Y].WallType == WallID.HiveUnsafe) { - CreateStandAndPlaceHoneyChest(vector3); + CreateStandAndPlaceHoneyChest(newStructureLocation); break; } } @@ -264,13 +264,13 @@ namespace CalamityMod.World private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth) { - int num = Math.Max(10, origin.X - squareHalfWidth); - int num2 = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth); - int num3 = Math.Max(10, origin.Y - squareHalfWidth); - int num4 = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth); - for (int i = num; i < num2; i++) + int maxXsize = Math.Max(10, origin.X - squareHalfWidth); + int minXsize = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth); + int maxYSize = Math.Max(10, origin.Y - squareHalfWidth); + int minYSize = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth); + for (int i = maxXsize; i < minXsize; i++) { - for (int j = num3; j < num4; j++) + for (int j = maxYSize; j < minYSize; j++) { Tile tile = Main.tile[i, j]; if (tile.HasTile && tile.TileType == TileID.Hive) @@ -284,73 +284,73 @@ namespace CalamityMod.World private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random) { - double num = random.Next(20, 26); - float num2 = random.Next(30, 41); - float num3 = Main.maxTilesX / 4200; - num3 = (num3 + 1f) / 2f; - num *= (double)num3; - num2 *= num3; + double randOffset = random.Next(20, 26); + float tunnelPlacementAttempts = random.Next(30, 41); + float miniMaxXTiles = Main.maxTilesX / 4200; + miniMaxXTiles = (miniMaxXTiles + 1f) / 2f; + randOffset *= (double)miniMaxXTiles; + tunnelPlacementAttempts *= miniMaxXTiles; - double num4 = num; + double randOffsetCopy = randOffset; Vector2 result = default; result.X = i; result.Y = j; - Vector2 vector = default; - vector.X = random.Next(-10, 11) * 0.2f; - vector.Y = random.Next(-10, 11) * 0.2f; - while (num > 0.0 && num2 > 0f) + Vector2 defaultTunnelPos = default; + defaultTunnelPos.X = random.Next(-10, 11) * 0.2f; + defaultTunnelPos.Y = random.Next(-10, 11) * 0.2f; + while (randOffset > 0.0 && tunnelPlacementAttempts > 0f) { if (result.Y > (Main.maxTilesY - 250)) - num2 = 0f; + tunnelPlacementAttempts = 0f; - num = num4 * (double)(1f + random.Next(-20, 20) * 0.01f); - num2 -= 1f; - int num5 = (int)(result.X - num); - int num6 = (int)(result.X + num); - int num7 = (int)(result.Y - num); - int num8 = (int)(result.Y + num); - if (num5 < 1) - num5 = 1; + randOffset = randOffsetCopy * (double)(1f + random.Next(-20, 20) * 0.01f); + tunnelPlacementAttempts -= 1f; + int mainXOffset = (int)(result.X - randOffset); + int maxXOffset = (int)(result.X + randOffset); + int minYOffset = (int)(result.Y - randOffset); + int maxYOffset = (int)(result.Y + randOffset); + if (mainXOffset < 1) + mainXOffset = 1; - if (num6 > Main.maxTilesX - 1) - num6 = Main.maxTilesX - 1; + if (maxXOffset > Main.maxTilesX - 1) + maxXOffset = Main.maxTilesX - 1; - if (num7 < 1) - num7 = 1; + if (minYOffset < 1) + minYOffset = 1; - if (num8 > Main.maxTilesY - 1) - num8 = Main.maxTilesY - 1; + if (maxYOffset > Main.maxTilesY - 1) + maxYOffset = Main.maxTilesY - 1; - for (int k = num5; k < num6; k++) + for (int k = mainXOffset; k < maxXOffset; k++) { - for (int l = num7; l < num8; l++) + for (int l = minYOffset; l < maxYOffset; l++) { if (!WorldGen.InWorld(k, l, 50)) { - num2 = 0f; + tunnelPlacementAttempts = 0f; } else { if (Main.tile[k - 10, l].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; if (Main.tile[k + 10, l].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; if (Main.tile[k, l - 10].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; if (Main.tile[k, l + 10].WallType == WallID.LihzahrdBrickUnsafe) - num2 = 0f; + tunnelPlacementAttempts = 0f; } if (l < Main.worldSurface && Main.tile[k, l - 5].WallType == WallID.None) - num2 = 0f; + tunnelPlacementAttempts = 0f; - float num9 = Math.Abs(k - result.X); - float num10 = Math.Abs(l - result.Y); - double num11 = Math.Sqrt(num9 * num9 + num10 * num10); - if (num11 < num4 * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) + float tileXDist = Math.Abs(k - result.X); + float tileYDist = Math.Abs(l - result.Y); + double tileDistance = Math.Sqrt(tileXDist * tileXDist + tileYDist * tileYDist); + if (tileDistance < randOffsetCopy * 0.4 * (1.0 + random.Next(-10, 11) * 0.005)) { Main.tile[k, l].LiquidAmount = byte.MaxValue; Main.tile[k, l].Get().LiquidType = LiquidID.Honey; @@ -359,7 +359,7 @@ namespace CalamityMod.World Main.tile[k, l].Get().IsHalfBlock = false; Main.tile[k, l].Get().Slope = SlopeType.Solid; } - else if (num11 < num4 * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) + else if (tileDistance < randOffsetCopy * 0.75 * (1.0 + random.Next(-10, 11) * 0.005)) { Main.tile[k, l].LiquidAmount = 0; if (Main.tile[k, l].WallType != WallID.HiveUnsafe) @@ -371,7 +371,7 @@ namespace CalamityMod.World } } - if (num11 < num4 * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) + if (tileDistance < randOffsetCopy * 0.6 * (1.0 + random.Next(-10, 11) * 0.005)) { Main.tile[k, l].WallType = WallID.HiveUnsafe; if (random.NextBool()) @@ -383,10 +383,10 @@ namespace CalamityMod.World } } - result += vector; - num2 -= 1f; - vector.Y += random.Next(-10, 11) * 0.05f; - vector.X += random.Next(-10, 11) * 0.05f; + result += defaultTunnelPos; + tunnelPlacementAttempts -= 1f; + defaultTunnelPos.Y += random.Next(-10, 11) * 0.05f; + defaultTunnelPos.X += random.Next(-10, 11) * 0.05f; } return result; @@ -396,13 +396,13 @@ namespace CalamityMod.World { int x = origin.X; int y = origin.Y; - int num = 150; - for (int i = x - num; i < x + num; i += 10) + int checkRadius = 150; + for (int i = x - checkRadius; i < x + checkRadius; i += 10) { if (i <= 0 || i > Main.maxTilesX - 1) continue; - for (int j = y - num; j < y + num; j += 10) + for (int j = y - checkRadius; j < y + checkRadius; j += 10) { if (j > 0 && j <= Main.maxTilesY - 1) { @@ -424,10 +424,10 @@ namespace CalamityMod.World { dir *= -1; y++; - int num = 0; - while ((num < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10) + int honeyDentTries = 0; + while ((honeyDentTries < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10) { - num++; + honeyDentTries++; x += dir; if (WorldGen.SolidTile(x, y)) { @@ -495,13 +495,13 @@ namespace CalamityMod.World if (GenVars.numLarva >= GenVars.larvaX.Length) GenVars.numLarva = GenVars.larvaX.Length - 1; - int num = (int)position.X; - int num2 = (int)position.Y; - for (int i = num - 1; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) + int larvaX = (int)position.X; + int larvaY = (int)position.Y; + for (int i = larvaX - 1; i <= larvaX + 1 && i > 0 && i < Main.maxTilesX; i++) { - for (int j = num2 - 2; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) + for (int j = larvaY - 2; j <= larvaY + 1 && j > 0 && j < Main.maxTilesY; j++) { - if (j != num2 + 1) + if (j != larvaY + 1) { Main.tile[i, j].Get().HasTile = false; continue; @@ -520,13 +520,13 @@ namespace CalamityMod.World int chestPlacementX = Utils.Clamp((int)position.X, 5, Main.maxTilesX - 5); int chestPlacementY = Utils.Clamp((int)position.Y, 5, Main.maxTilesY - 5); - int num = (int)position.X; - int num2 = (int)position.Y; - for (int i = num; i <= num + 1 && i > 0 && i < Main.maxTilesX; i++) + int chestX = (int)position.X; + int chestY = (int)position.Y; + for (int i = chestX; i <= chestX + 1 && i > 0 && i < Main.maxTilesX; i++) { - for (int j = num2 - 1; j <= num2 + 1 && j > 0 && j < Main.maxTilesY; j++) + for (int j = chestY - 1; j <= chestY + 1 && j > 0 && j < Main.maxTilesY; j++) { - if (j != num2 + 1) + if (j != chestY + 1) { Main.tile[i, j].Get().HasTile = false; continue; @@ -539,27 +539,27 @@ namespace CalamityMod.World } } - int num144 = chestPlacementX; - int num145 = chestPlacementY; - for (int num146 = num144; num146 <= num144 + 1; num146++) + int finalChestX = chestPlacementX; + int finalChestY = chestPlacementY; + for (int i = finalChestX; i <= finalChestX + 1; i++) { - for (int num147 = num145 - 1; num147 <= num145 + 1; num147++) + for (int j = finalChestY - 1; j <= finalChestY + 1; j++) { - if (num147 != num145 + 1) + if (j != finalChestY + 1) { - Main.tile[num146, num147].Get().HasTile = false; + Main.tile[i, j].Get().HasTile = false; } else { - Main.tile[num146, num147].Get().HasTile = true; - Main.tile[num146, num147].TileType = TileID.Hive; - Main.tile[num146, num147].Get().Slope = SlopeType.Solid; - Main.tile[num146, num147].Get().IsHalfBlock = false; + Main.tile[i, j].Get().HasTile = true; + Main.tile[i, j].TileType = TileID.Hive; + Main.tile[i, j].Get().Slope = SlopeType.Solid; + Main.tile[i, j].Get().IsHalfBlock = false; } } } - int chestID = WorldGen.PlaceChest(num144, num145, 21, false, 29); + int chestID = WorldGen.PlaceChest(finalChestX, finalChestY, 21, false, 29); FillHoneyChest(chestID, WorldGen.genRand); } diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index 3c80021f2b..eba1b6ab7e 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -181,7 +181,7 @@ namespace CalamityMod.World #region Chasm Generator public static void ChasmGenerator(int i, int j, int steps, bool ocean = false) { - float num = steps; //850 small 1450 medium 2050 large + float maxChasmSize = steps; //850 small 1450 medium 2050 large int limitIncrease = Main.remixWorld ? 110 : 0; if (ocean) { @@ -202,20 +202,20 @@ namespace CalamityMod.World } j = tileYLookup; } - Vector2 vector; - vector.X = i; - vector.Y = j; - Vector2 vector2; - vector2.X = WorldGen.genRand.Next(-1, 2) * 0.1f; - vector2.Y = WorldGen.genRand.Next(3, 8) * 0.2f + 0.5f; - int num2 = 5; - double num3 = WorldGen.genRand.Next(5, 7) + 20; //start width - while (num3 > 0.0) + Vector2 chasmGenPosition; + chasmGenPosition.X = i; + chasmGenPosition.Y = j; + Vector2 randChasmGenOffset; + randChasmGenOffset.X = WorldGen.genRand.Next(-1, 2) * 0.1f; + randChasmGenOffset.Y = WorldGen.genRand.Next(3, 8) * 0.2f + 0.5f; + int five = 5; + double chasmWidth = WorldGen.genRand.Next(5, 7) + 20; //start width + while (chasmWidth > 0.0) { - if (num > 0f) + if (maxChasmSize > 0f) { - num3 += WorldGen.genRand.Next(10); - num3 -= WorldGen.genRand.Next(10); + chasmWidth += WorldGen.genRand.Next(10); + chasmWidth -= WorldGen.genRand.Next(10); float smallHoleLimit = 790f; //small if (Main.maxTilesY > 1500) @@ -228,97 +228,97 @@ namespace CalamityMod.World } } - if (ocean && num > smallHoleLimit) + if (ocean && maxChasmSize > smallHoleLimit) { - if (num3 < 7.0) //min width + if (chasmWidth < 7.0) //min width { - num3 = 7.0; //min width + chasmWidth = 7.0; //min width } - if (num3 > 45.0) //max width + if (chasmWidth > 45.0) //max width { - num3 = 45.0; //max width + chasmWidth = 45.0; //max width } } else //dig large hole { - if (num3 < (ocean ? 30.0 : 8.0)) //min width + if (chasmWidth < (ocean ? 30.0 : 8.0)) //min width { - num3 = ocean ? 30.0 : 8.0; //min width + chasmWidth = ocean ? 30.0 : 8.0; //min width } - if (num3 > (ocean ? 70.0 : 20.0)) //max width + if (chasmWidth > (ocean ? 70.0 : 20.0)) //max width { - num3 = ocean ? 70.0 : 20.0; //max width + chasmWidth = ocean ? 70.0 : 20.0; //max width } - if (num == 1f && num3 < (ocean ? 50.0 : 15.0)) + if (maxChasmSize == 1f && chasmWidth < (ocean ? 50.0 : 15.0)) { - num3 = ocean ? 50.0 : 15.0; + chasmWidth = ocean ? 50.0 : 15.0; } } } else { - if ((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease)) + if ((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease)) { - num3 -= WorldGen.genRand.Next(5) + 8; + chasmWidth -= WorldGen.genRand.Next(5) + 8; } } if (Main.maxTilesY > 2100) { - if (((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease) && num > 0f && ocean) || - (vector.Y >= Main.maxTilesY && num > 0f && !ocean)) + if (((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease) && maxChasmSize > 0f && ocean) || + (chasmGenPosition.Y >= Main.maxTilesY && maxChasmSize > 0f && !ocean)) { - num = 0f; + maxChasmSize = 0f; } } else if (Main.maxTilesY > 1500) { - if (((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease) && num > 0f && ocean) || - (vector.Y > Main.maxTilesY && num > 0f && !ocean)) + if (((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease) && maxChasmSize > 0f && ocean) || + (chasmGenPosition.Y > Main.maxTilesY && maxChasmSize > 0f && !ocean)) { - num = 0f; + maxChasmSize = 0f; } } else { - if (((double)vector.Y > (Abyss.AbyssChasmBottom + limitIncrease) && num > 0f && ocean) || - (vector.Y > Main.maxTilesY && num > 0f && !ocean)) + if (((double)chasmGenPosition.Y > (Abyss.AbyssChasmBottom + limitIncrease) && maxChasmSize > 0f && ocean) || + (chasmGenPosition.Y > Main.maxTilesY && maxChasmSize > 0f && !ocean)) { - num = 0f; + maxChasmSize = 0f; } } - num -= 1f; - int num4; - int num5; - int num6; - int num7; - if (num > num2) + maxChasmSize -= 1f; + int chasmWidthMin; + int chasmWidthMax; + int chasmHeightMin; + int chasmHeightMax; + if (maxChasmSize > five) { - num4 = (int)(vector.X - num3 * 0.5); - num5 = (int)(vector.X + num3 * 0.5); - num6 = (int)(vector.Y - num3 * 0.5); - num7 = (int)(vector.Y + num3 * 0.5); - if (num4 < 0) + chasmWidthMin = (int)(chasmGenPosition.X - chasmWidth * 0.5); + chasmWidthMax = (int)(chasmGenPosition.X + chasmWidth * 0.5); + chasmHeightMin = (int)(chasmGenPosition.Y - chasmWidth * 0.5); + chasmHeightMax = (int)(chasmGenPosition.Y + chasmWidth * 0.5); + if (chasmWidthMin < 0) { - num4 = 0; + chasmWidthMin = 0; } - if (num5 > Main.maxTilesX - 1) + if (chasmWidthMax > Main.maxTilesX - 1) { - num5 = Main.maxTilesX - 1; + chasmWidthMax = Main.maxTilesX - 1; } - if (num6 < 0) + if (chasmHeightMin < 0) { - num6 = 0; + chasmHeightMin = 0; } - if (num7 > Main.maxTilesY) + if (chasmHeightMax > Main.maxTilesY) { - num7 = Main.maxTilesY; + chasmHeightMax = Main.maxTilesY; } - for (int k = num4; k < num5; k++) + for (int k = chasmWidthMin; k < chasmWidthMax; k++) { - for (int l = num6; l < num7; l++) + for (int l = chasmHeightMin; l < chasmHeightMax; l++) { - if ((Math.Abs(k - vector.X) + Math.Abs(l - vector.Y)) < num3 * 0.5 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + if ((Math.Abs(k - chasmGenPosition.X) + Math.Abs(l - chasmGenPosition.Y)) < chasmWidth * 0.5 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) { if (ocean) { @@ -336,51 +336,51 @@ namespace CalamityMod.World } } } - /*if (num <= 2f && vector.Y < (Main.rockLayer + Main.maxTilesY * 0.3)) + /*if (maxChasmSize <= 2f && chasmGenPosition.Y < (Main.rockLayer + Main.maxTilesY * 0.3)) { - num = 2f; + maxChasmSize = 2f; }*/ - vector += vector2; - vector2.X += WorldGen.genRand.Next(-1, 2) * 0.01f; - if (vector2.X > 0.02) + chasmGenPosition += randChasmGenOffset; + randChasmGenOffset.X += WorldGen.genRand.Next(-1, 2) * 0.01f; + if (randChasmGenOffset.X > 0.02) { - vector2.X = 0.02f; + randChasmGenOffset.X = 0.02f; } - if (vector2.X < -0.02) + if (randChasmGenOffset.X < -0.02) { - vector2.X = -0.02f; + randChasmGenOffset.X = -0.02f; } - num4 = (int)(vector.X - num3 * 1.1); - num5 = (int)(vector.X + num3 * 1.1); - num6 = (int)(vector.Y - num3 * 1.1); - num7 = (int)(vector.Y + num3 * 1.1); - if (num4 < 1) + chasmWidthMin = (int)(chasmGenPosition.X - chasmWidth * 1.1); + chasmWidthMax = (int)(chasmGenPosition.X + chasmWidth * 1.1); + chasmHeightMin = (int)(chasmGenPosition.Y - chasmWidth * 1.1); + chasmHeightMax = (int)(chasmGenPosition.Y + chasmWidth * 1.1); + if (chasmWidthMin < 1) { - num4 = 1; + chasmWidthMin = 1; } - if (num5 > Main.maxTilesX - 1) + if (chasmWidthMax > Main.maxTilesX - 1) { - num5 = Main.maxTilesX - 1; + chasmWidthMax = Main.maxTilesX - 1; } - if (num6 < 0) + if (chasmHeightMin < 0) { - num6 = 0; + chasmHeightMin = 0; } - if (num7 > Main.maxTilesY) + if (chasmHeightMax > Main.maxTilesY) { - num7 = Main.maxTilesY; + chasmHeightMax = Main.maxTilesY; } - for (int m = num4; m < num5; m++) + for (int m = chasmWidthMin; m < chasmWidthMax; m++) { - for (int n = num6; n < num7; n++) + for (int n = chasmHeightMin; n < chasmHeightMax; n++) { - if ((Math.Abs(m - vector.X) + Math.Abs(n - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + if ((Math.Abs(m - chasmGenPosition.X) + Math.Abs(n - chasmGenPosition.Y)) < chasmWidth * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) { if (n > j + WorldGen.genRand.Next(7, 16)) { Main.tile[m, n].Get().HasTile = false; } - if (steps <= num2) + if (steps <= five) { Main.tile[m, n].Get().HasTile = false; } @@ -397,25 +397,25 @@ namespace CalamityMod.World } } } - for (int num11 = num4; num11 < num5; num11++) + for (int r = chasmWidthMin; r < chasmWidthMax; r++) { - for (int num12 = num6; num12 < num7; num12++) + for (int s = chasmHeightMin; s < chasmHeightMax; s++) { - if ((Math.Abs(num11 - vector.X) + Math.Abs(num12 - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + if ((Math.Abs(r - chasmGenPosition.X) + Math.Abs(s - chasmGenPosition.Y)) < chasmWidth * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) { if (ocean) { - Main.tile[num11, num12].LiquidAmount = 255; - Main.tile[num11, num12].Get().LiquidType = LiquidID.Water; + Main.tile[r, s].LiquidAmount = 255; + Main.tile[r, s].Get().LiquidType = LiquidID.Water; } else { - Main.tile[num11, num12].LiquidAmount = 255; - Main.tile[num11, num12].Get().LiquidType = LiquidID.Lava; + Main.tile[r, s].LiquidAmount = 255; + Main.tile[r, s].Get().LiquidType = LiquidID.Lava; } - if (steps <= num2) + if (steps <= five) { - Main.tile[num11, num12].Get().HasTile = false; + Main.tile[r, s].Get().HasTile = false; } } } diff --git a/World/Planets/LuminitePlanet.cs b/World/Planets/LuminitePlanet.cs index b4a5b1d977..41ab36fe85 100644 --- a/World/Planets/LuminitePlanet.cs +++ b/World/Planets/LuminitePlanet.cs @@ -23,7 +23,6 @@ namespace CalamityMod.World.Planets var config = WorldGenConfiguration.FromEmbeddedPath("Terraria.GameContent.WorldBuilding.Configuration.json"); int totalPlanetoidsToGenerate = Main.maxTilesX / 1200 + 2; - Main.NewText("Tiles total: " + Main.maxTilesX); for (int i = 0; i < totalPlanetoidsToGenerate; i++) { for (int tries = 0; tries < 15000; tries++) @@ -39,7 +38,6 @@ namespace CalamityMod.World.Planets if (config.CreateBiome().Place(planetoidOrigin, GenVars.structures)) break; } - Main.NewText("Success"); } } } diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 9c7e747a2e..462f2e3021 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -67,13 +67,13 @@ namespace CalamityMod.World private void AttemptClaim(int x, int y, int[,] clusterIndexMap, List> pointClusters, int index) //Attempts to create a cluster { - int num = clusterIndexMap[x, y]; - if (num != -1 && num != index) + int clusterPos = clusterIndexMap[x, y]; + if (clusterPos != -1 && clusterPos != index) { - int num2 = (WorldGen.genRand.Next(2) == 0) ? -1 : index; - foreach (Point current in pointClusters[num]) + int clusterHeight = (WorldGen.genRand.Next(2) == 0) ? -1 : index; + foreach (Point current in pointClusters[clusterPos]) { - clusterIndexMap[current.X, current.Y] = num2; + clusterIndexMap[current.X, current.Y] = clusterHeight; } } } @@ -84,14 +84,14 @@ namespace CalamityMod.World Height = height; Clear(); bool[,] array = new bool[width, height]; - int num = (width >> 1) - 1; - int num2 = (height >> 1) - 1; - int num3 = (num + 1) * (num + 1); - Point point = new Point(num, num2); - for (int i = point.Y - num2; i <= point.Y + num2; i++) + int clusterPos = (width >> 1) - 1; + int clusterHeight = (height >> 1) - 1; + int clusterSize = (clusterPos + 1) * (clusterPos + 1); + Point point = new Point(clusterPos, clusterHeight); + for (int i = point.Y - clusterHeight; i <= point.Y + clusterHeight; i++) { - float num4 = (float)num / (float)num2 * (float)(i - point.Y); - int num5 = Math.Min(num, (int)Math.Sqrt((float)num3 - num4 * num4)); + float num4 = (float)clusterPos / (float)clusterHeight * (float)(i - point.Y); + int num5 = Math.Min(clusterPos, (int)Math.Sqrt((float)clusterSize - num4 * num4)); for (int j = point.X - num5; j <= point.X + num5; j++) { array[j, i] = WorldGen.genRand.Next(2) == 0; @@ -210,7 +210,7 @@ namespace CalamityMod.World for (int j = -20; j < totalHeight + 20; j++) { float num3 = 0f; - int num4 = -1; + int clusterAmt = -1; float num5 = 0f; int num6 = i + start.X; int num7 = j + start.Y; @@ -233,7 +233,7 @@ namespace CalamityMod.World num5 = num3; } num3 = num9; - num4 = k; + clusterAmt = k; } else if (num9 > num5) { @@ -248,7 +248,7 @@ namespace CalamityMod.World { tile.ClearEverything(); tile.LiquidAmount = 192; - if (num4 % 5 == 2) + if (clusterAmt % 5 == 2) { tile.ResetToType((ushort)ModContent.TileType()); tile.Get().HasTile = true; diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs index ded2e8ddc2..0c7d961f67 100644 --- a/World/WorldEvilIsland.cs +++ b/World/WorldEvilIsland.cs @@ -283,14 +283,14 @@ namespace CalamityMod.World ushort type = (ushort)(genCorruptHouse ? 152 : 347); //tile byte wall = (byte)(genCorruptHouse ? 35 : 174); //wall Vector2 vector = new Vector2((float)i, (float)j); - int num = 1; + int houseDirection = 1; if (WorldGen.genRand.Next(2) == 0) { - num = -1; + houseDirection = -1; } - int num2 = WorldGen.genRand.Next(7, 12); - int num3 = WorldGen.genRand.Next(5, 7); - vector.X = (float)(i + (num2 + 2) * num); + int largerRandValue = WorldGen.genRand.Next(7, 12); + int smallerRandValue = WorldGen.genRand.Next(5, 7); + vector.X = (float)(i + (largerRandValue + 2) * houseDirection); for (int k = j - 15; k < j + 30; k++) { if (Main.tile[(int)vector.X, k].HasTile) @@ -300,31 +300,31 @@ namespace CalamityMod.World } } vector.X = (float)i; - int num4 = (int)(vector.X - (float)num2 - 1f); - int num5 = (int)(vector.X + (float)num2 + 1f); - int num6 = (int)(vector.Y - (float)num3 - 1f); - int num7 = (int)(vector.Y + 2f); - if (num4 < 0) + int minXSize = (int)(vector.X - (float)largerRandValue - 1f); + int maxXSize = (int)(vector.X + (float)largerRandValue + 1f); + int minYSize = (int)(vector.Y - (float)smallerRandValue - 1f); + int maxYSize = (int)(vector.Y + 2f); + if (minXSize < 0) { - num4 = 0; + minXSize = 0; } - if (num5 > Main.maxTilesX) + if (maxXSize > Main.maxTilesX) { - num5 = Main.maxTilesX; + maxXSize = Main.maxTilesX; } - if (num6 < 0) + if (minYSize < 0) { - num6 = 0; + minYSize = 0; } - if (num7 > Main.maxTilesY) + if (maxYSize > Main.maxTilesY) { - num7 = Main.maxTilesY; + maxYSize = Main.maxTilesY; } - for (int l = num4; l <= num5; l++) + for (int l = minXSize; l <= maxXSize; l++) { - for (int m = num6 - 1; m < num7 + 1; m++) + for (int m = minYSize - 1; m < maxYSize + 1; m++) { - if (m != num6 - 1 || (l != num4 && l != num5)) + if (m != minYSize - 1 || (l != minXSize && l != maxXSize)) { Main.tile[l, m].Get().HasTile = true; Main.tile[l, m].LiquidAmount = 0; @@ -335,55 +335,55 @@ namespace CalamityMod.World } } } - num4 = (int)(vector.X - (float)num2); - num5 = (int)(vector.X + (float)num2); - num6 = (int)(vector.Y - (float)num3); - num7 = (int)(vector.Y + 1f); - if (num4 < 0) + minXSize = (int)(vector.X - (float)largerRandValue); + maxXSize = (int)(vector.X + (float)largerRandValue); + minYSize = (int)(vector.Y - (float)smallerRandValue); + maxYSize = (int)(vector.Y + 1f); + if (minXSize < 0) { - num4 = 0; + minXSize = 0; } - if (num5 > Main.maxTilesX) + if (maxXSize > Main.maxTilesX) { - num5 = Main.maxTilesX; + maxXSize = Main.maxTilesX; } - if (num6 < 0) + if (minYSize < 0) { - num6 = 0; + minYSize = 0; } - if (num7 > Main.maxTilesY) + if (maxYSize > Main.maxTilesY) { - num7 = Main.maxTilesY; + maxYSize = Main.maxTilesY; } - for (int n = num4; n <= num5; n++) + for (int n = minXSize; n <= maxXSize; n++) { - for (int num8 = num6; num8 < num7; num8++) + for (int p = minYSize; p < maxYSize; p++) { - if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].WallType == 0) + if ((p != minYSize || (n != minXSize && n != maxXSize)) && Main.tile[n, p].WallType == 0) { - Main.tile[n, num8].Get().HasTile = false; - Main.tile[n, num8].WallType = wall; + Main.tile[n, p].Get().HasTile = false; + Main.tile[n, p].WallType = wall; } } } - int num9 = i + (num2 + 1) * num; - int num10 = (int)vector.Y; - for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) + int xPos = i + (largerRandValue + 1) * houseDirection; + int t = (int)vector.Y; + for (int s = xPos - 2; s <= xPos + 2; s++) { - Main.tile[num11, num10].Get().HasTile = false; - Main.tile[num11, num10 - 1].Get().HasTile = false; - Main.tile[num11, num10 - 2].Get().HasTile = false; + Main.tile[s, t].Get().HasTile = false; + Main.tile[s, t - 1].Get().HasTile = false; + Main.tile[s, t - 2].Get().HasTile = false; } - WorldGen.PlaceTile(num9, num10, 10, true, false, -1, genCorruptHouse ? 1 : 10); //door - num9 = i + (num2 + 1) * -num - num; - for (int num12 = num6; num12 <= num7 + 1; num12++) + WorldGen.PlaceTile(xPos, t, 10, true, false, -1, genCorruptHouse ? 1 : 10); //door + xPos = i + (largerRandValue + 1) * -houseDirection - houseDirection; + for (int yPos = minYSize; yPos <= maxYSize + 1; yPos++) { - Main.tile[num9, num12].Get().HasTile = true; - Main.tile[num9, num12].LiquidAmount = 0; - Main.tile[num9, num12].TileType = type; - Main.tile[num9, num12].WallType = 0; - Main.tile[num9, num12].Get().IsHalfBlock = false; - Main.tile[num9, num12].Get().Slope = SlopeType.Solid; + Main.tile[xPos, yPos].Get().HasTile = true; + Main.tile[xPos, yPos].LiquidAmount = 0; + Main.tile[xPos, yPos].TileType = type; + Main.tile[xPos, yPos].WallType = 0; + Main.tile[xPos, yPos].Get().IsHalfBlock = false; + Main.tile[xPos, yPos].Get().Slope = SlopeType.Solid; } int contain; if (genCorruptHouse) @@ -394,37 +394,37 @@ namespace CalamityMod.World { contain = 1569; //vampire } - WorldGen.AddBuriedChest(i, num10 - 3, contain, false, genCorruptHouse ? 19 : 20); //chest - int num14 = i - num2 / 2 + 1; - int num15 = i + num2 / 2 - 1; - int num16 = 1; - if (num2 > 10) + WorldGen.AddBuriedChest(i, t - 3, contain, false, genCorruptHouse ? 19 : 20); //chest + int wallXMinSize = i - largerRandValue / 2 + 1; + int wallXMaxSize = i + largerRandValue / 2 - 1; + int wallYSize = 1; + if (largerRandValue > 10) { - num16 = 2; + wallYSize = 2; } - int num17 = (num6 + num7) / 2 - 1; - for (int num18 = num14 - num16; num18 <= num14 + num16; num18++) + int wallYRange = (minYSize + maxYSize) / 2 - 1; + for (int wallX = wallXMinSize - wallYSize; wallX <= wallXMinSize + wallYSize; wallX++) { - for (int num19 = num17 - 1; num19 <= num17 + 1; num19++) + for (int wallY = wallYRange - 1; wallY <= wallYRange + 1; wallY++) { - Main.tile[num18, num19].WallType = 21; //glass + Main.tile[wallX, wallY].WallType = 21; //glass } } - for (int num20 = num15 - num16; num20 <= num15 + num16; num20++) + for (int wallX2 = wallXMaxSize - wallYSize; wallX2 <= wallXMaxSize + wallYSize; wallX2++) { - for (int num21 = num17 - 1; num21 <= num17 + 1; num21++) + for (int wallY2 = wallYRange - 1; wallY2 <= wallYRange + 1; wallY2++) { - Main.tile[num20, num21].WallType = 21; //glass + Main.tile[wallX2, wallY2].WallType = 21; //glass } } - int num22 = i + (num2 / 2 + 1) * -num; - WorldGen.PlaceTile(num22, num7 - 1, 14, true, false, -1, genCorruptHouse ? 1 : 8); //table - WorldGen.PlaceTile(num22 - 2, num7 - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair - Tile tile = Main.tile[num22 - 2, num7 - 1]; + int furnitureXPos = i + (largerRandValue / 2 + 1) * -houseDirection; + WorldGen.PlaceTile(furnitureXPos, maxYSize - 1, 14, true, false, -1, genCorruptHouse ? 1 : 8); //table + WorldGen.PlaceTile(furnitureXPos - 2, maxYSize - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair + Tile tile = Main.tile[furnitureXPos - 2, maxYSize - 1]; tile.TileFrameX += 18; - Tile tile2 = Main.tile[num22 - 2, num7 - 2]; + Tile tile2 = Main.tile[furnitureXPos - 2, maxYSize - 2]; tile2.TileFrameX += 18; - WorldGen.PlaceTile(num22 + 2, num7 - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair + WorldGen.PlaceTile(furnitureXPos + 2, maxYSize - 1, 15, true, false, 0, genCorruptHouse ? 2 : 11); //chair } } }