BR Eater of Worlds works perfectly in SP.

This commit is contained in:
Ozzatron authored and Cameron Ewell committed 2020-09-27 22:12:39 -04:00
1 parent f3458de741
commit eaee130112
5 files changed
+115 -148

No files matched your search

-1
View File
@@ -32,7 +32,6 @@ using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
namespace CalamityMod.Events
+84 -127
View File
@@ -1392,7 +1392,6 @@ namespace CalamityMod.NPCs
{
CalamityGlobalNPC calamityGlobalNPC = npc.Calamity();
bool configBossRushBoost = CalamityConfig.Instance.BossRushXerocCurse && BossRushEvent.BossRushActive;
bool death = CalamityWorld.death || BossRushEvent.BossRushActive;
// Total body segments
@@ -1467,9 +1466,6 @@ namespace CalamityMod.NPCs
}
}
if (!BossRushEvent.BossRushActive)
npc.realLife = -1;
// Target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead)
npc.TargetClosest(true);
@@ -1481,142 +1477,103 @@ namespace CalamityMod.NPCs
npc.timeLeft = 300;
}
// Force kill BR Eater of Worlds if any of his segments fall below 5% health.
if (BossRushEvent.BossRushActive && npc.life <= npc.lifeMax * 0.05)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.NPCLoot();
for (int n = 0; n < Main.maxNPCs; n++)
if (Main.npc[n].aiStyle == npc.aiStyle)
Main.npc[n].active = false;
}
// Spawn the reamining segments of the worm (server side only of course!)
// All functions that modify the active worm segments are here. This includes spawning the worm originally and splitting effects.
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (BossRushEvent.BossRushActive)
// If this segment is a head or a body without a next-segment defined, then it needs to spawn its own next segment.
if ((npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody) && npc.ai[0] == 0f)
{
// In BR, spawn all segments from the head
if (npc.ai[0] == 0f && npc.type == NPCID.EaterofWorldsHead)
int spawnX = (int)npc.position.X;
int spawnY = (int)npc.position.Y;
// A head sets the length variable (npc.ai[2]) and then sets its next segment to a freshly spawned body.
if (npc.type == NPCID.EaterofWorldsHead)
{
// Set the head's own ai[3] and real life to point to itself.
npc.ai[3] = npc.whoAmI;
npc.realLife = npc.whoAmI;
int prevSegmentIndex = npc.whoAmI;
// Set head's "length beyond this point" to be the total length of the worm.
npc.ai[2] = totalSegments;
for (int j = 0; j <= totalSegments; j++)
{
int type = NPCID.EaterofWorldsBody;
if (j == totalSegments)
type = NPCID.EaterofWorldsTail;
int segment = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), type, npc.whoAmI);
// Set ai[3] and real life to point to the head's index.
Main.npc[segment].ai[3] = npc.whoAmI;
Main.npc[segment].realLife = npc.whoAmI;
// Link this segment to the previously spawned one with ai[0] and ai[1].
Main.npc[segment].ai[1] = prevSegmentIndex;
Main.npc[prevSegmentIndex].ai[0] = segment;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment, 0f, 0f, 0f, 0, 0, 0);
// Update the "previous segment" index.
prevSegmentIndex = segment;
}
// Body spawn
npc.ai[0] = NPC.NewNPC(spawnX, spawnY, NPCID.EaterofWorldsBody, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
}
// A body with a "length beyond this point" greater than zero just sets its next spawned segment to a freshly spawned body.
else if (npc.type == NPCID.EaterofWorldsBody && npc.ai[2] > 0f)
npc.ai[0] = NPC.NewNPC(spawnX, spawnY, NPCID.EaterofWorldsBody, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
// If the worm stops here ("length beyond this point" is zero), then spawn a tail instead.
else
npc.ai[0] = NPC.NewNPC(spawnX, spawnY, NPCID.EaterofWorldsTail, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
// Maintain the linked list of worm segments, and correctly set the "length beyond this point" of this segment.
Main.npc[(int)npc.ai[0]].ai[1] = npc.whoAmI;
Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f;
npc.netUpdate = true;
}
else
// Helper function to destroy this Eater of Worlds worm segment.
void DestroyThisSegment()
{
if ((npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody) && npc.ai[0] == 0f)
{
// Spawn entire worm
if (npc.type == NPCID.EaterofWorldsHead)
{
// Length
npc.ai[2] = totalSegments;
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
// Body spawn
npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
}
else if (npc.type == NPCID.EaterofWorldsBody && npc.ai[2] > 0f)
{
// Body spawn
npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), npc.type, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
}
else
{
// Tail spawn
npc.ai[0] = NPC.NewNPC((int)(npc.position.X + (npc.width / 2)), (int)(npc.position.Y + npc.height), npc.type + 1, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
}
// If this segment's previous and next segments are both dead, make it explode instantly. Single segments cannot live.
if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active)
DestroyThisSegment();
// Worm shit
Main.npc[(int)npc.ai[0]].ai[1] = npc.whoAmI;
Main.npc[(int)npc.ai[0]].ai[2] = npc.ai[2] - 1f;
npc.netUpdate = true;
}
// If this segment is a head and its next segment is dead, make it explode instantly. It's been decapitated.
if (npc.type == NPCID.EaterofWorldsHead && !Main.npc[(int)npc.ai[0]].active)
DestroyThisSegment();
// Splitting effect
if (!Main.npc[(int)npc.ai[1]].active && !Main.npc[(int)npc.ai[0]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
}
if (npc.type == NPCID.EaterofWorldsHead && !Main.npc[(int)npc.ai[0]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
}
if (npc.type == NPCID.EaterofWorldsTail && !Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
}
if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle))
{
npc.type = NPCID.EaterofWorldsHead;
int whoAmI = npc.whoAmI;
float num25 = npc.life / (float)npc.lifeMax;
float num26 = npc.ai[0];
int aiTimer = calamityGlobalNPC.AITimer;
npc.SetDefaultsKeepPlayerInteraction(npc.type);
npc.life = (int)(npc.lifeMax * num25);
npc.ai[0] = num26;
npc.TargetClosest(true);
npc.netUpdate = true;
npc.whoAmI = whoAmI;
calamityGlobalNPC.AITimer = aiTimer;
}
if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle))
{
int whoAmI2 = npc.whoAmI;
float num27 = npc.life / (float)npc.lifeMax;
float num28 = npc.ai[1];
int aiTimer = calamityGlobalNPC.AITimer;
npc.SetDefaultsKeepPlayerInteraction(npc.type);
npc.life = (int)(npc.lifeMax * num27);
npc.ai[1] = num28;
npc.TargetClosest(true);
npc.netUpdate = true;
npc.whoAmI = whoAmI2;
calamityGlobalNPC.AITimer = aiTimer;
}
// If this segment is a tail and its previous segment is dead, make it explode instantly. It's been chopped off.
if (npc.type == NPCID.EaterofWorldsTail && !Main.npc[(int)npc.ai[1]].active)
DestroyThisSegment();
if (!npc.active && Main.netMode == NetmodeID.Server)
NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
// If this segment is a body and its previous segment is dead (or was rendered into a tail), transform into a head.
if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != npc.aiStyle))
{
npc.type = NPCID.EaterofWorldsHead;
float segmentLifeRatio = npc.life / (float)npc.lifeMax;
int whoAmI = npc.whoAmI;
float ai0Holdover = npc.ai[0];
int aiTimer = calamityGlobalNPC.AITimer;
// Actually transform the body segment into a head segment.
npc.SetDefaultsKeepPlayerInteraction(npc.type);
npc.life = (int)(npc.lifeMax * segmentLifeRatio);
npc.whoAmI = whoAmI;
npc.ai[0] = ai0Holdover;
// Heads spawned mid fight by splitting do not get spawn invincibility.
CalamityGlobalNPC newCGN = npc.Calamity();
newCGN.newAI[1] = calamityGlobalNPC.newAI[1];
newCGN.AITimer = aiTimer;
npc.TargetClosest(true);
npc.netUpdate = true;
}
// If this segment is a body and its next segment is dead (or was rendered into a head), transform into a tail.
if (npc.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)npc.ai[0]].active || Main.npc[(int)npc.ai[0]].aiStyle != npc.aiStyle))
{
npc.type = NPCID.EaterofWorldsTail;
float segmentLifeRatio = npc.life / (float)npc.lifeMax;
int whoAmI = npc.whoAmI;
float ai1Holdover = npc.ai[1];
int aiTimer = calamityGlobalNPC.AITimer;
// Actually transform the body segment into a tail segment.
npc.SetDefaultsKeepPlayerInteraction(npc.type);
npc.life = (int)(npc.lifeMax * segmentLifeRatio);
npc.whoAmI = whoAmI;
npc.ai[1] = ai1Holdover;
npc.Calamity().AITimer = aiTimer;
npc.TargetClosest(true);
npc.netUpdate = true;
}
// If for any reason this segment was deleted, send info to clients so they also see it die.
if (!npc.active && Main.netMode == NetmodeID.Server)
NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI, -1f);
}
// Movement
+3 -3
View File
@@ -209,9 +209,9 @@ namespace CalamityMod.NPCs
{ NPCID.GolemFistLeft, 250000 },
{ NPCID.GolemFistRight, 250000 },
{ NPCID.EaterofWorldsHead, 15000000 }, // 30 seconds
{ NPCID.EaterofWorldsBody, 15000000 },
{ NPCID.EaterofWorldsTail, 15000000 },
{ NPCID.EaterofWorldsHead, 190000 }, // 30 seconds
{ NPCID.EaterofWorldsBody, 190000 }, // 77 segments on rev: 190K * 77 = 14.63M
{ NPCID.EaterofWorldsTail, 190000 },
// Tier 2
{ NPCID.TheDestroyer, 2500000 }, // 30 seconds + immunity timer at start
+22 -11
View File
@@ -1,7 +1,6 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.CalPlayer;
using CalamityMod.Events;
using CalamityMod.Items;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.DifficultyItems;
using CalamityMod.Items.LoreItems;
@@ -13,19 +12,10 @@ using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.NPCs.AquaticScourge;
using CalamityMod.NPCs.AstrumDeus;
using CalamityMod.NPCs.Bumblebirb;
using CalamityMod.NPCs.Calamitas;
using CalamityMod.NPCs.Crabulon;
using CalamityMod.NPCs.DesertScourge;
using CalamityMod.NPCs.DevourerofGods;
using CalamityMod.NPCs.HiveMind;
using CalamityMod.NPCs.Leviathan;
using CalamityMod.NPCs.NormalNPCs;
using CalamityMod.NPCs.Perforator;
using CalamityMod.NPCs.ProfanedGuardians;
using CalamityMod.NPCs.Ravager;
using CalamityMod.NPCs.SlimeGod;
using CalamityMod.NPCs.StormWeaver;
using CalamityMod.NPCs.SulphurousSea;
@@ -410,7 +400,21 @@ namespace CalamityMod.NPCs
#region Boss Rush Loot Cancel
private bool BossRushLootCancel(NPC npc, Mod mod)
{
if (npc.type == ModContent.NPCType<Siren>() || npc.type == ModContent.NPCType<Leviathan.Leviathan>())
// Eater of Worlds splits in Boss Rush now, so you have to kill every single segment to progress.
// Vanilla sets npc.boss to true for the last Eater of Worlds segment to die in NPC.checkDead.
// This means we do not need to manually check for other segments ourselves.
if (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsBody || npc.type == NPCID.EaterofWorldsTail)
{
if (npc.boss)
{
BossRushEvent.BossRushStage++;
CalamityUtils.KillAllHostileProjectiles();
CalamityWorld.bossRushHostileProjKillCounter = 3;
}
}
// Anahita and Leviathan manually check for each other (this probably isn't necessary).
else if (npc.type == ModContent.NPCType<Siren>() || npc.type == ModContent.NPCType<Leviathan.Leviathan>())
{
int bossType = (npc.type == ModContent.NPCType<Siren>()) ? ModContent.NPCType<Leviathan.Leviathan>() : ModContent.NPCType<Siren>();
if (!NPC.AnyNPCs(bossType))
@@ -420,12 +424,16 @@ namespace CalamityMod.NPCs
CalamityWorld.bossRushHostileProjKillCounter = 3;
}
}
// Killing any split Deus head ends the fight instantly. You don't need to kill both.
else if (npc.type == ModContent.NPCType<AstrumDeusHeadSpectral>() && npc.Calamity().newAI[0] != 0f)
{
BossRushEvent.BossRushStage++;
CalamityUtils.KillAllHostileProjectiles();
CalamityWorld.bossRushHostileProjKillCounter = 3;
}
// All Slime God entities must be killed to progress to the next stage.
else if (npc.type == ModContent.NPCType<SlimeGodCore>() || npc.type == ModContent.NPCType<SlimeGodSplit>() || npc.type == ModContent.NPCType<SlimeGodRunSplit>())
{
if (npc.type == ModContent.NPCType<SlimeGodCore>() && !NPC.AnyNPCs(ModContent.NPCType<SlimeGodSplit>()) && !NPC.AnyNPCs(ModContent.NPCType<SlimeGodRunSplit>()) &&
@@ -450,6 +458,8 @@ namespace CalamityMod.NPCs
CalamityWorld.bossRushHostileProjKillCounter = 3;
}
}
// This is the generic form of "Are there any remaining NPCs on the boss list for this boss rush stage?" check.
else if ((BossRushEvent.Bosses.Any(boss => boss.EntityID == npc.type) && !BossRushEvent.BossIDsAfterDeath.ContainsKey(npc.type)) ||
BossRushEvent.BossIDsAfterDeath.Values.Any(killList => killList.Contains(npc.type)))
{
@@ -459,6 +469,7 @@ namespace CalamityMod.NPCs
if (BossRushEvent.BossDeathEffects.ContainsKey(npc.type))
BossRushEvent.BossDeathEffects[npc.type].Invoke(npc);
}
if (Main.netMode == NetmodeID.Server)
{
var netMessage = mod.GetPacket();
+6 -6
View File
@@ -30,7 +30,7 @@ using Terraria.ModLoader;
namespace CalamityMod.UI
{
/*
/*
Heyo! Here's some things you might need to know about this class and where to change things:
In the "Load" method is where the "OneToMany" dictionary is updated.
@@ -53,7 +53,7 @@ namespace CalamityMod.UI
That should be it -- ask if you have any questions!
*/
internal static class BossHealthBarManager
internal static class BossHealthBarManager
{
private static readonly int MAX_BARS = 4;
@@ -208,7 +208,7 @@ namespace CalamityMod.UI
//Hardmode
NPCID.GoblinSummoner, //2000 HP
NPCID.WyvernHead,
NPCID.WyvernHead,
NPCID.Paladin,
NPCID.IceGolem,
NPCID.SandElemental,
@@ -585,8 +585,8 @@ namespace CalamityMod.UI
if (Main.npc[i].active && Main.npc[i].life > 0 && _arrayOfIds.Contains(Main.npc[i].type))
{
if ((Main.npc[i].type == NPCID.MoonLordHead && (Main.npc[i].ai[0] == -2f || Main.npc[i].ai[0] == -3f || Main.npc[i].Calamity().newAI[0] == 1f)) ||
(Main.npc[i].type == NPCID.MoonLordHand && (Main.npc[i].ai[0] == -2f || Main.npc[i].Calamity().newAI[0] == 1f)) ||
(Main.npc[i].type == NPCID.MoonLordCore && Main.npc[i].ai[0] == 2f))
(Main.npc[i].type == NPCID.MoonLordHand && (Main.npc[i].ai[0] == -2f || Main.npc[i].Calamity().newAI[0] == 1f)) ||
(Main.npc[i].type == NPCID.MoonLordCore && Main.npc[i].ai[0] == 2f))
continue;
currentLife += Main.npc[i].life;
@@ -809,7 +809,7 @@ namespace CalamityMod.UI
Vector2 countSize5 = Main.fontItemStack.MeasureString(count5) * textScale;
float countX5 = Math.Max(x, x + mainBarWidth - countSize5.X);
DrawBorderStringEightWay(sb, Main.fontItemStack, count5, new Vector2(countX5, y + MainBarYOffset + 17), Color.White, Color.Black * 0.24f, textScale);
return;
return;
}
string actualLife = "(" + _npc.life + " / " + _npc.lifeMax + ")";