From 4711b41a4831441fa8df97c027aceccae29af630 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Mon, 6 May 2024 09:57:13 -0500 Subject: [PATCH] 1 - Desert Scourge edits. 2 - Death Destroyer laser spreads made tighter. --- DataStructures/NPCStats.cs | 1 + Items/SummonItems/DesertMedallion.cs | 13 ---- NPCs/DesertScourge/DesertNuisanceHead.cs | 5 +- NPCs/DesertScourge/DesertNuisanceHeadYoung.cs | 52 ++++++++++++- NPCs/DesertScourge/DesertScourgeBody.cs | 6 +- NPCs/DesertScourge/DesertScourgeHead.cs | 75 +++++++++++++++---- NPCs/DesertScourge/DesertScourgeTail.cs | 6 +- .../Bosses/DestroyerAI.cs | 2 +- Projectiles/Boss/DesertScourgeSpit.cs | 4 +- 9 files changed, 130 insertions(+), 34 deletions(-) diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index dc4a0cf239..15d755c415 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -564,6 +564,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(NPCID.EyeofCthulhu, ProjectileID.BloodNautilusShot), new int[] { 26, 44, 60, 76, 108 } }, { new Tuple(ModContent.NPCType(), ProjectileID.BloodShot), new int[] { 26, 36, 44, 52, 84 } }, diff --git a/Items/SummonItems/DesertMedallion.cs b/Items/SummonItems/DesertMedallion.cs index cf9414bad1..14d89b62de 100644 --- a/Items/SummonItems/DesertMedallion.cs +++ b/Items/SummonItems/DesertMedallion.cs @@ -47,19 +47,6 @@ namespace CalamityMod.Items.SummonItems else NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, player.whoAmI, ModContent.NPCType()); - if (CalamityWorld.revenge) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, player.whoAmI, ModContent.NPCType()); - - if (Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - else - NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, player.whoAmI, ModContent.NPCType()); - } - return true; } diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 220984be48..051367fa15 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -110,6 +110,9 @@ namespace CalamityMod.NPCs.DesertScourge bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; + // Become angry when the other Nuisance dies. + bool getMad = !NPC.AnyNPCs(ModContent.NPCType()) && expertMode; + // Enrage if (!Main.player[NPC.target].ZoneDesert && !bossRush) { @@ -121,7 +124,7 @@ namespace CalamityMod.NPCs.DesertScourge bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - float enrageScale = bossRush ? 1f : 0f; + float enrageScale = bossRush ? 1f : getMad ? 0.5f : 0f; if (biomeEnraged) { NPC.Calamity().CurrentlyEnraged = !bossRush; diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 0a798ba1d3..8a639f3cfa 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -1,6 +1,7 @@ using System; using System.IO; using CalamityMod.Events; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -24,6 +25,8 @@ namespace CalamityMod.NPCs.DesertScourge public const float SegmentVelocity_GoodWorld = 15f; public const float SegmentVelocity_ZenithSeed = 17.5f; + public const float SpitGateValue = 180f; + public const float OpenMouthForBiteDistance = 220f; private const int OpenMouthStopFrame = 4; @@ -71,11 +74,15 @@ namespace CalamityMod.NPCs.DesertScourge public override void SendExtraAI(BinaryWriter writer) { writer.Write(biomeEnrageTimer); + for (int i = 0; i < 4; i++) + writer.Write(NPC.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) { biomeEnrageTimer = reader.ReadInt32(); + for (int i = 0; i < 4; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); } public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) @@ -98,6 +105,9 @@ namespace CalamityMod.NPCs.DesertScourge bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; + // Become angry when the other Nuisance dies. + bool getMad = !NPC.AnyNPCs(ModContent.NPCType()) && expertMode; + // Enrage if (!Main.player[NPC.target].ZoneDesert && !bossRush) { @@ -109,7 +119,7 @@ namespace CalamityMod.NPCs.DesertScourge bool biomeEnraged = biomeEnrageTimer <= 0 || bossRush; - float enrageScale = bossRush ? 1f : 0f; + float enrageScale = bossRush ? 1f : getMad ? 0.25f : 0f; if (biomeEnraged) { NPC.Calamity().CurrentlyEnraged = !bossRush; @@ -140,6 +150,42 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.alpha < 0) NPC.alpha = 0; + if (getMad && NPC.Distance(Main.player[NPC.target].Center) > 240f) + { + if ((Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) + NPC.Calamity().newAI[0] += 1f; + + if (NPC.Calamity().newAI[0] >= SpitGateValue) + { + NPC.Calamity().newAI[0] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (revenge ? 10f : 8f); + int numProj = death ? 6 : 4; + int spread = masterMode ? 28 : 20; + if (masterMode) + { + numProj += 2; + spread += 8; + } + + float rotation = MathHelper.ToRadians(spread); + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Main.projectile[proj].aiStyle = -1; + Main.projectile[proj].netUpdate = true; + } + } + } + } + } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!tailSpawned && NPC.ai[0] == 0f) @@ -504,6 +550,8 @@ namespace CalamityMod.NPCs.DesertScourge public override void FindFrame(int frameHeight) { // Open mouth to prepare for a nibble ;3 + // Also open mouth for projectile spreads + bool aboutToSpitSpread = NPC.Calamity().newAI[0] > SpitGateValue - 30f; bool openMouth = NPC.Distance(Main.player[NPC.target].Center) < OpenMouthForBiteDistance && (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation() && NPC.ai[3] == 0f; @@ -532,7 +580,7 @@ namespace CalamityMod.NPCs.DesertScourge NPC.frame.Y = 0; } } - else if (openMouth) + else if (openMouth || aboutToSpitSpread) { NPC.frameCounter += 1D; if (NPC.frameCounter > 4D) diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index 9237f734fb..c790ca2724 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -165,6 +165,8 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.life > Main.npc[(int)NPC.ai[1]].life) NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.dontTakeDamage = Main.npc[(int)NPC.ai[1]].dontTakeDamage; + // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -201,6 +203,8 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.alpha < 0) NPC.alpha = 0; } + else + NPC.alpha = Main.npc[(int)NPC.ai[1]].alpha; if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -287,7 +291,7 @@ namespace CalamityMod.NPCs.DesertScourge break; } - return minDist <= hitDistance * NPC.scale; + return minDist <= hitDistance * NPC.scale && NPC.alpha <= 0; } public override void FindFrame(int frameHeight) diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 59cde20e23..a83471e292 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; @@ -43,12 +44,13 @@ namespace CalamityMod.NPCs.DesertScourge public const float SegmentVelocity_GoodWorld = 21f; public const float SegmentVelocity_ZenithSeed = 24f; - public const float BurrowTimeGateValue = 540f; - public const float BurrowTimeGateValue_Death = 420f; + public const float BurrowTimeGateValue = 720f; + public const float BurrowTimeGateValue_Death = 600f; public const float BurrowResetTimeGateValue = 600f; public const float LungeUpwardDistanceOffset = 600f; public const float LungeUpwardCutoffDistance = 420f; + public const float BurrowDistance_Hide = 1080f; public const float BurrowDistance = 800f; public const float BurrowDistance_BossRush = 400f; public const float OpenMouthForBiteDistance = 220f; @@ -115,6 +117,12 @@ namespace CalamityMod.NPCs.DesertScourge NPC.Calamity().VulnerableToWater = true; } + public override void BossHeadSlot(ref int index) + { + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + index = -1; + } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] @@ -128,6 +136,7 @@ namespace CalamityMod.NPCs.DesertScourge { writer.Write(biomeEnrageTimer); writer.Write(playRoarSound); + writer.Write(NPC.localAI[2]); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); } @@ -136,6 +145,7 @@ namespace CalamityMod.NPCs.DesertScourge { biomeEnrageTimer = reader.ReadInt32(); playRoarSound = reader.ReadBoolean(); + NPC.localAI[2] = reader.ReadSingle(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); } @@ -148,6 +158,18 @@ namespace CalamityMod.NPCs.DesertScourge bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; + // Check for Nuisances + bool hide = NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()); + if (hide) + { + NPC.Calamity().newAI[0] = 0f; + NPC.Calamity().newAI[1] = 0f; + NPC.Calamity().newAI[3] = 0f; + playRoarSound = false; + } + + NPC.dontTakeDamage = hide; + // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -179,6 +201,17 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Summon the Nuisances. + if (lifeRatio < 0.5f) + { + if (NPC.localAI[2] == 0f) + { + NPC.localAI[2] = 1f; + NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); + NPC.SpawnOnPlayer(NPC.FindClosestPlayer(), ModContent.NPCType()); + } + } + // Only increment the burrow timer if the head is beneath the player. if (NPC.Center.Y > Main.player[NPC.target].Center.Y) { @@ -192,6 +225,8 @@ namespace CalamityMod.NPCs.DesertScourge bool lungeUpward = burrow && NPC.Calamity().newAI[1] == 1f; bool quickFall = NPC.Calamity().newAI[1] == 2f; + float burrowDistance = hide ? BurrowDistance_Hide : bossRush ? BurrowDistance_BossRush : BurrowDistance; + float speed = death ? 0.18f : 0.15f; float turnSpeed = death ? 0.36f : 0.3f; @@ -210,7 +245,7 @@ namespace CalamityMod.NPCs.DesertScourge turnSpeed *= 1.2f; } - if (lungeUpward || burrow) + if (lungeUpward || burrow || hide) { speed *= 1.5f; turnSpeed *= 1.5f; @@ -222,9 +257,18 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; - NPC.alpha -= 42; - if (NPC.alpha < 0) - NPC.alpha = 0; + if (hide) + { + NPC.alpha += 3; + if (NPC.alpha > 255) + NPC.alpha = 255; + } + else + { + NPC.alpha -= 42; + if (NPC.alpha < 0) + NPC.alpha = 0; + } if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -294,7 +338,7 @@ namespace CalamityMod.NPCs.DesertScourge if (tileWidthPosY > Main.maxTilesY) tileWidthPosY = Main.maxTilesY; - bool shouldFly = lungeUpward; + bool shouldFly = lungeUpward || hide; if (!shouldFly) { for (int k = tilePositionX; k < tileWidthPosX; k++) @@ -361,7 +405,7 @@ namespace CalamityMod.NPCs.DesertScourge masterMode ? SegmentVelocity_Master : expertMode ? SegmentVelocity_Expert : SegmentVelocity_Normal; - if (burrow || lungeUpward) + if (burrow || lungeUpward || hide) maxChaseSpeed *= 1.5f; if (expertMode) maxChaseSpeed += maxChaseSpeed * 0.5f * (1f - lifeRatio); @@ -386,12 +430,11 @@ namespace CalamityMod.NPCs.DesertScourge } } - float burrowDistance = bossRush ? BurrowDistance_BossRush : BurrowDistance; float burrowTarget = player.Center.Y + burrowDistance; float lungeTarget = NPC.Calamity().newAI[3]; Vector2 npcCenter = NPC.Center; float playerX = player.Center.X; - float targettingPosition = lungeUpward ? lungeTarget : burrow ? burrowTarget : player.Center.Y; + float targettingPosition = lungeUpward ? lungeTarget : (burrow || hide) ? burrowTarget : player.Center.Y; playerX = (float)((int)(playerX / 16f) * 16); targettingPosition = (float)((int)(targettingPosition / 16f) * 16); npcCenter.X = (float)((int)(npcCenter.X / 16f) * 16); @@ -412,7 +455,7 @@ namespace CalamityMod.NPCs.DesertScourge } // Quickly fall back down once above target - if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance) + if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance && Math.Abs(NPC.Center.X - player.Center.X) < 480f) { // Spit a huge spread of sand upwards that falls down SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); @@ -431,7 +474,7 @@ namespace CalamityMod.NPCs.DesertScourge Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); for (int k = 0; k < 10; k++) - Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, DustID.UnusedBrown, perturbedSpeed.X, perturbedSpeed.Y); + Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, (int)CalamityDusts.SulphurousSeaAcid, perturbedSpeed.X, perturbedSpeed.Y); if (Main.netMode != NetmodeID.MultiplayerClient) Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); @@ -597,6 +640,12 @@ namespace CalamityMod.NPCs.DesertScourge } } + if (!burrow && !quickFall && !hide) + { + if (NPC.Distance(player.Center) > 2000f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + } + // Calculate contact damage based on velocity float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; float minimalDamageVelocity = maxChaseSpeed * 0.5f; @@ -648,7 +697,7 @@ namespace CalamityMod.NPCs.DesertScourge if (hitboxBotRight < minDist) minDist = hitboxBotRight; - return minDist <= 60f * NPC.scale; + return minDist <= 60f * NPC.scale && NPC.alpha <= 0; } public override void FindFrame(int frameHeight) diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index 02a0c54e98..ab0e13b5b7 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -67,6 +67,8 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.life > Main.npc[(int)NPC.ai[1]].life) NPC.life = Main.npc[(int)NPC.ai[1]].life; + NPC.dontTakeDamage = Main.npc[(int)NPC.ai[1]].dontTakeDamage; + // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -103,6 +105,8 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.alpha < 0) NPC.alpha = 0; } + else + NPC.alpha = Main.npc[(int)NPC.ai[1]].alpha; if (Main.player[NPC.target].dead) NPC.TargetClosest(false); @@ -193,7 +197,7 @@ namespace CalamityMod.NPCs.DesertScourge if (hitboxBotRight < minDist) minDist = hitboxBotRight; - return minDist <= 30f * NPC.scale; + return minDist <= 30f * NPC.scale && NPC.alpha <= 0; } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index 5f4e5b99b6..e3c8676753 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -425,7 +425,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4); - int spread = masterMode ? 75 : 54; + int spread = masterMode ? 38 : 26; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { diff --git a/Projectiles/Boss/DesertScourgeSpit.cs b/Projectiles/Boss/DesertScourgeSpit.cs index 7abf1b3053..a73e39caac 100644 --- a/Projectiles/Boss/DesertScourgeSpit.cs +++ b/Projectiles/Boss/DesertScourgeSpit.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Boss public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 2; ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Boss if (Projectile.frame >= Main.projFrames[Projectile.type]) Projectile.frame = 0; - Projectile.tileCollide = Projectile.timeLeft < 540; + Projectile.tileCollide = Projectile.timeLeft < (Projectile.aiStyle == ProjAIStyleID.Arrow ? 540 : 300); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f)