1 - Master Mode Brain of Cthulhu.

2 - Fixed a few problems with Rev+ Brain of Cthulhu and allowed it to teleport in 8 directions instead of 4 while in phase 2.
This commit is contained in:
mountaindrew10 committed 2024-02-14 10:20:41 -06:00
1 parent 4fee9c0e7f
commit 54990207b7
3 files changed
+477 -46

No files matched your search

+2 -2
View File
@@ -3073,12 +3073,12 @@ namespace CalamityMod.NPCs
case NPCID.EaterofWorldsTail:
return EaterOfWorldsAI.VanillaEaterofWorldsAI(npc, Mod);
/*case NPCID.BrainofCthulhu:
case NPCID.BrainofCthulhu:
return BrainOfCthulhuAI.VanillaBrainofCthulhuAI(npc, Mod);
case NPCID.Creeper:
return BrainOfCthulhuAI.VanillaCreeperAI(npc, Mod);
case NPCID.QueenBee:
/*case NPCID.QueenBee:
return QueenBeeAI.VanillaQueenBeeAI(npc, Mod);
case NPCID.SkeletronHand:
@@ -22,6 +22,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
NPC.crimsonBoss = npc.whoAmI;
bool bossRush = BossRushEvent.BossRushActive;
bool masterMode = Main.masterMode || bossRush;
bool death = CalamityWorld.death || bossRush;
// Get a target
@@ -32,7 +33,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles)
npc.TargetClosest();
float enrageScale = bossRush ? 1.5f : 0f;
float enrageScale = bossRush ? 1.5f : masterMode ? 0.5f : 0f;
if ((npc.position.Y / 16f) < Main.worldSurface || bossRush)
{
npc.Calamity().CurrentlyEnraged = !bossRush;
@@ -60,7 +61,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
npc.localAI[3] -= 1f;
// Extra distance for teleports if enraged
int teleportDistanceIncrease = (int)(enrageScale * 3);
int teleportDistanceIncrease = (int)Math.Round(enrageScale * 3);
// Spawn Creepers
if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f)
@@ -135,7 +136,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
// Fire projectiles from 4 locations phase
bool phase5 = lifeRatio < 0.4f;
// Spin faster and shoot faster projectiles phase
// Spin faster, shoot faster projectiles and begin teleporting from cardinal directions phase
bool phase6 = lifeRatio < 0.25f;
// Super fast spin and charges phase
@@ -491,48 +492,69 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
npc.localAI[1] = 0f;
npc.TargetClosest();
int numTeleportTries = 0;
int maxTeleportTries = 100;
int teleportTileX;
int teleportTileY;
while (true)
bool cardinal = Main.rand.NextBool();
bool aboveOrBelow = Main.rand.NextBool();
do
{
numTeleportTries++;
teleportTileX = (int)Main.player[npc.target].Center.X / 16;
teleportTileY = (int)Main.player[npc.target].Center.Y / 16;
int min = 14;
int max = 17;
int minX = 14;
int maxX = 17;
int minY = 14;
int maxY = 17;
if (cardinal && phase6)
{
if (aboveOrBelow)
{
minX = 0;
maxX = 3;
minY = 21;
maxY = 24;
}
else
{
minX = 21;
maxX = 24;
minY = 0;
maxY = 3;
}
}
min += teleportDistanceIncrease;
max += teleportDistanceIncrease;
teleportTileX += Main.rand.Next(minX, maxX + 1) + teleportDistanceIncrease;
teleportTileY += Main.rand.Next(minY, maxY + 1) + teleportDistanceIncrease;
if (Main.rand.NextBool())
teleportTileX += Main.rand.Next(min, max);
else
teleportTileX -= Main.rand.Next(min, max);
teleportTileX *= -1;
if (Main.rand.NextBool())
teleportTileY += Main.rand.Next(min, max);
else
teleportTileY -= Main.rand.Next(min, max);
teleportTileY *= -1;
if (numTeleportTries > maxTeleportTries || !WorldGen.SolidTile(teleportTileX, teleportTileY))
{
// Avoid cheap bullshit
npc.damage = 0;
npc.ai[3] = 0f;
npc.ai[0] = npc.ai[0] == -6f ? -7f : -2f;
npc.ai[1] = teleportTileX;
npc.ai[2] = teleportTileY;
npc.netUpdate = true;
npc.netSpam = 0;
if (!WorldGen.SolidTile(teleportTileX, teleportTileY))
break;
if (numTeleportTries > 100)
goto Block;
}
else
{
cardinal = Main.rand.NextBool();
aboveOrBelow = Main.rand.NextBool();
}
}
// Avoid cheap bullshit
npc.damage = 0;
npc.ai[3] = 0f;
npc.ai[0] = npc.ai[0] == -6f ? -7f : -2f;
npc.ai[1] = teleportTileX;
npc.ai[2] = teleportTileY;
npc.netUpdate = true;
npc.netSpam = 0;
Block:
;
while (numTeleportTries <= maxTeleportTries);
}
}
}
@@ -669,9 +691,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
npc.localAI[1] = 0f;
npc.TargetClosest();
int phase1TeleportTries = 0;
int maxTeleportTries = 100;
int phase1TeleportTileX;
int phase1TeleportTileY;
while (true)
do
{
phase1TeleportTries++;
phase1TeleportTileX = (int)Main.player[npc.target].Center.X / 16;
@@ -690,18 +713,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
else
phase1TeleportTileY -= Main.rand.Next(min, max);
if (!WorldGen.SolidTile(phase1TeleportTileX, phase1TeleportTileY) && Collision.CanHit(new Vector2(phase1TeleportTileX * 16, phase1TeleportTileY * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
if (phase1TeleportTries > maxTeleportTries || (!WorldGen.SolidTile(phase1TeleportTileX, phase1TeleportTileY) && Collision.CanHit(new Vector2(phase1TeleportTileX * 16, phase1TeleportTileY * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)))
{
npc.ai[0] = 1f;
npc.ai[1] = phase1TeleportTileX;
npc.ai[2] = phase1TeleportTileY;
npc.netUpdate = true;
break;
if (phase1TeleportTries > 100)
goto Block;
}
}
npc.ai[0] = 1f;
npc.ai[1] = phase1TeleportTileX;
npc.ai[2] = phase1TeleportTileY;
npc.netUpdate = true;
Block:
;
while (phase1TeleportTries <= maxTeleportTries);
}
}
}
@@ -767,13 +788,14 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
}
bool bossRush = BossRushEvent.BossRushActive;
bool masterMode = Main.masterMode || bossRush;
bool death = CalamityWorld.death || bossRush;
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest();
float enrageScale = bossRush ? 1.5f : 0f;
float enrageScale = bossRush ? 1.5f : masterMode ? 0.5f : 0f;
if ((npc.position.Y / 16f) < Main.worldSurface || bossRush)
enrageScale += 0.5f;
if (!Main.player[npc.target].ZoneCrimson || bossRush)
@@ -882,11 +904,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
else
{
targetDirection *= chargeVelocity;
npc.velocity = (npc.velocity * 99f + targetDirection) / 100f;
float inertia = masterMode ? 75f : 100f;
npc.velocity = (npc.velocity * (inertia - 1f) + targetDirection) / inertia;
}
// Return to Brain after a set time
float chargeDistance = 600f;
float chargeDistance = masterMode ? 700f : 600f;
float returnToBrainGateValue = chargeDistance / chargeVelocity;
npc.ai[1] += 1f;
@@ -925,11 +948,397 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
return false;
}
public static bool VanillaBrainofCthulhuAI(NPC npc, Mod mod)
{
NPC.crimsonBoss = npc.whoAmI;
if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f)
{
npc.localAI[0] = 1f;
int brainOfCthuluCreepersCount = GetBrainOfCthuluCreepersCountVanilla();
for (int num837 = 0; num837 < brainOfCthuluCreepersCount; num837++)
{
float x2 = npc.Center.X;
float y4 = npc.Center.Y;
x2 += (float)Main.rand.Next(-npc.width, npc.width);
y4 += (float)Main.rand.Next(-npc.height, npc.height);
int num838 = NPC.NewNPC(npc.GetSource_FromAI(), (int)x2, (int)y4, NPCID.Creeper);
Main.npc[num838].velocity = new Vector2((float)Main.rand.Next(-30, 31) * 0.1f, (float)Main.rand.Next(-30, 31) * 0.1f);
Main.npc[num838].netUpdate = true;
}
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
npc.TargetClosest();
int num839 = 6000;
if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > (float)num839)
{
npc.active = false;
npc.life = 0;
if (Main.netMode == NetmodeID.Server)
NetMessage.SendData(23, -1, -1, null, npc.whoAmI);
}
}
if (npc.ai[0] < 0f)
{
if (Main.getGoodWorld)
NPC.brainOfGravity = npc.whoAmI;
if (npc.localAI[2] == 0f)
{
SoundEngine.PlaySound(SoundID.NPCHit1, npc.Center);
npc.localAI[2] = 1f;
Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 392);
Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 393);
Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 394);
Gore.NewGore(npc.GetSource_FromAI(), npc.position, new Vector2((float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f), 395);
for (int num840 = 0; num840 < 20; num840++)
Dust.NewDust(npc.position, npc.width, npc.height, 5, (float)Main.rand.Next(-30, 31) * 0.2f, (float)Main.rand.Next(-30, 31) * 0.2f);
SoundEngine.PlaySound(SoundID.Roar, npc.Center);
}
npc.dontTakeDamage = false;
npc.TargetClosest();
Vector2 vector104 = new Vector2(npc.Center.X, npc.Center.Y);
float num841 = Main.player[npc.target].Center.X - vector104.X;
float num842 = Main.player[npc.target].Center.Y - vector104.Y;
float num843 = (float)Math.Sqrt(num841 * num841 + num842 * num842);
float num844 = Main.masterMode ? 12f : 8f;
num843 = num844 / num843;
num841 *= num843;
num842 *= num843;
float inertia = Main.masterMode ? 40f : 50f;
npc.velocity.X = (npc.velocity.X * inertia + num841) / (inertia + 1f);
npc.velocity.Y = (npc.velocity.Y * inertia + num842) / (inertia + 1f);
if (npc.ai[0] == -1f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
npc.localAI[1] += 1f;
if (npc.justHit)
npc.localAI[1] -= Main.rand.Next(Main.masterMode ? 3 : 5);
int num845 = 60 + Main.rand.Next(Main.masterMode ? 60 : 120);
if (Main.netMode != NetmodeID.SinglePlayer)
num845 += Main.rand.Next(Main.masterMode ? 15 : 30, Main.masterMode ? 45 : 90);
if (npc.localAI[1] >= (float)num845)
{
npc.localAI[1] = 0f;
npc.TargetClosest();
int num846 = 0;
Player player2 = Main.player[npc.target];
do
{
num846++;
int num847 = (int)player2.Center.X / 16;
int num848 = (int)player2.Center.Y / 16;
int minValue = 10;
int num849 = 12;
float num850 = 16f;
int num851 = Main.rand.Next(minValue, num849 + 1);
int num852 = Main.rand.Next(minValue, num849 + 1);
if (Main.rand.NextBool())
num851 *= -1;
if (Main.rand.NextBool())
num852 *= -1;
Vector2 v = new Vector2(num851 * 16, num852 * 16);
if (Vector2.Dot(player2.velocity.SafeNormalize(Vector2.UnitY), v.SafeNormalize(Vector2.UnitY)) > 0f)
v += v.SafeNormalize(Vector2.Zero) * num850 * player2.velocity.Length();
num847 += (int)(v.X / 16f);
num848 += (int)(v.Y / 16f);
if (num846 > 100 || !WorldGen.SolidTile(num847, num848))
{
npc.ai[3] = 0f;
npc.ai[0] = -2f;
npc.ai[1] = num847;
npc.ai[2] = num848;
npc.netUpdate = true;
npc.netSpam = 0;
break;
}
}
while (num846 <= 100);
}
}
}
else if (npc.ai[0] == -2f)
{
npc.velocity *= 0.9f;
if (Main.netMode != NetmodeID.SinglePlayer)
npc.ai[3] += 15f;
else
npc.ai[3] += 25f;
if (npc.ai[3] >= 255f)
{
npc.ai[3] = 255f;
npc.position.X = npc.ai[1] * 16f - (float)(npc.width / 2);
npc.position.Y = npc.ai[2] * 16f - (float)(npc.height / 2);
SoundEngine.PlaySound(SoundID.Item8, npc.Center);
npc.ai[0] = -3f;
npc.netUpdate = true;
npc.netSpam = 0;
}
npc.alpha = (int)npc.ai[3];
}
else if (npc.ai[0] == -3f)
{
if (Main.netMode != 0)
npc.ai[3] -= 15f;
else
npc.ai[3] -= 25f;
if (npc.ai[3] <= 0f)
{
npc.ai[3] = 0f;
npc.ai[0] = -1f;
npc.netUpdate = true;
npc.netSpam = 0;
}
npc.alpha = (int)npc.ai[3];
}
}
else
{
npc.TargetClosest();
Vector2 vector105 = new Vector2(npc.Center.X, npc.Center.Y);
float num853 = Main.player[npc.target].Center.X - vector105.X;
float num854 = Main.player[npc.target].Center.Y - vector105.Y;
float num855 = (float)Math.Sqrt(num853 * num853 + num854 * num854);
float num856 = Main.masterMode ? 1.5f : 1f;
if (Main.getGoodWorld)
num856 *= 3f;
if (num855 < num856)
{
npc.velocity.X = num853;
npc.velocity.Y = num854;
}
else
{
num855 = num856 / num855;
npc.velocity.X = num853 * num855;
npc.velocity.Y = num854 * num855;
}
if (npc.ai[0] == 0f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int num857 = 0;
for (int num858 = 0; num858 < Main.maxNPCs; num858++)
{
if (Main.npc[num858].active && Main.npc[num858].type == NPCID.Creeper)
num857++;
}
if (num857 == 0)
{
npc.ai[0] = -1f;
npc.localAI[1] = 0f;
npc.alpha = 0;
npc.netUpdate = true;
}
npc.localAI[1] += 1f;
if (npc.localAI[1] >= (float)(120 + Main.rand.Next(Main.masterMode ? 150 : 300)))
{
npc.localAI[1] = 0f;
npc.TargetClosest();
int num859 = 0;
Player player3 = Main.player[npc.target];
do
{
num859++;
int num860 = (int)player3.Center.X / 16;
int num861 = (int)player3.Center.Y / 16;
int minValue2 = 12;
int num862 = 40;
float num863 = 16f;
int num864 = Main.rand.Next(minValue2, num862 + 1);
int num865 = Main.rand.Next(minValue2, num862 + 1);
if (Main.rand.NextBool())
num864 *= -1;
if (Main.rand.NextBool())
num865 *= -1;
Vector2 v2 = new Vector2(num864 * 16, num865 * 16);
if (Vector2.Dot(player3.velocity.SafeNormalize(Vector2.UnitY), v2.SafeNormalize(Vector2.UnitY)) > 0f)
v2 += v2.SafeNormalize(Vector2.Zero) * num863 * player3.velocity.Length();
num860 += (int)(v2.X / 16f);
num861 += (int)(v2.Y / 16f);
if (num859 > 100 || (!WorldGen.SolidTile(num860, num861) && (num859 > 75 || Collision.CanHit(new Vector2(num860 * 16, num861 * 16), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))))
{
npc.ai[0] = 1f;
npc.ai[1] = num860;
npc.ai[2] = num861;
npc.netUpdate = true;
break;
}
}
while (num859 <= 100);
}
}
}
else if (npc.ai[0] == 1f)
{
npc.alpha += 5;
if (npc.alpha >= 255)
{
SoundEngine.PlaySound(SoundID.Item8, npc.Center);
npc.alpha = 255;
npc.position.X = npc.ai[1] * 16f - (float)(npc.width / 2);
npc.position.Y = npc.ai[2] * 16f - (float)(npc.height / 2);
npc.ai[0] = 2f;
}
}
else if (npc.ai[0] == 2f)
{
npc.alpha -= 5;
if (npc.alpha <= 0)
{
npc.alpha = 0;
npc.ai[0] = 0f;
}
}
}
if (Main.player[npc.target].dead || !Main.player[npc.target].ZoneCrimson)
{
if (npc.localAI[3] < 120f)
npc.localAI[3]++;
if (npc.localAI[3] > 60f)
npc.velocity.Y += (npc.localAI[3] - 60f) * 0.25f;
npc.ai[0] = 2f;
npc.alpha = 10;
}
else if (npc.localAI[3] > 0f)
npc.localAI[3]--;
return false;
}
public static bool VanillaCreeperAI(NPC npc, Mod mod)
{
if (NPC.crimsonBoss < 0)
{
npc.active = false;
npc.netUpdate = true;
return false;
}
if (Main.masterMode)
npc.knockBackResist = 0f;
if (npc.ai[0] == 0f)
{
npc.ai[1] = 0f;
float maxVelocity = Main.masterMode ? 10f : 8f;
Vector2 vector106 = new Vector2(npc.Center.X, npc.Center.Y);
float num866 = Main.npc[NPC.crimsonBoss].Center.X - vector106.X;
float num867 = Main.npc[NPC.crimsonBoss].Center.Y - vector106.Y;
float num868 = (float)Math.Sqrt(num866 * num866 + num867 * num867);
if (num868 > 90f)
{
num868 = maxVelocity / num868;
num866 *= num868;
num867 *= num868;
npc.velocity.X = (npc.velocity.X * 15f + num866) / 16f;
npc.velocity.Y = (npc.velocity.Y * 15f + num867) / 16f;
return false;
}
if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < maxVelocity)
{
float velocityMult = Main.masterMode ? 1.07f : 1.05f;
npc.velocity.Y *= velocityMult;
npc.velocity.X *= velocityMult;
}
if (Main.netMode != NetmodeID.MultiplayerClient && ((Main.expertMode && Main.rand.NextBool(100)) || Main.rand.NextBool(200)))
{
npc.TargetClosest();
vector106 = new Vector2(npc.Center.X, npc.Center.Y);
num866 = Main.player[npc.target].Center.X - vector106.X;
num867 = Main.player[npc.target].Center.Y - vector106.Y;
num868 = (float)Math.Sqrt(num866 * num866 + num867 * num867);
num868 = maxVelocity / num868;
npc.velocity.X = num866 * num868;
npc.velocity.Y = num867 * num868;
npc.ai[0] = 1f;
npc.netUpdate = true;
}
return false;
}
if (Main.expertMode)
{
Vector2 vector107 = Main.player[npc.target].Center - npc.Center;
vector107.Normalize();
if (Main.getGoodWorld)
{
vector107 *= 12f;
npc.velocity = (npc.velocity * 49f + vector107) / 50f;
}
else
{
float chargeVelocity = Main.masterMode ? 10f : 9f;
vector107 *= chargeVelocity;
float inertia = Main.masterMode ? 75f : 100f;
npc.velocity = (npc.velocity * (inertia - 1f) + vector107) / inertia;
}
}
Vector2 vector108 = new Vector2(npc.Center.X, npc.Center.Y);
float num869 = Main.npc[NPC.crimsonBoss].Center.X - vector108.X;
float num870 = Main.npc[NPC.crimsonBoss].Center.Y - vector108.Y;
float num871 = (float)Math.Sqrt(num869 * num869 + num870 * num870);
if (num871 > 700f)
{
npc.ai[0] = 0f;
}
else
{
if (!npc.justHit)
return false;
if (npc.knockBackResist == 0f)
{
npc.ai[1] += 1f;
float returnToBrainGateValue = Main.masterMode ? 35f : 5f;
if (npc.ai[1] > returnToBrainGateValue)
npc.ai[0] = 0f;
}
else
npc.ai[0] = 0f;
}
return false;
}
public static int GetBrainOfCthuluCreepersCountRevDeath()
{
return CalamityWorld.LegendaryMode ? 40 : Main.getGoodWorld ? 35 : (CalamityWorld.death || BossRushEvent.BossRushActive) ? 30 : 20;
}
public static int GetBrainOfCthuluCreepersCountVanilla()
{
return Main.getGoodWorld ? 40 : Main.masterMode ? 30 : 20;
}
private static float GetCrimsonBossKnockBack(NPC npc, int numPlayers, float lifeScale, float baseKnockBackResist)
{
float balance = 1f;
@@ -247,6 +247,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
npc.TargetClosest();
npc.netUpdate = true;
npc.netSpam = 0;
npc.alpha = 0;
}
// If this segment is a body and its next segment is dead (or was rendered into a head), transform into a tail.
@@ -267,6 +268,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
npc.TargetClosest();
npc.netUpdate = true;
npc.netSpam = 0;
npc.alpha = 0;
}
// If for any reason this segment was deleted, send info to clients so they also see it die.
@@ -651,6 +653,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
}
}
if (npc.type == NPCID.EaterofWorldsHead || (npc.type != NPCID.EaterofWorldsHead && Main.npc[(int)npc.ai[1]].alpha >= 85))
{
if (npc.alpha > 0 && npc.life > 0)
{
for (int dustIndex = 0; dustIndex < 2; dustIndex++)
{
int dust = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 14, 0f, 0f, 100, default(Color), 2f);
Main.dust[dust].noGravity = true;
Main.dust[dust].noLight = true;
}
}
if ((npc.position - npc.oldPosition).Length() > 2f)
{
npc.alpha -= 42;
if (npc.alpha < 0)
npc.alpha = 0;
}
}
// Manually sync newAI because there is no GlobalNPC.SendExtraAI
if (npc.active && npc.netUpdate && Main.netMode == NetmodeID.Server)
{