From 1d0b406abcec76b7cbd63bbb0cfefc4433940135 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Tue, 25 Jan 2022 17:25:30 -0600 Subject: [PATCH] Reduced Yharon's invincibility time --- NPCs/Yharon/Yharon.cs | 2393 +++++++++++++++++++++-------------------- 1 file changed, 1197 insertions(+), 1196 deletions(-) diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 69bc14a8ee..6350d1e357 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -35,9 +35,9 @@ namespace CalamityMod.NPCs.Yharon public class Yharon : ModNPC { private Rectangle safeBox = default; - private Vector2 flareDustBulletHellSpawn = default; + private Vector2 flareDustBulletHellSpawn = default; - private bool enraged = false; + private bool enraged = false; private bool protectionBoost = false; private bool moveCloser = false; private bool useTornado = true; @@ -46,26 +46,27 @@ namespace CalamityMod.NPCs.Yharon private bool startSecondAI = false; private bool spawnArena = false; private int invincibilityCounter = 0; - private int fastChargeTelegraphTime = 120; + private int fastChargeTelegraphTime = 120; - private const float ai2GateValue = 0.55f; + private const float ai2GateValue = 0.55f; + public const int Phase2InvincibilityTime = 300; - public static float normalDR = 0.22f; + public static float normalDR = 0.22f; public static float EnragedDR = 0.9f; public override void SetStaticDefaults() { DisplayName.SetDefault("Jungle Dragon, Yharon"); Main.npcFrameCount[npc.type] = 7; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; + npc.Calamity().canBreakPlayerDefense = true; npc.npcSlots = 50f; - npc.GetNPCDamage(); - npc.width = 200; + npc.GetNPCDamage(); + npc.width = 200; npc.height = 200; npc.defense = 90; npc.LifeMaxNERB(1085000, 1300000, 370000); @@ -76,7 +77,7 @@ namespace CalamityMod.NPCs.Yharon aiType = -1; npc.value = Item.buyPrice(1, 0, 0, 0); npc.boss = true; - npc.DR_NERD(normalDR); + npc.DR_NERD(normalDR); npc.noGravity = true; npc.noTileCollide = true; @@ -87,10 +88,10 @@ namespace CalamityMod.NPCs.Yharon npc.HitSound = SoundID.NPCHit56; npc.DeathSound = SoundID.NPCDeath60; bossBag = ModContent.ItemType(); - npc.Calamity().VulnerableToHeat = false; - npc.Calamity().VulnerableToCold = true; - npc.Calamity().VulnerableToSickness = true; - } + npc.Calamity().VulnerableToHeat = false; + npc.Calamity().VulnerableToCold = true; + npc.Calamity().VulnerableToSickness = true; + } public override void SendExtraAI(BinaryWriter writer) { @@ -105,17 +106,17 @@ namespace CalamityMod.NPCs.Yharon writer.Write(secondPhasePhase); writer.Write(teleportLocation); writer.Write(invincibilityCounter); - writer.Write(fastChargeTelegraphTime); - writer.WriteVector2(flareDustBulletHellSpawn); + writer.Write(fastChargeTelegraphTime); + writer.WriteVector2(flareDustBulletHellSpawn); writer.Write(safeBox.X); writer.Write(safeBox.Y); writer.Write(safeBox.Width); writer.Write(safeBox.Height); - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - writer.Write(npc.localAI[3]); - } + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + writer.Write(npc.localAI[3]); + } public override void ReceiveExtraAI(BinaryReader reader) { @@ -129,59 +130,59 @@ namespace CalamityMod.NPCs.Yharon secondPhasePhase = reader.ReadInt32(); teleportLocation = reader.ReadInt32(); invincibilityCounter = reader.ReadInt32(); - fastChargeTelegraphTime = reader.ReadInt32(); - flareDustBulletHellSpawn = reader.ReadVector2(); - safeBox.X = reader.ReadInt32(); + fastChargeTelegraphTime = reader.ReadInt32(); + flareDustBulletHellSpawn = reader.ReadVector2(); + safeBox.X = reader.ReadInt32(); safeBox.Y = reader.ReadInt32(); safeBox.Width = reader.ReadInt32(); safeBox.Height = reader.ReadInt32(); - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - npc.localAI[3] = reader.ReadSingle(); - } + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + npc.localAI[3] = reader.ReadSingle(); + } public override void AI() { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - // Stop rain - CalamityMod.StopRain(); + // Stop rain + CalamityMod.StopRain(); - // Variables - bool enraged2 = calamityGlobalNPC.enraged > 0; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive || enraged2; - bool expertMode = Main.expertMode || malice; - bool revenge = CalamityWorld.revenge || malice; - bool death = CalamityWorld.death || malice; + // Variables + bool enraged2 = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive || enraged2; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; - if (revenge) - { - // Increase aggression if player is taking a long time to kill the boss - if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) - lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - } + if (revenge) + { + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; + } - float pie = (float)Math.PI; + float pie = (float)Math.PI; - Vector2 vectorCenter = npc.Center; + Vector2 vectorCenter = npc.Center; - // Start phase 2 or not - if (startSecondAI) + // Start phase 2 or not + if (startSecondAI) { Yharon_AI2(expertMode, revenge, death, malice, pie, lifeRatio, vectorCenter, calamityGlobalNPC); return; } - // Phase booleans - float phase2GateValue = revenge ? 0.9f : expertMode ? 0.85f : 0.75f; - bool phase2Check = death || lifeRatio <= phase2GateValue; + // Phase booleans + float phase2GateValue = revenge ? 0.9f : expertMode ? 0.85f : 0.75f; + bool phase2Check = death || lifeRatio <= phase2GateValue; bool phase3Check = lifeRatio <= (death ? 0.8f : revenge ? 0.75f : expertMode ? 0.7f : 0.625f); bool phase4Check = lifeRatio <= ai2GateValue; - bool phase1Change = npc.ai[0] > -1f; + bool phase1Change = npc.ai[0] > -1f; bool phase2Change = npc.ai[0] > 5f; bool phase3Change = npc.ai[0] > 12f; @@ -190,40 +191,40 @@ namespace CalamityMod.NPCs.Yharon float acceleration = expertMode ? 0.75f : 0.7f; float velocity = expertMode ? 12f : 11f; - // Damage immunity - if (phase3Change) - npc.dontTakeDamage = phase4Check; - else if (phase2Change) - npc.dontTakeDamage = phase3Check; - else if (phase1Change) - npc.dontTakeDamage = phase2Check; + // Damage immunity + if (phase3Change) + npc.dontTakeDamage = phase4Check; + else if (phase2Change) + npc.dontTakeDamage = phase3Check; + else if (phase1Change) + npc.dontTakeDamage = phase2Check; - if (phase3Change) + if (phase3Change) { - acceleration = expertMode ? 0.85f : 0.8f; - velocity = expertMode ? 14f : 13f; - phaseSwitchTimer = expertMode ? 25 : 28; - fastChargeTelegraphTime = 100; + acceleration = expertMode ? 0.85f : 0.8f; + velocity = expertMode ? 14f : 13f; + phaseSwitchTimer = expertMode ? 25 : 28; + fastChargeTelegraphTime = 100; } else if (phase2Change) { - acceleration = expertMode ? 0.8f : 0.75f; - velocity = expertMode ? 13f : 12f; - phaseSwitchTimer = expertMode ? 32 : 36; - fastChargeTelegraphTime = 110; + acceleration = expertMode ? 0.8f : 0.75f; + velocity = expertMode ? 13f : 12f; + phaseSwitchTimer = expertMode ? 32 : 36; + fastChargeTelegraphTime = 110; } else - phaseSwitchTimer = 25; + phaseSwitchTimer = 25; - // Timers and velocity for charging - float reduceSpeedChargeDistance = 540f; + // Timers and velocity for charging + float reduceSpeedChargeDistance = 540f; int chargeTime = expertMode ? 40 : 45; float chargeSpeed = expertMode ? 28f : 26f; - float fastChargeVelocityMultiplier = malice ? 2f : 1.5f; - bool playFastChargeRoarSound = npc.localAI[1] == fastChargeTelegraphTime * 0.5f; - bool doFastCharge = npc.localAI[1] > fastChargeTelegraphTime; + float fastChargeVelocityMultiplier = malice ? 2f : 1.5f; + bool playFastChargeRoarSound = npc.localAI[1] == fastChargeTelegraphTime * 0.5f; + bool doFastCharge = npc.localAI[1] > fastChargeTelegraphTime; - if (phase3Change) + if (phase3Change) { chargeTime = 35; chargeSpeed = 30f; @@ -236,18 +237,18 @@ namespace CalamityMod.NPCs.Yharon chargeSpeed = 28.5f; } - if (revenge) - { - int chargeTimeDecrease = malice ? 6 : death ? 4 : 2; - float velocityMult = malice ? 1.15f : death ? 1.1f : 1.05f; - phaseSwitchTimer -= chargeTimeDecrease; - acceleration *= velocityMult; - velocity *= velocityMult; - chargeTime -= chargeTimeDecrease; - chargeSpeed *= velocityMult; - } + if (revenge) + { + int chargeTimeDecrease = malice ? 6 : death ? 4 : 2; + float velocityMult = malice ? 1.15f : death ? 1.1f : 1.05f; + phaseSwitchTimer -= chargeTimeDecrease; + acceleration *= velocityMult; + velocity *= velocityMult; + chargeTime -= chargeTimeDecrease; + chargeSpeed *= velocityMult; + } - float reduceSpeedFlareBombDistance = 570f; + float reduceSpeedFlareBombDistance = 570f; int flareBombPhaseTimer = malice ? 30 : death ? 40 : 60; int flareBombSpawnDivisor = flareBombPhaseTimer / 20; float flareBombPhaseAcceleration = malice ? 1f : death ? 0.92f : 0.8f; @@ -257,74 +258,74 @@ namespace CalamityMod.NPCs.Yharon int newPhaseTimer = 180; - float flareDustPhaseScalar = death ? 48f : 60f; - phase2GateValue -= ai2GateValue; // 0.35, 70% HP = 0.7 - 0.55 = 0.15, 0.35 - 0.15 = 0.2 / 0.35 = 0.57, 60% HP = 0.6 - 0.55 = 0.05, 0.35 - 0.05 = 0.3 / 0.35 = 0.85, 80% HP = 0.8 - 0.55 = 0.25, 0.35 - 0.25 = 0.1 / 0.35 = 0.28 - int flareDustPhaseTimerReduction = revenge ? (int)(flareDustPhaseScalar * ((phase2GateValue - (lifeRatio - ai2GateValue)) / phase2GateValue)) : 0; - int flareDustPhaseTimer = (malice ? 210 : death ? 240 : 300) - flareDustPhaseTimerReduction; - int flareDustPhaseTimer2 = (malice ? 105 : death ? 120 : 150) - (flareDustPhaseTimerReduction / 2); + float flareDustPhaseScalar = death ? 48f : 60f; + phase2GateValue -= ai2GateValue; // 0.35, 70% HP = 0.7 - 0.55 = 0.15, 0.35 - 0.15 = 0.2 / 0.35 = 0.57, 60% HP = 0.6 - 0.55 = 0.05, 0.35 - 0.05 = 0.3 / 0.35 = 0.85, 80% HP = 0.8 - 0.55 = 0.25, 0.35 - 0.25 = 0.1 / 0.35 = 0.28 + int flareDustPhaseTimerReduction = revenge ? (int)(flareDustPhaseScalar * ((phase2GateValue - (lifeRatio - ai2GateValue)) / phase2GateValue)) : 0; + int flareDustPhaseTimer = (malice ? 210 : death ? 240 : 300) - flareDustPhaseTimerReduction; + int flareDustPhaseTimer2 = (malice ? 105 : death ? 120 : 150) - (flareDustPhaseTimerReduction / 2); - float spinTime = flareDustPhaseTimer / 2; + float spinTime = flareDustPhaseTimer / 2; - int flareDustSpawnDivisor = flareDustPhaseTimer / 10; - int flareDustSpawnDivisor2 = flareDustPhaseTimer2 / 30; - int flareDustSpawnDivisor3 = flareDustPhaseTimer / 25; + int flareDustSpawnDivisor = flareDustPhaseTimer / 10; + int flareDustSpawnDivisor2 = flareDustPhaseTimer2 / 30; + int flareDustSpawnDivisor3 = flareDustPhaseTimer / 25; - float spinPhaseVelocity = 25f; + float spinPhaseVelocity = 25f; float spinPhaseRotation = MathHelper.TwoPi * 3 / spinTime; - float increasedIdleTimeAfterBulletHell = -120f; + float increasedIdleTimeAfterBulletHell = -120f; - float teleportPhaseTimer = 30f; + float teleportPhaseTimer = 30f; - int spawnPhaseTimer = 75; + int spawnPhaseTimer = 75; - // Target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + // Target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(); npc.netUpdate = true; } - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player player = Main.player[npc.target]; + Player player = Main.player[npc.target]; - // Despawn - if (player.dead || !player.active) + // Despawn + if (player.dead || !player.active) { - npc.TargetClosest(); - player = Main.player[npc.target]; - if (player.dead || !player.active) - { - npc.velocity.Y -= 0.4f; + npc.TargetClosest(); + player = Main.player[npc.target]; + if (player.dead || !player.active) + { + npc.velocity.Y -= 0.4f; - if (npc.timeLeft > 60) - npc.timeLeft = 60; + if (npc.timeLeft > 60) + npc.timeLeft = 60; - if (npc.ai[0] > 12f) - npc.ai[0] = 13f; - else if (npc.ai[0] > 5f) - npc.ai[0] = 6f; - else - npc.ai[0] = 0f; + if (npc.ai[0] > 12f) + npc.ai[0] = 13f; + else if (npc.ai[0] > 5f) + npc.ai[0] = 6f; + else + npc.ai[0] = 0f; - npc.ai[2] = 0f; - } + npc.ai[2] = 0f; + } } else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - int xPos = 60 * npc.direction; - Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; - Vector2 fromMouth = new Vector2((int)vector.X + xPos, (int)vector.Y - 15); + int xPos = 60 * npc.direction; + Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (npc.width + 20) / 2f + vectorCenter; + Vector2 fromMouth = new Vector2((int)vector.X + xPos, (int)vector.Y - 15); - // Create the arena, but not as a multiplayer client. - // In single player, the arena gets created and never gets synced because it's single player. - // In multiplayer, only the server/host creates the arena, and everyone else receives it on the next frame via SendExtraAI. - // Everyone however sets spawnArena to true to confirm that the fight has started. - if (!spawnArena) + // Create the arena, but not as a multiplayer client. + // In single player, the arena gets created and never gets synced because it's single player. + // In multiplayer, only the server/host creates the arena, and everyone else receives it on the next frame via SendExtraAI. + // Everyone however sets spawnArena to true to confirm that the fight has started. + if (!spawnArena) { spawnArena = true; enraged = false; @@ -348,7 +349,7 @@ namespace CalamityMod.NPCs.Yharon npc.Calamity().CurrentlyEnraged = enraged || enraged2; if (enraged) { - phaseSwitchTimer = 15; + phaseSwitchTimer = 15; protectionBoost = true; npc.damage = npc.defDamage * 5; chargeSpeed += 25f; @@ -360,13 +361,13 @@ namespace CalamityMod.NPCs.Yharon } } - // Set DR based on protection boost (aka enrage) - bool chargeTelegraph = (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f) && npc.localAI[1] > 0f; - bool bulletHell = npc.ai[0] == 8f || npc.ai[0] == 15f; - calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; + // Set DR based on protection boost (aka enrage) + bool chargeTelegraph = (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f) && npc.localAI[1] > 0f; + bool bulletHell = npc.ai[0] == 8f || npc.ai[0] == 15f; + calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; - if (bulletHell) - npc.damage = 0; + if (bulletHell) + npc.damage = 0; // Trigger spawn effects if (npc.localAI[0] == 0f) @@ -394,16 +395,16 @@ namespace CalamityMod.NPCs.Yharon float npcRotationSpeed = 0.04f; if (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 8f || npc.ai[0] == 11f || npc.ai[0] == 12f || - npc.ai[0] == 14f || npc.ai[0] == 15f || npc.ai[0] == 18f || npc.ai[0] == 19f) + npc.ai[0] == 14f || npc.ai[0] == 15f || npc.ai[0] == 18f || npc.ai[0] == 19f) npcRotationSpeed = 0f; if (npc.ai[0] == 3f || npc.ai[0] == 4f || npc.ai[0] == 9f || npc.ai[0] == 16f) npcRotationSpeed = 0.01f; - if (npcRotationSpeed != 0f) - npc.rotation = npc.rotation.AngleTowards(npcRotation, npcRotationSpeed); + if (npcRotationSpeed != 0f) + npc.rotation = npc.rotation.AngleTowards(npcRotation, npcRotationSpeed); - // Alpha effects - if (npc.ai[0] != -1f && ((npc.ai[0] != 6f && npc.ai[0] != 13f) || npc.ai[2] <= phaseSwitchTimer)) + // Alpha effects + if (npc.ai[0] != -1f && ((npc.ai[0] != 6f && npc.ai[0] != 13f) || npc.ai[2] <= phaseSwitchTimer)) { bool colliding = Collision.SolidCollision(npc.position, npc.width, npc.height); @@ -476,20 +477,20 @@ namespace CalamityMod.NPCs.Yharon } #region Phase1 - // Phase switch + // Phase switch else if (npc.ai[0] == 0f && !player.dead) { if (npc.ai[1] == 0f) npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); - Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); - Vector2 distanceFromDestination = destination - vectorCenter; + Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); + Vector2 distanceFromDestination = destination - vectorCenter; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - npc.velocity) * velocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) - npc.SimpleFlyMovement(desiredVelocity, acceleration); - else - npc.velocity *= 0.98f; + if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + npc.SimpleFlyMovement(desiredVelocity, acceleration); + else + npc.velocity *= 0.98f; int num1471 = Math.Sign(player.Center.X - vectorCenter.X); if (num1471 != 0) @@ -571,41 +572,41 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - if (playFastChargeRoarSound) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (playFastChargeRoarSound) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (doFastCharge) - { - npc.ai[0] = 5f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[1] = 0f; + if (doFastCharge) + { + npc.ai[0] = 5f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[1] = 0f; - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num1471 != 0) - { - npc.direction = num1471; + if (num1471 != 0) + { + npc.direction = num1471; - if (npc.spriteDirection == 1) - npc.rotation += pie; + if (npc.spriteDirection == 1) + npc.rotation += pie; - npc.spriteDirection = -npc.direction; - } - } - else - npc.localAI[1] += 1f; + npc.spriteDirection = -npc.direction; + } + } + else + npc.localAI[1] += 1f; } npc.netUpdate = true; } } - // Charge + // Charge else if (npc.ai[0] == 1f) { - ChargeDust(7, pie); + ChargeDust(7, pie); npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) @@ -614,25 +615,25 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Fireball breath + // Fireball breath else if (npc.ai[0] == 2f) { if (npc.ai[1] == 0f) - npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); - Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); - Vector2 value17 = destination - vectorCenter; - Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * flareBombPhaseVelocity; + Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); + Vector2 value17 = destination - vectorCenter; + Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * flareBombPhaseVelocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedFlareBombDistance) - npc.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); - else - npc.velocity *= 0.98f; + if (Vector2.Distance(vectorCenter, destination) > reduceSpeedFlareBombDistance) + npc.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); + else + npc.velocity *= 0.98f; if (npc.ai[2] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); @@ -641,9 +642,9 @@ namespace CalamityMod.NPCs.Yharon { if (Main.netMode != NetmodeID.MultiplayerClient) { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(fromMouth, Vector2.Zero, type, damage, 0f, Main.myPlayer, npc.target, 1f); + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(fromMouth, Vector2.Zero, type, damage, 0f, Main.myPlayer, npc.target, 1f); } } @@ -664,12 +665,12 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Fire tornadoes + // Fire tornadoes else if (npc.ai[0] == 3f) { npc.velocity *= 0.98f; @@ -690,12 +691,12 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Enter new phase + // Enter new phase else if (npc.ai[0] == 4f) { npc.velocity *= 0.9f; @@ -711,16 +712,16 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.localAI[1] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.localAI[1] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Fast charge + // Fast charge else if (npc.ai[0] == 5f) { - ChargeDust(14, pie); + ChargeDust(14, pie); npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) @@ -729,27 +730,27 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } #endregion #region Phase2 - // Phase switch + // Phase switch else if (npc.ai[0] == 6f && !player.dead) { if (npc.ai[1] == 0f) - npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); - Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); - Vector2 distanceFromDestination = destination - vectorCenter; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - npc.velocity) * velocity; + Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); + Vector2 distanceFromDestination = destination - vectorCenter; + Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - npc.velocity) * velocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) - npc.SimpleFlyMovement(desiredVelocity, acceleration); - else - npc.velocity *= 0.98f; + if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + npc.SimpleFlyMovement(desiredVelocity, acceleration); + else + npc.velocity *= 0.98f; int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) @@ -816,28 +817,28 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 2) { - Vector2 npcCenter = vectorCenter; + Vector2 npcCenter = vectorCenter; - if (npc.alpha < 255) - { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; - } + if (npc.alpha < 255) + { + npc.alpha += 17; + if (npc.alpha > 255) + npc.alpha = 255; + } - if (npc.ai[2] == phaseSwitchTimer + 15f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == phaseSwitchTimer + 15f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == phaseSwitchTimer + 15f) - { - Vector2 center = player.Center + new Vector2(0f, -540f); - npcCenter = npc.Center = center; - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == phaseSwitchTimer + 15f) + { + Vector2 center = player.Center + new Vector2(0f, -540f); + npcCenter = npc.Center = center; + } - if (npc.ai[2] < phaseSwitchTimer + teleportPhaseTimer) - return; + if (npc.ai[2] < phaseSwitchTimer + teleportPhaseTimer) + return; - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num1477 != 0) @@ -853,8 +854,8 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 8f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.ai[3] = 1f; - } + npc.ai[3] = 1f; + } else if (aiState == 3) { npc.ai[0] = 9f; @@ -869,31 +870,31 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - if (playFastChargeRoarSound) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (playFastChargeRoarSound) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (doFastCharge) - { - npc.ai[0] = 11f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[1] = 0f; + if (doFastCharge) + { + npc.ai[0] = 11f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[1] = 0f; - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num1477 != 0) - { - npc.direction = num1477; + if (num1477 != 0) + { + npc.direction = num1477; - if (npc.spriteDirection == 1) - npc.rotation += pie; + if (npc.spriteDirection == 1) + npc.rotation += pie; - npc.spriteDirection = -npc.direction; - } - } - else - npc.localAI[1] += 1f; + npc.spriteDirection = -npc.direction; + } + } + else + npc.localAI[1] += 1f; } else if (aiState == 6) { @@ -919,10 +920,10 @@ namespace CalamityMod.NPCs.Yharon } } - // Charge + // Charge else if (npc.ai[0] == 7f) { - ChargeDust(7, pie); + ChargeDust(7, pie); npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) @@ -931,51 +932,51 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Flare Dust bullet hell + // Flare Dust bullet hell else if (npc.ai[0] == 8f) { - if (npc.ai[2] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - flareDustBulletHellSpawn = vectorCenter + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / (MathHelper.TwoPi * 3f); - } - - npc.ai[2] += 1f; - - if (npc.ai[2] % flareDustSpawnDivisor == 0f) + if (npc.ai[2] == 0f) { - if (Main.netMode != NetmodeID.MultiplayerClient) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + flareDustBulletHellSpawn = vectorCenter + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / (MathHelper.TwoPi * 3f); + } + + npc.ai[2] += 1f; + + if (npc.ai[2] % flareDustSpawnDivisor == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) { - int ringReduction = (int)MathHelper.Lerp(0f, 14f, npc.ai[2] / flareDustPhaseTimer); - int totalProjectiles = 38 - ringReduction; // 36 for first ring, 22 for last ring - DoFlareDustBulletHell(0, flareDustSpawnDivisor, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, false); + int ringReduction = (int)MathHelper.Lerp(0f, 14f, npc.ai[2] / flareDustPhaseTimer); + int totalProjectiles = 38 - ringReduction; // 36 for first ring, 22 for last ring + DoFlareDustBulletHell(0, flareDustSpawnDivisor, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, false); - // Fire a flame towards every player, with a limit of 5 - if (expertMode) - { - List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + // Fire a flame towards every player, with a limit of 5 + if (expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); - if (targets.Count > 4) - break; - } - foreach (int t in targets) - { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * 8f; - int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); - Main.projectile[proj].extraUpdates += 1; - } - } - } + if (targets.Count > 4) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * 8f; + int type = ModContent.ProjectileType(); + int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + Main.projectile[proj].extraUpdates += 1; + } + } + } } npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); @@ -983,15 +984,15 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[2] >= flareDustPhaseTimer) { - npc.ai[0] = 6f; + npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = increasedIdleTimeAfterBulletHell; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Infernado + // Infernado else if (npc.ai[0] == 9f) { npc.velocity *= 0.98f; @@ -1009,12 +1010,12 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Enter new phase + // Enter new phase else if (npc.ai[0] == 10f) { npc.velocity *= 0.9f; @@ -1030,47 +1031,47 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.localAI[1] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.localAI[1] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Fast charge + // Fast charge else if (npc.ai[0] == 11f) { - ChargeDust(14, pie); + ChargeDust(14, pie); - npc.ai[2] += 1f; + npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) { npc.ai[0] = 6f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Flare Dust that speeds up and whips around in a wave + // Flare Dust that speeds up and whips around in a wave else if (npc.ai[0] == 12f) { - if (npc.ai[2] == 0f) + if (npc.ai[2] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.ai[2] += 1f; + npc.ai[2] += 1f; - if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) + if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 projectileVelocity = player.Center - fromMouth; - projectileVelocity.Normalize(); - projectileVelocity *= 0.1f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(fromMouth, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + Vector2 projectileVelocity = player.Center - fromMouth; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(fromMouth, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); } } @@ -1083,27 +1084,27 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } #endregion #region Phase3 - // Phase switch + // Phase switch else if (npc.ai[0] == 13f && !player.dead) { if (npc.ai[1] == 0f) - npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); + npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); - Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); - Vector2 distanceFromDestination = destination - vectorCenter; - Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - npc.velocity) * velocity; + Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); + Vector2 distanceFromDestination = destination - vectorCenter; + Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - npc.velocity) * velocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) - npc.SimpleFlyMovement(desiredVelocity, acceleration); - else - npc.velocity *= 0.98f; + if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + npc.SimpleFlyMovement(desiredVelocity, acceleration); + else + npc.velocity *= 0.98f; int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) @@ -1138,15 +1139,15 @@ namespace CalamityMod.NPCs.Yharon aiState = 3; break; case 6: - aiState = 6; + aiState = 6; break; case 7: npc.ai[3] = 1f; aiState = 7; break; - case 8: - aiState = 2; - break; + case 8: + aiState = 2; + break; } if (phase4Check) @@ -1173,28 +1174,28 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 2) { - Vector2 npcCenter = vectorCenter; + Vector2 npcCenter = vectorCenter; - if (npc.alpha < 255) - { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; - } + if (npc.alpha < 255) + { + npc.alpha += 17; + if (npc.alpha > 255) + npc.alpha = 255; + } - if (npc.ai[2] == phaseSwitchTimer + 15f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == phaseSwitchTimer + 15f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == phaseSwitchTimer + 15f) - { - Vector2 center = player.Center + new Vector2(0f, -540f); - npcCenter = npc.Center = center; - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == phaseSwitchTimer + 15f) + { + Vector2 center = player.Center + new Vector2(0f, -540f); + npcCenter = npc.Center = center; + } - if (npc.ai[2] < phaseSwitchTimer + teleportPhaseTimer) - return; + if (npc.ai[2] < phaseSwitchTimer + teleportPhaseTimer) + return; - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); if (num1477 != 0) @@ -1210,8 +1211,8 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 15f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.ai[3] = 0f; - } + npc.ai[3] = 0f; + } else if (aiState == 3) { npc.ai[0] = 16f; @@ -1226,31 +1227,31 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 5) { - if (playFastChargeRoarSound) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (playFastChargeRoarSound) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (doFastCharge) - { - npc.ai[0] = 18f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[1] = 0f; + if (doFastCharge) + { + npc.ai[0] = 18f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[1] = 0f; - npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); + npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); - if (num1477 != 0) - { - npc.direction = num1477; + if (num1477 != 0) + { + npc.direction = num1477; - if (npc.spriteDirection == 1) - npc.rotation += pie; + if (npc.spriteDirection == 1) + npc.rotation += pie; - npc.spriteDirection = -npc.direction; - } - } - else - npc.localAI[1] += 1f; + npc.spriteDirection = -npc.direction; + } + } + else + npc.localAI[1] += 1f; } else if (aiState == 6) { @@ -1271,90 +1272,90 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; } - else if (aiState == 7) - { - npc.ai[0] = 20f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - } + else if (aiState == 7) + { + npc.ai[0] = 20f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } - npc.netUpdate = true; + npc.netUpdate = true; } } - // Charge + // Charge else if (npc.ai[0] == 14f) { - ChargeDust(7, pie); + ChargeDust(7, pie); - npc.ai[2] += 1f; + npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) { npc.ai[0] = 13f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Flare Dust bullet hell - else if (npc.ai[0] == 15f) + // Flare Dust bullet hell + else if (npc.ai[0] == 15f) { - if (npc.ai[2] == 0f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - flareDustBulletHellSpawn = vectorCenter + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / (MathHelper.TwoPi * 3f); - } + if (npc.ai[2] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + flareDustBulletHellSpawn = vectorCenter + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / (MathHelper.TwoPi * 3f); + } - npc.ai[2] += 1f; - if (npc.ai[2] % flareDustSpawnDivisor3 == 0f) - { - // Rotate spiral by 7.2 * (300 / 12) = +90 degrees and then back -90 degrees + npc.ai[2] += 1f; + if (npc.ai[2] % flareDustSpawnDivisor3 == 0f) + { + // Rotate spiral by 7.2 * (300 / 12) = +90 degrees and then back -90 degrees - if (Main.netMode != NetmodeID.MultiplayerClient) - { - DoFlareDustBulletHell(1, flareDustPhaseTimer, npc.GetProjectileDamage(ModContent.ProjectileType()), 8, 12f, 3.6f, false); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + DoFlareDustBulletHell(1, flareDustPhaseTimer, npc.GetProjectileDamage(ModContent.ProjectileType()), 8, 12f, 3.6f, false); - // Fire a flame towards every player, with a limit of 5 - if (expertMode && npc.ai[2] % (flareDustSpawnDivisor3 * 2) == 0f) - { - List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + // Fire a flame towards every player, with a limit of 5 + if (expertMode && npc.ai[2] % (flareDustSpawnDivisor3 * 2) == 0f) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); - if (targets.Count > 4) - break; - } - foreach (int t in targets) - { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * 8f; - int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); - Main.projectile[proj].extraUpdates += 1; - } - } - } - } + if (targets.Count > 4) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * 8f; + int type = ModContent.ProjectileType(); + int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + Main.projectile[proj].extraUpdates += 1; + } + } + } + } - npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); - npc.rotation -= spinPhaseRotation * npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); + npc.rotation -= spinPhaseRotation * npc.direction; - if (npc.ai[2] >= flareDustPhaseTimer) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.localAI[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } + if (npc.ai[2] >= flareDustPhaseTimer) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.localAI[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } } - // Infernado + // Infernado else if (npc.ai[0] == 16f) { npc.velocity *= 0.98f; @@ -1373,147 +1374,147 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 3f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Enter new phase + // Enter new phase else if (npc.ai[0] == 17f) { - npc.velocity *= 0.9f; - npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); + npc.velocity *= 0.9f; + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, 0f, 0.02f); - if (npc.ai[2] == newPhaseTimer - 60) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == newPhaseTimer - 60) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.ai[2] += 1f; - if (npc.ai[2] >= newPhaseTimer) - { - startSecondAI = true; - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.localAI[1] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } + npc.ai[2] += 1f; + if (npc.ai[2] >= newPhaseTimer) + { + startSecondAI = true; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.localAI[1] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } } - // Fast charge + // Fast charge else if (npc.ai[0] == 18f) { - ChargeDust(14, pie); + ChargeDust(14, pie); - npc.ai[2] += 1f; + npc.ai[2] += 1f; if (npc.ai[2] >= chargeTime) { npc.ai[0] = 13f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } - // Fireball ring + // Fireball ring else if (npc.ai[0] == 19f) { - if (npc.ai[2] == 0f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.ai[2] += 1f; + npc.ai[2] += 1f; - if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 projectileVelocity = player.Center - fromMouth; - projectileVelocity.Normalize(); - projectileVelocity *= 0.1f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(fromMouth, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } + if (npc.ai[2] % flareDustSpawnDivisor2 == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 projectileVelocity = player.Center - fromMouth; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(fromMouth, projectileVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + } + } - npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); - npc.rotation -= spinPhaseRotation * npc.direction; + npc.velocity = npc.velocity.RotatedBy(-(double)spinPhaseRotation * (float)npc.direction); + npc.rotation -= spinPhaseRotation * npc.direction; - if (npc.ai[2] >= flareDustPhaseTimer2 - 50) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.ai[3] += 1f; - npc.TargetClosest(); - npc.netUpdate = true; - } + if (npc.ai[2] >= flareDustPhaseTimer2 - 50) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.ai[3] += 1f; + npc.TargetClosest(); + npc.netUpdate = true; + } } - // Fireball breath - else if (npc.ai[0] == 20f) - { - if (npc.ai[1] == 0f) - npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); + // Fireball breath + else if (npc.ai[0] == 20f) + { + if (npc.ai[1] == 0f) + npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); - Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); - Vector2 value17 = destination - vectorCenter; - Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * flareBombPhaseVelocity; + Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); + Vector2 value17 = destination - vectorCenter; + Vector2 vector170 = Vector2.Normalize(value17 - npc.velocity) * flareBombPhaseVelocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedFlareBombDistance) - npc.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); - else - npc.velocity *= 0.98f; + if (Vector2.Distance(vectorCenter, destination) > reduceSpeedFlareBombDistance) + npc.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); + else + npc.velocity *= 0.98f; - if (npc.ai[2] == 0f) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[2] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - if (npc.ai[2] % flareBombSpawnDivisor == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(fromMouth, Vector2.Zero, type, damage, 0f, Main.myPlayer, npc.target, 1f); - } - } + if (npc.ai[2] % flareBombSpawnDivisor == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(fromMouth, Vector2.Zero, type, damage, 0f, Main.myPlayer, npc.target, 1f); + } + } - int num1476 = Math.Sign(player.Center.X - vectorCenter.X); - if (num1476 != 0) - { - npc.direction = num1476; + int num1476 = Math.Sign(player.Center.X - vectorCenter.X); + if (num1476 != 0) + { + npc.direction = num1476; - if (npc.spriteDirection != -npc.direction) - npc.rotation += pie; + if (npc.spriteDirection != -npc.direction) + npc.rotation += pie; - npc.spriteDirection = -npc.direction; - } + npc.spriteDirection = -npc.direction; + } - npc.ai[2] += 1f; - if (npc.ai[2] >= flareBombPhaseTimer - 15) - { - npc.ai[0] = 13f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } - #endregion - } + npc.ai[2] += 1f; + if (npc.ai[2] >= flareBombPhaseTimer - 15) + { + npc.ai[0] = 13f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + #endregion + } #region AI2 public void Yharon_AI2(bool expertMode, bool revenge, bool death, bool malice, float pie, float lifeRatio, Vector2 vectorCenter, CalamityGlobalNPC calamityGlobalNPC) { - float phase2GateValue = revenge ? 0.44f : expertMode ? 0.385f : 0.275f; - bool phase2 = death || lifeRatio <= phase2GateValue; - float phase3GateValue = death ? 0.358f : revenge ? 0.275f : expertMode ? 0.22f : 0.138f; - bool phase3 = lifeRatio <= phase3GateValue; - float phase4GateValue = death ? 0.165f : 0.11f; - bool phase4 = lifeRatio <= phase4GateValue && revenge; + float phase2GateValue = revenge ? 0.44f : expertMode ? 0.385f : 0.275f; + bool phase2 = death || lifeRatio <= phase2GateValue; + float phase3GateValue = death ? 0.358f : revenge ? 0.275f : expertMode ? 0.22f : 0.138f; + bool phase3 = lifeRatio <= phase3GateValue; + float phase4GateValue = death ? 0.165f : 0.11f; + bool phase4 = lifeRatio <= phase4GateValue && revenge; if (npc.ai[0] != 8f) { @@ -1535,142 +1536,142 @@ namespace CalamityMod.NPCs.Yharon CalamityUtils.DisplayLocalizedText(key, messageColor); } - if (invincibilityCounter < 900) - { - phase2 = phase3 = phase4 = false; - invincibilityCounter += 1; - } - else - { - // Damage immunity - switch (secondPhasePhase) - { - case 1: - npc.dontTakeDamage = phase2; - break; - case 2: - npc.dontTakeDamage = phase3; - break; - case 3: - npc.dontTakeDamage = phase4; - break; - case 4: - npc.dontTakeDamage = false; - break; - } + if (invincibilityCounter < Phase2InvincibilityTime) + { + phase2 = phase3 = phase4 = false; + invincibilityCounter += 1; + } + else + { + // Damage immunity + switch (secondPhasePhase) + { + case 1: + npc.dontTakeDamage = phase2; + break; + case 2: + npc.dontTakeDamage = phase3; + break; + case 3: + npc.dontTakeDamage = phase4; + break; + case 4: + npc.dontTakeDamage = false; + break; + } - if (!npc.dontTakeDamage) - npc.dontTakeDamage = npc.ai[0] == 9f; - } + if (!npc.dontTakeDamage) + npc.dontTakeDamage = npc.ai[0] == 9f; + } - // Acquire target and determine enrage state - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) - { - npc.TargetClosest(); - npc.netUpdate = true; - } + // Acquire target and determine enrage state + if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) + { + npc.TargetClosest(); + npc.netUpdate = true; + } - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, vectorCenter) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); - Player targetData = Main.player[npc.target]; + Player targetData = Main.player[npc.target]; - // Despawn - bool targetDead = false; - if (targetData.dead || !targetData.active) - { - npc.TargetClosest(); - targetData = Main.player[npc.target]; - if (targetData.dead || !targetData.active) - { - targetDead = true; + // Despawn + bool targetDead = false; + if (targetData.dead || !targetData.active) + { + npc.TargetClosest(); + targetData = Main.player[npc.target]; + if (targetData.dead || !targetData.active) + { + targetDead = true; - npc.velocity.Y -= 0.4f; + npc.velocity.Y -= 0.4f; - if (npc.timeLeft > 60) - npc.timeLeft = 60; + if (npc.timeLeft > 60) + npc.timeLeft = 60; - npc.ai[0] = 1f; - npc.ai[1] = 0f; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; + npc.ai[0] = 1f; + npc.ai[1] = 0f; + } + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; - enraged = !targetData.Hitbox.Intersects(safeBox); - if (enraged) - { - protectionBoost = true; - npc.damage = npc.defDamage * 5; - } - else - { - protectionBoost = false; - npc.damage = npc.defDamage; - } + enraged = !targetData.Hitbox.Intersects(safeBox); + if (enraged) + { + protectionBoost = true; + npc.damage = npc.defDamage * 5; + } + else + { + protectionBoost = false; + npc.damage = npc.defDamage; + } - // Set DR based on protection boost (aka enrage) - bool chargeTelegraph = npc.ai[0] < 2f && npc.localAI[1] > 0f; - bool bulletHell = npc.ai[0] == 5f; - calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; + // Set DR based on protection boost (aka enrage) + bool chargeTelegraph = npc.ai[0] < 2f && npc.localAI[1] > 0f; + bool bulletHell = npc.ai[0] == 5f; + calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; - if (bulletHell) - npc.damage = 0; + if (bulletHell) + npc.damage = 0; - float reduceSpeedChargeDistance = 500f; - float phaseSwitchTimer = malice ? 28f : expertMode ? 30f : 32f; - float acceleration = expertMode ? 0.92f : 0.9f; + float reduceSpeedChargeDistance = 500f; + float phaseSwitchTimer = malice ? 28f : expertMode ? 30f : 32f; + float acceleration = expertMode ? 0.92f : 0.9f; float velocity = expertMode ? 14.5f : 14f; - float chargeTime = expertMode ? 32f : 35f; + float chargeTime = expertMode ? 32f : 35f; float chargeSpeed = expertMode ? 32f : 30f; - float fastChargeVelocityMultiplier = malice ? 2f : 1.5f; - fastChargeTelegraphTime = protectionBoost ? 60 : (100 - secondPhasePhase * 10); - bool playFastChargeRoarSound = npc.localAI[1] == fastChargeTelegraphTime * 0.5f; - bool doFastChargeTelegraph = npc.localAI[1] <= fastChargeTelegraphTime; + float fastChargeVelocityMultiplier = malice ? 2f : 1.5f; + fastChargeTelegraphTime = protectionBoost ? 60 : (100 - secondPhasePhase * 10); + bool playFastChargeRoarSound = npc.localAI[1] == fastChargeTelegraphTime * 0.5f; + bool doFastChargeTelegraph = npc.localAI[1] <= fastChargeTelegraphTime; - float fireballBreathTimer = 60f; + float fireballBreathTimer = 60f; float fireballBreathPhaseTimer = fireballBreathTimer + 120f; - float fireballBreathPhaseVelocity = 22f; + float fireballBreathPhaseVelocity = 22f; float splittingFireballBreathTimer = 40f; float splittingFireballBreathPhaseVelocity = 22f; int splittingFireballBreathDivisor = 10; - int splittingFireballs = 10; + int splittingFireballs = 10; int splittingFireballBreathTimer2 = splittingFireballs * splittingFireballBreathDivisor; float splittingFireballBreathYVelocityTimer = 40f; float splittingFireballBreathPhaseTimer = splittingFireballBreathTimer + splittingFireballBreathTimer2 + splittingFireballBreathYVelocityTimer; - float flareDustPhaseScalar = secondPhasePhase == 4 ? (death ? 54f : 60f) : (death ? 67f : 80f); - int spinPhaseTimerReduction = revenge ? (secondPhasePhase == 4 ? (int)(flareDustPhaseScalar * ((phase4GateValue - lifeRatio) / phase4GateValue)) : (int)(flareDustPhaseScalar * (ai2GateValue - lifeRatio))) : 0; - int spinPhaseTimer = (secondPhasePhase == 4 ? (malice ? 150 : death ? 160 : 180) : (malice ? 180 : death ? 200 : 240)) - spinPhaseTimerReduction; - float spinTime = spinPhaseTimer / 2; - float spinRotation = MathHelper.TwoPi * 3 / spinTime; - float spinPhaseVelocity = 25f; - int flareDustSpawnDivisor = spinPhaseTimer / 10; - int flareDustSpawnDivisor2 = spinPhaseTimer / 20 + (secondPhasePhase == 4 ? spinPhaseTimer / 60 : 0); - float increasedIdleTimeAfterBulletHell = -120f; + float flareDustPhaseScalar = secondPhasePhase == 4 ? (death ? 54f : 60f) : (death ? 67f : 80f); + int spinPhaseTimerReduction = revenge ? (secondPhasePhase == 4 ? (int)(flareDustPhaseScalar * ((phase4GateValue - lifeRatio) / phase4GateValue)) : (int)(flareDustPhaseScalar * (ai2GateValue - lifeRatio))) : 0; + int spinPhaseTimer = (secondPhasePhase == 4 ? (malice ? 150 : death ? 160 : 180) : (malice ? 180 : death ? 200 : 240)) - spinPhaseTimerReduction; + float spinTime = spinPhaseTimer / 2; + float spinRotation = MathHelper.TwoPi * 3 / spinTime; + float spinPhaseVelocity = 25f; + int flareDustSpawnDivisor = spinPhaseTimer / 10; + int flareDustSpawnDivisor2 = spinPhaseTimer / 20 + (secondPhasePhase == 4 ? spinPhaseTimer / 60 : 0); + float increasedIdleTimeAfterBulletHell = -120f; - float flareSpawnDecelerationTimer = malice ? 60f : death ? 75f : 90f; - int flareSpawnPhaseTimerReduction = revenge ? (int)(flareSpawnDecelerationTimer * (ai2GateValue - lifeRatio)) : 0; - float flareSpawnPhaseTimer = (malice ? 120f : death ? 150f : 180f) - flareSpawnPhaseTimerReduction; + float flareSpawnDecelerationTimer = malice ? 60f : death ? 75f : 90f; + int flareSpawnPhaseTimerReduction = revenge ? (int)(flareSpawnDecelerationTimer * (ai2GateValue - lifeRatio)) : 0; + float flareSpawnPhaseTimer = (malice ? 120f : death ? 150f : 180f) - flareSpawnPhaseTimerReduction; - float teleportPhaseTimer = 45f; + float teleportPhaseTimer = 45f; - if (revenge) - { - float chargeTimeDecrease = malice ? 6f : death ? 4f : 2f; - float velocityMult = malice ? 1.15f : death ? 1.1f : 1.05f; - acceleration *= velocityMult; - velocity *= velocityMult; - chargeTime -= chargeTimeDecrease; - chargeSpeed *= velocityMult; - } + if (revenge) + { + float chargeTimeDecrease = malice ? 6f : death ? 4f : 2f; + float velocityMult = malice ? 1.15f : death ? 1.1f : 1.05f; + acceleration *= velocityMult; + velocity *= velocityMult; + chargeTime -= chargeTimeDecrease; + chargeSpeed *= velocityMult; + } if (npc.ai[0] == 0f) { - npc.ai[1] += 1f; + npc.ai[1] += 1f; if (npc.ai[1] >= 10f) { npc.ai[1] = 0f; @@ -1682,24 +1683,24 @@ namespace CalamityMod.NPCs.Yharon else if (npc.ai[0] == 1f) { if (npc.ai[2] == 0f) - npc.ai[2] = (vectorCenter.X < targetData.Center.X) ? 1 : -1; + npc.ai[2] = (vectorCenter.X < targetData.Center.X) ? 1 : -1; - Vector2 destination = targetData.Center + new Vector2(-npc.ai[2], 0f); - Vector2 desiredVelocity = npc.SafeDirectionTo(destination) * velocity; + Vector2 destination = targetData.Center + new Vector2(-npc.ai[2], 0f); + Vector2 desiredVelocity = npc.SafeDirectionTo(destination) * velocity; - if (!targetDead) - { - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) - npc.SimpleFlyMovement(desiredVelocity, acceleration); - else - npc.velocity *= 0.98f; - } + if (!targetDead) + { + if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + npc.SimpleFlyMovement(desiredVelocity, acceleration); + else + npc.velocity *= 0.98f; + } int num27 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; npc.direction = npc.spriteDirection = num27; - npc.ai[1] += 1f; - if (npc.ai[1] >= phaseSwitchTimer) + npc.ai[1] += 1f; + if (npc.ai[1] >= phaseSwitchTimer) { int num28 = 1; if (phase4) @@ -1842,65 +1843,65 @@ namespace CalamityMod.NPCs.Yharon } } - if (num28 == 5 && npc.ai[1] < phaseSwitchTimer + teleportPhaseTimer) - { - float newRotation = npc.AngleTo(targetData.Center); - float amount = 0.04f; + if (num28 == 5 && npc.ai[1] < phaseSwitchTimer + teleportPhaseTimer) + { + float newRotation = npc.AngleTo(targetData.Center); + float amount = 0.04f; - if (npc.spriteDirection == -1) - newRotation += pie; + if (npc.spriteDirection == -1) + newRotation += pie; - if (amount != 0f) - npc.rotation = npc.rotation.AngleTowards(newRotation, amount); + if (amount != 0f) + npc.rotation = npc.rotation.AngleTowards(newRotation, amount); - Vector2 npcCenter = vectorCenter; + Vector2 npcCenter = vectorCenter; - if (npc.alpha < 255) - { - npc.alpha += 17; - if (npc.alpha > 255) - npc.alpha = 255; - } + if (npc.alpha < 255) + { + npc.alpha += 17; + if (npc.alpha > 255) + npc.alpha = 255; + } - float timeBeforeTeleport = teleportPhaseTimer - 15f; - if (npc.ai[1] == phaseSwitchTimer + timeBeforeTeleport) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + float timeBeforeTeleport = teleportPhaseTimer - 15f; + if (npc.ai[1] == phaseSwitchTimer + timeBeforeTeleport) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == phaseSwitchTimer + timeBeforeTeleport) - { - Vector2 center = targetData.Center + new Vector2(0f, -540f); - npcCenter = npc.Center = center; - } + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == phaseSwitchTimer + timeBeforeTeleport) + { + Vector2 center = targetData.Center + new Vector2(0f, -540f); + npcCenter = npc.Center = center; + } - return; - } + return; + } - if (num28 == 7 && doFastChargeTelegraph) - { - float newRotation = npc.AngleTo(targetData.Center); - float amount = 0.04f; + if (num28 == 7 && doFastChargeTelegraph) + { + float newRotation = npc.AngleTo(targetData.Center); + float amount = 0.04f; - if (npc.spriteDirection == -1) - newRotation += pie; + if (npc.spriteDirection == -1) + newRotation += pie; - if (amount != 0f) - npc.rotation = npc.rotation.AngleTowards(newRotation, amount); + if (amount != 0f) + npc.rotation = npc.rotation.AngleTowards(newRotation, amount); - if (playFastChargeRoarSound) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + if (playFastChargeRoarSound) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - npc.localAI[1] += 1f; + npc.localAI[1] += 1f; - return; - } + return; + } npc.ai[0] = num28; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 1f; - npc.localAI[1] = 0f; + npc.localAI[1] = 0f; - switch (secondPhasePhase) + switch (secondPhasePhase) { case 1: if (phase2) @@ -1980,9 +1981,9 @@ namespace CalamityMod.NPCs.Yharon npc.rotation += pie; npc.velocity = vector3 * spinPhaseVelocity; - - npc.localAI[3] = Main.rand.Next(2); - + + npc.localAI[3] = Main.rand.Next(2); + break; } case 7: //fast charge @@ -2002,32 +2003,32 @@ namespace CalamityMod.NPCs.Yharon } } - // Charge + // Charge else if (npc.ai[0] == 2f) { if (npc.ai[1] == 1f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - ChargeDust(7, pie); + ChargeDust(7, pie); - npc.ai[1] += 1f; - if (npc.ai[1] >= chargeTime) + npc.ai[1] += 1f; + if (npc.ai[1] >= chargeTime) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); + npc.TargetClosest(); } } - // Fireball spit + // Fireball spit else if (npc.ai[0] == 3f) { int num29 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; npc.ai[2] = num29; - npc.ai[1] += 1f; - if (npc.ai[1] < fireballBreathTimer) + npc.ai[1] += 1f; + if (npc.ai[1] < fireballBreathTimer) { Vector2 vector4 = targetData.Center + new Vector2(num29 * -750f, -300f); Vector2 value = npc.SafeDirectionTo(vector4) * 16f; @@ -2055,12 +2056,12 @@ namespace CalamityMod.NPCs.Yharon { float xOffset = 30f; Vector2 position = vectorCenter + new Vector2((110f + xOffset) * npc.direction, -20f).RotatedBy(npc.rotation); - Vector2 projectileVelocity = targetData.Center - position; - projectileVelocity.Normalize(); - projectileVelocity *= 0.1f; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(position, projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f); + Vector2 projectileVelocity = targetData.Center - position; + projectileVelocity.Normalize(); + projectileVelocity *= 0.1f; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(position, projectileVelocity, type, damage, 0f, Main.myPlayer, 1f, 0f); } if (Math.Abs(targetData.Center.X - vectorCenter.X) > 700f && Math.Abs(npc.velocity.X) < chargeSpeed) @@ -2072,11 +2073,11 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - } + npc.TargetClosest(); + } } - // Splitting fireball breath + // Splitting fireball breath else if (npc.ai[0] == 4f) { int num31 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; @@ -2119,9 +2120,9 @@ namespace CalamityMod.NPCs.Yharon Vector2 position = vectorCenter + new Vector2((110f + xOffset) * npc.direction, -20f).RotatedBy(npc.rotation); int num34 = (int)(npc.ai[1] - splittingFireballBreathTimer + 1f); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - if (num34 <= splittingFireballBreathTimer2 && num34 % splittingFireballBreathDivisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + if (num34 <= splittingFireballBreathTimer2 && num34 % splittingFireballBreathDivisor == 0 && Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(position, npc.velocity, type, damage, 0f, Main.myPlayer, 0f, 0f); } @@ -2134,101 +2135,101 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - } + npc.TargetClosest(); + } } - // Fireball spin + // Fireball spin else if (npc.ai[0] == 5f) { - npc.velocity = npc.velocity.RotatedBy(-(double)spinRotation * (float)npc.direction); + npc.velocity = npc.velocity.RotatedBy(-(double)spinRotation * (float)npc.direction); npc.rotation -= spinRotation * npc.direction; - if (npc.ai[1] == 1f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); - flareDustBulletHellSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / (MathHelper.TwoPi * 3f); - } - - npc.ai[1] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.ai[1] == 1f) { - if (secondPhasePhase >= 3) - { - // Rotate spiral by 9 * (240 / 12) = +90 degrees and then back -90 degrees + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoar"), (int)npc.position.X, (int)npc.position.Y); + flareDustBulletHellSpawn = npc.Center + npc.velocity.RotatedBy(MathHelper.PiOver2 * -npc.direction) * spinTime / (MathHelper.TwoPi * 3f); + } - // For phase 4: Rotate spiral by 18 * (240 / 16) = +135 degrees and then back -135 degrees + npc.ai[1] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (secondPhasePhase >= 3) + { + // Rotate spiral by 9 * (240 / 12) = +90 degrees and then back -90 degrees - if (npc.ai[1] % flareDustSpawnDivisor2 == 0f) - { - int totalProjectiles = secondPhasePhase == 4 ? 12 : 10; - float projectileVelocity = secondPhasePhase == 4 ? 16f : 12f; - float radialOffset = secondPhasePhase == 4 ? 2.8f : 3.2f; - if (npc.localAI[3] == 0f) - { - DoFlareDustBulletHell(1, spinPhaseTimer, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, projectileVelocity, radialOffset, true); - } - else - { - int ringReduction = (int)MathHelper.Lerp(0f, 12f, npc.ai[1] / spinPhaseTimer); - int totalProjectiles2 = 38 - ringReduction; // 36 for first ring, 24 for last ring - DoFlareDustBulletHell(0, flareDustSpawnDivisor2, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles2, 0f, 0f, true); - } + // For phase 4: Rotate spiral by 18 * (240 / 16) = +135 degrees and then back -135 degrees - // Fire a flame towards every player, with a limit of 10 - if (expertMode && npc.ai[2] % (flareDustSpawnDivisor2 * 2) == 0f) - { - List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (npc.ai[1] % flareDustSpawnDivisor2 == 0f) + { + int totalProjectiles = secondPhasePhase == 4 ? 12 : 10; + float projectileVelocity = secondPhasePhase == 4 ? 16f : 12f; + float radialOffset = secondPhasePhase == 4 ? 2.8f : 3.2f; + if (npc.localAI[3] == 0f) + { + DoFlareDustBulletHell(1, spinPhaseTimer, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, projectileVelocity, radialOffset, true); + } + else + { + int ringReduction = (int)MathHelper.Lerp(0f, 12f, npc.ai[1] / spinPhaseTimer); + int totalProjectiles2 = 38 - ringReduction; // 36 for first ring, 24 for last ring + DoFlareDustBulletHell(0, flareDustSpawnDivisor2, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles2, 0f, 0f, true); + } - if (targets.Count > 4) - break; - } - foreach (int t in targets) - { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * (projectileVelocity * 0.7f); - int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); - Main.projectile[proj].extraUpdates += 1; - } - } - } - } - else - { - if (npc.ai[1] % flareDustSpawnDivisor == 0f) - { - int ringReduction = (int)MathHelper.Lerp(0f, 12f, npc.ai[1] / spinPhaseTimer); - int totalProjectiles = 38 - ringReduction; // 36 for first ring, 24 for last ring - DoFlareDustBulletHell(0, flareDustSpawnDivisor, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, true); + // Fire a flame towards every player, with a limit of 10 + if (expertMode && npc.ai[2] % (flareDustSpawnDivisor2 * 2) == 0f) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); - // Fire a flame towards every player, with a limit of 10 - if (expertMode) - { - List targets = new List(); - for (int p = 0; p < Main.maxPlayers; p++) - { - if (Main.player[p].active && !Main.player[p].dead) - targets.Add(p); + if (targets.Count > 4) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * (projectileVelocity * 0.7f); + int type = ModContent.ProjectileType(); + int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + Main.projectile[proj].extraUpdates += 1; + } + } + } + } + else + { + if (npc.ai[1] % flareDustSpawnDivisor == 0f) + { + int ringReduction = (int)MathHelper.Lerp(0f, 12f, npc.ai[1] / spinPhaseTimer); + int totalProjectiles = 38 - ringReduction; // 36 for first ring, 24 for last ring + DoFlareDustBulletHell(0, flareDustSpawnDivisor, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, true); - if (targets.Count > 4) - break; - } - foreach (int t in targets) - { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * 8f; - int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); - Main.projectile[proj].extraUpdates += 1; - } - } - } - } + // Fire a flame towards every player, with a limit of 10 + if (expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); - if (npc.ai[1] == 210f && secondPhasePhase == 4 && useTornado) + if (targets.Count > 4) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 40f - flareDustBulletHellSpawn) * 8f; + int type = ModContent.ProjectileType(); + int proj = Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + Main.projectile[proj].extraUpdates += 1; + } + } + } + } + + if (npc.ai[1] == 210f && secondPhasePhase == 4 && useTornado) { useTornado = false; Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); @@ -2240,13 +2241,13 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 1f; npc.ai[1] = increasedIdleTimeAfterBulletHell; npc.ai[2] = 0f; - npc.localAI[2] = 0f; - npc.TargetClosest(); - npc.velocity /= 2f; + npc.localAI[2] = 0f; + npc.TargetClosest(); + npc.velocity /= 2f; } } - // Fire ring + // Fire ring else if (npc.ai[0] == 6f) { if (npc.ai[1] == 0f) @@ -2282,14 +2283,14 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient) { - if (npc.ai[1] == 20f || npc.ai[1] == 80f || npc.ai[1] == 140f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + if (npc.ai[1] == 20f || npc.ai[1] == 80f || npc.ai[1] == 140f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - DoFireRing(expertMode ? 300 : 180, npc.GetProjectileDamage(ModContent.ProjectileType()), npc.target, 1f); + DoFireRing(expertMode ? 300 : 180, npc.GetProjectileDamage(ModContent.ProjectileType()), npc.target, 1f); - Vector2 vector7 = vectorCenter + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 100f * (0.6f + Main.rand.NextFloat() * 0.4f); - } + Vector2 vector7 = vectorCenter + (MathHelper.TwoPi * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 100f * (0.6f + Main.rand.NextFloat() * 0.4f); + } } npc.ai[1] += 1f; @@ -2297,37 +2298,37 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[1] >= flareSpawnPhaseTimer) { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(vectorCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, npc.target + 1); npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - } + npc.TargetClosest(); + } } - // Fast charge + // Fast charge else if (npc.ai[0] == 7f) { if (npc.ai[1] == 1f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonRoarShort"), (int)npc.position.X, (int)npc.position.Y); - ChargeDust(14, pie); + ChargeDust(14, pie); - npc.ai[1] += 1f; - if (npc.ai[1] >= chargeTime) + npc.ai[1] += 1f; + if (npc.ai[1] >= chargeTime) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); - } + npc.TargetClosest(); + } } - // Teleport + // Teleport else if (npc.ai[0] == 8f) { Vector2 npcCenter = vectorCenter; @@ -2361,12 +2362,12 @@ namespace CalamityMod.NPCs.Yharon npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.localAI[1] = fastChargeTelegraphTime + 1f; - npc.netUpdate = true; + npc.localAI[1] = fastChargeTelegraphTime + 1f; + npc.netUpdate = true; } } - // Enter new phase + // Enter new phase else if (npc.ai[0] == 9f) { npc.velocity *= 0.9f; @@ -2410,8 +2411,8 @@ namespace CalamityMod.NPCs.Yharon npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); - npc.netUpdate = true; + npc.TargetClosest(); + npc.netUpdate = true; } } @@ -2465,363 +2466,363 @@ namespace CalamityMod.NPCs.Yharon if (num43 != 0f) npc.rotation = npc.rotation.AngleTowards(num42, num43); } - #endregion + #endregion - #region Charge Dust - private void ChargeDust(int dustAmt, float pie) - { - 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, 244, 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; - } - } - #endregion - - #region Flare Dust Bullet Hell - private void DoFlareDustBulletHell(int attackType, int timer, int projectileDamage, int totalProjectiles, float projectileVelocity, float radialOffset, bool phase2) - { - Main.PlaySound(SoundID.Item20, flareDustBulletHellSpawn); - float aiVariableUsed = phase2 ? npc.ai[1] : npc.ai[2]; - switch (attackType) - { - case 0: - float offsetAngle = 360 / totalProjectiles; - int totalSpaces = totalProjectiles / 5; - int spaceStart = Main.rand.Next(totalProjectiles - totalSpaces); - float ai0 = aiVariableUsed % (timer * 2) == 0f ? 1f : 0f; - - int spacesMade = 0; - for (int i = 0; i < totalProjectiles; i++) - { - if (i >= spaceStart && spacesMade < totalSpaces) - spacesMade++; - else - Projectile.NewProjectile(flareDustBulletHellSpawn, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, ai0, i * offsetAngle); - } - break; - - case 1: - double radians = MathHelper.TwoPi / totalProjectiles; - Vector2 spinningPoint = Vector2.Normalize(new Vector2(-npc.localAI[2], -projectileVelocity)); - - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 vector2 = spinningPoint.RotatedBy(radians * i) * projectileVelocity; - Projectile.NewProjectile(flareDustBulletHellSpawn, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); - } - - float newRadialOffset = (int)aiVariableUsed / (timer / 4) % 2f == 0f ? radialOffset : -radialOffset; - npc.localAI[2] += newRadialOffset; - break; - - default: - break; - } - } - #endregion - - #region Fire Ring - public void DoFireRing(int timeLeft, int damage, float ai0, float ai1) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float velocity = ai1 == 0f ? 10f : 5f; - int totalProjectiles = 50; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * i); - int proj = Projectile.NewProjectile(npc.Center, vector255, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, ai0, ai1); - Main.projectile[proj].timeLeft = timeLeft; - } - } - } - #endregion - - #region Drawing - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + #region Charge Dust + private void ChargeDust(int dustAmt, float pie) { - bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); + 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, 244, 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; + } + } + #endregion - bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f)) || - (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); + #region Flare Dust Bullet Hell + private void DoFlareDustBulletHell(int attackType, int timer, int projectileDamage, int totalProjectiles, float projectileVelocity, float radialOffset, bool phase2) + { + Main.PlaySound(SoundID.Item20, flareDustBulletHellSpawn); + float aiVariableUsed = phase2 ? npc.ai[1] : npc.ai[2]; + switch (attackType) + { + case 0: + float offsetAngle = 360 / totalProjectiles; + int totalSpaces = totalProjectiles / 5; + int spaceStart = Main.rand.Next(totalProjectiles - totalSpaces); + float ai0 = aiVariableUsed % (timer * 2) == 0f ? 1f : 0f; - bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 20f)) || - (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f)); + int spacesMade = 0; + for (int i = 0; i < totalProjectiles; i++) + { + if (i >= spaceStart && spacesMade < totalSpaces) + spacesMade++; + else + Projectile.NewProjectile(flareDustBulletHellSpawn, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, ai0, i * offsetAngle); + } + break; - bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f); + case 1: + double radians = MathHelper.TwoPi / totalProjectiles; + Vector2 spinningPoint = Vector2.Normalize(new Vector2(-npc.localAI[2], -projectileVelocity)); - bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f)) || (startSecondAI && npc.ai[0] == 9f); + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector2 = spinningPoint.RotatedBy(radians * i) * projectileVelocity; + Projectile.NewProjectile(flareDustBulletHellSpawn, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); + } - bool pauseAfterTeleportPhase = startSecondAI && npc.ai[0] == 8f; + float newRadialOffset = (int)aiVariableUsed / (timer / 4) % 2f == 0f ? radialOffset : -radialOffset; + npc.localAI[2] += newRadialOffset; + break; - bool ai2 = startSecondAI; + default: + break; + } + } + #endregion - SpriteEffects spriteEffects = ai2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = ai2 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + #region Fire Ring + public void DoFireRing(int timeLeft, int damage, float ai0, float ai1) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float velocity = ai1 == 0f ? 10f : 5f; + int totalProjectiles = 50; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int i = 0; i < totalProjectiles; i++) + { + Vector2 vector255 = new Vector2(0f, -velocity).RotatedBy(radians * i); + int proj = Projectile.NewProjectile(npc.Center, vector255, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, ai0, ai1); + Main.projectile[proj].timeLeft = timeLeft; + } + } + } + #endregion - Texture2D texture = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(texture.Width / 2, texture.Height / Main.npcFrameCount[npc.type] / 2); - Color color = lightColor; - Color invincibleColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); - Color color36 = Color.White; + #region Drawing + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); - float amount9 = 0f; - bool invincible = ai2 && invincibilityCounter < 900; - bool flag8 = npc.ai[0] > 5f; - bool flag9 = npc.ai[0] > 12f; - bool flag10 = startSecondAI; - int num150 = 120; - int num151 = 60; + bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f)) || + (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); - if (flag10) - color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.7f, 0.3f, 1f); - else if (flag9) - color = CalamityGlobalNPC.buffColor(color, 0.8f, 0.7f, 0.4f, 1f); - else if (flag8) - color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.5f, 1f); - else if (npc.ai[0] == 4f && npc.ai[2] > num150) - { - float num152 = npc.ai[2] - num150; - num152 /= num151; - color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); - } + bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 20f)) || + (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f)); - int num153 = 10; - int num154 = 2; - if (npc.ai[0] == -1f) - num153 = 0; - if (idlePhases) - num153 = 7; + bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f); - if (invincible) - color36 = invincibleColor; - else if (chargingOrSpawnPhases) - { - color36 = Color.Red; - amount9 = 0.5f; - } - else - color = lightColor; + bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f)) || (startSecondAI && npc.ai[0] == 9f); - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += num154) - { - Color color38 = color; - 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 - Main.screenPosition; - vector41 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * 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); - } - } + bool pauseAfterTeleportPhase = startSecondAI && npc.ai[0] == 8f; - int num156 = 0; - float num157 = 0f; - float scaleFactor9 = 0f; + bool ai2 = startSecondAI; - if (npc.ai[0] == -1f) - num156 = 0; + SpriteEffects spriteEffects = ai2 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = ai2 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; - if (tornadoPhase) - { - int num158 = 60; - int num159 = 30; - if (npc.ai[2] > num158) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((npc.ai[2] - num158) / num159 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 40f; - } - } + Texture2D texture = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(texture.Width / 2, texture.Height / Main.npcFrameCount[npc.type] / 2); + Color color = lightColor; + Color invincibleColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 0); + Color color36 = Color.White; - if (newPhasePhase && npc.ai[2] > num150) - { - num156 = 6; - num157 = 1f - (float)Math.Cos((npc.ai[2] - num150) / num151 * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 60f; - } + float amount9 = 0f; + bool invincible = ai2 && invincibilityCounter < Phase2InvincibilityTime; + bool flag8 = npc.ai[0] > 5f; + bool flag9 = npc.ai[0] > 12f; + bool flag10 = startSecondAI; + int num150 = 120; + int num151 = 60; - if (pauseAfterTeleportPhase) - { - num156 = 6; - num157 = 1f - (float)Math.Cos(npc.ai[2] / 30f * MathHelper.TwoPi); - num157 /= 3f; - scaleFactor9 = 20f; - } + if (flag10) + color = CalamityGlobalNPC.buffColor(color, 0.9f, 0.7f, 0.3f, 1f); + else if (flag9) + color = CalamityGlobalNPC.buffColor(color, 0.8f, 0.7f, 0.4f, 1f); + else if (flag8) + color = CalamityGlobalNPC.buffColor(color, 0.7f, 0.7f, 0.5f, 1f); + else if (npc.ai[0] == 4f && npc.ai[2] > num150) + { + float num152 = npc.ai[2] - num150; + num152 /= num151; + color = CalamityGlobalNPC.buffColor(color, 1f - 0.3f * num152, 1f - 0.3f * num152, 1f - 0.5f * num152, 1f); + } - if (CalamityConfig.Instance.Afterimages) - { - for (int num160 = 0; num160 < num156; num160++) - { - Color color39 = lightColor; - color39 = Color.Lerp(color39, color36, amount9); - color39 = npc.GetAlpha(color39); - color39 *= 1f - num157; - Vector2 vector42 = npc.Center + (num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; - vector42 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + int num153 = 10; + int num154 = 2; + if (npc.ai[0] == -1f) + num153 = 0; + if (idlePhases) + num153 = 7; - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector43, npc.frame, invincible ? invincibleColor : npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (invincible) + color36 = invincibleColor; + else if (chargingOrSpawnPhases) + { + color36 = Color.Red; + amount9 = 0.5f; + } + else + color = lightColor; - if (flag8 || npc.ai[0] == 4f || startSecondAI) - { - texture = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowOrange"); - Color color40 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Orange, 0.5f); - color36 = invincible ? invincibleColor : Color.Orange; + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += num154) + { + Color color38 = color; + 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 - Main.screenPosition; + vector41 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * 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); + } + } - Texture2D texture2 = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowGreen"); - Color color43 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Chartreuse, 0.5f); - Color color44 = invincible ? invincibleColor : Color.Chartreuse; + int num156 = 0; + float num157 = 0f; + float scaleFactor9 = 0f; - Texture2D texture3 = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowPurple"); - Color color45 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.BlueViolet, 0.5f); - Color color46 = invincible ? invincibleColor : Color.BlueViolet; + if (npc.ai[0] == -1f) + num156 = 0; - amount9 = 1f; - num157 = 0.5f; - scaleFactor9 = 10f; - num154 = 1; + if (tornadoPhase) + { + int num158 = 60; + int num159 = 30; + if (npc.ai[2] > num158) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((npc.ai[2] - num158) / num159 * MathHelper.TwoPi); + num157 /= 3f; + scaleFactor9 = 40f; + } + } - if (newPhasePhase) - { - float num161 = npc.ai[2] - num150; - num161 /= num151; - color36 *= num161; - color40 *= num161; + if (newPhasePhase && npc.ai[2] > num150) + { + num156 = 6; + num157 = 1f - (float)Math.Cos((npc.ai[2] - num150) / num151 * MathHelper.TwoPi); + num157 /= 3f; + scaleFactor9 = 60f; + } - if (flag9 || npc.ai[0] == 10f || startSecondAI) - { - color43 *= num161; - color44 *= num161; - } + if (pauseAfterTeleportPhase) + { + num156 = 6; + num157 = 1f - (float)Math.Cos(npc.ai[2] / 30f * MathHelper.TwoPi); + num157 /= 3f; + scaleFactor9 = 20f; + } - if (flag10 || npc.ai[0] == 17f) - { - color45 *= num161; - color46 *= num161; - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num160 = 0; num160 < num156; num160++) + { + Color color39 = lightColor; + color39 = Color.Lerp(color39, color36, amount9); + color39 = npc.GetAlpha(color39); + color39 *= 1f - num157; + Vector2 vector42 = npc.Center + (num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector42 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - if (pauseAfterTeleportPhase) - { - float num162 = npc.ai[2]; - num162 /= 30f; + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector43, npc.frame, invincible ? invincibleColor : npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (num162 > 0.5f) - num162 = 1f - num162; + if (flag8 || npc.ai[0] == 4f || startSecondAI) + { + texture = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowOrange"); + Color color40 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Orange, 0.5f); + color36 = invincible ? invincibleColor : Color.Orange; - num162 *= 2f; - num162 = 1f - num162; - color36 *= num162; - color40 *= num162; - color43 *= num162; - color44 *= num162; - color45 *= num162; - color46 *= num162; - } + Texture2D texture2 = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowGreen"); + Color color43 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.Chartreuse, 0.5f); + Color color44 = invincible ? invincibleColor : Color.Chartreuse; - if (CalamityConfig.Instance.Afterimages) - { - for (int num163 = 1; num163 < num153; num163 += num154) - { - Color color41 = color40; - color41 = Color.Lerp(color41, color36, amount9); - color41 *= (num153 - num163) / 15f; - Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; - vector44 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Texture2D texture3 = ModContent.GetTexture("CalamityMod/NPCs/Yharon/YharonGlowPurple"); + Color color45 = Color.Lerp(Color.White, invincible ? invincibleColor : Color.BlueViolet, 0.5f); + Color color46 = invincible ? invincibleColor : Color.BlueViolet; - if (flag9 || npc.ai[0] == 10f || startSecondAI) - { - Color color47 = color43; - color47 = Color.Lerp(color47, color44, amount9); - color47 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture2, vector44, npc.frame, color47, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + amount9 = 1f; + num157 = 0.5f; + scaleFactor9 = 10f; + num154 = 1; - if (flag10 || npc.ai[0] == 17f) - { - Color color48 = color45; - color48 = Color.Lerp(color48, color46, amount9); - color48 *= (num153 - num163) / 15f; - spriteBatch.Draw(texture3, vector44, npc.frame, color48, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (newPhasePhase) + { + float num161 = npc.ai[2] - num150; + num161 /= num151; + color36 *= num161; + color40 *= num161; - for (int num164 = 1; num164 < num156; num164++) - { - Color color42 = color40; - color42 = Color.Lerp(color42, color36, amount9); - color42 = npc.GetAlpha(color42); - color42 *= 1f - num157; - Vector2 vector45 = npc.Center + (num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; - vector45 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (flag9 || npc.ai[0] == 10f || startSecondAI) + { + color43 *= num161; + color44 *= num161; + } - if (flag9 || npc.ai[0] == 10f || startSecondAI) - { - Color color49 = color43; - color49 = Color.Lerp(color49, color44, amount9); - color49 = npc.GetAlpha(color49); - color49 *= 1f - num157; - spriteBatch.Draw(texture2, vector45, npc.frame, color49, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + if (flag10 || npc.ai[0] == 17f) + { + color45 *= num161; + color46 *= num161; + } + } - if (flag10 || npc.ai[0] == 17f) - { - Color color50 = color45; - color50 = Color.Lerp(color50, color46, amount9); - color50 = npc.GetAlpha(color50); - color50 *= 1f - num157; - spriteBatch.Draw(texture3, vector45, npc.frame, color50, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - } + if (pauseAfterTeleportPhase) + { + float num162 = npc.ai[2]; + num162 /= 30f; - spriteBatch.Draw(texture, vector43, npc.frame, color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + if (num162 > 0.5f) + num162 = 1f - num162; - if (flag9 || npc.ai[0] == 10f || startSecondAI) - spriteBatch.Draw(texture2, vector43, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + num162 *= 2f; + num162 = 1f - num162; + color36 *= num162; + color40 *= num162; + color43 *= num162; + color44 *= num162; + color45 *= num162; + color46 *= num162; + } - if (flag10 || npc.ai[0] == 17f) - spriteBatch.Draw(texture3, vector43, npc.frame, color45, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num163 = 1; num163 < num153; num163 += num154) + { + Color color41 = color40; + color41 = Color.Lerp(color41, color36, amount9); + color41 *= (num153 - num163) / 15f; + Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; + vector44 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + { + Color color47 = color43; + color47 = Color.Lerp(color47, color44, amount9); + color47 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture2, vector44, npc.frame, color47, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + if (flag10 || npc.ai[0] == 17f) + { + Color color48 = color45; + color48 = Color.Lerp(color48, color46, amount9); + color48 *= (num153 - num163) / 15f; + spriteBatch.Draw(texture3, vector44, npc.frame, color48, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + for (int num164 = 1; num164 < num156; num164++) + { + Color color42 = color40; + color42 = Color.Lerp(color42, color36, amount9); + color42 = npc.GetAlpha(color42); + color42 *= 1f - num157; + Vector2 vector45 = npc.Center + (num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; + vector45 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + { + Color color49 = color43; + color49 = Color.Lerp(color49, color44, amount9); + color49 = npc.GetAlpha(color49); + color49 *= 1f - num157; + spriteBatch.Draw(texture2, vector45, npc.frame, color49, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + if (flag10 || npc.ai[0] == 17f) + { + Color color50 = color45; + color50 = Color.Lerp(color50, color46, amount9); + color50 = npc.GetAlpha(color50); + color50 *= 1f - num157; + spriteBatch.Draw(texture3, vector45, npc.frame, color50, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + } + + spriteBatch.Draw(texture, vector43, npc.frame, color40, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag9 || npc.ai[0] == 10f || startSecondAI) + spriteBatch.Draw(texture2, vector43, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (flag10 || npc.ai[0] == 17f) + spriteBatch.Draw(texture3, vector43, npc.frame, color45, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } return false; } - #endregion + #endregion - #region Loot - public override void NPCLoot() - { - CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedYharon); + #region Loot + public override void NPCLoot() + { + CalamityGlobalNPC.SetNewShopVariable(new int[] { ModContent.NPCType() }, CalamityWorld.downedYharon); - CalamityGlobalNPC.SetNewBossJustDowned(npc); + CalamityGlobalNPC.SetNewBossJustDowned(npc); - // Bags occur in either phase 1 or 2, as they don't contain phase 2 only drops - DropHelper.DropBags(npc); + // Bags occur in either phase 1 or 2, as they don't contain phase 2 only drops + DropHelper.DropBags(npc); // Normal drops: Everything that would otherwise be in the bag if (!Main.expertMode) @@ -2837,8 +2838,8 @@ namespace CalamityMod.NPCs.Yharon DropHelper.WeightStack(w), // Yharon Kindle Staff DropHelper.WeightStack(w), // Infernal Spear DropHelper.WeightStack(w), - DropHelper.WeightStack(w) - ); + DropHelper.WeightStack(w) + ); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); @@ -2850,32 +2851,32 @@ namespace CalamityMod.NPCs.Yharon int soulFragMax = 22; DropHelper.DropItem(npc, ModContent.ItemType(), true, soulFragMin, soulFragMax); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), true); - DropHelper.DropItem(npc, ModContent.ItemType(), true); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), true); + DropHelper.DropItem(npc, ModContent.ItemType(), true); } // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - // Other - // DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedYharon); + // Other + // DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedYharon); - // If Yharon has not been killed yet, notify players of Auric Ore - if (!CalamityWorld.downedYharon) - { - CalamityUtils.SpawnOre(ModContent.TileType(), 2E-05, 0.6f, 0.8f, 10, 20); + // If Yharon has not been killed yet, notify players of Auric Ore + if (!CalamityWorld.downedYharon) + { + CalamityUtils.SpawnOre(ModContent.TileType(), 2E-05, 0.6f, 0.8f, 10, 20); - string key = "Mods.CalamityMod.AuricOreText"; - Color messageColor = Color.Gold; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } + string key = "Mods.CalamityMod.AuricOreText"; + Color messageColor = Color.Gold; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } - // Mark Yharon as dead - CalamityWorld.downedYharon = true; - CalamityNetcode.SyncWorld(); - } + // Mark Yharon as dead + CalamityWorld.downedYharon = true; + CalamityNetcode.SyncWorld(); + } public override void BossLoot(ref string name, ref int potionType) { @@ -2883,16 +2884,16 @@ namespace CalamityMod.NPCs.Yharon } #endregion - #region On Hit Player - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 420, true); - } - #endregion + #region On Hit Player + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 420, true); + } + #endregion - #region Projectile Resists - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { + #region Projectile Resists + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { if (projectile.type == ModContent.ProjectileType()) damage = (int)(damage * 0.85); if (projectile.type == ModContent.ProjectileType()) @@ -2900,10 +2901,10 @@ namespace CalamityMod.NPCs.Yharon if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) damage = (int)(damage * 0.95); } - #endregion + #endregion - #region HP Bar Cooldown Slot and Stats - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + #region HP Bar Cooldown Slot and Stats + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { scale = 2f; return null; @@ -2925,57 +2926,57 @@ namespace CalamityMod.NPCs.Yharon #region Find Frame public override void FindFrame(int frameHeight) { - bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); + bool idlePhases = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f)) || (startSecondAI && (npc.ai[0] == 5f || npc.ai[0] < 2f)); - bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f)) || - (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); + bool chargingOrSpawnPhases = (!startSecondAI && (npc.ai[0] == 1f || npc.ai[0] == 5f || npc.ai[0] == 7f || npc.ai[0] == 11f || npc.ai[0] == 14f || npc.ai[0] == 18f)) || + (startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 2f || npc.ai[0] == 7f)); - bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 20f)) || - (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f || npc.ai[0] == 8f)); + bool projectileOrCirclePhases = (!startSecondAI && (npc.ai[0] == 2f || npc.ai[0] == 8f || npc.ai[0] == 12f || npc.ai[0] == 15f || npc.ai[0] == 19f || npc.ai[0] == 20f)) || + (startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 3f || npc.ai[0] == 8f)); - bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f); + bool tornadoPhase = !startSecondAI && (npc.ai[0] == 3f || npc.ai[0] == 9f || npc.ai[0] == -1f || npc.ai[0] == 16f); - bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f)) || (startSecondAI && npc.ai[0] == 9f); + bool newPhasePhase = (!startSecondAI && (npc.ai[0] == 4f || npc.ai[0] == 10f || npc.ai[0] == 17f)) || (startSecondAI && npc.ai[0] == 9f); - bool chargeTelegraph = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f) && npc.localAI[1] > 0f) || - (startSecondAI && npc.ai[0] < 2f && npc.localAI[1] > 0f); + bool chargeTelegraph = (!startSecondAI && (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f) && npc.localAI[1] > 0f) || + (startSecondAI && npc.ai[0] < 2f && npc.localAI[1] > 0f); - if (chargeTelegraph) - { - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + if (chargeTelegraph) + { + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; - if (CalamityWorld.revenge || CalamityWorld.malice || BossRushEvent.BossRushActive) - { - // Increase aggression if player is taking a long time to kill the boss - if (lifeRatio > npc.Calamity().killTimeRatio_IncreasedAggression) - lifeRatio = npc.Calamity().killTimeRatio_IncreasedAggression; - } + if (CalamityWorld.revenge || CalamityWorld.malice || BossRushEvent.BossRushActive) + { + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > npc.Calamity().killTimeRatio_IncreasedAggression) + lifeRatio = npc.Calamity().killTimeRatio_IncreasedAggression; + } - bool doTelegraphFlightAnimation = npc.localAI[1] < fastChargeTelegraphTime * 0.5f || npc.localAI[1] > fastChargeTelegraphTime - (fastChargeTelegraphTime / 6f); - bool doTelegraphRoarAnimation = npc.localAI[1] > fastChargeTelegraphTime - fastChargeTelegraphTime * 0.4f && npc.localAI[1] < fastChargeTelegraphTime - fastChargeTelegraphTime * 0.2f; - bool phase4 = startSecondAI && lifeRatio <= ((CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) ? 0.165f : 0.11f) && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice); - if (doTelegraphFlightAnimation) - { - npc.frameCounter += phase4 ? 2D : 1D; - if (npc.frameCounter > 5D) - { - npc.frameCounter = 0D; - npc.frame.Y += frameHeight; - } - if (npc.frame.Y >= frameHeight * 5) - npc.frame.Y = 0; - } - else - { - npc.frame.Y = frameHeight * 5; - if (doTelegraphRoarAnimation) - npc.frame.Y = frameHeight * 6; - } - return; - } + bool doTelegraphFlightAnimation = npc.localAI[1] < fastChargeTelegraphTime * 0.5f || npc.localAI[1] > fastChargeTelegraphTime - (fastChargeTelegraphTime / 6f); + bool doTelegraphRoarAnimation = npc.localAI[1] > fastChargeTelegraphTime - fastChargeTelegraphTime * 0.4f && npc.localAI[1] < fastChargeTelegraphTime - fastChargeTelegraphTime * 0.2f; + bool phase4 = startSecondAI && lifeRatio <= ((CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) ? 0.165f : 0.11f) && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice); + if (doTelegraphFlightAnimation) + { + npc.frameCounter += phase4 ? 2D : 1D; + if (npc.frameCounter > 5D) + { + npc.frameCounter = 0D; + npc.frame.Y += frameHeight; + } + if (npc.frame.Y >= frameHeight * 5) + npc.frame.Y = 0; + } + else + { + npc.frame.Y = frameHeight * 5; + if (doTelegraphRoarAnimation) + npc.frame.Y = frameHeight * 6; + } + return; + } - if (idlePhases) + if (idlePhases) { int num84 = 5; if (!startSecondAI && (npc.ai[0] == 6f || npc.ai[0] == 13f))