From c5ba717e5d76d40ac3355ab5512cd69c2a06fa0f Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Fri, 22 Jul 2022 23:47:53 -0500 Subject: [PATCH] 1 - Ebonian and Crimulan Slime Gods can teleport ahead of their targets. --- NPCs/SlimeGod/CrimulanSlimeGod.cs | 143 +++++++++++++++++++++++- NPCs/SlimeGod/EbonianSlimeGod.cs | 144 ++++++++++++++++++++++++- NPCs/SlimeGod/SplitCrimulanSlimeGod.cs | 137 ++++++++++++++++++++++- NPCs/SlimeGod/SplitEbonianSlimeGod.cs | 137 ++++++++++++++++++++++- 4 files changed, 553 insertions(+), 8 deletions(-) diff --git a/NPCs/SlimeGod/CrimulanSlimeGod.cs b/NPCs/SlimeGod/CrimulanSlimeGod.cs index 006e44f0b5..878daf1dac 100644 --- a/NPCs/SlimeGod/CrimulanSlimeGod.cs +++ b/NPCs/SlimeGod/CrimulanSlimeGod.cs @@ -53,16 +53,28 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(NPC.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) { + NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); } public override void AI() { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + CalamityGlobalNPC.slimeGodRed = NPC.whoAmI; bool bossRush = BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || bossRush; @@ -79,6 +91,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = NPC.defDamage + 25; } + float scale = Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; NPC.noGravity = false; @@ -103,6 +116,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; NPC.netUpdate = true; } } @@ -139,6 +153,68 @@ namespace CalamityMod.NPCs.SlimeGod NPC.defense = NPC.defDefense * 2; } + // Teleport + float teleportGateValue = 720f; + if (!player.dead && NPC.timeLeft > 10 && calamityGlobalNPC.newAI[0] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.netUpdate = true; + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; + Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); + int num5 = 5; + int num8 = 0; + while (num8 < 100) + { + num8++; + int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); + int num10 = Main.rand.Next(point2.Y - num5, point2.Y); + if (Main.tile[num9, num10].HasUnactuatedTile) + continue; + + bool flag4 = true; + if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) + flag4 = false; + if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + flag4 = false; + + if (flag4) + { + NPC.localAI[0] = num9 * 16 + 8; + NPC.localAI[3] = num10 * 16 + 16; + calamityGlobalNPC.newAI[0] = 0f; + break; + } + } + + // Default teleport if the above conditions aren't met in 100 iterations + if (num8 >= 100) + { + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + NPC.localAI[0] = bottom.X; + NPC.localAI[3] = bottom.Y; + calamityGlobalNPC.newAI[0] = 0f; + } + } + } + + // Get ready to teleport by increasing ai[3] + if (calamityGlobalNPC.newAI[0] < teleportGateValue) + { + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + calamityGlobalNPC.newAI[0] += death ? 3f : 2f; + else + calamityGlobalNPC.newAI[0] += 1f; + } + float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); if (NPC.ai[0] == 0f) @@ -461,16 +537,79 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; } + else if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.aiAction = 1; + NPC.ai[1] += 1f; + float teleportTime = bossRush ? 20f : death ? 30f : 40f; + scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) + { + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Crimson, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } + else if (NPC.ai[0] == 6f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] += 1f; + float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + NPC.TargetClosest(); + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.TargetClosest(); + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Crimson, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; - float num644 = Main.getGoodWorld ? 0.8f : 1f; if (NPC.life > 0) { float num659 = lifeRatio; num659 = num659 * 0.5f + 0.75f; - num659 *= num644; + num659 *= scale; if (num659 != NPC.scale) { diff --git a/NPCs/SlimeGod/EbonianSlimeGod.cs b/NPCs/SlimeGod/EbonianSlimeGod.cs index 41cd6d78bb..0cfe4d494d 100644 --- a/NPCs/SlimeGod/EbonianSlimeGod.cs +++ b/NPCs/SlimeGod/EbonianSlimeGod.cs @@ -50,16 +50,28 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); + for (int i = 0; i < 4; i++) + writer.Write(NPC.Calamity().newAI[i]); } public override void ReceiveExtraAI(BinaryReader reader) { + NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); + for (int i = 0; i < 4; i++) + NPC.Calamity().newAI[i] = reader.ReadSingle(); } public override void AI() { + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); + CalamityGlobalNPC.slimeGodPurple = NPC.whoAmI; bool bossRush = BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || bossRush; @@ -76,6 +88,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = NPC.defDamage + 22; } + float scale = Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; NPC.noGravity = false; @@ -100,6 +113,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] = 0f; NPC.ai[2] = 0f; NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; } } else if (NPC.timeLeft < 1800) @@ -131,6 +146,68 @@ namespace CalamityMod.NPCs.SlimeGod hyperMode = true; } + // Teleport + float teleportGateValue = 720f; + if (!player.dead && NPC.timeLeft > 10 && calamityGlobalNPC.newAI[0] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.netUpdate = true; + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; + Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); + int num5 = 5; + int num8 = 0; + while (num8 < 100) + { + num8++; + int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); + int num10 = Main.rand.Next(point2.Y - num5, point2.Y); + if (Main.tile[num9, num10].HasUnactuatedTile) + continue; + + bool flag4 = true; + if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) + flag4 = false; + if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + flag4 = false; + + if (flag4) + { + NPC.localAI[0] = num9 * 16 + 8; + NPC.localAI[3] = num10 * 16 + 16; + calamityGlobalNPC.newAI[0] = 0f; + break; + } + } + + // Default teleport if the above conditions aren't met in 100 iterations + if (num8 >= 100) + { + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + NPC.localAI[0] = bottom.X; + NPC.localAI[3] = bottom.Y; + calamityGlobalNPC.newAI[0] = 0f; + } + } + } + + // Get ready to teleport by increasing ai[3] + if (calamityGlobalNPC.newAI[0] < teleportGateValue) + { + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + calamityGlobalNPC.newAI[0] += death ? 3f : 2f; + else + calamityGlobalNPC.newAI[0] += 1f; + } + float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); if (NPC.ai[0] == 0f) @@ -473,16 +550,79 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; } + else if (NPC.ai[0] == 6f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.aiAction = 1; + NPC.ai[1] += 1f; + float teleportTime = bossRush ? 20f : death ? 30f : 40f; + scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) + { + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Lavender, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } + else if (NPC.ai[0] == 7f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] += 1f; + float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + NPC.TargetClosest(); + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.TargetClosest(); + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Lavender, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; - float num644 = Main.getGoodWorld ? 0.8f : 1f; if (NPC.life > 0) { float num659 = lifeRatio; num659 = num659 * 0.5f + 0.75f; - num659 *= num644; + num659 *= scale; if (num659 != NPC.scale) { diff --git a/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs b/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs index 3bde8ba4a1..2b365b5a3a 100644 --- a/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs +++ b/NPCs/SlimeGod/SplitCrimulanSlimeGod.cs @@ -73,12 +73,18 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); } public override void ReceiveExtraAI(BinaryReader reader) { + NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); } public override void AI() @@ -101,6 +107,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = NPC.defDamage + 22; } + float scale = Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; NPC.noGravity = false; @@ -124,6 +131,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[0] = 3f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.ai[3] = 0f; NPC.netUpdate = true; } } @@ -149,6 +157,68 @@ namespace CalamityMod.NPCs.SlimeGod NPC.defense = NPC.defDefense * 2; } + // Teleport + float teleportGateValue = 720f; + if (!player.dead && NPC.timeLeft > 10 && NPC.ai[3] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 5f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.netUpdate = true; + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; + Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); + int num5 = 5; + int num8 = 0; + while (num8 < 100) + { + num8++; + int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); + int num10 = Main.rand.Next(point2.Y - num5, point2.Y); + if (Main.tile[num9, num10].HasUnactuatedTile) + continue; + + bool flag4 = true; + if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) + flag4 = false; + if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + flag4 = false; + + if (flag4) + { + NPC.localAI[0] = num9 * 16 + 8; + NPC.localAI[3] = num10 * 16 + 16; + NPC.ai[3] = 0f; + break; + } + } + + // Default teleport if the above conditions aren't met in 100 iterations + if (num8 >= 100) + { + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + NPC.localAI[0] = bottom.X; + NPC.localAI[3] = bottom.Y; + NPC.ai[3] = 0f; + } + } + } + + // Get ready to teleport by increasing ai[3] + if (NPC.ai[3] < teleportGateValue) + { + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + NPC.ai[3] += death ? 3f : 2f; + else + NPC.ai[3] += 1f; + } + float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); if (NPC.ai[0] == 0f) @@ -459,16 +529,79 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; } + else if (NPC.ai[0] == 5f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.aiAction = 1; + NPC.ai[1] += 1f; + float teleportTime = bossRush ? 20f : death ? 30f : 40f; + scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) + { + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Crimson, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } + else if (NPC.ai[0] == 6f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] += 1f; + float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + NPC.TargetClosest(); + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.TargetClosest(); + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Crimson, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; - float num644 = Main.getGoodWorld ? 0.8f : 1f; if (NPC.life > 0) { float num659 = lifeRatio; num659 = num659 * 0.5f + 0.75f; - num659 *= num644; + num659 *= scale; if (num659 != NPC.scale) { diff --git a/NPCs/SlimeGod/SplitEbonianSlimeGod.cs b/NPCs/SlimeGod/SplitEbonianSlimeGod.cs index 58a5d924a8..f7abc4505c 100644 --- a/NPCs/SlimeGod/SplitEbonianSlimeGod.cs +++ b/NPCs/SlimeGod/SplitEbonianSlimeGod.cs @@ -73,12 +73,18 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.localAI[3]); } public override void ReceiveExtraAI(BinaryReader reader) { + NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.localAI[3] = reader.ReadSingle(); } public override void AI() @@ -101,6 +107,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.damage = NPC.defDamage + 20; } + float scale = Main.getGoodWorld ? 0.8f : 1f; NPC.aiAction = 0; NPC.noTileCollide = false; NPC.noGravity = false; @@ -124,6 +131,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[0] = 4f; NPC.ai[1] = 0f; NPC.ai[2] = 0f; + NPC.ai[3] = 0f; NPC.netUpdate = true; } } @@ -145,6 +153,68 @@ namespace CalamityMod.NPCs.SlimeGod hyperMode = true; } + // Teleport + float teleportGateValue = 720f; + if (!player.dead && NPC.timeLeft > 10 && NPC.ai[3] >= teleportGateValue && NPC.ai[0] == 0f && NPC.velocity.Y == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[0] = 6f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.netUpdate = true; + NPC.TargetClosest(false); + player = Main.player[NPC.target]; + Vector2 vectorAimedAheadOfTarget = player.Center + new Vector2((float)Math.Round(player.velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; + Point point2 = vectorAimedAheadOfTarget.ToTileCoordinates(); + int num5 = 5; + int num8 = 0; + while (num8 < 100) + { + num8++; + int num9 = Main.rand.Next(point2.X - num5, point2.X + num5 + 1); + int num10 = Main.rand.Next(point2.Y - num5, point2.Y); + if (Main.tile[num9, num10].HasUnactuatedTile) + continue; + + bool flag4 = true; + if (flag4 && Main.tile[num9, num10].LiquidType == LiquidID.Lava) + flag4 = false; + if (flag4 && !Collision.CanHitLine(NPC.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + flag4 = false; + + if (flag4) + { + NPC.localAI[0] = num9 * 16 + 8; + NPC.localAI[3] = num10 * 16 + 16; + NPC.ai[3] = 0f; + break; + } + } + + // Default teleport if the above conditions aren't met in 100 iterations + if (num8 >= 100) + { + Vector2 bottom = Main.player[Player.FindClosest(NPC.position, NPC.width, NPC.height)].Bottom; + NPC.localAI[0] = bottom.X; + NPC.localAI[3] = bottom.Y; + NPC.ai[3] = 0f; + } + } + } + + // Get ready to teleport by increasing ai[3] + if (NPC.ai[3] < teleportGateValue) + { + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + NPC.ai[3] += death ? 3f : 2f; + else + NPC.ai[3] += 1f; + } + float distanceSpeedBoost = Vector2.Distance(player.Center, NPC.Center) * (bossRush ? 0.008f : 0.005f); if (NPC.ai[0] == 0f) @@ -476,16 +546,79 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; } + else if (NPC.ai[0] == 6f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.aiAction = 1; + NPC.ai[1] += 1f; + float teleportTime = bossRush ? 20f : death ? 30f : 40f; + scale = MathHelper.Clamp((teleportTime - NPC.ai[1]) / teleportTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.Bottom = new Vector2(NPC.localAI[0], NPC.localAI[3]); + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportTime * 2f) + { + NPC.ai[0] = 7f; + NPC.ai[1] = 0f; + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Lavender, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } + else if (NPC.ai[0] == 7f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.ai[1] += 1f; + float teleportEndTime = bossRush ? 10f : death ? 15f : 20f; + scale = MathHelper.Clamp(NPC.ai[1] / teleportEndTime, 0f, 1f); + scale = 0.5f + scale * 0.5f; + if (NPC.ai[1] >= teleportEndTime && Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + NPC.TargetClosest(); + } + + if (Main.netMode == NetmodeID.MultiplayerClient && NPC.ai[1] >= teleportEndTime * 2f) + { + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.TargetClosest(); + } + + // Emit teleport dust + for (int num245 = 0; num245 < 10; num245++) + { + int num246 = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, 4, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, Color.Lavender, 2f); + Main.dust[num246].noGravity = true; + Main.dust[num246].velocity *= 0.5f; + } + } if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; - float num644 = Main.getGoodWorld ? 0.8f : 1f; if (NPC.life > 0) { float num659 = lifeRatio; num659 = num659 * 0.5f + 0.75f; - num659 *= num644; + num659 *= scale; if (num659 != NPC.scale) {