diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 97c7cd1b98..020b0c2646 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -971,8 +971,15 @@ namespace CalamityMod.CalPlayer // Calculate the % of HP the player has left. float maxLifeRatio = Player.statLife / (float)actualMaxLife; + // Calculate the ratio of the player's current max life relative to the starting HP of 100. + // This makes the soft cap far less harsh at lower amounts of max life. + // Ranges from 10 (at 100 max life) to 2 (at 500 max life) to 1 (at 1000 max life) to 0 (at greater than 2000 max life). + int lifeRegenSoftCapMin = (int)Math.Round(100f / actualMaxLife * 10f); + int lifeRegenSoftCapMax = 10; + // The soft cap for life regen which ranges from 10 (at less than 5% HP) to 0 (at greater than or equal to 95% HP). - int lifeRegenSoftCap = (int)Math.Round((1f - maxLifeRatio) * 10f); + // This value is capped at a min and max amount. + int lifeRegenSoftCap = (int)MathHelper.Clamp((int)Math.Round((1f - maxLifeRatio) * 10f), lifeRegenSoftCapMin, lifeRegenSoftCapMax); // If life regen is greater than the calculated soft cap, reduce it. if (Player.lifeRegen > lifeRegenSoftCap) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 41cc6aa349..aefe8380dd 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -3488,11 +3488,18 @@ namespace CalamityMod.NPCs npc.dontTakeDamage = true; npc.noTileCollide = true; - if (Vector2.Distance(npc.Center, targetData.Center) > 80f) + // Teleport to the player if far enough away. + if (Vector2.Distance(npc.Center, targetData.Center) > 1000f) + { + npc.Center = targetData.Center; + } + + // Move towards the player if far enough away. + else if (Vector2.Distance(npc.Center, targetData.Center) > 80f) { Rectangle r = Utils.CenteredRectangle(targetData.Center, new Vector2(targetData.Width + 60, targetData.Height / 2)); Vector2 vector3 = r.ClosestPointInRect(npc.Center); - Vector2 value = npc.DirectionTo(vector3) * 2f; + Vector2 value = npc.DirectionTo(vector3) * ((targetData.Velocity.Length() * 0.5f) + 2f); float num8 = npc.Distance(vector3); if (num8 > 225f) value *= 2f; @@ -4259,7 +4266,7 @@ namespace CalamityMod.NPCs { if (projectile.Calamity().pointBlankShotDuration > 0) { - double pointBlankShotDamageMultiplier = 1D + (projectile.Calamity().pointBlankShotDuration / (CalamityGlobalProjectile.basePointBlankShotDuration * 0.5)); + float pointBlankShotDamageMultiplier = 1f + (projectile.Calamity().pointBlankShotDuration / (float)CalamityGlobalProjectile.basePointBlankShotDuration * 0.5f); damage = (int)(damage * pointBlankShotDamageMultiplier); projectile.Calamity().pointBlankShotDuration = 0; } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index 94ee64e674..3a3638023b 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -272,7 +272,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); Vector2 normalizedPerturbedSpeed = Vector2.Normalize(perturbedSpeed); - Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter, normalizedPerturbedSpeed * NPC.velocity.Length() * 1.25f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), vectorCenter, normalizedPerturbedSpeed * NPC.velocity.Length() * 1.25f, type, damage, 0f, Main.myPlayer, 3f, 0f); } } } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index b4d8aa55f3..853b8b2ec8 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -165,7 +165,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians SoundEngine.PlaySound(SoundID.Item20, NPC.position); int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * NPC.velocity.Length() * 0.5f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, Vector2.Normalize(player.Center - NPC.Center) * NPC.velocity.Length() * 0.5f, type, damage, 0f, Main.myPlayer, 3f, 0f); } } diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index aedcb59d1c..71dfbc9b4d 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -364,6 +364,7 @@ namespace CalamityMod.NPCs.Ravager NPC.noTileCollide = true; NPC.TargetClosest(); + player = Main.player[NPC.target]; bool shouldFall = player.position.Y >= NPC.Bottom.Y; float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); @@ -465,6 +466,7 @@ namespace CalamityMod.NPCs.Ravager calamityGlobalNPC.newAI[1] = 0f; calamityGlobalNPC.newAI[3] = 0f; + NPC.TargetClosest(); for (int stompDustArea = (int)NPC.position.X - 30; stompDustArea < (int)NPC.position.X + NPC.width + 60; stompDustArea += 30) @@ -508,17 +510,18 @@ namespace CalamityMod.NPCs.Ravager NPC.velocity.Y = -velocityY; } - float maxOffsetScale = death ? 320f : 240f; - float maxOffset = maxOffsetScale * (1f - lifeRatio); - float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; - // Set offset to 0 if the target stops moving if (Math.Abs(player.velocity.X) < 0.5f) calamityGlobalNPC.newAI[2] = 0f; else calamityGlobalNPC.newAI[2] = player.direction; - if ((NPC.position.X < targetVector.X + offset && NPC.position.X + NPC.width > targetVector.X + player.width + offset && (inRange || NPC.ai[0] != 2f)) || NPC.ai[1] > 0f || calamityGlobalNPC.newAI[3] >= 180f) + float maxOffsetScale = death ? 320f : 240f; + float maxOffset = maxOffsetScale * (1f - lifeRatio); + float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; + int quarterWidth = (int)(NPC.width * 0.25f); + + if ((NPC.position.X + quarterWidth < targetVector.X + offset && NPC.position.X + NPC.width - quarterWidth > targetVector.X + player.width + offset && (inRange || NPC.ai[0] != 2f)) || NPC.ai[1] > 0f || calamityGlobalNPC.newAI[3] >= 180f) { NPC.damage = NPC.defDamage; diff --git a/NPCs/SlimeGod/SlimeGod.cs b/NPCs/SlimeGod/SlimeGod.cs index 04b2b35ce1..5a05d4ed80 100644 --- a/NPCs/SlimeGod/SlimeGod.cs +++ b/NPCs/SlimeGod/SlimeGod.cs @@ -1,9 +1,9 @@ using CalamityMod.Events; -using CalamityMod.Items.TreasureBags; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.Collections.Generic; using System.IO; using Terraria; using Terraria.GameContent.Bestiary; @@ -129,78 +129,36 @@ namespace CalamityMod.NPCs.SlimeGod return; } - bool flag100 = false; + bool enraged = true; bool hyperMode = NPC.localAI[1] == 1f; if (CalamityGlobalNPC.slimeGodRed != -1) { if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) { - flag100 = true; + enraged = false; } } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { NPC.localAI[1] = 0f; - flag100 = false; + enraged = true; hyperMode = true; } if (malice) { - flag100 = false; + enraged = true; hyperMode = true; } float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * ((malice || hyperMode) ? 0.008f : 0.005f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += (!flag100 || hyperMode) ? 2f : 1f; - if (revenge) - NPC.localAI[0] += 0.5f; - if (malice) - NPC.localAI[0] += 1f; - - if (NPC.localAI[0] >= 600f && Vector2.Distance(player.Center, NPC.Center) > 160f) - { - NPC.localAI[0] = 0f; - float num179 = 5f; - Vector2 value9 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - NPC.netUpdate = true; - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - int totalProjectiles = expertMode ? 6 : 4; - int spread = expertMode ? 90 : 60; - for (int num186 = 0; num186 < totalProjectiles; num186++) - { - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 += (float)Main.rand.Next(-spread, spread + 1); - num182 += (float)Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - if (NPC.ai[0] == 0f) { if (NPC.velocity.Y == 0f) { NPC.TargetClosest(); NPC.velocity.X *= 0.8f; - NPC.ai[1] += (!flag100 || hyperMode) ? 2f : 1f; + NPC.ai[1] += hyperMode ? 2f : 1f; float jumpGateValue = 60f; float velocityX = death ? 8f : revenge ? 7f : expertMode ? 6f : 4f; @@ -296,11 +254,10 @@ namespace CalamityMod.NPCs.SlimeGod } else if (NPC.ai[0] == 1f) { - NPC.localAI[0] += 6f; NPC.velocity.X *= 0.85f; NPC.ai[1] += 1f; - if (NPC.ai[1] >= 80f) + if (NPC.ai[1] >= 30f) { NPC.localAI[2] = NPC.ai[0]; NPC.ai[0] = 0f; @@ -368,6 +325,47 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += 1f; if (NPC.ai[1] > 10f) { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Eruption of slime balls + float projectileVelocity = 4f; + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; + destination.Normalize(); + destination *= projectileVelocity; + int numProj = 9; + float rotation = MathHelper.ToRadians(90); + for (int i = 0; i < numProj; i++) + { + // Spawn projectiles 0, 1, 2, 6, 7 and 8 + if (i < 3 || i > 5) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer); + } + } + + // Fire slime balls directly at players with a max of 2 + if (enraged && expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); + + if (targets.Count > 1) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer); + } + } + } + NPC.localAI[2] = NPC.ai[0] - 0.1f; NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -398,7 +396,7 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[1] = 0f; - NPC.velocity.Y -= 3f; + NPC.velocity.Y -= 6f; if (player.position.Y + player.height < NPC.Center.Y) NPC.velocity.Y -= 1.2f; if (player.position.Y + player.height < NPC.Center.Y - 40f) @@ -423,7 +421,7 @@ namespace CalamityMod.NPCs.SlimeGod else { NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; + float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) diff --git a/NPCs/SlimeGod/SlimeGodRun.cs b/NPCs/SlimeGod/SlimeGodRun.cs index c4bd465c28..eabf7d48d4 100644 --- a/NPCs/SlimeGod/SlimeGodRun.cs +++ b/NPCs/SlimeGod/SlimeGodRun.cs @@ -1,9 +1,9 @@ using CalamityMod.Events; -using CalamityMod.Items.TreasureBags; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.Collections.Generic; using System.IO; using Terraria; using Terraria.GameContent.Bestiary; @@ -133,83 +133,42 @@ namespace CalamityMod.NPCs.SlimeGod return; } - bool flag100 = false; + bool enraged = true; bool hyperMode = NPC.localAI[1] == 1f; if (CalamityGlobalNPC.slimeGodPurple != -1) { if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) { - flag100 = true; + enraged = false; } } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { NPC.localAI[1] = 0f; hyperMode = true; - flag100 = false; + enraged = true; } if (malice) { - flag100 = false; + enraged = true; hyperMode = true; } if (NPC.localAI[1] != 1f) { - if (!flag100) + if (enraged) NPC.defense = NPC.defDefense * 2; } float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * ((malice || hyperMode) ? 0.008f : 0.005f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += flag100 ? 1f : 2f; - if (revenge) - NPC.localAI[0] += 0.5f; - if (malice) - NPC.localAI[0] += 1f; - - if (NPC.localAI[0] >= 450f && Vector2.Distance(player.Center, NPC.Center) > 160f) - { - NPC.localAI[0] = 0f; - float num179 = expertMode ? 10f : 8f; - Vector2 value9 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - int totalProjectiles = 2; - int spread = 20; - for (int num186 = 0; num186 < totalProjectiles; num186++) - { - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 += (float)Main.rand.Next(-spread, spread + 1); - num182 += (float)Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - if (NPC.ai[0] == 0f) { if (NPC.velocity.Y == 0f) { NPC.TargetClosest(); NPC.velocity.X *= 0.8f; - NPC.ai[1] += (!flag100 || hyperMode) ? 2f : 1f; + NPC.ai[1] += hyperMode ? 2f : 1f; float jumpGateValue = 50f; float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; @@ -360,6 +319,43 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += 1f; if (NPC.ai[1] > 10f) { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Eruption of slime balls + float projectileVelocity = 8f; + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; + destination.Normalize(); + destination *= projectileVelocity; + int numProj = 3; + float rotation = MathHelper.ToRadians(45); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer); + } + + // Fire slime balls directly at players with a max of 2 + if (enraged && expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); + + if (targets.Count > 1) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer); + } + } + } + NPC.localAI[2] = NPC.ai[0] - 0.1f; NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -390,7 +386,7 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[1] = 0f; - NPC.velocity.Y -= 4f; + NPC.velocity.Y -= 3f; if (player.position.Y + player.height < NPC.Center.Y) NPC.velocity.Y -= 1.25f; if (player.position.Y + player.height < NPC.Center.Y - 40f) @@ -406,7 +402,7 @@ namespace CalamityMod.NPCs.SlimeGod if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) NPC.velocity.Y -= 2f; - NPC.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * NPC.direction; + NPC.velocity.X = ((death ? 14f : revenge ? 13f : expertMode ? 12f : 11f) + distanceSpeedBoost) * NPC.direction; NPC.ai[2] += 1f; } else @@ -415,7 +411,7 @@ namespace CalamityMod.NPCs.SlimeGod else { NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; + float velocityLimit = (death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) diff --git a/NPCs/SlimeGod/SlimeGodRunSplit.cs b/NPCs/SlimeGod/SlimeGodRunSplit.cs index 753d6d78c8..7b0e2fa67d 100644 --- a/NPCs/SlimeGod/SlimeGodRunSplit.cs +++ b/NPCs/SlimeGod/SlimeGodRunSplit.cs @@ -1,9 +1,9 @@ using CalamityMod.Events; -using CalamityMod.Items.TreasureBags; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.Collections.Generic; using System.IO; using Terraria; using Terraria.GameContent.Bestiary; @@ -123,76 +123,42 @@ namespace CalamityMod.NPCs.SlimeGod else if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; - bool flag100 = false; + bool enraged = true; bool hyperMode = NPC.localAI[1] == 1f; if (CalamityGlobalNPC.slimeGodPurple != -1) { if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) { - flag100 = true; + enraged = false; } } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { NPC.localAI[1] = 0f; hyperMode = true; - flag100 = false; + enraged = true; } if (malice) { - flag100 = false; + enraged = true; hyperMode = true; } if (NPC.localAI[1] != 1f) { - if (!flag100) + if (enraged) NPC.defense = NPC.defDefense * 2; } float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * ((malice || hyperMode) ? 0.008f : 0.005f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += flag100 ? 0.5f : 1f; - if (revenge) - NPC.localAI[0] += 0.5f; - if (malice) - NPC.localAI[0] += 1f; - - if (NPC.localAI[0] >= 450f && Vector2.Distance(player.Center, NPC.Center) > 160f) - { - NPC.localAI[0] = 0f; - float num179 = expertMode ? 10f : 8f; - Vector2 value9 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - if (NPC.ai[0] == 0f) { if (NPC.velocity.Y == 0f) { NPC.TargetClosest(); NPC.velocity.X *= 0.8f; - NPC.ai[1] += (!flag100 || hyperMode) ? 2f : 1f; + NPC.ai[1] += hyperMode ? 2f : 1f; float jumpGateValue = 35f; float velocityX = death ? 11.5f : revenge ? 10.5f : expertMode ? 9.5f : 7.5f; @@ -336,6 +302,43 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += 1f; if (NPC.ai[1] > 10f) { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Eruption of slime balls + float projectileVelocity = 8f; + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; + destination.Normalize(); + destination *= projectileVelocity; + int numProj = 2; + float rotation = MathHelper.ToRadians(45); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer); + } + + // Fire slime balls directly at players with a max of 2 + if (enraged && expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); + + if (targets.Count > 1) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer); + } + } + } + NPC.localAI[2] = NPC.ai[0] - 0.1f; NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -366,7 +369,7 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[1] = 0f; - NPC.velocity.Y -= 4f; + NPC.velocity.Y -= 3f; if (player.position.Y + player.height < NPC.Center.Y) NPC.velocity.Y -= 1.25f; if (player.position.Y + player.height < NPC.Center.Y - 40f) @@ -382,7 +385,7 @@ namespace CalamityMod.NPCs.SlimeGod if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) NPC.velocity.Y -= 2f; - NPC.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * NPC.direction; + NPC.velocity.X = ((death ? 14f : revenge ? 13f : expertMode ? 12f : 11f) + distanceSpeedBoost) * NPC.direction; NPC.ai[2] += 1f; } else @@ -391,7 +394,7 @@ namespace CalamityMod.NPCs.SlimeGod else { NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 7f : revenge ? 6f : expertMode ? 5f : 4f) + distanceSpeedBoost; + float velocityLimit = (death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) diff --git a/NPCs/SlimeGod/SlimeGodSplit.cs b/NPCs/SlimeGod/SlimeGodSplit.cs index 0be97facda..f9a8efec31 100644 --- a/NPCs/SlimeGod/SlimeGodSplit.cs +++ b/NPCs/SlimeGod/SlimeGodSplit.cs @@ -1,9 +1,9 @@ using CalamityMod.Events; -using CalamityMod.Items.TreasureBags; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using System; +using System.Collections.Generic; using System.IO; using Terraria; using Terraria.GameContent.Bestiary; @@ -123,77 +123,36 @@ namespace CalamityMod.NPCs.SlimeGod else if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; - bool flag100 = false; + bool enraged = true; bool hyperMode = NPC.localAI[1] == 1f; if (CalamityGlobalNPC.slimeGodRed != -1) { if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) { - flag100 = true; + enraged = false; } } if (CalamityGlobalNPC.slimeGod < 0 || !Main.npc[CalamityGlobalNPC.slimeGod].active) { NPC.localAI[1] = 0f; hyperMode = true; - flag100 = false; + enraged = true; } if (malice) { - flag100 = false; + enraged = true; hyperMode = true; } float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * ((malice || hyperMode) ? 0.008f : 0.005f); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.localAI[0] += flag100 ? 0.5f : 1f; - if (revenge) - NPC.localAI[0] += 0.5f; - if (malice) - NPC.localAI[0] += 1f; - - if (NPC.localAI[0] >= 600f && Vector2.Distance(player.Center, NPC.Center) > 160f) - { - NPC.localAI[0] = 0f; - float num179 = 5f; - Vector2 value9 = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); - float num180 = player.position.X + (float)player.width * 0.5f - value9.X; - float num181 = Math.Abs(num180) * 0.1f; - float num182 = player.position.Y + (float)player.height * 0.5f - value9.Y - num181; - float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 *= num183; - num182 *= num183; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - value9.X += num180; - value9.Y += num182; - int totalProjectiles = expertMode ? 3 : 2; - int spread = expertMode ? 45 : 30; - for (int num186 = 0; num186 < totalProjectiles; num186++) - { - num180 = player.position.X + (float)player.width * 0.5f - value9.X; - num182 = player.position.Y + (float)player.height * 0.5f - value9.Y; - num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182)); - num183 = num179 / num183; - num180 += (float)Main.rand.Next(-spread, spread + 1); - num182 += (float)Main.rand.Next(-spread, spread + 1); - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(NPC.GetSource_FromAI(), value9.X, value9.Y, num180, num182, type, damage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - if (NPC.ai[0] == 0f) { if (NPC.velocity.Y == 0f) { NPC.TargetClosest(); NPC.velocity.X *= 0.8f; - NPC.ai[1] += (!flag100 || hyperMode) ? 2f : 1f; + NPC.ai[1] += hyperMode ? 2f : 1f; float jumpGateValue = 40f; float velocityX = death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; @@ -283,11 +242,10 @@ namespace CalamityMod.NPCs.SlimeGod } else if (NPC.ai[0] == 1f) { - NPC.localAI[0] += 6f; - NPC.velocity.X *= 0.85f; + NPC.velocity.X *= 0.8f; NPC.ai[1] += 1f; - if (NPC.ai[1] >= 40f) + if (NPC.ai[1] >= 15f) { NPC.localAI[2] = NPC.ai[0]; NPC.ai[0] = 0f; @@ -355,6 +313,47 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] += 1f; if (NPC.ai[1] > 10f) { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Eruption of slime balls + float projectileVelocity = 4f; + int type = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; + destination.Normalize(); + destination *= projectileVelocity; + int numProj = 7; + float rotation = MathHelper.ToRadians(90); + for (int i = 0; i < numProj; i++) + { + // Spawn projectiles 0, 1, 5 and 6 + if (i < 2 || i > 4) + { + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer); + } + } + + // Fire slime balls directly at players with a max of 2 + if (enraged && expertMode) + { + List targets = new List(); + for (int p = 0; p < Main.maxPlayers; p++) + { + if (Main.player[p].active && !Main.player[p].dead) + targets.Add(p); + + if (targets.Count > 1) + break; + } + foreach (int t in targets) + { + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity2, type, damage, 0f, Main.myPlayer); + } + } + } + NPC.localAI[2] = NPC.ai[0] - 0.1f; NPC.ai[0] = 0f; NPC.ai[1] = 0f; @@ -385,7 +384,7 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[1] = 0f; - NPC.velocity.Y -= 3f; + NPC.velocity.Y -= 6f; if (player.position.Y + player.height < NPC.Center.Y) NPC.velocity.Y -= 1.2f; if (player.position.Y + player.height < NPC.Center.Y - 40f) @@ -401,7 +400,7 @@ namespace CalamityMod.NPCs.SlimeGod if (!Collision.CanHit(NPC.Center, 1, 1, player.Center, 1, 1)) NPC.velocity.Y -= 2f; - NPC.velocity.X = ((death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * NPC.direction; + NPC.velocity.X = ((death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost) * NPC.direction; NPC.ai[2] += 1f; } else @@ -410,7 +409,7 @@ namespace CalamityMod.NPCs.SlimeGod else { NPC.velocity.X *= 0.98f; - float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f) + distanceSpeedBoost; + float velocityLimit = (death ? 6.5f : revenge ? 6f : expertMode ? 5.5f : 5f); if (NPC.direction < 0 && NPC.velocity.X > -velocityLimit) NPC.velocity.X = -velocityLimit; if (NPC.direction > 0 && NPC.velocity.X < velocityLimit) diff --git a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs index 6185711819..17e9650318 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/KingSlimeAI.cs @@ -238,7 +238,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { npc.ai[0] += 2f; if (malice) + { npc.ai[0] += 9f; + } else { if (lifeRatio < 0.8f) diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs index bc046f28fa..276503bca7 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenSlimeAI.cs @@ -484,7 +484,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center.X, npc.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, 0f, Main.myPlayer, 0f, -2f); + Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, perturbedSpeed, type, damage, 0f, Main.myPlayer, 0f, -2f); } } } diff --git a/Projectiles/Boss/AbyssBallVolley.cs b/Projectiles/Boss/AbyssBallVolley.cs index 43ca078549..c30eef2ea0 100644 --- a/Projectiles/Boss/AbyssBallVolley.cs +++ b/Projectiles/Boss/AbyssBallVolley.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.velocity.Length() < 12f && (Main.expertMode || BossRushEvent.BossRushActive)) { - float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1f; + float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; Projectile.velocity *= velocityMult; } diff --git a/Projectiles/Boss/AbyssBallVolley2.cs b/Projectiles/Boss/AbyssBallVolley2.cs index 6d384bc495..d2d5040667 100644 --- a/Projectiles/Boss/AbyssBallVolley2.cs +++ b/Projectiles/Boss/AbyssBallVolley2.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.velocity.Length() < 15f && (Main.expertMode || BossRushEvent.BossRushActive)) { - float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1f; + float velocityMult = (CalamityWorld.malice || BossRushEvent.BossRushActive) ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; Projectile.velocity *= velocityMult; } diff --git a/Projectiles/Boss/FlareDust.cs b/Projectiles/Boss/FlareDust.cs index 287e52a2ee..c4aede6f9c 100644 --- a/Projectiles/Boss/FlareDust.cs +++ b/Projectiles/Boss/FlareDust.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Boss Lighting.AddLight(Projectile.Center, 0.5f, 0.25f, 0f); - if (Projectile.ai[0] == 2f) + if (Projectile.ai[0] >= 2f) return; if (start) @@ -213,7 +213,10 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 240); + if (Projectile.ai[0] == 3f) + target.AddBuff(ModContent.BuffType(), 240); + else + target.AddBuff(ModContent.BuffType(), 240); } public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit)