Fixed sudden bro AI update when other bro dies

Also fixed a mistake that made phase 2 brothers pre bro death not use their special attack
This commit is contained in:
Xyk committed 2024-04-23 01:36:30 -07:00
1 parent 8f5ca180fb
commit c3b366b25a
3 files changed
+39 -29

No files matched your search

+11 -9
View File
@@ -45,6 +45,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
public bool EnrageRoar = true;
public int doublePunchCounter = 0;
public bool setMovement = true;
public bool broIsAlive = true;
public Player Target => Main.player[NPC.target];
public ref float PunchCounter => ref NPC.ai[1];
@@ -202,7 +203,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
float acceleration = Utils.Remap(AttackDelayTimer, 0f, 120f, 2f, 4f);
int verticalSpeed = (int)Math.Round(MathHelper.Lerp(2f, 6.5f, 1f - totalLifeRatio));
bool Phase2 = NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false ? true : false;
bool Phase2 = broIsAlive == false ? true : false;
if (NPC.life / (float)NPC.lifeMax < (death ? 0.6 : 0.4) && !Phase2)
{
if (EnrageRoar)
@@ -220,10 +221,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas
if (Phase2 && BigAttackTimer > 400)
BigAttackTimer = 400;
if (NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false && BigAttackTimer > 0 && BigAttackLimit < 29)
if (broIsAlive == false && BigAttackTimer > 0 && BigAttackLimit < 29)
BigAttackLimit = 29;
else if (Phase2 && BigAttackTimer > 0 && BigAttackLimit < 11)
BigAttackLimit = 11;
else if (BigAttackTimer > 0 && BigAttackLimit < 7)
BigAttackLimit = 7;
if (BigAttackTimer > PreBigAttackPause)
{
@@ -318,7 +319,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
else if (BigAttackTimer > PreBigAttackPause)
{
// Shoot fists.
float fireRate = BossRushEvent.BossRushActive ? 2f : MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false ? death ? 1.32f : 1.1f : 1);
float fireRate = BossRushEvent.BossRushActive ? 2f : MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (broIsAlive == false ? death ? 1.32f : 1.1f : 1);
PunchCounter += fireRate;
if (PunchCounter >= PunchCounterLimit)
@@ -342,8 +343,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas
}
else
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center).RotatedBy(NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false ? 0.48f : 0.55f) * 15f, type, damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 2);
Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center).RotatedBy(NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false ? - 0.48f : -0.55f) * 15f, type, damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 2);
Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center).RotatedBy(broIsAlive == false ? 0.48f : 0.55f) * 15f, type, damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 2);
Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, NPC.DirectionTo(Target.Center).RotatedBy(broIsAlive == false ? - 0.48f : -0.55f) * 15f, type, damage, 0f, Main.myPlayer, 0f, PunchingFromRight.ToInt(), 2);
doublePunchCounter = 0;
}
}
@@ -352,6 +353,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
}
PunchingFromRight = !PunchingFromRight;
CurrentFrame = 0;
broIsAlive = NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>());
}
}
// Pause before attacking
@@ -378,7 +380,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
{
// Shoot fists.
float fireRate = BossRushEvent.BossRushActive ? 2.8f : MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio);
if (NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false)
if (broIsAlive == false)
fireRate = BossRushEvent.BossRushActive ? 3.5f + (29 - BigAttackLimit) * 0.45f : MathHelper.Lerp(3f, (4f + (29 - BigAttackLimit) * 0.45f), 1f - totalLifeRatio) * 1.2f;
if (Phase2 && BigAttackLimit == 0)
fireRate = 1;
@@ -394,7 +396,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
damage /= 2;
Vector2 fistSpawnPosition = NPC.Center + Vector2.UnitX * 74f * NPC.direction;
if ((NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 0) && death)
if ((broIsAlive == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 1) && death)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, (NPC.DirectionTo(Target.Center) * 11f).RotatedBy(0.6f - BigAttackLimit * 0.16f), type, damage, 0f, Main.myPlayer, 0f, 0, 2);
Projectile.NewProjectile(NPC.GetSource_FromAI(), fistSpawnPosition, (NPC.DirectionTo(Target.Center) * 11f).RotatedBy(-0.6f + BigAttackLimit * 0.16f), type, damage, 0f, Main.myPlayer, 0f, 0, 2);
+11 -7
View File
@@ -39,6 +39,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
public bool EnrageRoar = true;
public int accSlashCounter = 0;
public bool setMovement = true;
public bool broIsAlive = true;
public Player Target => Main.player[NPC.target];
public ref float SlashCounter => ref NPC.ai[1];
public ref float DartBurstCounter => ref NPC.ai[2];
@@ -196,7 +197,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
float acceleration = Utils.Remap(AttackDelayTimer, 0f, 120f, 2f, 4f);
int verticalSpeed = (int)Math.Round(MathHelper.Lerp(2f, 6.5f, 1f - totalLifeRatio));
bool Phase2 = NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false ? true : false;
bool Phase2 = broIsAlive == false ? true : false;
if (NPC.life / (float)NPC.lifeMax < (death ? 0.6 : 0.4) && !Phase2)
{
if (EnrageRoar)
@@ -215,6 +216,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas
if (Phase2 && BigAttackTimer > 0 && BigAttackLimit < 11)
BigAttackLimit = 11;
else if (BigAttackTimer > 0 && BigAttackLimit < 7)
BigAttackLimit = 7;
if (BigAttackTimer > PreBigAttackPause)
{
@@ -270,7 +273,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, NPC.velocity.SafeNormalize(Vector2.UnitY) * 0.1f, type, damage, 0f, Main.myPlayer, 0f, SlashingFromRight.ToInt(), 4 + dashes);
dashes++;
if (dashes == 30 && NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false)
if (dashes == 30 && broIsAlive == false)
{
SoundStyle slash = new("CalamityMod/Sounds/Item/MurasamaBigSwing");
SoundEngine.PlaySound(slash with { Volume = 0.55f, Pitch = -0.3f }, NPC.Center);
@@ -338,7 +341,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
else if (BigAttackTimer > PreBigAttackPause)
{
// Shoot sword slashes.
float fireRate = BossRushEvent.BossRushActive ? 2f : MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false ? death ? 1.25f : 1.05f : 1);
float fireRate = BossRushEvent.BossRushActive ? 2f : MathHelper.Lerp(1.5f, 2f, 1f - totalLifeRatio) * (broIsAlive == false ? death ? 1.25f : 1.05f : 1);
SlashCounter += fireRate;
if (SlashCounter >= SlashCounterLimit)
{
@@ -352,7 +355,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
Vector2 slashSpawnPosition = NPC.Center + Vector2.UnitX * 125f * NPC.direction;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Vector2 firingVelocity = (NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false ? (NPC.DirectionTo(Target.Center) + Target.velocity * 0.0305f).SafeNormalize(Vector2.UnitY) : NPC.DirectionTo(Target.Center));
Vector2 firingVelocity = (broIsAlive == false ? (NPC.DirectionTo(Target.Center) + Target.velocity * 0.0305f).SafeNormalize(Vector2.UnitY) : NPC.DirectionTo(Target.Center));
if (Phase2)
{
if (accSlashCounter < 2)
@@ -374,6 +377,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
}
SlashingFromRight = !SlashingFromRight;
CurrentFrame = 0;
broIsAlive = NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>());
}
}
// Pause before attacking
@@ -399,7 +403,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
else
{
// Shoot sword slashes.
float fireRate = BossRushEvent.BossRushActive ? 2.8f : MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio) * (NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false ? 1.35f : 1);
float fireRate = BossRushEvent.BossRushActive ? 2.8f : MathHelper.Lerp(2.5f, 3f, 1f - totalLifeRatio) * (broIsAlive == false ? 1.35f : 1);
if (Phase2 && BigAttackLimit == 0)
fireRate = 1;
SlashCounter += fireRate;
@@ -412,9 +416,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas
if (bossRush)
damage /= 2;
Vector2 slashSpawnPosition = NPC.Center;
Vector2 firingVelocity = (NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false ? (NPC.DirectionTo(Target.Center) + Target.velocity * 0.032f).SafeNormalize(Vector2.UnitY) : NPC.DirectionTo(Target.Center));
Vector2 firingVelocity = (broIsAlive == false ? (NPC.DirectionTo(Target.Center) + Target.velocity * 0.032f).SafeNormalize(Vector2.UnitY) : NPC.DirectionTo(Target.Center));
if ((NPC.AnyNPCs(ModContent.NPCType<SupremeCataclysm>()) == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 0) && death)
if ((broIsAlive == false ? BigAttackLimit <= 3 && BigAttackLimit > 0 : BigAttackLimit == 1) && death)
{
Projectile.NewProjectile(NPC.GetSource_FromAI(), slashSpawnPosition + firingVelocity * 130, (Phase2 ? NPC.DirectionTo(Target.Center) : firingVelocity) * 90f, type, damage, 0f, Main.myPlayer, 0f, 5, 50);
SoundStyle slash = new("CalamityMod/Sounds/Item/MurasamaBigSwing");
+17 -13
View File
@@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Boss
public ref float Time => ref Projectile.ai[0];
public Vector2 shootVel;
public int rotDirection = 1;
public bool broIsAlive = true;
public override void SetStaticDefaults()
{
@@ -56,6 +57,7 @@ namespace CalamityMod.Projectiles.Boss
Projectile.timeLeft = 240;
rotDirection = Main.rand.NextBool() ? -1 : 1;
Projectile.velocity *= 5.5f;
broIsAlive = NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>());
}
else
{
@@ -75,8 +77,7 @@ namespace CalamityMod.Projectiles.Boss
//shootVel = shootVel.RotatedBy(Time * 0.00011f * rotDirection);
if (Projectile.timeLeft == 205)
if (Projectile.timeLeft == 205) // Fist direction telegraphs
{
for (int k = 0; k < 28; k++)
{
@@ -84,17 +85,20 @@ namespace CalamityMod.Projectiles.Boss
GlowSparkParticle spark = new GlowSparkParticle(Projectile.Center + vel1 * (9 + k * 11), vel1, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false);
GeneralParticleHandler.SpawnParticle(spark);
}
for (int k = 0; k < 28; k++)
if (broIsAlive == false)
{
Vector2 vel2 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(120f));
GlowSparkParticle spark2 = new GlowSparkParticle(Projectile.Center + vel2 * (9 + k * 11), vel2, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false);
GeneralParticleHandler.SpawnParticle(spark2);
}
for (int k = 0; k < 28; k++)
{
Vector2 vel3 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(-120f));
GlowSparkParticle spark3 = new GlowSparkParticle(Projectile.Center + vel3 * (9 + k * 11), vel3, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false);
GeneralParticleHandler.SpawnParticle(spark3);
for (int k = 0; k < 28; k++)
{
Vector2 vel2 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(120f));
GlowSparkParticle spark2 = new GlowSparkParticle(Projectile.Center + vel2 * (9 + k * 11), vel2, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false);
GeneralParticleHandler.SpawnParticle(spark2);
}
for (int k = 0; k < 28; k++)
{
Vector2 vel3 = (-shootVel * MathHelper.Clamp(Time * 0.1f, 1, 1.8f)).RotatedBy(MathHelper.ToRadians(-120f));
GlowSparkParticle spark3 = new GlowSparkParticle(Projectile.Center + vel3 * (9 + k * 11), vel3, false, 7, 0.17f, Color.Lerp(Color.Red, Color.Magenta, 0.5f) * 0.5f, new Vector2(0.9f, 0.4f), true, false);
GeneralParticleHandler.SpawnParticle(spark3);
}
}
}
@@ -105,7 +109,7 @@ namespace CalamityMod.Projectiles.Boss
SoundEngine.PlaySound(SupremeCalamitas.BrimstoneShotSound with { Volume = 1.2f, Pitch = 0.55f }, Projectile.Center);
Projectile.NewProjectile(Projectile.GetSource_FromAI(), Projectile.Center + randPos, (-shootVel * MathHelper.Clamp(Time * 0.02f, 0.1f, 1.8f)) * Main.rand.NextFloat(0.75f, 1f), type, Projectile.damage, 0f, Main.myPlayer, 0f, Main.rand.Next(0, 1 + 1), 0);
}
if (Projectile.timeLeft <= 200 && Time % 3 == 0 && NPC.AnyNPCs(ModContent.NPCType<SupremeCatastrophe>()) == false)
if (Projectile.timeLeft <= 200 && Time % 3 == 0 && broIsAlive == false)
{
Vector2 randPos = (-shootVel * 1.5f).RotatedBy(MathHelper.ToRadians(120f)).RotatedByRandom(1) * Main.rand.NextFloat(5, 15);
Vector2 randPos2 = (-shootVel * 1.5f).RotatedBy(MathHelper.ToRadians(-120f)).RotatedByRandom(1) * Main.rand.NextFloat(5, 15);