From 37ac833ed5bb8fff7cd6a8a6ba4ce899e981820c Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Thu, 21 Oct 2021 04:41:51 -0500 Subject: [PATCH] 1 - Storm Weaver is now a boss with a single HP bar. --- CalPlayer/CalamityPlayer.cs | 4 +- CalPlayer/CalamityPlayerDrawEffects.cs | 2 +- CalamityLists.cs | 10 +- CalamityMod.cs | 12 +- Events/BossRushEvent.cs | 1 - Items/SummonItems/RuneofCos.cs | 2 +- Items/TreasureBags/StormWeaverBag.cs | 2 +- ModSupport/WeakReferenceSupport.cs | 2 +- NPCs/CalamityGlobalNPC.cs | 8 +- NPCs/StormWeaver/StormWeaverBody.cs | 228 ++++-- NPCs/StormWeaver/StormWeaverBodyNaked.cs | 294 ------- NPCs/StormWeaver/StormWeaverHead.cs | 743 +++++++++++------ NPCs/StormWeaver/StormWeaverHeadNaked.cs | 752 ------------------ NPCs/StormWeaver/StormWeaverTail.cs | 221 +++-- NPCs/StormWeaver/StormWeaverTailNaked.cs | 292 ------- Projectiles/Rogue/AlphaVirusProjectile.cs | 2 +- .../Summon/ProfanedSoulCrystalProjectiles.cs | 6 +- Skies/StormWeaverFlashSky.cs | 4 +- UI/BossHealthBarManager.cs | 3 - Utilities/NPCDebuffs.cs | 9 +- Utilities/NPCStats.cs | 13 +- 21 files changed, 852 insertions(+), 1758 deletions(-) delete mode 100644 NPCs/StormWeaver/StormWeaverBodyNaked.cs delete mode 100644 NPCs/StormWeaver/StormWeaverHeadNaked.cs delete mode 100644 NPCs/StormWeaver/StormWeaverTailNaked.cs diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index d10b17ddcc..467ae81a4d 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -2590,7 +2590,7 @@ namespace CalamityMod.CalPlayer bool useNebulaS = NPC.AnyNPCs(ModContent.NPCType()); player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHeadS", useNebulaS); - bool useFlash = NPC.AnyNPCs(ModContent.NPCType()); + bool useFlash = NPC.AnyNPCs(ModContent.NPCType()); if (SkyManager.Instance["CalamityMod:StormWeaverFlash"] != null && useFlash != SkyManager.Instance["CalamityMod:StormWeaverFlash"].IsActive()) { if (useFlash) @@ -6569,7 +6569,7 @@ namespace CalamityMod.CalPlayer else if (proj.type == ProjectileID.CultistBossIceMist || proj.type == ProjectileID.CultistBossLightningOrbArc) { if (bannerNPCType == ModContent.NPCType() || bannerNPCType == ModContent.NPCType()) - reduceDamage = !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(NPCID.CultistBoss) && proj.Calamity().lineColor != 1; + reduceDamage = !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(NPCID.CultistBoss) && proj.Calamity().lineColor != 1; } else if (proj.type == ProjectileID.SaucerScrap) { diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index d53ab2353c..e8db889c54 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -982,7 +982,7 @@ namespace CalamityMod.CalPlayer break; case 34: - texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; + texture = Main.npcHeadBossTexture[NPCID.Sets.BossHeadTextures[ModContent.NPCType()]]; break; case 35: diff --git a/CalamityLists.cs b/CalamityLists.cs index 88ef4b2c93..f53888412f 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -1946,8 +1946,6 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), @@ -2709,9 +2707,9 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), - NPCType(), + NPCType(), + NPCType(), + NPCType(), NPCType(), NPCType(), NPCType(), @@ -2818,7 +2816,7 @@ namespace CalamityMod { NPCType(), 31 }, { NPCType(), 32 }, { NPCType(), 33 }, - { NPCType(), 34 }, + { NPCType(), 34 }, { NPCType(), 35 }, { NPCType(), 36 }, { NPCType(), 37 }, diff --git a/CalamityMod.cs b/CalamityMod.cs index bc93f8cb11..4612385af7 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -289,7 +289,8 @@ namespace CalamityMod Apollo.LoadHeadIcons(); Artemis.LoadHeadIcons(); Polterghast.LoadHeadIcons(); - SupremeCalamitas.LoadHeadIcons(); + StormWeaverHead.LoadHeadIcons(); + SupremeCalamitas.LoadHeadIcons(); ThanatosHead.LoadHeadIcons(); ThanatosBody1.LoadHeadIcons(); ThanatosBody2.LoadHeadIcons(); @@ -602,9 +603,9 @@ namespace CalamityMod { ModContent.NPCType(), 14400 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 1200 }, - { ModContent.NPCType(), 7200 }, - { ModContent.NPCType(), 7200 }, - { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 8100 }, + { ModContent.NPCType(), 8100 }, + { ModContent.NPCType(), 8100 }, { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, @@ -729,9 +730,6 @@ namespace CalamityMod { ModContent.NPCType(), bitingEnemeyVelocityScale }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, - { ModContent.NPCType(), bitingEnemeyVelocityScale }, - { ModContent.NPCType(), velocityScaleMin }, - { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), bitingEnemeyVelocityScale }, diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 33bd251e41..7c0b157104 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -100,7 +100,6 @@ namespace CalamityMod.Events BossIDsAfterDeath = new Dictionary() { [ModContent.NPCType()] = new int[] { ModContent.NPCType() }, - [ModContent.NPCType()] = new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }, }; Bosses = new List() diff --git a/Items/SummonItems/RuneofCos.cs b/Items/SummonItems/RuneofCos.cs index 64a37ea826..6df3e95a55 100644 --- a/Items/SummonItems/RuneofCos.cs +++ b/Items/SummonItems/RuneofCos.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { return (player.ZoneSkyHeight || player.ZoneUnderworldHeight || player.ZoneDungeon) && - !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && + !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.DoGSecondStageCountdown <= 0 && !BossRushEvent.BossRushActive; } diff --git a/Items/TreasureBags/StormWeaverBag.cs b/Items/TreasureBags/StormWeaverBag.cs index df2d8d51a5..37ae215c34 100644 --- a/Items/TreasureBags/StormWeaverBag.cs +++ b/Items/TreasureBags/StormWeaverBag.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.TreasureBags { public class StormWeaverBag : ModItem { - public override int BossBagNPC => ModContent.NPCType(); + public override int BossBagNPC => ModContent.NPCType(); public override void SetStaticDefaults() { diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 2a982e75d2..cecc35dca7 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -504,7 +504,7 @@ namespace CalamityMod // Storm Weaver { BossDifficulty.TryGetValue("StormWeaver", out float order); - List segments = new List() { NPCType(), NPCType(), NPCType(), NPCType(), NPCType(), NPCType() }; + List segments = new List() { NPCType(), NPCType(), NPCType() }; int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType() }; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 08dc5fd9d6..b8ef9567a4 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -452,9 +452,9 @@ namespace CalamityMod.NPCs public static List StormWeaverIDs = new List { - NPCType(), - NPCType(), - NPCType() + NPCType(), + NPCType(), + NPCType() }; public static List GrenadeResistIDs = new List @@ -5054,7 +5054,7 @@ namespace CalamityMod.NPCs { return CalamityWorld.downedSentinel1; } - else if (type == NPCType() || type == NPCType() || type == NPCType()) + else if (type == NPCType() || type == NPCType() || type == NPCType()) { return CalamityWorld.downedSentinel2; } diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index b8d40642a5..e96b9cf13b 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -1,18 +1,24 @@ +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { - public class StormWeaverBody : ModNPC + public class StormWeaverBody : ModNPC { + private int invinceTime = 180; + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -20,35 +26,39 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 40; npc.height = 40; - npc.defense = 0; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + // Phase one settings + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.chaseable = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.boss = true; npc.behindTiles = true; npc.noGravity = true; + npc.boss = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; - npc.chaseable = false; npc.dontCountMe = true; if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) @@ -59,6 +69,20 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(invinceTime); + writer.Write(npc.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; @@ -66,14 +90,46 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + if (invinceTime > 0) + { + invinceTime--; + npc.damage = 0; + npc.dontTakeDamage = true; + } + else + { + npc.damage = npc.defDamage; + npc.dontTakeDamage = false; + } + + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + + // Update armored settings to naked settings + if (shedArmor) + { + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0f; + global.unbreakableDR = false; + + // Spawn armor gore + if (!npc.chaseable) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody3"), 1f); + } + + npc.chaseable = true; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + } + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - npc.TargetClosest(true); - // Check if other segments are still alive, if not, die bool shouldDespawn = true; for (int i = 0; i < Main.maxNPCs; i++) @@ -116,33 +172,32 @@ namespace CalamityMod.NPCs.StormWeaver npc.alpha = 0; } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); - - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -156,13 +211,64 @@ namespace CalamityMod.NPCs.StormWeaver } } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverBodyNaked") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; + } + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; } - public override bool CheckActive() + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 180 : 90; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } + + public override bool CheckActive() { return false; } @@ -172,55 +278,52 @@ namespace CalamityMod.NPCs.StormWeaver return false; } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x)) + public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + if (CalamityLists.projectileDestroyExceptionList.TrueForAll(x => projectile.type != x) && npc.life / (float)npc.lifeMax >= 0.9f) { if (projectile.penetrate == -1 && !projectile.minion) - { projectile.penetrate = 1; - } else if (projectile.penetrate >= 1) - { projectile.penetrate = 1; - } } - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Electrified, 90, true); } public override void HitEffect(int hitDirection, double damage) { - if (npc.life <= 0) + for (int k = 0; k < 3; k++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); + + if (npc.life <= 0) { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorBody3"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody3"), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 20; num621++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); + int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 40; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } @@ -231,5 +334,6 @@ namespace CalamityMod.NPCs.StormWeaver npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } + } } diff --git a/NPCs/StormWeaver/StormWeaverBodyNaked.cs b/NPCs/StormWeaver/StormWeaverBodyNaked.cs deleted file mode 100644 index 97006260ab..0000000000 --- a/NPCs/StormWeaver/StormWeaverBodyNaked.cs +++ /dev/null @@ -1,294 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.StormWeaver -{ - public class StormWeaverBodyNaked : ModNPC - { - private int invinceTime = 180; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 40; - npc.height = 40; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 760500 : 126750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) - music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; - // If fought as a DoG interlude, keep the DoG music playing - else - music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.boss = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.netAlways = true; - npc.dontCountMe = true; - - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - npc.damage = 0; - npc.dontTakeDamage = true; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - - npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 180 : 90; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } - - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody2"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody3"), 1f); - - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - - } -} diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index b2e79ec7ef..a7387810e2 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -1,7 +1,17 @@ using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.LoreItems; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; +using CalamityMod.Items.Placeables.Furniture.Trophies; +using CalamityMod.Items.Potions; +using CalamityMod.Items.TreasureBags; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.World; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; @@ -10,19 +20,37 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { - [AutoloadBossHead] public class StormWeaverHead : ModNPC { - private const float BoltAngleSpread = 170; - private int BoltCountdown = 0; - private const float speed = 10f; - private const float turnSpeed = 0.3f; - private bool tail = false; + public static int normalIconIndex; + public static int vulnerableIconIndex; - public override void SetStaticDefaults() + internal static void LoadHeadIcons() + { + string normalIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHead_Head_Boss"; + string vulnerableIconPath = "CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked_Head_Boss"; + + CalamityMod.Instance.AddBossHeadTexture(normalIconPath, -1); + normalIconIndex = ModContent.GetModBossHeadSlot(normalIconPath); + + CalamityMod.Instance.AddBossHeadTexture(vulnerableIconPath, -1); + vulnerableIconIndex = ModContent.GetModBossHeadSlot(vulnerableIconPath); + } + + private const float BoltAngleSpread = 280; + private bool tail = false; + private int invinceTime = 180; + + // Lightning flash variables + public float lightning = 0f; + private float lightningDecay = 1f; + private float lightningSpeed = 0f; + + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -31,21 +59,31 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 74; npc.height = 74; - npc.defense = 0; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) + { + npc.value = Item.buyPrice(0, 35, 0, 0); music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; + } // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + // Phase one settings + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.chaseable = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -55,10 +93,8 @@ namespace CalamityMod.NPCs.StormWeaver npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; - npc.chaseable = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; + bossBag = ModContent.ItemType(); if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) npc.scale = 1.2f; @@ -68,28 +104,101 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; } - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) + { + if (npc.life / (float)npc.lifeMax < 0.9f) + index = vulnerableIconIndex; + else + index = normalIconIndex; + } + + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(BoltCountdown); - } + writer.Write(npc.chaseable); + writer.Write(invinceTime); + writer.Write(npc.dontTakeDamage); + writer.Write(npc.localAI[1]); + writer.Write(npc.localAI[2]); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } public override void ReceiveExtraAI(BinaryReader reader) { - BoltCountdown = reader.ReadInt32(); - } + npc.chaseable = reader.ReadBoolean(); + invinceTime = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + npc.localAI[1] = reader.ReadSingle(); + npc.localAI[2] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } public override void AI() { - bool enraged = npc.Calamity().enraged > 0; + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + bool enraged = calamityGlobalNPC.enraged > 0; bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || malice; - bool revenge = CalamityWorld.revenge || malice; bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - if (!Main.raining && !BossRushEvent.BossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0) + if (invinceTime > 0) + { + invinceTime--; + npc.damage = 0; + npc.dontTakeDamage = true; + } + else + { + npc.damage = npc.defDamage; + npc.dontTakeDamage = false; + } + + if (!Main.raining) CalamityUtils.StartRain(); + float lifeRatio = npc.life / (float)npc.lifeMax; + + if (revenge) + { + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; + } + + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + + // Start charging at the target + bool phase2 = lifeRatio < 0.7f; + + // Lightning strike flash phase + bool phase3 = lifeRatio < 0.4f; + + // Become weak and cancel the storm + bool phase4 = npc.life / (float)npc.lifeMax < 0.05f; + + // Update armored settings to naked settings + if (shedArmor) + { + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0f; + global.unbreakableDR = false; + + // Spawn armor gore + if (!npc.chaseable) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorHead1"), 1f); + + npc.chaseable = true; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + } + + int boltProjectiles = (phase3 || death) ? 4 : phase2 ? 3 : 2; + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[2] > 0f) @@ -127,13 +236,10 @@ namespace CalamityMod.NPCs.StormWeaver { int lol; if (num36 >= 0 && num36 < totalLength - 1) - { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } else - { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } + Main.npc[lol].realLife = npc.whoAmI; Main.npc[lol].ai[2] = npc.whoAmI; Main.npc[lol].ai[1] = Previous; @@ -141,66 +247,41 @@ namespace CalamityMod.NPCs.StormWeaver npc.netUpdate = true; Previous = lol; } + tail = true; } - if (expertMode) + if (expertMode && !phase4) { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 360f) + npc.localAI[0] += enraged ? 2f : malice ? 1.5f : 1f; + float spawnOrbGateValue = shedArmor ? 450f : 360f; + if (npc.localAI[0] >= spawnOrbGateValue) { npc.localAI[0] = 0f; - npc.TargetClosest(); npc.netUpdate = true; - float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + 375f : Main.player[npc.target].position.X - 375f; - float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + 375f : Main.player[npc.target].position.Y - 375f; + + float orbDistance = shedArmor ? 250f : 350f; + float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + orbDistance : Main.player[npc.target].position.X - orbDistance; + float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + orbDistance : Main.player[npc.target].position.Y - orbDistance; Vector2 spawnPos = new Vector2(xPos, yPos); + int type = ProjectileID.CultistBossLightningOrb; int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer); } } - - if (BoltCountdown == 0) - { - BoltCountdown = malice ? 480 : 600; - } - if (BoltCountdown > 0) - { - BoltCountdown--; - if (BoltCountdown == 0) - { - int speed2 = enraged ? 10 : revenge ? 8 : 7; - float spawnX2 = Main.rand.Next(2001) - 1000f + Main.player[npc.target].Center.X; - float spawnY2 = -1000f + Main.player[npc.target].Center.Y; - Vector2 baseSpawn = new Vector2(spawnX2, spawnY2); - Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; - int BoltProjectiles = 1; - for (int i = 0; i < BoltProjectiles; i++) - { - Vector2 source = baseSpawn; - source.X += i * 30 - (BoltProjectiles * 15); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / BoltProjectiles))); - velocity.X = velocity.X + 3 * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[npc.target].Center - source; - float ai = Main.rand.Next(100); - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); - } - } - } } - if (Main.player[npc.target].dead) + + if (Main.player[npc.target].dead && npc.life > 0) { - npc.TargetClosest(false); + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + npc.TargetClosest(false); + npc.velocity.Y = npc.velocity.Y - 10f; if ((double)npc.position.Y < Main.topWorld + 16f) - { npc.velocity.Y = npc.velocity.Y - 10f; - } + if ((double)npc.position.Y < Main.topWorld + 16f) { CalamityWorld.DoGSecondStageCountdown = 0; @@ -211,9 +292,10 @@ namespace CalamityMod.NPCs.StormWeaver netMessage.Write(CalamityWorld.DoGSecondStageCountdown); netMessage.Send(); } + for (int num957 = 0; num957 < Main.maxNPCs; num957++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() + if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType())) { @@ -222,7 +304,8 @@ namespace CalamityMod.NPCs.StormWeaver } } } - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 10000f) + + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 10000f && npc.life > 0) { CalamityWorld.DoGSecondStageCountdown = 0; if (Main.netMode == NetmodeID.Server) @@ -232,72 +315,91 @@ namespace CalamityMod.NPCs.StormWeaver netMessage.Write(CalamityWorld.DoGSecondStageCountdown); netMessage.Send(); } + for (int num957 = 0; num957 < Main.maxNPCs; num957++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType())) + if (Main.npc[num957].type == ModContent.NPCType() + || Main.npc[num957].type == ModContent.NPCType() + || Main.npc[num957].type == ModContent.NPCType()) { Main.npc[num957].active = false; } } } + if (npc.velocity.X < 0f) - { npc.spriteDirection = -1; - } else if (npc.velocity.X > 0f) - { npc.spriteDirection = 1; - } - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - int num42 = -1; - int num43 = (int)(Main.player[npc.target].Center.X / 16f); - int num44 = (int)(Main.player[npc.target].Center.Y / 16f); - for (int num45 = num43 - 2; num45 <= num43 + 2; num45++) - { - for (int num46 = num44; num46 <= num44 + 15; num46++) - { - if (WorldGen.SolidTile2(num45, num46)) - { - num42 = num46; - break; - } - } - if (num42 > 0) - { - break; - } - } - if (num42 > 0) - { - num42 *= 16; - float num47 = (float)(num42 - 800); - if (Main.player[npc.target].position.Y > num47) - { - num192 = num47; - if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) < 500f) - { - if (npc.velocity.X > 0f) - { - num191 = Main.player[npc.target].Center.X + 600f; - } - else - { - num191 = Main.player[npc.target].Center.X - 600f; - } - } - } - } - else - { - num188 = enraged ? 15f : malice ? 13f : revenge ? 11f : 10f; - num189 = enraged ? 0.45f : malice ? 0.38f : revenge ? 0.31f : 0.28f; - } + + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + float num188 = (shedArmor ? 12f : 10f) + (enraged ? 5f : malice ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); + float num189 = (shedArmor ? 0.24f : 0.2f) + (enraged ? 0.18f : malice ? 0.12f : revenge ? 0.08f : expertMode ? 0.04f : 0f); + + // Start charging at the player when in phase 2 + if (phase2 && !phase4) + { + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] >= 400f) + { + if (npc.localAI[1] == 0f) + npc.localAI[1] = 1f; + + if (calamityGlobalNPC.newAI[0] >= 500f) + { + npc.TargetClosest(); + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + + if (revenge) + { + if (npc.localAI[1] == 2f) + { + num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio); + num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (0.7f - lifeRatio); + num188 *= 2f; + num189 *= 0.85f; + + float stopChargeDistance = 800f * npc.localAI[2]; + if (stopChargeDistance < 0) + { + if (npc.Center.X < Main.player[npc.target].Center.X + stopChargeDistance) + { + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + else + { + if (npc.Center.X > Main.player[npc.target].Center.X + stopChargeDistance) + { + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + } + } + } + + int dustAmt = 5; + 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)MathHelper.Pi / (float)dustAmt) + npc.Center; + Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); + int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); + Main.dust[num1475].noGravity = true; + Main.dust[num1475].noLight = true; + Main.dust[num1475].velocity /= 4f; + Main.dust[num1475].velocity -= npc.velocity; + } + } + } + else if (revenge) + calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (0.7f - lifeRatio); + } + float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; float num50 = npc.velocity.Length(); @@ -314,52 +416,88 @@ namespace CalamityMod.NPCs.StormWeaver npc.velocity *= num49; } } - if (num42 > 0) - { - for (int num51 = 0; num51 < Main.maxNPCs; num51++) - { - if (Main.npc[num51].active && Main.npc[num51].type == npc.type && num51 != npc.whoAmI) - { - Vector2 vector3 = Main.npc[num51].Center - npc.Center; - if (vector3.Length() < 400f) - { - vector3.Normalize(); - vector3 *= 1000f; - num191 -= vector3.X; - num192 -= vector3.Y; - } - } - } - } - else - { - for (int num52 = 0; num52 < Main.maxNPCs; num52++) - { - if (Main.npc[num52].active && Main.npc[num52].type == npc.type && num52 != npc.whoAmI) - { - Vector2 vector4 = Main.npc[num52].Center - npc.Center; - if (vector4.Length() < 60f) - { - vector4.Normalize(); - vector4 *= 200f; - num191 -= vector4.X; - num192 -= vector4.Y; - } - } - } - } - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + + if (phase2 && !phase4) + { + if (npc.localAI[1] == 1f) + { + // Play lightning sound on the target if not in phase 3 + Vector2 soundCenter = Main.player[npc.target].Center; + + // Play lightning sound on all nearby players if in phase 3 + if (phase3) + { + if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < 2800f) + { + soundCenter = Main.player[Main.myPlayer].Center; + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + + if (Main.netMode != NetmodeID.Server) + { + // Set how quickly the lightning flash dissipates + lightningDecay = Main.rand.NextFloat() * 0.05f + 0.008f; + + // Set how quickly the lightning flash intensifies + lightningSpeed = Main.rand.NextFloat() * 0.05f + 0.05f; + } + } + } + else + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + + npc.localAI[1] = 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int speed2 = enraged ? 10 : revenge ? 8 : 7; + float spawnX2 = npc.Center.X > Main.player[npc.target].Center.X ? 1000f : -1000f; + float spawnY2 = -1000f + Main.player[npc.target].Center.Y; + Vector2 baseSpawn = new Vector2(spawnX2 + Main.player[npc.target].Center.X, spawnY2); + Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; + baseVelocity.Normalize(); + baseVelocity *= speed2; + + for (int i = 0; i < boltProjectiles; i++) + { + Vector2 source = baseSpawn; + source.X += i * 30f - (boltProjectiles * 15f); + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); + velocity.X = velocity.X + 3f * Main.rand.NextFloat() - 1.5f; + Vector2 vector94 = Main.player[npc.target].Center - source; + float ai = Main.rand.Next(100); + int type = ProjectileID.CultistBossLightningOrbArc; + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); + } + } + + if (revenge) + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num188 + Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio)) * 2f; + + float chargeDirection = 0; + if (npc.velocity.X < 0f) + chargeDirection = -1f; + else if (npc.velocity.X > 0f) + chargeDirection = 1f; + + npc.localAI[2] = chargeDirection; + } + } + + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - float num196 = System.Math.Abs(num191); - float num197 = System.Math.Abs(num192); + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + float num196 = Math.Abs(num191); + float num197 = Math.Abs(num192); float num198 = num188 / num193; num191 *= num198; num192 *= num198; + if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) { if (npc.velocity.X < num191) @@ -369,10 +507,9 @@ namespace CalamityMod.NPCs.StormWeaver else { if (npc.velocity.X > num191) - { npc.velocity.X = npc.velocity.X - num189; - } } + if (npc.velocity.Y < num192) { npc.velocity.Y = npc.velocity.Y + num189; @@ -380,31 +517,23 @@ namespace CalamityMod.NPCs.StormWeaver else { if (npc.velocity.Y > num192) - { npc.velocity.Y = npc.velocity.Y - num189; - } } - if ((double)System.Math.Abs(num192) < (double)num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) + + if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) { if (npc.velocity.Y > 0f) - { npc.velocity.Y = npc.velocity.Y + num189 * 2f; - } else - { npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } } - if ((double)System.Math.Abs(num191) < (double)num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) + + if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) { if (npc.velocity.X > 0f) - { - npc.velocity.X = npc.velocity.X + num189 * 2f; //changed from 2 - } + npc.velocity.X = npc.velocity.X + num189 * 2f; else - { - npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 - } + npc.velocity.X = npc.velocity.X - num189 * 2f; } } else @@ -412,49 +541,114 @@ namespace CalamityMod.NPCs.StormWeaver if (num196 > num197) { if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 - } + npc.velocity.X = npc.velocity.X + num189 * 1.1f; else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + npc.velocity.X = npc.velocity.X - num189 * 1.1f; + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.Y > 0f) - { npc.velocity.Y = npc.velocity.Y + num189; - } else - { npc.velocity.Y = npc.velocity.Y - num189; - } } } else { if (npc.velocity.Y < num192) - { npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - } else if (npc.velocity.Y > num192) - { npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - } - if ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)num188 * 0.5) + + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) { if (npc.velocity.X > 0f) - { npc.velocity.X = npc.velocity.X + num189; - } else - { npc.velocity.X = npc.velocity.X - num189; - } } } } - npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + MathHelper.PiOver2; + + npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; + + if (phase4) + { + // Become weak and stop the storm when in phase 4 + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + CalamityMod.StopRain(); + } + else if (phase3) + { + // Adjust lightning flash variables when in phase 3 + if (Main.netMode != NetmodeID.Server) + { + if (lightningSpeed > 0f) + { + lightning += lightningSpeed; + if (lightning >= 1f) + { + lightning = 1f; + lightningSpeed = 0f; + } + } + else if (lightning > 0f) + lightning -= lightningDecay; + } + + // Start a storm when in third phase + if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f) + return; + + CalamityUtils.StartRain(true, true); + calamityGlobalNPC.newAI[1] = 1f; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverHeadNaked") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + + if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); + + if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + return false; } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -463,31 +657,34 @@ namespace CalamityMod.NPCs.StormWeaver return true; } - public override bool CheckActive() + public override void OnHitPlayer(Player player, int damage, bool crit) + { + int buffDuration = npc.Calamity().newAI[0] >= 400f ? 360 : 180; + player.AddBuff(BuffID.Electrified, buffDuration, true); + } + + public override bool CheckActive() { return false; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Electrified, 180, true); - } - - public override void HitEffect(int hitDirection, double damage) + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorHead1"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead2"), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); @@ -495,9 +692,10 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); @@ -511,23 +709,94 @@ namespace CalamityMod.NPCs.StormWeaver public override bool CheckDead() { - for (int num957 = 0; num957 < Main.maxNPCs; num957++) + for (int num569 = 0; num569 < Main.maxNPCs; num569++) { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType())) - { - Main.npc[num957].life = 0; - } - } - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.SpawnOnPlayer(Main.LocalPlayer.whoAmI, ModContent.NPCType()); + if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) + Main.npc[num569].life = 0; } + return true; } - public override bool PreNPCLoot() => false; + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override bool SpecialNPCLoot() + { + int closestSegmentID = DropHelper.FindClosestWormSegment(npc, + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType()); + npc.position = Main.npc[closestSegmentID].position; + return false; + } + + public override void NPCLoot() + { + // Only drop items if fought at full strength + bool fullStrength = !CalamityWorld.downedSentinel2 || CalamityWorld.DoGSecondStageCountdown <= 0; + if (fullStrength) + { + CalamityGlobalNPC.SetNewBossJustDowned(npc); + + DropHelper.DropBags(npc); + + // Legendary drop for Storm Weaver + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); + + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + bool lastSentinelKilled = CalamityWorld.downedSentinel1 && !CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; + DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); + + if (!Main.expertMode) + { + // Materials + DropHelper.DropItem(npc, ModContent.ItemType(), true, 5, 8); + + // Weapons + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + + // Light pet. + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + if (Main.rand.NextBool(20)) + { + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + } + } + } + + // If DoG's fight is active, set the timer for Signus' phase + if (CalamityWorld.DoGSecondStageCountdown > 7260) + { + CalamityWorld.DoGSecondStageCountdown = 7260; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(CalamityWorld.DoGSecondStageCountdown); + netMessage.Send(); + } + } + + // Mark Storm Weaver as dead + if (fullStrength) + { + CalamityWorld.downedSentinel2 = true; + CalamityNetcode.SyncWorld(); + } + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); } diff --git a/NPCs/StormWeaver/StormWeaverHeadNaked.cs b/NPCs/StormWeaver/StormWeaverHeadNaked.cs deleted file mode 100644 index f3d159eb71..0000000000 --- a/NPCs/StormWeaver/StormWeaverHeadNaked.cs +++ /dev/null @@ -1,752 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.Items.Armor.Vanity; -using CalamityMod.Items.LoreItems; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture.Trophies; -using CalamityMod.Items.Potions; -using CalamityMod.Items.TreasureBags; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.StormWeaver -{ - [AutoloadBossHead] - public class StormWeaverHeadNaked : ModNPC - { - private const float BoltAngleSpread = 280; - private const float speed = 13f; - private const float turnSpeed = 0.35f; - private bool tail = false; - private int invinceTime = 180; - - // Lightning flash variables - public float lightning = 0f; - private float lightningDecay = 1f; - private float lightningSpeed = 0f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 74; - npc.height = 74; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 760500 : 126750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) - { - npc.value = Item.buyPrice(0, 35, 0, 0); - music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; - } - // If fought as a DoG interlude, keep the DoG music playing - else - music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.boss = true; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.netAlways = true; - bossBag = ModContent.ItemType(); - - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - writer.Write(npc.localAI[1]); - writer.Write(npc.localAI[2]); - for (int i = 0; i < 4; i++) - writer.Write(npc.Calamity().newAI[i]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - npc.localAI[1] = reader.ReadSingle(); - npc.localAI[2] = reader.ReadSingle(); - for (int i = 0; i < 4; i++) - npc.Calamity().newAI[i] = reader.ReadSingle(); - } - - public override void AI() - { - CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - - bool enraged = calamityGlobalNPC.enraged > 0; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || malice; - bool revenge = CalamityWorld.revenge || malice; - bool expertMode = Main.expertMode || malice; - npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - - if (invinceTime > 0) - { - invinceTime--; - npc.damage = 0; - npc.dontTakeDamage = true; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - if (!Main.raining) - CalamityUtils.StartRain(); - - float lifeRatio = npc.life / (float)npc.lifeMax; - - if (revenge) - { - // Increase aggression if player is taking a long time to kill the boss - if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) - lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - } - - // Start charging at the target - bool phase2 = lifeRatio < 0.7f; - - // Lightning strike flash phase - bool phase3 = lifeRatio < 0.4f; - - // Become weak and cancel the storm - bool phase4 = npc.life / (float)npc.lifeMax < 0.05f; - - int boltProjectiles = (phase3 || death) ? 4 : phase2 ? 3 : 2; - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - 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, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 12; - if (npc.alpha < 0) - npc.alpha = 0; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (!tail && npc.ai[0] == 0f) - { - int Previous = npc.whoAmI; - int totalLength = death ? 60 : revenge ? 50 : expertMode ? 40 : 30; - for (int num36 = 0; num36 < totalLength; num36++) - { - int lol; - if (num36 >= 0 && num36 < totalLength - 1) - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - else - { - lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } - Main.npc[lol].realLife = npc.whoAmI; - Main.npc[lol].ai[2] = npc.whoAmI; - Main.npc[lol].ai[1] = Previous; - Main.npc[Previous].ai[0] = lol; - npc.netUpdate = true; - Previous = lol; - } - tail = true; - } - - if (expertMode && !phase4) - { - npc.localAI[0] += enraged ? 2f : malice ? 1.5f : 1f; - if (npc.localAI[0] >= 450f) - { - npc.localAI[0] = 0f; - npc.netUpdate = true; - - float xPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.X + 250f : Main.player[npc.target].position.X - 250f; - float yPos = Main.rand.NextBool(2) ? Main.player[npc.target].position.Y + 250f : Main.player[npc.target].position.Y - 250f; - Vector2 spawnPos = new Vector2(xPos, yPos); - - int type = ProjectileID.CultistBossLightningOrb; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(spawnPos, Vector2.Zero, type, damage, 0f, Main.myPlayer); - } - } - } - - if (Main.player[npc.target].dead && npc.life > 0) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - npc.TargetClosest(false); - - npc.velocity.Y = npc.velocity.Y - 10f; - if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y = npc.velocity.Y - 10f; - - if ((double)npc.position.Y < Main.topWorld + 16f) - { - CalamityWorld.DoGSecondStageCountdown = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - for (int num957 = 0; num957 < Main.maxNPCs; num957++) - { - if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType())) - { - Main.npc[num957].active = false; - } - } - } - } - - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 10000f && npc.life > 0) - { - CalamityWorld.DoGSecondStageCountdown = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - for (int num957 = 0; num957 < Main.maxNPCs; num957++) - { - if (Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType() - || Main.npc[num957].type == ModContent.NPCType()) - { - Main.npc[num957].active = false; - } - } - } - - if (npc.velocity.X < 0f) - npc.spriteDirection = -1; - else if (npc.velocity.X > 0f) - npc.spriteDirection = 1; - - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - float num188 = enraged ? 17f : malice ? 15f : revenge ? 13f : 12f; - float num189 = enraged ? 0.41f : malice ? 0.36f : revenge ? 0.31f : 0.28f; - - // Start charging at the player when in phase 2 - if (phase2 && !phase4) - { - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= 400f) - { - if (npc.localAI[1] == 0f) - npc.localAI[1] = 1f; - - if (calamityGlobalNPC.newAI[0] >= 500f) - { - npc.TargetClosest(); - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - - if (revenge) - { - if (npc.localAI[1] == 2f) - { - num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio); - num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (0.7f - lifeRatio); - num188 *= 2f; - num189 *= 0.85f; - - float stopChargeDistance = 800f * npc.localAI[2]; - if (stopChargeDistance < 0) - { - if (npc.Center.X < Main.player[npc.target].Center.X + stopChargeDistance) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - else - { - if (npc.Center.X > Main.player[npc.target].Center.X + stopChargeDistance) - { - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } - } - } - - int dustAmt = 5; - 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)MathHelper.Pi / (float)dustAmt) + npc.Center; - Vector2 value18 = ((float)(Main.rand.NextDouble() * MathHelper.Pi) - MathHelper.PiOver2).ToRotationVector2() * Main.rand.Next(3, 8); - int num1475 = Dust.NewDust(vector171 + value18, 0, 0, 206, value18.X, value18.Y, 100, default, 3f); - Main.dust[num1475].noGravity = true; - Main.dust[num1475].noLight = true; - Main.dust[num1475].velocity /= 4f; - Main.dust[num1475].velocity -= npc.velocity; - } - } - } - else if (revenge) - calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (0.7f - lifeRatio); - } - - float num48 = num188 * 1.3f; - float num49 = num188 * 0.7f; - float num50 = npc.velocity.Length(); - if (num50 > 0f) - { - if (num50 > num48) - { - npc.velocity.Normalize(); - npc.velocity *= num48; - } - else if (num50 < num49) - { - npc.velocity.Normalize(); - npc.velocity *= num49; - } - } - - if (phase2 && !phase4) - { - if (npc.localAI[1] == 1f) - { - // Play lightning sound on the target if not in phase 3 - Vector2 soundCenter = Main.player[npc.target].Center; - - // Play lightning sound on all nearby players if in phase 3 - if (phase3) - { - if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, npc.Center) < 2800f) - { - soundCenter = Main.player[Main.myPlayer].Center; - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); - - if (Main.netMode != NetmodeID.Server) - { - // Set how quickly the lightning flash dissipates - lightningDecay = Main.rand.NextFloat() * 0.05f + 0.008f; - - // Set how quickly the lightning flash intensifies - lightningSpeed = Main.rand.NextFloat() * 0.05f + 0.05f; - } - } - } - else - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); - - npc.localAI[1] = 2f; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int speed2 = enraged ? 10 : revenge ? 8 : 7; - float spawnX2 = npc.Center.X > Main.player[npc.target].Center.X ? 1000f : -1000f; - float spawnY2 = -1000f + Main.player[npc.target].Center.Y; - Vector2 baseSpawn = new Vector2(spawnX2 + Main.player[npc.target].Center.X, spawnY2); - Vector2 baseVelocity = Main.player[npc.target].Center - baseSpawn; - baseVelocity.Normalize(); - baseVelocity *= speed2; - - for (int i = 0; i < boltProjectiles; i++) - { - Vector2 source = baseSpawn; - source.X += i * 30f - (boltProjectiles * 15f); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / boltProjectiles))); - velocity.X = velocity.X + 3f * Main.rand.NextFloat() - 1.5f; - Vector2 vector94 = Main.player[npc.target].Center - source; - float ai = Main.rand.Next(100); - int type = ProjectileID.CultistBossLightningOrbArc; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(source, velocity, type, damage, 0f, Main.myPlayer, vector94.ToRotation(), ai); - } - } - - if (revenge) - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num188 + Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (0.7f - lifeRatio)) * 2f; - - float chargeDirection = 0; - if (npc.velocity.X < 0f) - chargeDirection = -1f; - else if (npc.velocity.X > 0f) - chargeDirection = 1f; - - npc.localAI[2] = chargeDirection; - } - } - - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); - float num196 = Math.Abs(num191); - float num197 = Math.Abs(num192); - float num198 = num188 / num193; - num191 *= num198; - num192 *= num198; - - if ((npc.velocity.X > 0f && num191 > 0f) || (npc.velocity.X < 0f && num191 < 0f) || (npc.velocity.Y > 0f && num192 > 0f) || (npc.velocity.Y < 0f && num192 < 0f)) - { - if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189; - } - else - { - if (npc.velocity.X > num191) - npc.velocity.X = npc.velocity.X - num189; - } - - if (npc.velocity.Y < num192) - { - npc.velocity.Y = npc.velocity.Y + num189; - } - else - { - if (npc.velocity.Y > num192) - npc.velocity.Y = npc.velocity.Y - num189; - } - - if (Math.Abs(num192) < num188 * 0.2 && ((npc.velocity.X > 0f && num191 < 0f) || (npc.velocity.X < 0f && num191 > 0f))) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num189 * 2f; - else - npc.velocity.Y = npc.velocity.Y - num189 * 2f; - } - - if (Math.Abs(num191) < num188 * 0.2 && ((npc.velocity.Y > 0f && num192 < 0f) || (npc.velocity.Y < 0f && num192 > 0f))) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num189 * 2f; - else - npc.velocity.X = npc.velocity.X - num189 * 2f; - } - } - else - { - if (num196 > num197) - { - if (npc.velocity.X < num191) - npc.velocity.X = npc.velocity.X + num189 * 1.1f; - else if (npc.velocity.X > num191) - npc.velocity.X = npc.velocity.X - num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = npc.velocity.Y + num189; - else - npc.velocity.Y = npc.velocity.Y - num189; - } - } - else - { - if (npc.velocity.Y < num192) - npc.velocity.Y = npc.velocity.Y + num189 * 1.1f; - else if (npc.velocity.Y > num192) - npc.velocity.Y = npc.velocity.Y - num189 * 1.1f; - - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < num188 * 0.5) - { - if (npc.velocity.X > 0f) - npc.velocity.X = npc.velocity.X + num189; - else - npc.velocity.X = npc.velocity.X - num189; - } - } - } - - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) + MathHelper.PiOver2; - - if (phase4) - { - // Become weak and stop the storm when in phase 4 - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - CalamityMod.StopRain(); - } - else if (phase3) - { - // Adjust lightning flash variables when in phase 3 - if (Main.netMode != NetmodeID.Server) - { - if (lightningSpeed > 0f) - { - lightning += lightningSpeed; - if (lightning >= 1f) - { - lightning = 1f; - lightningSpeed = 0f; - } - } - else if (lightning > 0f) - lightning -= lightningDecay; - } - - // Start a storm when in third phase - if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu) || calamityGlobalNPC.newAI[1] > 0f) - return; - - CalamityUtils.StartRain(true, true); - calamityGlobalNPC.newAI[1] = 1f; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - - if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); - - if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((npc.Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = npc.Calamity().newAI[0] >= 400f ? 360 : 180; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } - - public override bool CheckActive() - { - return false; - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 5; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead2"), 1f); - - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override bool CheckDead() - { - for (int num569 = 0; num569 < Main.maxNPCs; num569++) - { - if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) - Main.npc[num569].life = 0; - } - - return true; - } - - public override void BossLoot(ref string name, ref int potionType) - { - potionType = ModContent.ItemType(); - } - - public override bool SpecialNPCLoot() - { - int closestSegmentID = DropHelper.FindClosestWormSegment(npc, - ModContent.NPCType(), - ModContent.NPCType(), - ModContent.NPCType()); - npc.position = Main.npc[closestSegmentID].position; - return false; - } - - public override void NPCLoot() - { - // Only drop items if fought at full strength - bool fullStrength = !CalamityWorld.downedSentinel2 || CalamityWorld.DoGSecondStageCountdown <= 0; - if (fullStrength) - { - CalamityGlobalNPC.SetNewBossJustDowned(npc); - - DropHelper.DropBags(npc); - - // Legendary drop for Storm Weaver - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - bool lastSentinelKilled = CalamityWorld.downedSentinel1 && !CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3; - DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, lastSentinelKilled); - - if (!Main.expertMode) - { - // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), true, 5, 8); - - // Weapons - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); - - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - - // Light pet. - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - if (Main.rand.NextBool(20)) - { - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItem(npc, ModContent.ItemType()); - } - } - } - - // If DoG's fight is active, set the timer for Signus' phase - if (CalamityWorld.DoGSecondStageCountdown > 7260) - { - CalamityWorld.DoGSecondStageCountdown = 7260; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(CalamityWorld.DoGSecondStageCountdown); - netMessage.Send(); - } - } - - // Mark Storm Weaver as dead - if (fullStrength) - { - CalamityWorld.downedSentinel2 = true; - CalamityNetcode.SyncWorld(); - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - } - } -} diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 5b5fd26d44..874727bb36 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -1,20 +1,24 @@ -using CalamityMod.Dusts; +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.StormWeaver { - public class StormWeaverTail : ModNPC + public class StormWeaverTail : ModNPC { + private int invinceTime = 180; + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { @@ -22,31 +26,35 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 48; npc.height = 80; - npc.defense = 0; - npc.takenDamageMultiplier = 3f; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + // 10% of HP is phase one + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; + npc.lifeMax = notDoGFight ? 825500 : 139750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 475000); + + // If fought alone, Storm Weaver plays its own theme + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + // Phase one settings + npc.takenDamageMultiplier = 3f; + npc.HitSound = SoundID.NPCHit53; + npc.DeathSound = SoundID.NPCDeath14; + + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.boss = true; npc.behindTiles = true; npc.noGravity = true; + npc.boss = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit53; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; @@ -58,6 +66,18 @@ namespace CalamityMod.NPCs.StormWeaver npc.scale = 1.1f; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(invinceTime); + writer.Write(npc.dontTakeDamage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + invinceTime = reader.ReadInt32(); + npc.dontTakeDamage = reader.ReadBoolean(); + } + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return false; @@ -65,14 +85,41 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); + if (invinceTime > 0) + { + invinceTime--; + npc.damage = 0; + npc.dontTakeDamage = true; + } + else + { + npc.damage = npc.defDamage; + npc.dontTakeDamage = false; + } + + // Shed armor + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + + // Update armored settings to naked settings + if (shedArmor) + { + // Spawn armor gore + if (npc.takenDamageMultiplier == 3f) + { + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail2"), 1f); + } + + npc.takenDamageMultiplier = 1f; + npc.HitSound = SoundID.NPCHit13; + npc.DeathSound = SoundID.NPCDeath13; + } + + Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - npc.TargetClosest(true); - // Check if other segments are still alive, if not, die bool shouldDespawn = true; for (int i = 0; i < Main.maxNPCs; i++) @@ -115,33 +162,32 @@ namespace CalamityMod.NPCs.StormWeaver npc.alpha = 0; } - if (Main.player[npc.target].dead) - npc.TargetClosest(false); - - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2); - num191 = (float)((int)(num191 / 16f) * 16); - num192 = (float)((int)(num192 / 16f) * 16); - vector18.X = (float)((int)(vector18.X / 16f) * 16); - vector18.Y = (float)((int)(vector18.Y / 16f) * 16); + Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); + float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); + num191 = (int)(num191 / 16f) * 16; + num192 = (int)(num192 / 16f) * 16; + vector18.X = (int)(vector18.X / 16f) * 16; + vector18.Y = (int)(vector18.Y / 16f) * 16; num191 -= vector18.X; num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; @@ -155,7 +201,60 @@ namespace CalamityMod.NPCs.StormWeaver } } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + bool shedArmor = npc.life / (float)npc.lifeMax < 0.9f; + Texture2D texture2D15 = shedArmor ? ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailNaked") : Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); + Color color36 = Color.White; + float amount9 = 0.5f; + int num153 = 5; + + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } + + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); + Color color = npc.GetAlpha(lightColor); + + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) + color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); + + spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + + if (!shedArmor) + { + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow"); + Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); + Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); + spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + + return false; + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -163,25 +262,27 @@ namespace CalamityMod.NPCs.StormWeaver public override void OnHitPlayer(Player player, int damage, bool crit) { - player.AddBuff(BuffID.Electrified, 60, true); + int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 120 : 60; + player.AddBuff(BuffID.Electrified, buffDuration, true); } public override void HitEffect(int hitDirection, double damage) { - for (int k = 0; k < 5; k++) - { + for (int k = 0; k < 3; k++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWArmorTail2"), 1f); - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail2"), 1f); + + npc.position.X = npc.position.X + (npc.width / 2); + npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); + npc.position.X = npc.position.X - (npc.width / 2); + npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); @@ -189,9 +290,10 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); @@ -203,30 +305,7 @@ namespace CalamityMod.NPCs.StormWeaver } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/StormWeaver/StormWeaverTailGlow"); - Color rainbowBecauseWhyTheFuckNot = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - Color color37 = Color.Lerp(Color.White, rainbowBecauseWhyTheFuckNot, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CheckActive() + public override bool CheckActive() { return false; } diff --git a/NPCs/StormWeaver/StormWeaverTailNaked.cs b/NPCs/StormWeaver/StormWeaverTailNaked.cs deleted file mode 100644 index 4716088ed3..0000000000 --- a/NPCs/StormWeaver/StormWeaverTailNaked.cs +++ /dev/null @@ -1,292 +0,0 @@ -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.StormWeaver -{ - public class StormWeaverTailNaked : ModNPC - { - private int invinceTime = 180; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Storm Weaver"); - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.GetNPCDamage(); - npc.npcSlots = 5f; - npc.width = 48; - npc.height = 80; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.lifeMax = notDoGFight ? 760500 : 126750; - npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - - // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) - music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; - // If fought as a DoG interlude, keep the DoG music playing - else - music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0f; - npc.alpha = 255; - npc.behindTiles = true; - npc.noGravity = true; - npc.boss = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; - npc.netAlways = true; - npc.dontCountMe = true; - - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) - npc.scale = 1.2f; - else if (CalamityWorld.revenge) - npc.scale = 1.15f; - else if (Main.expertMode) - npc.scale = 1.1f; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - } - - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } - - public override void AI() - { - if (invinceTime > 0) - { - invinceTime--; - npc.damage = 0; - npc.dontTakeDamage = true; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); - - if (npc.ai[2] > 0f) - npc.realLife = (int)npc.ai[2]; - - // Check if other segments are still alive, if not, die - bool shouldDespawn = true; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType()) - { - shouldDespawn = false; - break; - } - } - if (!shouldDespawn) - { - if (npc.ai[1] <= 0f) - shouldDespawn = true; - else if (Main.npc[(int)npc.ai[1]].life <= 0) - shouldDespawn = true; - } - if (shouldDespawn) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - npc.active = false; - } - - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - - npc.alpha -= 42; - if (npc.alpha < 0) - npc.alpha = 0; - } - - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } catch - { - } - - npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - - if (num191 < 0f) - npc.spriteDirection = -1; - else if (num191 > 0f) - npc.spriteDirection = 1; - } - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); - Color color36 = Color.White; - float amount9 = 0.5f; - int num153 = 5; - - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color38 = Color.Lerp(color38, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - 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(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } - - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - Color color = npc.GetAlpha(lightColor); - - if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) - color = Color.Lerp(color, Color.Cyan, MathHelper.Clamp((Main.npc[(int)npc.ai[2]].Calamity().newAI[0] - 280f) / 120f, 0f, 1f)); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - int buffDuration = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= 400f ? 120 : 60; - player.AddBuff(BuffID.Electrified, buffDuration, true); - } - - public override void HitEffect(int hitDirection, double damage) - { - for (int k = 0; k < 3; k++) - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, hitDirection, -1f, 0, default, 1f); - - if (npc.life <= 0) - { - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail1"), 1f); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail2"), 1f); - - npc.position.X = npc.position.X + (npc.width / 2); - npc.position.Y = npc.position.Y + (npc.height / 2); - npc.width = 30; - npc.height = 30; - npc.position.X = npc.position.X - (npc.width / 2); - npc.position.Y = npc.position.Y - (npc.height / 2); - - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; - } - } - - for (int num623 = 0; num623 < 40; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmilite, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - } - - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); - npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); - } - } -} diff --git a/Projectiles/Rogue/AlphaVirusProjectile.cs b/Projectiles/Rogue/AlphaVirusProjectile.cs index a0ce21a17e..9803143626 100644 --- a/Projectiles/Rogue/AlphaVirusProjectile.cs +++ b/Projectiles/Rogue/AlphaVirusProjectile.cs @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Rogue public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) + if (target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType()) { damage /= 5; } diff --git a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs index 38e65e8656..e718783cfc 100644 --- a/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs +++ b/Projectiles/Summon/ProfanedSoulCrystalProjectiles.cs @@ -318,8 +318,7 @@ namespace CalamityMod.Projectiles.Summon public override bool? CanHitNPC(NPC target) { - bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() - || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); + bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); if (!instakill && this.target != null && target != this.target) { if (projectile.getRect().Intersects(target.getRect())) @@ -714,8 +713,7 @@ namespace CalamityMod.Projectiles.Summon public override bool? CanHitNPC(NPC target) { - bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() - || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); + bool instakill = target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType() || target.type == ModContent.NPCType(); if (!instakill && this.target != null && target != this.target) return false; return null; diff --git a/Skies/StormWeaverFlashSky.cs b/Skies/StormWeaverFlashSky.cs index 6481e2987d..78dba77b3b 100644 --- a/Skies/StormWeaverFlashSky.cs +++ b/Skies/StormWeaverFlashSky.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Skies public override void Update(GameTime gameTime) { - int weaverType = ModContent.NPCType(); + int weaverType = ModContent.NPCType(); if (StormWeaverHeadIndex >= 0 && Main.npc[StormWeaverHeadIndex].active && Main.npc[StormWeaverHeadIndex].type == weaverType) return; @@ -36,7 +36,7 @@ namespace CalamityMod.Skies // Draw lightning in the background based on Main.magicPixel. // It is a long, white vertical strip that exists for some reason. // This lightning effect is achieved by expanding this to fit the entire background and then drawing it as a distinct element. - float lightningFlashPower = (Main.npc[StormWeaverHeadIndex].modNPC as StormWeaverHeadNaked).lightning; + float lightningFlashPower = (Main.npc[StormWeaverHeadIndex].modNPC as StormWeaverHead).lightning; Vector2 scale = new Vector2(Main.screenWidth * 1.1f / Main.magicPixel.Width, Main.screenHeight * 1.1f / Main.magicPixel.Height); Vector2 screenCenter = new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; Color drawColor = Color.White * MathHelper.Lerp(0f, 0.88f, lightningFlashPower); diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 516551a6cd..affc696f26 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -191,11 +191,8 @@ namespace CalamityMod.UI NPCType(), NPCType(), NPCType(), - NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 0bd6769842..657d6de98e 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -151,12 +151,9 @@ namespace CalamityMod { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(true, new int[] { }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, - { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, + { ModContent.NPCType(), new Tuple(false, new int[] { BuffID.Electrified }) }, { ModContent.NPCType(), new Tuple(false, new int[] { ModContent.BuffType() }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index 01981d44e5..0ef46ad2dc 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -265,8 +265,6 @@ namespace CalamityMod { ModContent.NPCType(), 0.8 }, { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, - { ModContent.NPCType(), 0.8 }, { ModContent.NPCType(), 0.9 }, @@ -504,12 +502,9 @@ namespace CalamityMod { ModContent.NPCType(), new int[] { 150, 300, 330, 348, 450 } }, { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 360 } }, - { ModContent.NPCType(), new int[] { 140, 280, 308, 324, 420 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 208, 300 } }, - { ModContent.NPCType(), new int[] { 80, 128, 160, 176, 240 } }, - { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, - { ModContent.NPCType(), new int[] { 120, 192, 224, 250, 330 } }, - { ModContent.NPCType(), new int[] { 100, 160, 192, 210, 270 } }, + { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, + { ModContent.NPCType(), new int[] { 120, 192, 224, 250, 330 } }, + { ModContent.NPCType(), new int[] { 100, 160, 192, 210, 270 } }, { ModContent.NPCType(), new int[] { 175, 315, 351, 369, 459 } }, { ModContent.NPCType(), new int[] { 110, 220, 242, 256, 336 } }, @@ -758,8 +753,6 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 300, 432 } }, { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrb), new int[] { 150, 264, 288, 300, 432 } }, - { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 150, 264, 288, 300, 432 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 192, 212, 224, 318 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 140, 240, 264, 280, 396 } },