Skip to content

Commit 41fe835

Browse files
fixed inconsistencies with despawn and limb messages for Moon Lord
1 parent 098348b commit 41fe835

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

BossChecklist.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public override void HandlePacket(BinaryReader reader, int whoAmI) {
375375
NPC limbNPC = Main.npc[reader.ReadInt32()];
376376
bossTracker.IsEntryLimb(limbNPC.type, out EntryInfo limbEntry);
377377
if (limbEntry is not null && limbEntry.GetLimbMessage(limbNPC) is LocalizedText limbMessage)
378-
Main.NewText(limbMessage.Format(limbNPC.FullName), Colors.RarityPurple);
378+
Main.NewText(limbMessage.Format(limbNPC.FullName), Colors.RarityGreen);
379379
}
380380
else if (messageType == ClientMessageType.Moon) {
381381
if (WorldAssist.DetermineMoonAnnoucement(reader.ReadString()) is string message)

BossTracker.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private void InitializeVanillaEntries() {
156156
EntryInfo.MakeVanillaBoss(EntryType.Boss, LunaticCultist, "NPCName.CultistBoss", NPCID.CultistBoss, () => NPC.downedAncientCultist)
157157
.WithCustomPortrait($"BossChecklist/Resources/BossTextures/Boss{NPCID.CultistBoss}"),
158158
EntryInfo.MakeVanillaBoss(EntryType.Boss, Moonlord, "Enemies.MoonLord", new List<int>() { NPCID.MoonLordHead }, () => NPC.downedMoonlord)
159-
.WithCustomLimbs(new List<int>() { NPCID.MoonLordCore, NPCID.MoonLordHand })
159+
.WithCustomLimbs(new List<int>() { NPCID.MoonLordHead, NPCID.MoonLordHand })
160160
.WithCustomPortrait($"BossChecklist/Resources/BossTextures/Boss{NPCID.MoonLordHead}"),
161161

162162
// Minibosses and Events -- Vanilla

NPCAssist.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,23 @@ public override void OnSpawn(NPC npc, IEntitySource source) {
3131
// Special case for moon lord. The hands and head do not 'die' when the messages need to be triggered
3232
public override void HitEffect(NPC npc, NPC.HitInfo hit) {
3333
if ((npc.type == NPCID.MoonLordHand || npc.type == NPCID.MoonLordHead) && npc.life <= 0) {
34+
if (Main.npc.Any(x => x.type == NPCID.MoonLordCore && x.life <= 0))
35+
return; // Messages shouldn't be sent if the Moon Lord's core is defeated as that would mean the entire boss is defeated
36+
3437
if (BossChecklist.bossTracker.IsEntryLimb(npc.type, out EntryInfo limbEntry) && limbEntry.GetLimbMessage(npc) is LocalizedText message) {
35-
if (Main.netMode != NetmodeID.Server)
38+
if (Main.netMode == NetmodeID.SinglePlayer) {
3639
Main.NewText(message.Format(npc.FullName), Colors.RarityGreen);
40+
}
41+
else if (Main.netMode == NetmodeID.Server) {
42+
// Send a packet to all multiplayer clients. Limb messages are client based, so they will need to read their own configs to determine the message.
43+
foreach (Player player in Main.ActivePlayers) {
44+
ModPacket packet = BossChecklist.instance.GetPacket();
45+
packet.Write((byte)PacketMessageType.SendClientConfigMessage);
46+
packet.Write((byte)ClientMessageType.Limb);
47+
packet.Write(npc.whoAmI);
48+
packet.Send(player.whoAmI); // Server --> Multiplayer client
49+
}
50+
}
3751
}
3852
}
3953
}
@@ -46,7 +60,7 @@ public override void OnKill(NPC npc) {
4660
// Display a message for Limbs/Towers if config is enabled, which should be checked after the active flags update
4761
if (BossChecklist.bossTracker.IsEntryLimb(npc.type, out EntryInfo limbEntry) && limbEntry.GetLimbMessage(npc) is LocalizedText message) {
4862
if (Main.netMode == NetmodeID.SinglePlayer) {
49-
Main.NewText(message.Format(npc.FullName), Colors.RarityPurple);
63+
Main.NewText(message.Format(npc.FullName), Colors.RarityGreen);
5064
}
5165
else if (Main.netMode == NetmodeID.Server) {
5266
// Send a packet to all multiplayer clients. Limb messages are client based, so they will need to read their own configs to determine the message.

WorldAssist.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ public void HandleDespawnFlags() {
263263
continue; // do nothing if any other npcs are apart of the entry and are still active
264264

265265
// Now that the entry no longer exists within ActiveNPCEntryFlags, it is determined to have despawned
266-
if (selectedEntry.GetDespawnMessage(npc) is LocalizedText message) {
266+
// The Moon Lord has a special case, since it technically despawns when its killed
267+
if (selectedEntry.GetDespawnMessage(npc) is LocalizedText message && (selectedEntry.Key != "Terraria MoonLord" || npc.life > 0)) {
267268
if (Main.netMode == NetmodeID.SinglePlayer) {
268269
Main.NewText(message.Format(npc.FullName), Colors.RarityPurple);
269270
}

0 commit comments

Comments
 (0)