1 - Fixed Desert Scourge body and tail not showing up in mp.

2 - Fixed certain worms having despawn issues in mp.
This commit is contained in:
mountaindrew10 committed 2024-05-15 14:54:31 -05:00
1 parent ef2b524df1
commit 22fb323008
7 files changed
+58 -141

No files matched your search

+15 -22
View File
@@ -118,19 +118,18 @@ namespace CalamityMod.NPCs.Abyss
}
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead)
{
NPC.TargetClosest(true);
}
NPC.TargetClosest();
if (NPC.justHit || detectsPlayer || Main.player[NPC.target].chaosState || adultWyrmAlive || (Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f))
{
detectsPlayer = true;
NPC.damage = Main.expertMode ? 340 : 170;
}
else
{
NPC.damage = 0;
}
NPC.chaseable = detectsPlayer;
if (detectsPlayer)
{
if (NPC.soundDelay <= 0)
@@ -142,14 +141,12 @@ namespace CalamityMod.NPCs.Abyss
else
{
if (Main.rand.NextBool(900))
{
SoundEngine.PlaySound(roar, NPC.Center);
}
}
if (NPC.ai[2] > 0f)
{
NPC.realLife = (int)NPC.ai[2];
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && NPC.ai[0] == 0f)
@@ -161,18 +158,13 @@ namespace CalamityMod.NPCs.Abyss
if (segments >= 0 && segments < minLength)
{
if (segments % 2 == 0)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<EidolonWyrmBody>(), NPC.whoAmI);
}
else
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<EidolonWyrmBodyAlt>(), NPC.whoAmI);
}
}
else
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<EidolonWyrmTail>(), NPC.whoAmI);
}
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = (float)NPC.whoAmI;
Main.npc[lol].ai[1] = (float)Previous;
@@ -180,17 +172,16 @@ namespace CalamityMod.NPCs.Abyss
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
if (NPC.velocity.X < 0f)
{
NPC.spriteDirection = -1;
}
else if (NPC.velocity.X > 0f)
{
NPC.spriteDirection = 1;
}
if (Main.player[NPC.target].dead)
{
NPC.TargetClosest(false);
@@ -208,14 +199,16 @@ namespace CalamityMod.NPCs.Abyss
}
}
}
NPC.alpha -= 42;
if (NPC.alpha < 0)
{
NPC.alpha = 0;
}
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f)
{
NPC.active = false;
NPC.TargetClosest(false);
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f)
NPC.active = false;
}
float currentSpeed = speed;
+15 -24
View File
@@ -115,19 +115,16 @@ namespace CalamityMod.NPCs.Abyss
}
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead)
{
NPC.TargetClosest(true);
}
if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) ||
NPC.justHit)
{
NPC.TargetClosest();
if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || NPC.justHit)
detectsPlayer = true;
}
NPC.chaseable = detectsPlayer;
if (NPC.ai[2] > 0f)
{
NPC.realLife = (int)NPC.ai[2];
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && NPC.ai[0] == 0f)
@@ -139,18 +136,13 @@ namespace CalamityMod.NPCs.Abyss
if (segments >= 0 && segments < minLength)
{
if (segments == 0)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<GulperEelBody>(), NPC.whoAmI);
}
else
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<GulperEelBodyAlt>(), NPC.whoAmI);
}
}
else
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<GulperEelTail>(), NPC.whoAmI);
}
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = (float)NPC.whoAmI;
Main.npc[lol].ai[1] = (float)Previous;
@@ -158,29 +150,28 @@ namespace CalamityMod.NPCs.Abyss
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
if (NPC.velocity.X < 0f)
{
NPC.spriteDirection = 1;
}
else if (NPC.velocity.X > 0f)
{
NPC.spriteDirection = -1;
}
if (Main.player[NPC.target].dead)
{
NPC.TargetClosest(false);
}
NPC.alpha -= 42;
if (NPC.alpha < 0)
{
NPC.alpha = 0;
}
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
{
NPC.active = false;
NPC.TargetClosest(false);
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
NPC.active = false;
}
float currentSpeed = speed;
+5 -1
View File
@@ -155,7 +155,11 @@ namespace CalamityMod.NPCs.Abyss
NPC.alpha = 0;
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
NPC.active = false;
{
NPC.TargetClosest(false);
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
NPC.active = false;
}
float currentSpeed = speed;
float currentTurnSpeed = turnSpeed;
+3 -26
View File
@@ -69,23 +69,6 @@ namespace CalamityMod.NPCs.DesertScourge
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false;
public override void SendExtraAI(BinaryWriter writer)
{
// Frame syncs
writer.Write(NPC.frame.X);
writer.Write(NPC.frame.Y);
writer.Write(NPC.frame.Width);
writer.Write(NPC.frame.Height);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
// Frame syncs
Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
if (frame.Width > 0 && frame.Height > 0)
NPC.frame = frame;
}
public override void AI()
{
bool bossRush = BossRushEvent.BossRushActive;
@@ -104,10 +87,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 1f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture2.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture2.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height());
NPC.netUpdate = true;
@@ -121,10 +102,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 2f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture3.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture3.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height());
NPC.netUpdate = true;
@@ -138,10 +117,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 3f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture4.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture4.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height());
NPC.netUpdate = true;
+3 -26
View File
@@ -69,23 +69,6 @@ namespace CalamityMod.NPCs.DesertScourge
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false;
public override void SendExtraAI(BinaryWriter writer)
{
// Frame syncs
writer.Write(NPC.frame.X);
writer.Write(NPC.frame.Y);
writer.Write(NPC.frame.Width);
writer.Write(NPC.frame.Height);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
// Frame syncs
Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
if (frame.Width > 0 && frame.Height > 0)
NPC.frame = frame;
}
public override void AI()
{
bool bossRush = BossRushEvent.BossRushActive;
@@ -104,10 +87,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 1f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture2.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture2.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height());
NPC.netUpdate = true;
@@ -121,10 +102,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 2f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture3.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture3.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height());
NPC.netUpdate = true;
@@ -138,10 +117,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 3f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture4.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture4.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height());
NPC.netUpdate = true;
+3 -20
View File
@@ -80,23 +80,12 @@ namespace CalamityMod.NPCs.DesertScourge
{
writer.Write(NPC.alpha);
writer.Write(NPC.dontTakeDamage);
// Frame syncs
writer.Write(NPC.frame.X);
writer.Write(NPC.frame.Y);
writer.Write(NPC.frame.Width);
writer.Write(NPC.frame.Height);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
NPC.alpha = reader.ReadInt32();
NPC.dontTakeDamage = reader.ReadBoolean();
// Frame syncs
Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
if (frame.Width > 0 && frame.Height > 0)
NPC.frame = frame;
}
public override void AI()
@@ -117,10 +106,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 1f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture2.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture2.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height());
NPC.netUpdate = true;
@@ -134,10 +121,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 2f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture3.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture3.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height());
NPC.netUpdate = true;
@@ -151,10 +136,8 @@ namespace CalamityMod.NPCs.DesertScourge
NPC.ai[3] = 3f;
NPC.position = NPC.Center;
//NPC.width = (int)(BodyTexture4.Width() * NPC.scale);
//NPC.height = (int)(BodyTexture4.Height() * NPC.scale);
NPC.position -= NPC.Size * 0.5f;
NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height());
NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height());
NPC.netUpdate = true;
+14 -22
View File
@@ -84,15 +84,14 @@ namespace CalamityMod.NPCs.SunkenSea
}
}
Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f);
Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 0.3f / 255f, (255 - NPC.alpha) * 0.3f / 255f);
if (NPC.ai[2] > 0f)
{
NPC.realLife = (int)NPC.ai[2];
}
if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead)
{
NPC.TargetClosest(true);
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && NPC.ai[0] == 0f)
@@ -102,21 +101,14 @@ namespace CalamityMod.NPCs.SunkenSea
{
int lol = 0;
if (segment == 0 || segment == 1 || segment == 4 || segment == 5)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent2>(), NPC.whoAmI);
}
else if (segment == 2 || segment == 3 || segment == 6)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent3>(), NPC.whoAmI);
}
else if (segment == 7)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent4>(), NPC.whoAmI);
}
else if (segment == 8)
{
lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType<SeaSerpent5>(), NPC.whoAmI);
}
Main.npc[lol].realLife = NPC.whoAmI;
Main.npc[lol].ai[2] = (float)NPC.whoAmI;
Main.npc[lol].ai[1] = (float)Previous;
@@ -124,30 +116,30 @@ namespace CalamityMod.NPCs.SunkenSea
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0);
Previous = lol;
}
TailSpawned = true;
}
}
if (NPC.velocity.X < 0f)
{
NPC.spriteDirection = -1;
}
else if (NPC.velocity.X > 0f)
{
NPC.spriteDirection = 1;
}
if (Main.player[NPC.target].dead)
{
NPC.TargetClosest(false);
}
NPC.alpha -= 42;
if (NPC.alpha < 0)
{
NPC.alpha = 0;
}
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
{
NPC.active = false;
NPC.TargetClosest(false);
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f)
NPC.active = false;
}
float currentSpeed = speed;
float currentTurnSpeed = turnSpeed;
Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f);