From f3c8a06ffc45a528a48458ba92b84427c850d9e5 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Thu, 12 May 2022 15:36:55 -0500 Subject: [PATCH] 1 - Several entities now have coldDamage set to true. 2 - Several bosses are no longer capable of occassional cheap contact damage. 3 - Yharon creates a swirling fire vortex for his bullet hell instead of spinning and has various other edits. --- Buffs/CalamityGlobalBuff.cs | 2 +- Items/CalamityGlobalItemTooltip.cs | 2 +- NPCs/CalamityAI.cs | 21 +- NPCs/CalamityGlobalNPC.cs | 11 + NPCs/Cryogen/Cryogen.cs | 1 + NPCs/Cryogen/CryogenIce.cs | 1 + NPCs/Leviathan/SirenIce.cs | 1 + NPCs/NormalNPCs/CryoSlime.cs | 1 + NPCs/NormalNPCs/Cryocore.cs | 1 + NPCs/NormalNPCs/Cryocore2.cs | 1 + NPCs/NormalNPCs/IceClasper.cs | 1 - NPCs/NormalNPCs/IceMass.cs | 1 + .../ProfanedGuardians/ProfanedGuardianBoss.cs | 4 +- .../ProfanedGuardianBoss2.cs | 2 +- NPCs/SlimeGod/SlimeGodCore.cs | 9 + .../Bosses/BrainOfCthulhuAI.cs | 15 + .../Bosses/DukeFishronAI.cs | 8 +- .../VanillaNPCOverrides/Bosses/KingSlimeAI.cs | 12 + .../Bosses/QueenSlimeAI.cs | 703 +++++++++--------- NPCs/Yharon/Yharon.cs | 378 +++++----- Projectiles/Boss/IceBlast.cs | 1 + Projectiles/Boss/IceBomb.cs | 1 + Projectiles/Boss/IceRain.cs | 1 + Projectiles/Boss/RavagerFlame.cs | 3 +- Projectiles/Boss/YharonBulletHellVortex.cs | 70 ++ 25 files changed, 711 insertions(+), 540 deletions(-) create mode 100644 Projectiles/Boss/YharonBulletHellVortex.cs diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 42a0030581..c8d0d0e5e8 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -182,7 +182,7 @@ namespace CalamityMod.Buffs break; case BuffID.Warmth: - tip += ". Immunity to the Chilled, Frozen, and Glacial State debuffs"; + tip += ". Grants immunity to Chilled, Frozen and Glacial State"; break; case BuffID.Invisibility: diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index d636daec15..1f0f5a1dde 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -285,7 +285,7 @@ namespace CalamityMod.Items // Warmth Potion provides debuff immunities if (item.type == ItemID.WarmthPotion) { - string immunityLine = "\nMakes you immune to the Chilled, Frozen, and Glacial State debuffs"; + string immunityLine = "\nGrants immunity to Chilled, Frozen and Glacial State"; EditTooltipByNum(0, (line) => line.Text += immunityLine); } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 9bebf63bea..fcd99ac92e 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -640,6 +640,9 @@ namespace CalamityMod.NPCs // Center Vector2 vectorCenter = npc.Center; + // Set damage + npc.damage = npc.defDamage; + // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); @@ -884,6 +887,9 @@ namespace CalamityMod.NPCs // Teleport to location else if (npc.ai[0] == 1f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.chaseable = true; Vector2 position = new Vector2(npc.ai[1] * 16f - (npc.width / 2), npc.ai[2] * 16f - (npc.height / 2)); for (int m = 0; m < 5; m++) @@ -915,6 +921,9 @@ namespace CalamityMod.NPCs // Either teleport again or go to next AI state else if (npc.ai[0] == 2f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.alpha -= 50; if (npc.alpha <= 0) { @@ -2938,9 +2947,6 @@ namespace CalamityMod.NPCs // Teleport else if (npc.ai[0] == 5f) { - // Don't deal damage - npc.damage = 0; - // Slow down npc.velocity.X *= 0.9f; @@ -3016,6 +3022,9 @@ namespace CalamityMod.NPCs // Mid-teleport else if (npc.ai[0] == 6f) { + // Avoid cheap bullshit + npc.damage = 0; + if (death) npc.localAI[2] += 1f + 0.33f * (1f - lifeRatio); @@ -3059,6 +3068,9 @@ namespace CalamityMod.NPCs // End of teleport else if (npc.ai[0] == 7f) { + // Avoid cheap bullshit + npc.damage = 0; + // Turn visible npc.alpha -= 10; if (npc.alpha <= 0) @@ -6431,6 +6443,9 @@ namespace CalamityMod.NPCs // Pause before teleport else if (npc.ai[0] == 12f) { + // Avoid cheap bullshit + npc.damage = 0; + // Alpha if (npc.alpha < 255 && npc.ai[2] >= num12 - 15f) { diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index e178833980..1ec229eecb 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -2076,6 +2076,17 @@ namespace CalamityMod.NPCs canBreakPlayerDefense = true; break; + // Enemies that should have coldDamage set to true + case NPCID.IceMimic: + canBreakPlayerDefense = true; + npc.coldDamage = true; + break; + + case NPCID.IceBat: + case NPCID.IceTortoise: + npc.coldDamage = true; + break; + case NPCID.BloodSquid: npc.lifeMax = (int)(npc.lifeMax * 0.25); break; diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index e41643ab7d..7f1d255aba 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -64,6 +64,7 @@ namespace CalamityMod.NPCs.Cryogen NPC.boss = true; NPC.noGravity = true; NPC.noTileCollide = true; + NPC.coldDamage = true; NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath15; Music = CalamityMod.Instance.GetMusicFromMusicMod("Cryogen") ?? MusicID.FrostMoon; diff --git a/NPCs/Cryogen/CryogenIce.cs b/NPCs/Cryogen/CryogenIce.cs index 238579e87e..5bfa4c3b45 100644 --- a/NPCs/Cryogen/CryogenIce.cs +++ b/NPCs/Cryogen/CryogenIce.cs @@ -24,6 +24,7 @@ namespace CalamityMod.NPCs.Cryogen AIType = -1; NPC.canGhostHeal = false; NPC.noTileCollide = true; + NPC.coldDamage = true; NPC.GetNPCDamage(); NPC.width = 216; NPC.height = 216; diff --git a/NPCs/Leviathan/SirenIce.cs b/NPCs/Leviathan/SirenIce.cs index c5a4e7ab6d..1ccbd16aec 100644 --- a/NPCs/Leviathan/SirenIce.cs +++ b/NPCs/Leviathan/SirenIce.cs @@ -20,6 +20,7 @@ namespace CalamityMod.NPCs.Leviathan AIType = -1; NPC.canGhostHeal = false; NPC.noTileCollide = true; + NPC.coldDamage = true; NPC.GetNPCDamage(); NPC.width = 100; NPC.height = 100; diff --git a/NPCs/NormalNPCs/CryoSlime.cs b/NPCs/NormalNPCs/CryoSlime.cs index 69e81cd636..02f0e47bd7 100644 --- a/NPCs/NormalNPCs/CryoSlime.cs +++ b/NPCs/NormalNPCs/CryoSlime.cs @@ -31,6 +31,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; + NPC.coldDamage = true; NPC.HitSound = SoundID.NPCHit1; NPC.DeathSound = SoundID.NPCDeath1; Banner = NPC.type; diff --git a/NPCs/NormalNPCs/Cryocore.cs b/NPCs/NormalNPCs/Cryocore.cs index 6d27757873..0e6aca1929 100644 --- a/NPCs/NormalNPCs/Cryocore.cs +++ b/NPCs/NormalNPCs/Cryocore.cs @@ -27,6 +27,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.value = Item.buyPrice(0, 0, 3, 50); NPC.knockBackResist = 0.75f; NPC.noGravity = true; + NPC.coldDamage = true; NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath15; NPC.Calamity().VulnerableToHeat = true; diff --git a/NPCs/NormalNPCs/Cryocore2.cs b/NPCs/NormalNPCs/Cryocore2.cs index e1749f5a09..4fa5163e0a 100644 --- a/NPCs/NormalNPCs/Cryocore2.cs +++ b/NPCs/NormalNPCs/Cryocore2.cs @@ -27,6 +27,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.value = Item.buyPrice(0, 0, 5, 0); NPC.knockBackResist = 0.5f; NPC.noGravity = true; + NPC.coldDamage = true; NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath15; NPC.Calamity().VulnerableToHeat = true; diff --git a/NPCs/NormalNPCs/IceClasper.cs b/NPCs/NormalNPCs/IceClasper.cs index c2c37de9cb..067a3d420e 100644 --- a/NPCs/NormalNPCs/IceClasper.cs +++ b/NPCs/NormalNPCs/IceClasper.cs @@ -33,7 +33,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.value = Item.buyPrice(0, 0, 25, 0); NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath7; - NPC.coldDamage = true; NPC.rarity = 2; Banner = NPC.type; BannerItem = ModContent.ItemType(); diff --git a/NPCs/NormalNPCs/IceMass.cs b/NPCs/NormalNPCs/IceMass.cs index 3418447ae8..f30282e53e 100644 --- a/NPCs/NormalNPCs/IceMass.cs +++ b/NPCs/NormalNPCs/IceMass.cs @@ -28,6 +28,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.knockBackResist = 0f; NPC.HitSound = SoundID.NPCHit5; NPC.DeathSound = SoundID.NPCDeath15; + NPC.coldDamage = true; NPC.Calamity().VulnerableToHeat = true; NPC.Calamity().VulnerableToCold = false; NPC.Calamity().VulnerableToSickness = false; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index ae303a6c89..a8ca86dc7e 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -234,7 +234,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = NPC.direction; } - float velocity = (malice || biomeEnraged) ? 18.5f : death ? 16.5f : revenge ? 15.5f : expertMode ? 14.5f : 12.5f; + float velocity = (malice || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; Vector2 targetVector = player.Center - vectorCenter; targetVector = Vector2.Normalize(targetVector) * velocity; float phaseGateValue = (malice || biomeEnraged) ? 60f : death ? 80f : revenge ? 90f : expertMode ? 100f : 120f; @@ -303,7 +303,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.netUpdate = true; Vector2 velocity = new Vector2(NPC.ai[2], NPC.ai[3]); velocity.Normalize(); - velocity *= (malice || biomeEnraged) ? 35f : death ? 31f : revenge ? 29f : expertMode ? 27f : 23f; + velocity *= (malice || biomeEnraged) ? 32f : death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; if (defenderAlive) velocity *= 0.8f; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index cf3eaf7256..ca1b7af44d 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -218,7 +218,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.netUpdate = true; Vector2 velocity = new Vector2(NPC.ai[2], NPC.ai[3]); velocity.Normalize(); - velocity *= (malice || biomeEnraged) ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 18f; + velocity *= (malice || biomeEnraged) ? 25f : death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; NPC.velocity = velocity; } } diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 11d0dcbe06..f93f69c638 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -242,6 +242,9 @@ namespace CalamityMod.NPCs.SlimeGod if (calamityGlobalNPC.newAI[3] == 1f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.dontTakeDamage = true; NPC.rotation = NPC.velocity.X * 0.1f; @@ -333,6 +336,9 @@ namespace CalamityMod.NPCs.SlimeGod { if (NPC.localAI[1] == 0f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Slow down, rotation NPC.rotation = NPC.velocity.X * 0.1f; @@ -356,6 +362,9 @@ namespace CalamityMod.NPCs.SlimeGod } else if (NPC.localAI[1] == 1f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Rotation NPC.rotation = NPC.velocity.X * 0.1f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs index a85e054877..813344293c 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/BrainOfCthulhuAI.cs @@ -344,6 +344,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport and turn invisible else if (npc.ai[0] == -2f || npc.ai[0] == -8f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.velocity *= 0.9f; if (Main.netMode != NetmodeID.SinglePlayer) @@ -368,6 +371,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Become visible else if (npc.ai[0] == -3f || npc.ai[0] == -9f) { + // Avoid cheap bullshit + npc.damage = 0; + if (Main.netMode != NetmodeID.SinglePlayer) npc.ai[3] -= 15f; else @@ -409,6 +415,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Phase 1 else { + // Set damage + npc.damage = npc.defDamage; + // Creeper count int creeperCount = NPC.CountNPCS(NPCID.Creeper); int creeperScale = GetBrainOfCthuluCreepersCountRevDeath() + 1 - creeperCount; @@ -500,6 +509,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Turn invisible and teleport else if (npc.ai[0] == 1f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.alpha += 25; if (npc.alpha >= 255) { @@ -514,6 +526,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Become visible else if (npc.ai[0] == 2f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.alpha -= 25; if (npc.alpha <= 0) { diff --git a/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs index 45e05d3485..3b99b309b2 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DukeFishronAI.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -808,6 +808,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Phase 3 else if (npc.ai[0] == 10f && !player.dead) { + // Avoid cheap bullshit + npc.damage = 0; + // Alpha if (npc.alpha < 255) { @@ -966,6 +969,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Pause before teleport else if (npc.ai[0] == 12f) { + // Avoid cheap bullshit + npc.damage = 0; + // Alpha if (npc.alpha < 255) { diff --git a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs index f60442a271..d0b1a2b0c9 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs @@ -25,6 +25,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool flag9 = false; npc.aiAction = 0; + // Reset damage + npc.damage = npc.defDamage; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || BossRushEvent.BossRushActive; npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && malice; @@ -103,6 +106,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Activate teleport if (!Main.player[npc.target].dead && npc.ai[2] >= 300f && npc.ai[1] < 5f && npc.velocity.Y == 0f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.ai[2] = 0f; npc.ai[0] = 0f; npc.ai[1] = 5f; @@ -146,6 +152,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport if (npc.ai[1] == 5f) { + // Avoid cheap bullshit + npc.damage = 0; + teleporting = true; npc.aiAction = 1; npc.ai[0] += 1f; @@ -187,6 +196,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Post-teleport else if (npc.ai[1] == 6f) { + // Avoid cheap bullshit + npc.damage = 0; + teleporting = true; npc.aiAction = 0; npc.ai[0] += 1f; diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs index 22d48f42e4..a6321d4627 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs @@ -25,6 +25,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses bool phase3 = lifeRatio <= 0.35f; bool phase4 = lifeRatio <= 0.15f; + // Reset damage + npc.damage = npc.defDamage; + // Spawn settings if (npc.localAI[0] == 0f) { @@ -55,6 +58,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport if (!Main.player[npc.target].dead && npc.timeLeft > 10 && !phase2 && npc.ai[3] >= 300f && npc.ai[0] == 0f && npc.velocity.Y == 0f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.ai[0] = 2f; npc.ai[1] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -185,122 +191,127 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { // Phase switch phase case 0: + + if (phase2) { - if (phase2) - { - QueenSlime_FlyMovement(npc); - } - else - { - npc.noTileCollide = false; - npc.noGravity = false; - if (npc.velocity.Y == 0f) - { - npc.velocity.X *= 0.8f; - if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) - npc.velocity.X = 0f; - } - } - - if (npc.timeLeft <= 10 || (!phase2 && npc.velocity.Y != 0f)) - break; - - npc.ai[1] += 1f; - int idleTime = malice ? 20 : death ? 30 : 40; - if (phase2) - idleTime = malice ? 40 : death ? 60 : 80; - if (phase4) - idleTime /= 2; - - if (!(npc.ai[1] > idleTime)) - break; - - npc.ai[1] = 0f; - if (phase2) - { - Player player = Main.player[npc.target]; - - switch ((int)npc.Calamity().newAI[0]) - { - default: - npc.ai[0] = Main.rand.NextBool() ? 6f : 5f; - break; - case 5: - npc.ai[0] = phase4 ? 6f : Main.rand.NextBool() ? 4f : 6f; - break; - case 6: - npc.ai[0] = phase4 ? 5f : Main.rand.NextBool() ? 5f : 4f; - break; - } - - if (npc.ai[0] == 4f || npc.ai[0] == 6f) - { - npc.ai[2] = 1f; - if (player != null && player.active && !player.dead && (player.Bottom.Y < npc.Bottom.Y || Math.Abs(player.Center.X - npc.Center.X) > 450f)) - { - npc.ai[0] = 5f; - npc.ai[2] = 0f; - } - } - } - else - { - switch ((int)npc.Calamity().newAI[0]) - { - default: - npc.ai[0] = Main.rand.NextBool() ? 5f : 4f; - break; - case 4: - npc.ai[0] = Main.rand.NextBool() ? 3f : 5f; - break; - case 5: - npc.ai[0] = Main.rand.NextBool() ? 4f : 3f; - break; - } - } - - npc.netUpdate = true; - break; + QueenSlime_FlyMovement(npc); } + else + { + npc.noTileCollide = false; + npc.noGravity = false; + if (npc.velocity.Y == 0f) + { + npc.velocity.X *= 0.8f; + if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) + npc.velocity.X = 0f; + } + } + + if (npc.timeLeft <= 10 || (!phase2 && npc.velocity.Y != 0f)) + break; + + npc.ai[1] += 1f; + int idleTime = malice ? 20 : death ? 30 : 40; + if (phase2) + idleTime = malice ? 40 : death ? 60 : 80; + if (phase4) + idleTime /= 2; + + if (!(npc.ai[1] > idleTime)) + break; + + npc.ai[1] = 0f; + if (phase2) + { + Player player = Main.player[npc.target]; + + switch ((int)npc.Calamity().newAI[0]) + { + default: + npc.ai[0] = Main.rand.NextBool() ? 6f : 5f; + break; + case 5: + npc.ai[0] = phase4 ? 6f : Main.rand.NextBool() ? 4f : 6f; + break; + case 6: + npc.ai[0] = phase4 ? 5f : Main.rand.NextBool() ? 5f : 4f; + break; + } + + if (npc.ai[0] == 4f || npc.ai[0] == 6f) + { + npc.ai[2] = 1f; + if (player != null && player.active && !player.dead && (player.Bottom.Y < npc.Bottom.Y || Math.Abs(player.Center.X - npc.Center.X) > 450f)) + { + npc.ai[0] = 5f; + npc.ai[2] = 0f; + } + } + } + else + { + switch ((int)npc.Calamity().newAI[0]) + { + default: + npc.ai[0] = Main.rand.NextBool() ? 5f : 4f; + break; + case 4: + npc.ai[0] = Main.rand.NextBool() ? 3f : 5f; + break; + case 5: + npc.ai[0] = Main.rand.NextBool() ? 4f : 3f; + break; + } + } + + npc.netUpdate = true; + break; // Enlarge after teleport case 1: + + // Avoid cheap bullshit + npc.damage = 0; + + npc.rotation = 0f; + npc.ai[1] += 1f; + float teleportEndTime = malice ? 10f : death ? 15f : 20f; + num3 = MathHelper.Clamp(npc.ai[1] / teleportEndTime, 0f, 1f); + num3 = 0.5f + num3 * 0.5f; + if (npc.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) { - npc.rotation = 0f; - npc.ai[1] += 1f; - float teleportEndTime = malice ? 10f : death ? 15f : 20f; - num3 = MathHelper.Clamp(npc.ai[1] / teleportEndTime, 0f, 1f); - num3 = 0.5f + num3 * 0.5f; - if (npc.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.netUpdate = true; - npc.TargetClosest(); - } - - if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[1] >= teleportEndTime * 2f) - { - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.TargetClosest(); - } - - // Emit teleport dust - Color newColor2 = NPC.AI_121_QueenSlime_GetDustColor(); - newColor2.A = 150; - for (int num26 = 0; num26 < 10; num26++) - { - int num27 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 50, newColor2, 1.5f); - Main.dust[num27].noGravity = true; - Main.dust[num27].velocity *= 2f; - } - - break; + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.netUpdate = true; + npc.TargetClosest(); } + if (Main.netMode == NetmodeID.MultiplayerClient && npc.ai[1] >= teleportEndTime * 2f) + { + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.TargetClosest(); + } + + // Emit teleport dust + Color newColor2 = NPC.AI_121_QueenSlime_GetDustColor(); + newColor2.A = 150; + for (int num26 = 0; num26 < 10; num26++) + { + int num27 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 50, newColor2, 1.5f); + Main.dust[num27].noGravity = true; + Main.dust[num27].velocity *= 2f; + } + + break; + // Shrink and spawn teleport gore and dust case 2: + + // Avoid cheap bullshit + npc.damage = 0; + npc.rotation = 0f; npc.ai[1] += 1f; float teleportTime = malice ? 20f : death ? 30f : 40f; @@ -340,6 +351,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Main.dust[num25].velocity *= 0.5f; } } + break; // She jump @@ -423,6 +435,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.X *= malice ? 0.88f : death ? 0.9f : 0.91f; } } + break; // Slam down and create shockwave @@ -430,281 +443,279 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Release a massive eruption of crystals in phase 3 and the case is 6 case 4: case 6: + + npc.rotation *= 0.9f; + npc.noTileCollide = true; + npc.noGravity = true; + + if (npc.ai[2] == 1f) { - npc.rotation *= 0.9f; - npc.noTileCollide = true; - npc.noGravity = true; + npc.noTileCollide = false; + npc.noGravity = false; - if (npc.ai[2] == 1f) - { - npc.noTileCollide = false; - npc.noGravity = false; + int num20 = 30; + if (phase2) + num20 = 10; - int num20 = 30; - if (phase2) - num20 = 10; + if (Main.getGoodWorld) + num20 = 0; - if (Main.getGoodWorld) - num20 = 0; - - if (npc.velocity.Y == 0f) - { - SoundEngine.PlaySound(SoundID.Item167, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int type = ProjectileID.QueenSlimeSmash; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Bottom, Vector2.Zero, type, damage, 0f, Main.myPlayer); - - // Eruption of crystals in phase 3 - if (npc.ai[0] == 6f && phase3) - { - float projectileVelocity = 12f; - type = ProjectileID.QueenSlimeMinionBlueSpike; - damage = npc.GetProjectileDamage(type); - Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y - 100f) - npc.Center; - destination.Normalize(); - destination *= projectileVelocity; - int numProj = 18; - float rotation = MathHelper.ToRadians(90); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, -2f); - } - } - } - - for (int l = 0; l < 20; l++) - { - int num21 = Dust.NewDust(npc.Bottom - new Vector2(npc.width / 2, 30f), npc.width, 30, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); - Main.dust[num21].noGravity = true; - Main.dust[num21].velocity.Y = -5f + Main.rand.NextFloat() * -3f; - Main.dust[num21].velocity.X *= 7f; - } - - npc.Calamity().newAI[0] = npc.ai[0]; - npc.SyncExtraAI(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.netUpdate = true; - } - else if (npc.ai[1] >= num20) - { - for (int m = 0; m < 4; m++) - { - Vector2 position = npc.Bottom - new Vector2(Main.rand.NextFloatDirection() * 16f, Main.rand.Next(8)); - int num22 = Dust.NewDust(position, 2, 2, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); - Main.dust[num22].position = position; - Main.dust[num22].noGravity = true; - Main.dust[num22].velocity.Y = npc.velocity.Y * 0.9f; - Main.dust[num22].velocity.X = ((Main.rand.Next(2) == 0) ? (-10f) : 10f) + Main.rand.NextFloatDirection() * 3f; - } - } - - npc.velocity.X *= 0.8f; - float num23 = npc.ai[1]; - npc.ai[1] += 1f; - if (npc.ai[1] >= num20) - { - if (num23 < num20) - npc.netUpdate = true; - - if (phase2 && npc.ai[1] > (num20 + 120)) - { - npc.Calamity().newAI[0] = npc.ai[0]; - npc.SyncExtraAI(); - npc.ai[0] = 0f; - npc.ai[1] = 0f; - npc.ai[2] = 0f; - npc.velocity.Y *= 0.8f; - npc.netUpdate = true; - break; - } - - npc.velocity.Y += malice ? 2f : death ? 1.75f : 1.5f; - float num24 = malice ? 15.99f : death ? 15.5f : 15f; - if (Main.getGoodWorld) - { - npc.velocity.Y += 1f; - num24 = 15.99f; - } - - if (npc.velocity.Y == 0f) - npc.velocity.Y = 0.01f; - - if (npc.velocity.Y >= num24) - npc.velocity.Y = num24; - - // Cascade of crystals in phase 3 or 4 while falling down - if (((npc.ai[0] == 4f && phase3) || phase4) && npc.ai[1] % 12f == 0f) - { - SoundEngine.PlaySound(SoundID.Item154, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 fireFrom = npc.Center; - int projectileAmt = 2; - int type = ProjectileID.QueenSlimeMinionBlueSpike; - int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < projectileAmt; i++) - { - int totalProjectiles = 2; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int j = 0; j < totalProjectiles; j++) - { - Vector2 projVelocity = npc.velocity.RotatedBy(radians * j + MathHelper.PiOver2); - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); - } - } - } - } - } - else - npc.velocity.Y *= 0.8f; - - break; - } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) - { - npc.TargetClosest(); - npc.netUpdate = true; - } - - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 30f)) - break; - - if (npc.ai[1] >= 60f) - { - npc.ai[1] = 60f; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.velocity.Y = -3f; - npc.netUpdate = true; - } - } - - Player player3 = Main.player[npc.target]; - Vector2 center = npc.Center; - if (!player3.dead && player3.active && Math.Abs(npc.Center.X - player3.Center.X) / 16f <= despawnDistanceInTiles) - center = player3.Center; - - center.Y -= 384f; if (npc.velocity.Y == 0f) { - npc.velocity = center - npc.Center; - npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); - npc.velocity *= malice ? 30f : death ? 26f : 24f; - } - else - npc.velocity.Y *= 0.95f; - - break; - } - - // Fire spread of gel projectiles - case 5: - { - npc.rotation *= 0.9f; - npc.noTileCollide = true; - npc.noGravity = true; - - if (phase2) - npc.ai[3] = 0f; - - if (npc.ai[2] == 1f) - { - npc.ai[1] += 1f; - if (!(npc.ai[1] >= 10f)) - break; - + SoundEngine.PlaySound(SoundID.Item167, npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - int numGelProjectiles = phase4 ? Main.rand.Next(9, 12) : phase2 ? Main.rand.Next(6, 9) : 12; - if (Main.getGoodWorld) - numGelProjectiles = 15; - - float projectileVelocity = death ? 12f : 10.5f; - int type = ProjectileID.QueenSlimeGelAttack; + int type = ProjectileID.QueenSlimeSmash; int damage = npc.GetProjectileDamage(type); - if (phase2) + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Bottom, Vector2.Zero, type, damage, 0f, Main.myPlayer); + + // Eruption of crystals in phase 3 + if (npc.ai[0] == 6f && phase3) { - Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y + 100f) - npc.Center; + float projectileVelocity = 12f; + type = ProjectileID.QueenSlimeMinionBlueSpike; + damage = npc.GetProjectileDamage(type); + Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y - 100f) - npc.Center; destination.Normalize(); destination *= projectileVelocity; - float rotation = MathHelper.ToRadians(120); - for (int i = 0; i < numGelProjectiles; i++) + int numProj = 18; + float rotation = MathHelper.ToRadians(90); + for (int i = 0; i < numProj; i++) { - Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numGelProjectiles - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, -2f); - Main.projectile[proj].timeLeft = 900; - } - } - else - { - for (int j = 0; j < numGelProjectiles; j++) - { - Vector2 spinningpoint = new Vector2(projectileVelocity, 0f); - spinningpoint = spinningpoint.RotatedBy((-j) * ((float)Math.PI * 2f) / numGelProjectiles, Vector2.Zero); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, spinningpoint.X, spinningpoint.Y, type, damage, 0f, Main.myPlayer, 0f, -1f); + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, -2f); } } } - SoundEngine.PlaySound(SoundID.Item155, npc.Center); + for (int l = 0; l < 20; l++) + { + int num21 = Dust.NewDust(npc.Bottom - new Vector2(npc.width / 2, 30f), npc.width, 30, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor()); + Main.dust[num21].noGravity = true; + Main.dust[num21].velocity.Y = -5f + Main.rand.NextFloat() * -3f; + Main.dust[num21].velocity.X *= 7f; + } + npc.Calamity().newAI[0] = npc.ai[0]; npc.SyncExtraAI(); npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.netUpdate = true; - break; } - - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) + else if (npc.ai[1] >= num20) { - npc.TargetClosest(); - npc.netUpdate = true; - } - - npc.ai[1] += 1f; - if (npc.ai[1] >= 50f) - { - npc.ai[1] = 50f; - if (Main.netMode != NetmodeID.MultiplayerClient) + for (int m = 0; m < 4; m++) { - npc.ai[1] = 0f; - npc.ai[2] = 1f; - npc.netUpdate = true; + Vector2 position = npc.Bottom - new Vector2(Main.rand.NextFloatDirection() * 16f, Main.rand.Next(8)); + int num22 = Dust.NewDust(position, 2, 2, 31, npc.velocity.X, npc.velocity.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.4f); + Main.dust[num22].position = position; + Main.dust[num22].noGravity = true; + Main.dust[num22].velocity.Y = npc.velocity.Y * 0.9f; + Main.dust[num22].velocity.X = ((Main.rand.Next(2) == 0) ? (-10f) : 10f) + Main.rand.NextFloatDirection() * 3f; } } - float num16 = 100f; - for (int k = 0; k < 4; k++) + npc.velocity.X *= 0.8f; + float num23 = npc.ai[1]; + npc.ai[1] += 1f; + if (npc.ai[1] >= num20) { - Vector2 vector2 = npc.Center + Main.rand.NextVector2CircularEdge(num16, num16); - if (!phase2) - vector2 += new Vector2(0f, 20f); + if (num23 < num20) + npc.netUpdate = true; - Vector2 v = vector2 - npc.Center; - v = v.SafeNormalize(Vector2.Zero) * -8f; - int num17 = Dust.NewDust(vector2, 2, 2, 31, v.X, v.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.8f); - Main.dust[num17].position = vector2; - Main.dust[num17].noGravity = true; - Main.dust[num17].alpha = 250; - Main.dust[num17].velocity = v; - Main.dust[num17].customData = npc; + if (phase2 && npc.ai[1] > (num20 + 120)) + { + npc.Calamity().newAI[0] = npc.ai[0]; + npc.SyncExtraAI(); + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.velocity.Y *= 0.8f; + npc.netUpdate = true; + break; + } + + npc.velocity.Y += malice ? 2f : death ? 1.75f : 1.5f; + float num24 = malice ? 15.99f : death ? 15.5f : 15f; + if (Main.getGoodWorld) + { + npc.velocity.Y += 1f; + num24 = 15.99f; + } + + if (npc.velocity.Y == 0f) + npc.velocity.Y = 0.01f; + + if (npc.velocity.Y >= num24) + npc.velocity.Y = num24; + + // Cascade of crystals in phase 3 or 4 while falling down + if (((npc.ai[0] == 4f && phase3) || phase4) && npc.ai[1] % 12f == 0f) + { + SoundEngine.PlaySound(SoundID.Item154, npc.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 fireFrom = npc.Center; + int projectileAmt = 2; + int type = ProjectileID.QueenSlimeMinionBlueSpike; + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < projectileAmt; i++) + { + int totalProjectiles = 2; + float radians = MathHelper.TwoPi / totalProjectiles; + for (int j = 0; j < totalProjectiles; j++) + { + Vector2 projVelocity = npc.velocity.RotatedBy(radians * j + MathHelper.PiOver2); + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); + } + } + } + } } - - if (phase2) - QueenSlime_FlyMovement(npc); + else + npc.velocity.Y *= 0.8f; break; } + + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) + { + npc.TargetClosest(); + npc.netUpdate = true; + } + + npc.ai[1] += 1f; + if (!(npc.ai[1] >= 30f)) + break; + + if (npc.ai[1] >= 60f) + { + npc.ai[1] = 60f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[1] = 0f; + npc.ai[2] = 1f; + npc.velocity.Y = -3f; + npc.netUpdate = true; + } + } + + Player player3 = Main.player[npc.target]; + Vector2 center = npc.Center; + if (!player3.dead && player3.active && Math.Abs(npc.Center.X - player3.Center.X) / 16f <= despawnDistanceInTiles) + center = player3.Center; + + center.Y -= 384f; + if (npc.velocity.Y == 0f) + { + npc.velocity = center - npc.Center; + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero); + npc.velocity *= malice ? 30f : death ? 26f : 24f; + } + else + npc.velocity.Y *= 0.95f; + + break; + + // Fire spread of gel projectiles + case 5: + + npc.rotation *= 0.9f; + npc.noTileCollide = true; + npc.noGravity = true; + + if (phase2) + npc.ai[3] = 0f; + + if (npc.ai[2] == 1f) + { + npc.ai[1] += 1f; + if (!(npc.ai[1] >= 10f)) + break; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int numGelProjectiles = phase4 ? Main.rand.Next(9, 12) : phase2 ? Main.rand.Next(6, 9) : 12; + if (Main.getGoodWorld) + numGelProjectiles = 15; + + float projectileVelocity = death ? 12f : 10.5f; + int type = ProjectileID.QueenSlimeGelAttack; + int damage = npc.GetProjectileDamage(type); + if (phase2) + { + Vector2 destination = new Vector2(npc.Center.X, npc.Center.Y + 100f) - npc.Center; + destination.Normalize(); + destination *= projectileVelocity; + float rotation = MathHelper.ToRadians(120); + for (int i = 0; i < numGelProjectiles; i++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numGelProjectiles - 1))); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, -2f); + Main.projectile[proj].timeLeft = 900; + } + } + else + { + for (int j = 0; j < numGelProjectiles; j++) + { + Vector2 spinningpoint = new Vector2(projectileVelocity, 0f); + spinningpoint = spinningpoint.RotatedBy((-j) * ((float)Math.PI * 2f) / numGelProjectiles, Vector2.Zero); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, spinningpoint.X, spinningpoint.Y, type, damage, 0f, Main.myPlayer, 0f, -1f); + } + } + } + + SoundEngine.PlaySound(SoundID.Item155, npc.Center); + npc.Calamity().newAI[0] = npc.ai[0]; + npc.SyncExtraAI(); + npc.ai[0] = 0f; + npc.ai[1] = 0f; + npc.ai[2] = 0f; + npc.netUpdate = true; + break; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] == 0f) + { + npc.TargetClosest(); + npc.netUpdate = true; + } + + npc.ai[1] += 1f; + if (npc.ai[1] >= 50f) + { + npc.ai[1] = 50f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + npc.ai[1] = 0f; + npc.ai[2] = 1f; + npc.netUpdate = true; + } + } + + float num16 = 100f; + for (int k = 0; k < 4; k++) + { + Vector2 vector2 = npc.Center + Main.rand.NextVector2CircularEdge(num16, num16); + if (!phase2) + vector2 += new Vector2(0f, 20f); + + Vector2 v = vector2 - npc.Center; + v = v.SafeNormalize(Vector2.Zero) * -8f; + int num17 = Dust.NewDust(vector2, 2, 2, 31, v.X, v.Y, 40, NPC.AI_121_QueenSlime_GetDustColor(), 1.8f); + Main.dust[num17].position = vector2; + Main.dust[num17].noGravity = true; + Main.dust[num17].alpha = 250; + Main.dust[num17].velocity = v; + Main.dust[num17].customData = npc; + } + + if (phase2) + QueenSlime_FlyMovement(npc); + + break; } // Don't take damage while teleporting diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 85e7eb866e..f8dd24ab6d 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -39,7 +39,6 @@ namespace CalamityMod.NPCs.Yharon public class Yharon : ModNPC { private Rectangle safeBox = default; - private Vector2 flareDustBulletHellSpawn = default; private bool enraged = false; private bool protectionBoost = false; @@ -130,7 +129,6 @@ namespace CalamityMod.NPCs.Yharon writer.Write(teleportLocation); writer.Write(invincibilityCounter); writer.Write(fastChargeTelegraphTime); - writer.WriteVector2(flareDustBulletHellSpawn); writer.Write(safeBox.X); writer.Write(safeBox.Y); writer.Write(safeBox.Width); @@ -154,7 +152,6 @@ namespace CalamityMod.NPCs.Yharon teleportLocation = reader.ReadInt32(); invincibilityCounter = reader.ReadInt32(); fastChargeTelegraphTime = reader.ReadInt32(); - flareDustBulletHellSpawn = reader.ReadVector2(); safeBox.X = reader.ReadInt32(); safeBox.Y = reader.ReadInt32(); safeBox.Width = reader.ReadInt32(); @@ -183,12 +180,10 @@ namespace CalamityMod.NPCs.Yharon float pie = (float)Math.PI; - Vector2 vectorCenter = NPC.Center; - // Start phase 2 or not if (startSecondAI) { - Yharon_AI2(expertMode, revenge, death, malice, pie, lifeRatio, vectorCenter, calamityGlobalNPC); + Yharon_AI2(expertMode, revenge, death, malice, pie, lifeRatio, calamityGlobalNPC); return; } @@ -285,13 +280,10 @@ namespace CalamityMod.NPCs.Yharon // 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) + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) NPC.TargetClosest(); Player player = Main.player[NPC.target]; @@ -322,7 +314,7 @@ namespace CalamityMod.NPCs.Yharon NPC.timeLeft = 1800; int xPos = 60 * NPC.direction; - Vector2 vector = Vector2.Normalize(player.Center - vectorCenter) * (NPC.width + 20) / 2f + vectorCenter; + Vector2 vector = Vector2.Normalize(player.Center - NPC.Center) * (NPC.width + 20) / 2f + NPC.Center; Vector2 fromMouth = new Vector2((int)vector.X + xPos, (int)vector.Y - 15); // Create the arena, but not as a multiplayer client. @@ -394,6 +386,8 @@ namespace CalamityMod.NPCs.Yharon if (bulletHell) NPC.damage = 0; + NPC.dontTakeDamage = bulletHell; + // Trigger spawn effects if (NPC.localAI[0] == 0f) { @@ -408,7 +402,7 @@ namespace CalamityMod.NPCs.Yharon } // Rotation - float npcRotation = (float)Math.Atan2(player.Center.Y - vectorCenter.Y, player.Center.X - vectorCenter.X); + float npcRotation = (float)Math.Atan2(player.Center.Y - NPC.Center.Y, player.Center.X - NPC.Center.X); if (NPC.spriteDirection == 1) npcRotation += pie; if (npcRotation < 0f) @@ -419,8 +413,7 @@ namespace CalamityMod.NPCs.Yharon npcRotation = 0f; 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) + if (NPC.ai[0] == 1f || NPC.ai[0] == 5f || NPC.ai[0] == 7f || NPC.ai[0] == 11f || NPC.ai[0] == 12f || NPC.ai[0] == 14f || 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; @@ -429,14 +422,14 @@ namespace CalamityMod.NPCs.Yharon 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)) + if (NPC.ai[0] != -1f && !bulletHell && ((NPC.ai[0] != 6f && NPC.ai[0] != 13f) || NPC.ai[2] <= phaseSwitchTimer)) { bool colliding = Collision.SolidCollision(NPC.position, NPC.width, NPC.height); if (colliding) - NPC.alpha += 15; + NPC.alpha += 25; else - NPC.alpha -= 15; + NPC.alpha -= 25; if (NPC.alpha < 0) NPC.alpha = 0; @@ -450,7 +443,7 @@ namespace CalamityMod.NPCs.Yharon { NPC.velocity *= 0.98f; - int num1467 = Math.Sign(player.Center.X - vectorCenter.X); + int num1467 = Math.Sign(player.Center.X - NPC.Center.X); if (num1467 != 0) { NPC.direction = num1467; @@ -460,12 +453,12 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[2] > 20f) { NPC.velocity.Y = -2f; - NPC.alpha -= 5; + NPC.alpha -= 25; bool colliding = Collision.SolidCollision(NPC.position, NPC.width, NPC.height); if (colliding) - NPC.alpha += 15; + NPC.alpha += 25; if (NPC.alpha < 0) NPC.alpha = 0; @@ -480,8 +473,8 @@ namespace CalamityMod.NPCs.Yharon for (int num1469 = 0; num1469 < num1468; num1469++) { Vector2 vector169 = Vector2.Normalize(NPC.velocity) * new Vector2(NPC.width / 2f, NPC.height) * 0.75f * 0.5f; - vector169 = vector169.RotatedBy((num1469 - (num1468 / 2 - 1)) * MathHelper.TwoPi / num1468) + vectorCenter; - Vector2 value16 = vector169 - vectorCenter; + vector169 = vector169.RotatedBy((num1469 - (num1468 / 2 - 1)) * MathHelper.TwoPi / num1468) + NPC.Center; + Vector2 value16 = vector169 - NPC.Center; int num1470 = Dust.NewDust(vector169 + value16, 0, 0, 244, value16.X * 2f, value16.Y * 2f, 100, default, 1.4f); Main.dust[num1470].noGravity = true; Main.dust[num1470].noLight = true; @@ -507,18 +500,18 @@ namespace CalamityMod.NPCs.Yharon else if (NPC.ai[0] == 0f && !player.dead) { if (NPC.ai[1] == 0f) - NPC.ai[1] = Math.Sign((vectorCenter - player.Center).X); + NPC.ai[1] = Math.Sign((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 distanceFromDestination = destination - vectorCenter; + Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; - int num1471 = Math.Sign(player.Center.X - vectorCenter.X); + int num1471 = Math.Sign(player.Center.X - NPC.Center.X); if (num1471 != 0) { if (NPC.ai[2] == 0f && num1471 != NPC.direction) @@ -564,8 +557,9 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[0] = 1f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1471 != 0) @@ -583,18 +577,21 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[0] = 2f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 3) { NPC.ai[0] = 3f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 4) { NPC.ai[0] = 4f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 5) { @@ -607,8 +604,9 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.localAI[1] = 0f; + NPC.netUpdate = true; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed * fastChargeVelocityMultiplier; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1471 != 0) @@ -624,8 +622,6 @@ namespace CalamityMod.NPCs.Yharon else NPC.localAI[1] += 1f; } - - NPC.netUpdate = true; } } @@ -650,13 +646,13 @@ namespace CalamityMod.NPCs.Yharon 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((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 value17 = destination - vectorCenter; + Vector2 value17 = destination - NPC.Center; Vector2 vector170 = Vector2.Normalize(value17 - NPC.velocity) * flareBombPhaseVelocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedFlareBombDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedFlareBombDistance) NPC.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); else NPC.velocity *= 0.98f; @@ -674,7 +670,7 @@ namespace CalamityMod.NPCs.Yharon } } - int num1476 = Math.Sign(player.Center.X - vectorCenter.X); + int num1476 = Math.Sign(player.Center.X - NPC.Center.X); if (num1476 != 0) { NPC.direction = num1476; @@ -707,8 +703,8 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == fireTornadoPhaseTimer - 30) { - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, NPC.direction * 4, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, -(float)NPC.direction * 4, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, NPC.direction * 4, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, -(float)NPC.direction * 4, 8f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); } NPC.ai[2] += 1f; @@ -767,18 +763,18 @@ namespace CalamityMod.NPCs.Yharon 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((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 distanceFromDestination = destination - vectorCenter; + Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; - int num1477 = Math.Sign(player.Center.X - vectorCenter.X); + int num1477 = Math.Sign(player.Center.X - NPC.Center.X); if (num1477 != 0) { if (NPC.ai[2] == 0f && num1477 != NPC.direction) @@ -827,8 +823,9 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[0] = 7f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1477 != 0) @@ -843,56 +840,64 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 2) { - Vector2 npcCenter = vectorCenter; + NPC.damage = 0; if (NPC.alpha < 255) { - NPC.alpha += 17; + NPC.alpha += 42; if (NPC.alpha > 255) NPC.alpha = 255; } - if (NPC.ai[2] == phaseSwitchTimer + 15f) + bool spawnBulletHellVortex = NPC.ai[2] == phaseSwitchTimer + 15f; + if (spawnBulletHellVortex) + { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/YharonRoarShort"), (int)NPC.position.X, (int)NPC.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == phaseSwitchTimer + 15f) + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 center = player.Center + new Vector2(0f, -540f); + NPC.Center = center; + + float bulletHellVortexDuration = flareDustPhaseTimer + teleportPhaseTimer - 15f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, bulletHellVortexDuration, NPC.whoAmI); + + // Yharon takes a small amount of damage in order to summon the bullet hell. This is to compensate for him being invulnerable during it. + int damageAmt = (int)(NPC.lifeMax * (bulletHellVortexDuration / calamityGlobalNPC.KillTime)); + NPC.life -= damageAmt; + NPC.HealEffect(-damageAmt, true); + NPC.netUpdate = true; + } + } + + if (NPC.ai[2] >= phaseSwitchTimer + 15f) { - Vector2 center = player.Center + new Vector2(0f, -540f); - npcCenter = NPC.Center = center; + NPC.dontTakeDamage = true; + NPC.velocity = Vector2.Zero; } if (NPC.ai[2] < phaseSwitchTimer + teleportPhaseTimer) return; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; - NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - - if (num1477 != 0) - { - NPC.direction = num1477; - - if (NPC.spriteDirection == 1) - NPC.rotation += pie; - - NPC.spriteDirection = -NPC.direction; - } - NPC.ai[0] = 8f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] = 1f; + NPC.netUpdate = true; } else if (aiState == 3) { NPC.ai[0] = 9f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 4) { NPC.ai[0] = 10f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 5) { @@ -905,8 +910,9 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.localAI[1] = 0f; + NPC.netUpdate = true; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed * fastChargeVelocityMultiplier; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1477 != 0) @@ -924,7 +930,7 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 6) { - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * spinPhaseVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1477 != 0) @@ -940,9 +946,8 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[0] = 12f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } - - NPC.netUpdate = true; } } @@ -967,10 +972,7 @@ namespace CalamityMod.NPCs.Yharon else if (NPC.ai[0] == 8f) { if (NPC.ai[2] == 0f) - { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "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; @@ -996,18 +998,15 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 8f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * 8f; int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), flareDustBulletHellSpawn, velocity2, type, NPC.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, 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; - if (NPC.ai[2] >= flareDustPhaseTimer) { NPC.ai[0] = 6f; @@ -1028,7 +1027,7 @@ namespace CalamityMod.NPCs.Yharon SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/YharonRoarShort"), (int)NPC.position.X, (int)NPC.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == fireTornadoPhaseTimer - 30) - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); NPC.ai[2] += 1f; if (NPC.ai[2] >= fireTornadoPhaseTimer) @@ -1121,18 +1120,18 @@ namespace CalamityMod.NPCs.Yharon 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((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 distanceFromDestination = destination - vectorCenter; + Vector2 distanceFromDestination = destination - NPC.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; - int num1477 = Math.Sign(player.Center.X - vectorCenter.X); + int num1477 = Math.Sign(player.Center.X - NPC.Center.X); if (num1477 != 0) { if (NPC.ai[2] == 0f && num1477 != NPC.direction) @@ -1184,8 +1183,9 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[0] = 14f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1477 != 0) @@ -1200,56 +1200,64 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 2) { - Vector2 npcCenter = vectorCenter; + NPC.damage = 0; if (NPC.alpha < 255) { - NPC.alpha += 17; + NPC.alpha += 42; if (NPC.alpha > 255) NPC.alpha = 255; } - if (NPC.ai[2] == phaseSwitchTimer + 15f) + bool spawnBulletHellVortex = NPC.ai[2] == phaseSwitchTimer + 15f; + if (spawnBulletHellVortex) + { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/YharonRoarShort"), (int)NPC.position.X, (int)NPC.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == phaseSwitchTimer + 15f) + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 center = player.Center + new Vector2(0f, -540f); + NPC.Center = center; + + float bulletHellVortexDuration = flareDustPhaseTimer + teleportPhaseTimer - 15f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, bulletHellVortexDuration, NPC.whoAmI); + + // Yharon takes a small amount of damage in order to summon the bullet hell. This is to compensate for him being invulnerable during it. + int damageAmt = (int)(NPC.lifeMax * (bulletHellVortexDuration / calamityGlobalNPC.KillTime)); + NPC.life -= damageAmt; + NPC.HealEffect(-damageAmt, true); + NPC.netUpdate = true; + } + } + + if (NPC.ai[2] >= phaseSwitchTimer + 15f) { - Vector2 center = player.Center + new Vector2(0f, -540f); - npcCenter = NPC.Center = center; + NPC.dontTakeDamage = true; + NPC.velocity = Vector2.Zero; } if (NPC.ai[2] < phaseSwitchTimer + teleportPhaseTimer) return; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; - NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); - - if (num1477 != 0) - { - NPC.direction = num1477; - - if (NPC.spriteDirection == 1) - NPC.rotation += pie; - - NPC.spriteDirection = -NPC.direction; - } - NPC.ai[0] = 15f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] = 0f; + NPC.netUpdate = true; } else if (aiState == 3) { NPC.ai[0] = 16f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 4) { NPC.ai[0] = 17f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 5) { @@ -1262,8 +1270,9 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.localAI[1] = 0f; + NPC.netUpdate = true; - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeSpeed * fastChargeVelocityMultiplier; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * chargeSpeed * fastChargeVelocityMultiplier; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1477 != 0) @@ -1281,7 +1290,7 @@ namespace CalamityMod.NPCs.Yharon } else if (aiState == 6) { - NPC.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; + NPC.velocity = Vector2.Normalize(player.Center - NPC.Center) * spinPhaseVelocity; NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X); if (num1477 != 0) @@ -1297,15 +1306,15 @@ namespace CalamityMod.NPCs.Yharon NPC.ai[0] = 19f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } else if (aiState == 7) { NPC.ai[0] = 20f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.netUpdate = true; } - - NPC.netUpdate = true; } } @@ -1330,10 +1339,7 @@ namespace CalamityMod.NPCs.Yharon else if (NPC.ai[0] == 15f) { if (NPC.ai[2] == 0f) - { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "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) @@ -1358,18 +1364,15 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 8f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * 8f; int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), flareDustBulletHellSpawn, velocity2, type, NPC.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, 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; - if (NPC.ai[2] >= flareDustPhaseTimer) { NPC.ai[0] = 13f; @@ -1391,7 +1394,7 @@ namespace CalamityMod.NPCs.Yharon SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/YharonRoarShort"), (int)NPC.position.X, (int)NPC.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == fireTornadoPhaseTimer - 30) - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter.X, vectorCenter.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); NPC.ai[2] += 1f; if (NPC.ai[2] >= fireTornadoPhaseTimer) @@ -1484,13 +1487,13 @@ namespace CalamityMod.NPCs.Yharon else if (NPC.ai[0] == 20f) { if (NPC.ai[1] == 0f) - NPC.ai[1] = Math.Sign((vectorCenter - player.Center).X); + NPC.ai[1] = Math.Sign((NPC.Center - player.Center).X); Vector2 destination = player.Center + new Vector2(NPC.ai[1], 0); - Vector2 value17 = destination - vectorCenter; + Vector2 value17 = destination - NPC.Center; Vector2 vector170 = Vector2.Normalize(value17 - NPC.velocity) * flareBombPhaseVelocity; - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedFlareBombDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedFlareBombDistance) NPC.SimpleFlyMovement(vector170, flareBombPhaseAcceleration); else NPC.velocity *= 0.98f; @@ -1508,7 +1511,7 @@ namespace CalamityMod.NPCs.Yharon } } - int num1476 = Math.Sign(player.Center.X - vectorCenter.X); + int num1476 = Math.Sign(player.Center.X - NPC.Center.X); if (num1476 != 0) { NPC.direction = num1476; @@ -1533,7 +1536,7 @@ namespace CalamityMod.NPCs.Yharon } #region AI2 - public void Yharon_AI2(bool expertMode, bool revenge, bool death, bool malice, float pie, float lifeRatio, Vector2 vectorCenter, CalamityGlobalNPC calamityGlobalNPC) + public void Yharon_AI2(bool expertMode, bool revenge, bool death, bool malice, float pie, float lifeRatio, CalamityGlobalNPC calamityGlobalNPC) { float phase2GateValue = revenge ? 0.44f : expertMode ? 0.385f : 0.275f; bool phase2 = death || lifeRatio <= phase2GateValue; @@ -1542,7 +1545,7 @@ namespace CalamityMod.NPCs.Yharon float phase4GateValue = death ? 0.165f : 0.11f; bool phase4 = lifeRatio <= phase4GateValue && revenge; - if (NPC.ai[0] != 8f) + if (NPC.ai[0] != 5f && NPC.ai[0] != 8f) { NPC.alpha -= 25; if (NPC.alpha < 0) @@ -1579,7 +1582,7 @@ namespace CalamityMod.NPCs.Yharon } // 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) + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) NPC.TargetClosest(); Player targetData = Main.player[NPC.target]; @@ -1620,6 +1623,7 @@ namespace CalamityMod.NPCs.Yharon // Set DR based on protection boost (aka enrage) bool bulletHell = NPC.ai[0] == 5f; + NPC.dontTakeDamage = bulletHell; calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = protectionBoost; @@ -1653,6 +1657,7 @@ namespace CalamityMod.NPCs.Yharon NPC.damage = 0; float reduceSpeedChargeDistance = 500f; + float reduceSpeedFireballSpitChargeDistance = 800f; float phaseSwitchTimer = malice ? 28f : expertMode ? 30f : 32f; float acceleration = expertMode ? 0.92f : 0.9f; float velocity = expertMode ? 14.5f : 14f; @@ -1677,9 +1682,6 @@ namespace CalamityMod.NPCs.Yharon float splittingFireballBreathPhaseTimer = splittingFireballBreathTimer + splittingFireballBreathTimer2 + splittingFireballBreathYVelocityTimer; int spinPhaseTimer = secondPhasePhase == 4 ? (malice ? 80 : death ? 100 : 120) : (malice ? 120 : death ? 150 : 180); - 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; @@ -1724,20 +1726,20 @@ 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] = (NPC.Center.X < targetData.Center.X) ? 1 : -1; Vector2 destination = targetData.Center + new Vector2(-NPC.ai[2], 0f); Vector2 desiredVelocity = NPC.SafeDirectionTo(destination) * velocity; if (!targetDead) { - if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedChargeDistance) NPC.SimpleFlyMovement(desiredVelocity, acceleration); else NPC.velocity *= 0.98f; } - int num27 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; + int num27 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.direction = NPC.spriteDirection = num27; NPC.ai[1] += 1f; @@ -1886,6 +1888,8 @@ namespace CalamityMod.NPCs.Yharon if (num28 == 5 && NPC.ai[1] < phaseSwitchTimer + teleportPhaseTimer) { + NPC.damage = 0; + float newRotation = NPC.AngleTo(targetData.Center); float amount = 0.04f; @@ -1895,23 +1899,39 @@ namespace CalamityMod.NPCs.Yharon if (amount != 0f) NPC.rotation = NPC.rotation.AngleTowards(newRotation, amount); - Vector2 npcCenter = vectorCenter; - if (NPC.alpha < 255) { - NPC.alpha += 17; + NPC.alpha += 42; if (NPC.alpha > 255) NPC.alpha = 255; } float timeBeforeTeleport = teleportPhaseTimer - 15f; - if (NPC.ai[1] == phaseSwitchTimer + timeBeforeTeleport) + bool spawnBulletHellVortex = NPC.ai[1] == phaseSwitchTimer + timeBeforeTeleport; + if (spawnBulletHellVortex) + { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/YharonRoarShort"), (int)NPC.position.X, (int)NPC.position.Y); - if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] == phaseSwitchTimer + timeBeforeTeleport) + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 center = targetData.Center + new Vector2(0f, -540f); + NPC.Center = center; + + float bulletHellVortexDuration = spinPhaseTimer + 15f; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, bulletHellVortexDuration, NPC.whoAmI); + + // Yharon takes a small amount of damage in order to summon the bullet hell. This is to compensate for him being invulnerable during it. + int damageAmt = (int)(NPC.lifeMax * (bulletHellVortexDuration / calamityGlobalNPC.KillTime)); + NPC.life -= damageAmt; + NPC.HealEffect(-damageAmt, true); + NPC.netUpdate = true; + } + } + + if (NPC.ai[1] >= phaseSwitchTimer + timeBeforeTeleport) { - Vector2 center = targetData.Center + new Vector2(0f, -540f); - npcCenter = NPC.Center = center; + NPC.dontTakeDamage = true; + NPC.velocity = Vector2.Zero; } return; @@ -2006,7 +2026,7 @@ namespace CalamityMod.NPCs.Yharon } case 3: //fireballs { - Vector2 vector2 = new Vector2((targetData.Center.X > vectorCenter.X) ? 1 : -1, 0f); + Vector2 vector2 = new Vector2((targetData.Center.X > NPC.Center.X) ? 1 : -1, 0f); NPC.spriteDirection = (vector2.X > 0f) ? 1 : -1; NPC.velocity = vector2 * -2f; @@ -2014,16 +2034,10 @@ namespace CalamityMod.NPCs.Yharon } case 5: //spin move { - Vector2 vector3 = NPC.SafeDirectionTo(targetData.Center, Vector2.UnitX * NPC.spriteDirection); - NPC.spriteDirection = (vector3.X > 0f) ? 1 : -1; - NPC.rotation = vector3.ToRotation(); - - if (NPC.spriteDirection == -1) - NPC.rotation += pie; - - NPC.velocity = vector3 * spinPhaseVelocity; - + NPC.damage = 0; + NPC.dontTakeDamage = true; NPC.localAI[3] = Main.rand.Next(2); + NPC.velocity = Vector2.Zero; break; } @@ -2065,21 +2079,26 @@ namespace CalamityMod.NPCs.Yharon // Fireball spit charge else if (NPC.ai[0] == 3f) { - int num29 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; - NPC.ai[2] = num29; + int num29 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.ai[1] += 1f; if (NPC.ai[1] < fireballBreathTimer) { - Vector2 vector4 = targetData.Center + new Vector2(num29 * -750f, -300f); - Vector2 value = NPC.SafeDirectionTo(vector4) * 16f; + Vector2 destination = targetData.Center + new Vector2(num29, 0); + Vector2 distanceFromDestination = destination - NPC.Center; + Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination - NPC.velocity) * velocity; - if (NPC.Distance(vector4) < 16f) - NPC.Center = vector4; - else - NPC.position += value; + if (!targetDead) + { + if (Vector2.Distance(NPC.Center, destination) > reduceSpeedFireballSpitChargeDistance) + NPC.SimpleFlyMovement(desiredVelocity, acceleration); + else + NPC.velocity *= 0.98f; + } - if (Vector2.Distance(vector4, NPC.Center) < 32f) + NPC.direction = NPC.spriteDirection = num29; + + if (Vector2.Distance(destination, NPC.Center) < 32f) NPC.ai[1] = fireballBreathTimer - 1f; } @@ -2102,7 +2121,7 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[1] % (expertMode ? 6f : 8f) == 0f && Main.netMode != NetmodeID.MultiplayerClient) { float xOffset = 30f; - Vector2 position = vectorCenter + new Vector2((110f + xOffset) * NPC.direction, -20f).RotatedBy(NPC.rotation); + Vector2 position = NPC.Center + new Vector2((110f + xOffset) * NPC.direction, -20f).RotatedBy(NPC.rotation); Vector2 projectileVelocity = NPC.velocity; projectileVelocity.Normalize(); projectileVelocity *= 2f; @@ -2111,7 +2130,7 @@ namespace CalamityMod.NPCs.Yharon Projectile.NewProjectile(NPC.GetSource_FromAI(), position, projectileVelocity, type, damage, 0f, Main.myPlayer); } - if (Math.Abs(targetData.Center.X - vectorCenter.X) > 700f && Math.Abs(NPC.velocity.X) < chargeSpeed) + if (Math.Abs(targetData.Center.X - NPC.Center.X) > 700f && Math.Abs(NPC.velocity.X) < chargeSpeed) NPC.velocity.X += Math.Sign(NPC.velocity.X) * 0.5f; } @@ -2119,7 +2138,6 @@ namespace CalamityMod.NPCs.Yharon { NPC.ai[0] = 1f; NPC.ai[1] = 0f; - NPC.ai[2] = 0f; NPC.TargetClosest(); } } @@ -2127,7 +2145,7 @@ namespace CalamityMod.NPCs.Yharon // Splitting fireball breath else if (NPC.ai[0] == 4f) { - int num31 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; + int num31 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.ai[2] = num31; if (NPC.ai[1] < splittingFireballBreathTimer) @@ -2137,10 +2155,10 @@ namespace CalamityMod.NPCs.Yharon NPC.velocity = Vector2.Lerp(NPC.velocity, value2, 0.0333333351f); - int direction = (vectorCenter.X < targetData.Center.X) ? 1 : -1; + int direction = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.direction = NPC.spriteDirection = direction; - if (Vector2.Distance(vector5, vectorCenter) < 32f) + if (Vector2.Distance(vector5, NPC.Center) < 32f) NPC.ai[1] = splittingFireballBreathTimer - 1f; } else if (NPC.ai[1] == splittingFireballBreathTimer) @@ -2164,7 +2182,7 @@ namespace CalamityMod.NPCs.Yharon NPC.position.Y += NPC.SafeDirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f; float xOffset = 30f; - Vector2 position = vectorCenter + new Vector2((110f + xOffset) * NPC.direction, -20f).RotatedBy(NPC.rotation); + Vector2 position = NPC.Center + new Vector2((110f + xOffset) * NPC.direction, -20f).RotatedBy(NPC.rotation); int num34 = (int)(NPC.ai[1] - splittingFireballBreathTimer + 1f); int type = ModContent.ProjectileType(); @@ -2189,14 +2207,8 @@ namespace CalamityMod.NPCs.Yharon // Fireball spin else if (NPC.ai[0] == 5f) { - NPC.velocity = NPC.velocity.RotatedBy(-(double)spinRotation * (float)NPC.direction); - NPC.rotation -= spinRotation * NPC.direction; - if (NPC.ai[1] == 1f) - { SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "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) @@ -2237,9 +2249,9 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * (projectileVelocity * 0.7f); + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * (projectileVelocity * 0.7f); int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), flareDustBulletHellSpawn, velocity2, type, NPC.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, NPC.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); Main.projectile[proj].extraUpdates += 1; } } @@ -2267,9 +2279,9 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 8f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * 8f; int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), flareDustBulletHellSpawn, velocity2, type, NPC.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, NPC.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); Main.projectile[proj].extraUpdates += 1; } } @@ -2279,7 +2291,7 @@ namespace CalamityMod.NPCs.Yharon if (NPC.ai[1] == 210f && secondPhasePhase == 4 && useTornado) { useTornado = false; - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); } } @@ -2303,7 +2315,7 @@ namespace CalamityMod.NPCs.Yharon Vector2 desiredVelocity2 = NPC.SafeDirectionTo(destination2) * velocity * 1.5f; NPC.SimpleFlyMovement(desiredVelocity2, acceleration * 1.5f); - int num35 = (vectorCenter.X < targetData.Center.X) ? 1 : -1; + int num35 = (NPC.Center.X < targetData.Center.X) ? 1 : -1; NPC.direction = NPC.spriteDirection = num35; NPC.ai[2] += 1f; @@ -2346,7 +2358,7 @@ namespace CalamityMod.NPCs.Yharon SoundEngine.PlaySound(SoundLoader.GetLegacySoundSlot(Mod, "Sounds/Custom/YharonRoarShort"), (int)NPC.position.X, (int)NPC.position.Y); if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 1f, NPC.target + 1); NPC.ai[0] = 1f; NPC.ai[1] = 0f; @@ -2376,8 +2388,6 @@ namespace CalamityMod.NPCs.Yharon // Teleport else if (NPC.ai[0] == 8f) { - Vector2 npcCenter = vectorCenter; - if (NPC.alpha < 255) { NPC.alpha += 17; @@ -2394,11 +2404,11 @@ namespace CalamityMod.NPCs.Yharon if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[2] == 15f) { if (NPC.ai[1] == 0f) - NPC.ai[1] = 450 * Math.Sign((npcCenter - targetData.Center).X); + NPC.ai[1] = 450 * Math.Sign((NPC.Center - targetData.Center).X); teleportLocation = Main.rand.NextBool(2) ? (revenge ? 500 : 600) : (revenge ? -500 : -600); Vector2 center = targetData.Center + new Vector2(-NPC.ai[1], teleportLocation); - npcCenter = NPC.Center = center; + NPC.Center = center; } NPC.ai[2] += 1f; @@ -2467,13 +2477,18 @@ namespace CalamityMod.NPCs.Yharon switch ((int)NPC.ai[0]) { case 2: - case 3: - case 5: case 7: case 8: case 9: num43 = 0f; break; + + case 3: + if (NPC.ai[1] >= fireballBreathTimer) + num43 = 0f; + + break; + case 4: num43 = 0.01f; num42 = pie; @@ -2520,7 +2535,7 @@ namespace CalamityMod.NPCs.Yharon #region Flare Dust Bullet Hell private void DoFlareDustBulletHell(int attackType, int timer, int projectileDamage, int totalProjectiles, float projectileVelocity, float radialOffset, bool phase2) { - SoundEngine.PlaySound(SoundID.Item20, flareDustBulletHellSpawn); + SoundEngine.PlaySound(SoundID.Item20, NPC.Center); float aiVariableUsed = phase2 ? NPC.ai[1] : NPC.ai[2]; switch (attackType) { @@ -2536,7 +2551,7 @@ namespace CalamityMod.NPCs.Yharon if (i >= spaceStart && spacesMade < totalSpaces) spacesMade++; else - Projectile.NewProjectile(NPC.GetSource_FromAI(), flareDustBulletHellSpawn, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, ai0, i * offsetAngle); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, ai0, i * offsetAngle); } break; @@ -2547,7 +2562,7 @@ namespace CalamityMod.NPCs.Yharon for (int i = 0; i < totalProjectiles; i++) { Vector2 vector2 = spinningPoint.RotatedBy(radians * i) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), flareDustBulletHellSpawn, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, vector2, ModContent.ProjectileType(), projectileDamage, 0f, Main.myPlayer, 2f, 0f); } float newRadialOffset = (int)aiVariableUsed / (timer / 4) % 2f == 0f ? radialOffset : -radialOffset; @@ -2586,9 +2601,6 @@ namespace CalamityMod.NPCs.Yharon 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] == 3f || 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); - 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); @@ -2962,12 +2974,12 @@ 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] == 8f || NPC.ai[0] == 13f || NPC.ai[0] == 15f)) || (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 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)) || + bool projectileOrCirclePhases = (!startSecondAI && (NPC.ai[0] == 2f || NPC.ai[0] == 12f || 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); diff --git a/Projectiles/Boss/IceBlast.cs b/Projectiles/Boss/IceBlast.cs index 27045f6b87..39b93a62a2 100644 --- a/Projectiles/Boss/IceBlast.cs +++ b/Projectiles/Boss/IceBlast.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 10; Projectile.penetrate = -1; Projectile.hostile = true; + Projectile.coldDamage = true; Projectile.timeLeft = 300; Projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; } diff --git a/Projectiles/Boss/IceBomb.cs b/Projectiles/Boss/IceBomb.cs index 89e46d8d04..36648d77b5 100644 --- a/Projectiles/Boss/IceBomb.cs +++ b/Projectiles/Boss/IceBomb.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 30; Projectile.scale = 0.5f; Projectile.hostile = true; + Projectile.coldDamage = true; Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; diff --git a/Projectiles/Boss/IceRain.cs b/Projectiles/Boss/IceRain.cs index d035ccb360..4fb0a28d38 100644 --- a/Projectiles/Boss/IceRain.cs +++ b/Projectiles/Boss/IceRain.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.width = 10; Projectile.height = 10; Projectile.hostile = true; + Projectile.coldDamage = true; Projectile.penetrate = -1; Projectile.timeLeft = 300; } diff --git a/Projectiles/Boss/RavagerFlame.cs b/Projectiles/Boss/RavagerFlame.cs index a81c3b76e5..34197546df 100644 --- a/Projectiles/Boss/RavagerFlame.cs +++ b/Projectiles/Boss/RavagerFlame.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Events; using CalamityMod.World; using Terraria; using Terraria.ID; @@ -23,6 +23,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; + Projectile.coldDamage = true; Projectile.alpha = 255; Projectile.penetrate = 1; Projectile.timeLeft = 300; diff --git a/Projectiles/Boss/YharonBulletHellVortex.cs b/Projectiles/Boss/YharonBulletHellVortex.cs new file mode 100644 index 0000000000..a97d5b8eed --- /dev/null +++ b/Projectiles/Boss/YharonBulletHellVortex.cs @@ -0,0 +1,70 @@ +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using CalamityMod.NPCs.Yharon; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class YharonBulletHellVortex : ModProjectile + { + public ref float TimeCountdown => ref Projectile.ai[0]; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bullet Hell Vortex"); + ProjectileID.Sets.DrawScreenCheckFluff[Projectile.type] = 10000; + } + + public override void SetDefaults() + { + Projectile.width = 408; + Projectile.height = 408; + Projectile.scale = 0.05f; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.penetrate = -1; + Projectile.alpha = 255; + } + + public override void AI() + { + if (Main.npc[(int)Projectile.ai[1]].active && Main.npc[(int)Projectile.ai[1]].type == ModContent.NPCType()) + { + if (TimeCountdown > 0f) + { + if (TimeCountdown > 140f) + Projectile.scale = MathHelper.Clamp(Projectile.scale + 0.05f, 0f, 1f); + if (TimeCountdown < 25f) + Projectile.scale = MathHelper.Clamp(Projectile.scale - 0.05f, 0f, 1f); + TimeCountdown--; + } + else + Projectile.Kill(); + } + else + Projectile.Kill(); + } + + internal Color ColorFunction(float completionRatio) => Color.Lerp(Color.Yellow, Color.Yellow, completionRatio); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D vortexTexture = ModContent.Request("CalamityMod/Projectiles/Boss/OldDukeVortex").Value; + for (int i = 0; i < 110; i++) + { + float angle = MathHelper.TwoPi * i / 50f + Main.GlobalTimeWrappedHourly * MathHelper.TwoPi; + Color drawColor = Color.White * 0.04f; + drawColor.A = 0; + Vector2 drawPosition = Projectile.Center; + + drawPosition += (angle + Main.GlobalTimeWrappedHourly * i / 16f).ToRotationVector2() * 6f; + Main.EntitySpriteDraw(vortexTexture, drawPosition, null, drawColor, angle + MathHelper.PiOver2, vortexTexture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + } + + return false; + } + } +}