1 - Added some logic into worm NPCs to make them 'work better'.

This commit is contained in:
Andrew Marheine committed 2021-08-08 04:01:23 -05:00
1 parent 5019a0680a
commit 8c738c19fe
54 files changed
+932 -904

No files matched your search

+30 -28
View File
@@ -45,37 +45,42 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
npc.damage = 0;
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<EidolonWyrmHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<EidolonWyrmHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -105,14 +110,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+30 -28
View File
@@ -45,37 +45,42 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
npc.damage = 0;
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<EidolonWyrmHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<EidolonWyrmHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -105,14 +110,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+3
View File
@@ -70,7 +70,10 @@ namespace CalamityMod.NPCs.Abyss
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<EidolonWyrmHeadHuge>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+3
View File
@@ -70,7 +70,10 @@ namespace CalamityMod.NPCs.Abyss
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<EidolonWyrmHeadHuge>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+1 -17
View File
@@ -238,7 +238,7 @@ namespace CalamityMod.NPCs.Abyss
{
npc.alpha = 0;
}
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 6400f || !NPC.AnyNPCs(ModContent.NPCType<EidolonWyrmTail>()))
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 6400f)
{
npc.active = false;
}
@@ -500,22 +500,6 @@ namespace CalamityMod.NPCs.Abyss
{
return false;
}
if (npc.timeLeft <= 0 && Main.netMode != NetmodeID.MultiplayerClient)
{
for (int k = (int)npc.ai[0]; k > 0; k = (int)Main.npc[k].ai[0])
{
if (Main.npc[k].active)
{
Main.npc[k].active = false;
if (Main.netMode == NetmodeID.Server)
{
Main.npc[k].life = 0;
Main.npc[k].netSkip = -1;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
return true;
}
+30 -28
View File
@@ -44,37 +44,42 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
npc.damage = 0;
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<EidolonWyrmHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<EidolonWyrmHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -104,14 +109,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+3
View File
@@ -59,7 +59,10 @@ namespace CalamityMod.NPCs.Abyss
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<EidolonWyrmHeadHuge>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+29 -28
View File
@@ -46,36 +46,40 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<GulperEelHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<GulperEelHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -105,14 +109,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+29 -28
View File
@@ -46,36 +46,40 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<GulperEelHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<GulperEelHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -105,14 +109,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+1 -22
View File
@@ -134,7 +134,7 @@ namespace CalamityMod.NPCs.Abyss
{
npc.alpha = 0;
}
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f || !NPC.AnyNPCs(ModContent.NPCType<GulperEelTail>()))
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f)
{
npc.active = false;
}
@@ -357,27 +357,6 @@ namespace CalamityMod.NPCs.Abyss
}
}
public override bool CheckActive()
{
if (npc.timeLeft <= 0 && Main.netMode != NetmodeID.MultiplayerClient)
{
for (int k = (int)npc.ai[0]; k > 0; k = (int)Main.npc[k].ai[0])
{
if (Main.npc[k].active)
{
Main.npc[k].active = false;
if (Main.netMode == NetmodeID.Server)
{
Main.npc[k].life = 0;
Main.npc[k].netSkip = -1;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
return true;
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(ModContent.BuffType<CrushDepth>(), 300, true);
+29 -28
View File
@@ -46,36 +46,40 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<GulperEelHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<GulperEelHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -105,14 +109,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+29 -28
View File
@@ -44,36 +44,40 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<OarfishHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<OarfishHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -103,14 +107,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+10 -41
View File
@@ -63,21 +63,17 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f) ||
npc.justHit)
{
if ((Main.player[npc.target].Center - npc.Center).Length() < Main.player[npc.target].Calamity().GetAbyssAggro(250f, 150f) || npc.justHit)
detectsPlayer = true;
}
npc.chaseable = detectsPlayer;
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && npc.ai[0] == 0f)
@@ -104,27 +100,21 @@ namespace CalamityMod.NPCs.Abyss
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.AnyNPCs(ModContent.NPCType<OarfishTail>()))
{
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f)
npc.active = false;
}
float num188 = speed;
float num189 = turnSpeed;
@@ -324,27 +314,6 @@ namespace CalamityMod.NPCs.Abyss
}
}
public override bool CheckActive()
{
if (npc.timeLeft <= 0 && Main.netMode != NetmodeID.MultiplayerClient)
{
for (int k = (int)npc.ai[0]; k > 0; k = (int)Main.npc[k].ai[0])
{
if (Main.npc[k].active)
{
Main.npc[k].active = false;
if (Main.netMode == NetmodeID.Server)
{
Main.npc[k].life = 0;
Main.npc[k].netSkip = -1;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
return true;
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(ModContent.BuffType<CrushDepth>(), 90);
+29 -28
View File
@@ -44,36 +44,40 @@ namespace CalamityMod.NPCs.Abyss
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<OarfishHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<OarfishHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -103,14 +107,11 @@ namespace CalamityMod.NPCs.Abyss
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+31 -41
View File
@@ -45,53 +45,46 @@ namespace CalamityMod.NPCs.AquaticScourge
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (npc.velocity.X < 0f)
{
npc.spriteDirection = 1;
}
else if (npc.velocity.X > 0f)
{
npc.spriteDirection = -1;
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<AquaticSeekerHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticSeekerHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
if (Main.player[npc.target].dead)
{
npc.TargetClosest(false);
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -121,14 +114,11 @@ namespace CalamityMod.NPCs.AquaticScourge
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = 1;
}
else if (num191 > 0f)
{
npc.spriteDirection = -1;
}
}
}
+1 -23
View File
@@ -54,7 +54,6 @@ namespace CalamityMod.NPCs.AquaticScourge
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned && npc.ai[0] == 0f)
@@ -98,7 +97,7 @@ namespace CalamityMod.NPCs.AquaticScourge
{
npc.alpha = 0;
}
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f || !NPC.AnyNPCs(ModContent.NPCType<AquaticSeekerTail>()))
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f)
{
npc.active = false;
}
@@ -277,27 +276,6 @@ namespace CalamityMod.NPCs.AquaticScourge
}
}
public override bool CheckActive()
{
if (npc.timeLeft <= 0 && Main.netMode != NetmodeID.MultiplayerClient)
{
for (int k = (int)npc.ai[0]; k > 0; k = (int)Main.npc[k].ai[0])
{
if (Main.npc[k].active)
{
Main.npc[k].active = false;
if (Main.netMode == NetmodeID.Server)
{
Main.npc[k].life = 0;
Main.npc[k].netSkip = -1;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
return true;
}
public override void OnHitPlayer(Player player, int damage, bool crit)
{
player.AddBuff(ModContent.BuffType<Irradiated>(), 120, true);
+31 -41
View File
@@ -45,53 +45,46 @@ namespace CalamityMod.NPCs.AquaticScourge
public override void AI()
{
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (npc.velocity.X < 0f)
{
npc.spriteDirection = 1;
}
else if (npc.velocity.X > 0f)
{
npc.spriteDirection = -1;
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<AquaticSeekerHead>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticSeekerHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
if (Main.player[npc.target].dead)
{
npc.TargetClosest(false);
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -121,14 +114,11 @@ namespace CalamityMod.NPCs.AquaticScourge
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = 1;
}
else if (num191 > 0f)
{
npc.spriteDirection = -1;
}
}
}
+3
View File
@@ -355,7 +355,10 @@ namespace CalamityMod.NPCs
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<AquaticScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+10 -4
View File
@@ -1777,8 +1777,11 @@ namespace CalamityMod.NPCs
bool everyoneDead = true;
for (int num58 = 0; num58 < Main.maxPlayers; num58++)
{
if (Main.player[num58].active && !Main.player[num58].dead)
everyoneDead = false;
if (Main.player[num58].active && !Main.player[num58].dead)
{
everyoneDead = false;
break;
}
}
if (everyoneDead)
@@ -4653,8 +4656,11 @@ namespace CalamityMod.NPCs
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == NPCID.TheDestroyer)
shouldDespawn = false;
if (Main.npc[i].active && Main.npc[i].type == NPCID.TheDestroyer)
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+25 -9
View File
@@ -58,9 +58,7 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
{
npc.TargetClosest(true);
}
Player player = Main.player[npc.target];
bool enraged = npc.Calamity().enraged > 0;
@@ -70,14 +68,32 @@ namespace CalamityMod.NPCs.DesertScourge
float burrowTimeGateValue = death ? 420f : 540f;
bool burrow = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= burrowTimeGateValue;
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DesertScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
+26 -9
View File
@@ -46,19 +46,36 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DesertScourgeHeadSmall>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
+5 -6
View File
@@ -49,19 +49,17 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
if (npc.ai[3] > 0f)
{
npc.realLife = (int)npc.ai[3];
}
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
{
npc.TargetClosest();
}
Player player = Main.player[npc.target];
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
if (!TailSpawned)
{
int Previous = npc.whoAmI;
@@ -85,6 +83,7 @@ namespace CalamityMod.NPCs.DesertScourge
}
TailSpawned = true;
}
int num180 = (int)(npc.position.X / 16f) - 1;
int num181 = (int)((npc.position.X + (float)npc.width) / 16f) + 2;
int num182 = (int)(npc.position.Y / 16f) - 1;
+23 -12
View File
@@ -55,25 +55,36 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
npc.TargetClosest(true);
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DesertScourgeHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
Player player = Main.player[npc.target];
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
+26 -9
View File
@@ -45,19 +45,36 @@ namespace CalamityMod.NPCs.DesertScourge
public override void AI()
{
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DesertScourgeHeadSmall>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
+25 -21
View File
@@ -90,28 +90,32 @@ namespace CalamityMod.NPCs.DevourerofGods
Player player = Main.player[npc.target];
if (npc.velocity.X < 0f)
npc.spriteDirection = -1;
else if (npc.velocity.X > 0f)
npc.spriteDirection = 1;
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DevourerofGodsHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
+16 -10
View File
@@ -75,24 +75,31 @@ namespace CalamityMod.NPCs.DevourerofGods
}
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
flag = true;
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DevourerofGodsHead2>())
{
shouldDespawn = false;
break;
}
}
else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0)
if (!shouldDespawn)
{
flag = true;
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (flag)
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
@@ -103,11 +110,10 @@ namespace CalamityMod.NPCs.DevourerofGods
Main.dust[num935].noGravity = true;
Main.dust[num935].noLight = true;
}
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
+32 -42
View File
@@ -81,23 +81,20 @@ namespace CalamityMod.NPCs.DevourerofGods
public override void AI()
{
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (invinceTime > 0)
{
invinceTime--;
npc.dontTakeDamage = true;
}
else
{
npc.dontTakeDamage = Main.npc[(int)npc.ai[2]].dontTakeDamage;
}
if (Main.npc[(int)npc.ai[2]].dontTakeDamage)
{
invinceTime = 240;
}
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
// Target
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
@@ -105,34 +102,32 @@ namespace CalamityMod.NPCs.DevourerofGods
Player player = Main.player[npc.target];
if (npc.velocity.X < 0f)
{
npc.spriteDirection = -1;
}
else if (npc.velocity.X > 0f)
{
npc.spriteDirection = 1;
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (CalamityGlobalNPC.DoGHead < 0 || !Main.npc[CalamityGlobalNPC.DoGHead].active)
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DevourerofGodsHeadS>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha)
{
npc.alpha -= 42;
if (npc.alpha <= 0 && invinceTime <= 0)
@@ -142,13 +137,11 @@ namespace CalamityMod.NPCs.DevourerofGods
}
}
else
{
npc.alpha = Main.npc[(int)npc.ai[2]].alpha;
}
if (player.dead)
{
npc.TargetClosest(false);
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = player.position.X + (float)(player.width / 2);
float num192 = player.position.Y + (float)(player.height / 2);
@@ -178,14 +171,11 @@ namespace CalamityMod.NPCs.DevourerofGods
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
@@ -83,9 +83,7 @@ namespace CalamityMod.NPCs.DevourerofGods
Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
if (npc.alpha != 0)
{
@@ -96,9 +94,7 @@ namespace CalamityMod.NPCs.DevourerofGods
npc.alpha -= 12;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
@@ -528,10 +528,6 @@ namespace CalamityMod.NPCs.DevourerofGods
}
}
// Despawn
if (!NPC.AnyNPCs(ModContent.NPCType<DevourerofGodsTailS>()))
npc.active = false;
float fallSpeed = enraged ? 21f : malice ? 19.5f : death ? 17.75f : 16f;
if (expertMode)
+30 -27
View File
@@ -53,10 +53,9 @@ namespace CalamityMod.NPCs.DevourerofGods
public override void AI()
{
Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
// Target
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
@@ -74,24 +73,32 @@ namespace CalamityMod.NPCs.DevourerofGods
else
npc.takenDamageMultiplier = 1.25f;
if (npc.velocity.X < 0f)
npc.spriteDirection = -1;
else if (npc.velocity.X > 0f)
npc.spriteDirection = 1;
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DevourerofGodsHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
bool flag = false;
if (npc.ai[1] <= 0f)
flag = true;
else if (Main.npc[(int)npc.ai[1]].life <= 0)
flag = true;
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
@@ -102,16 +109,15 @@ namespace CalamityMod.NPCs.DevourerofGods
Main.dust[num935].noLight = true;
}
}
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
if (player.dead)
{
npc.TargetClosest(false);
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = player.position.X + (float)(player.width / 2);
float num192 = player.position.Y + (float)(player.height / 2);
@@ -141,14 +147,11 @@ namespace CalamityMod.NPCs.DevourerofGods
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+16 -10
View File
@@ -72,24 +72,31 @@ namespace CalamityMod.NPCs.DevourerofGods
}
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
flag = true;
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DevourerofGodsHead2>())
{
shouldDespawn = false;
break;
}
}
else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0)
if (!shouldDespawn)
{
flag = true;
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (flag)
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
@@ -100,11 +107,10 @@ namespace CalamityMod.NPCs.DevourerofGods
Main.dust[num935].noGravity = true;
Main.dust[num935].noLight = true;
}
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f);
+27 -21
View File
@@ -82,7 +82,9 @@ namespace CalamityMod.NPCs.DevourerofGods
public override void AI()
{
if (invinceTime > 0)
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (invinceTime > 0)
{
invinceTime--;
npc.dontTakeDamage = true;
@@ -112,27 +114,31 @@ namespace CalamityMod.NPCs.DevourerofGods
else
npc.takenDamageMultiplier = 1.25f;
if (npc.velocity.X < 0f)
npc.spriteDirection = -1;
else if (npc.velocity.X > 0f)
npc.spriteDirection = 1;
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<DevourerofGodsHeadS>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
bool flag = false;
if (npc.ai[1] <= 0f)
flag = true;
else if (Main.npc[(int)npc.ai[1]].life <= 0)
flag = true;
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (CalamityGlobalNPC.DoGHead < 0 || !Main.npc[CalamityGlobalNPC.DoGHead].active)
npc.active = false;
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha)
{
npc.alpha -= 42;
+3
View File
@@ -98,7 +98,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<ThanatosHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+3
View File
@@ -98,7 +98,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<ThanatosHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
+3
View File
@@ -97,7 +97,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<ThanatosHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
-1
View File
@@ -51,7 +51,6 @@ namespace CalamityMod.NPCs.NormalNPCs
{
npc.TargetClosest(true);
}
npc.velocity.Length();
bool flag = false;
if (npc.ai[1] <= 0f)
{
-1
View File
@@ -52,7 +52,6 @@ namespace CalamityMod.NPCs.NormalNPCs
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (!TailSpawned)
-1
View File
@@ -51,7 +51,6 @@ namespace CalamityMod.NPCs.NormalNPCs
{
npc.TargetClosest(true);
}
npc.velocity.Length();
bool flag = false;
if (npc.ai[1] <= 0f)
{
+24 -16
View File
@@ -56,28 +56,36 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Target
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest(true);
Player player = Main.player[npc.target];
if (player.dead)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
npc.TargetClosest(false);
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<PerforatorHeadLarge>())
{
shouldDespawn = false;
break;
}
}
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
+24 -16
View File
@@ -56,28 +56,36 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
// Target
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
npc.TargetClosest(true);
Player player = Main.player[npc.target];
if (player.dead)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
npc.TargetClosest(false);
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<PerforatorHeadSmall>())
{
shouldDespawn = false;
break;
}
}
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
-4
View File
@@ -119,9 +119,7 @@ namespace CalamityMod.NPCs.Perforator
}
if (npc.ai[3] > 0f)
{
npc.realLife = (int)npc.ai[3];
}
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
@@ -135,9 +133,7 @@ namespace CalamityMod.NPCs.Perforator
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
-4
View File
@@ -90,9 +90,7 @@ namespace CalamityMod.NPCs.Perforator
}
if (npc.ai[3] > 0f)
{
npc.realLife = (int)npc.ai[3];
}
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
@@ -106,9 +104,7 @@ namespace CalamityMod.NPCs.Perforator
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
+26 -9
View File
@@ -54,19 +54,36 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<PerforatorHeadLarge>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
+26 -9
View File
@@ -55,19 +55,36 @@ namespace CalamityMod.NPCs.Perforator
public override void AI()
{
if (!Main.npc[(int)npc.ai[1]].active)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<PerforatorHeadSmall>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
}
+33 -37
View File
@@ -67,39 +67,39 @@ namespace CalamityMod.NPCs.StormWeaver
public override void AI()
{
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (npc.velocity.X < 0f)
{
npc.spriteDirection = -1;
}
else if (npc.velocity.X > 0f)
{
npc.spriteDirection = 1;
}
bool flag1 = false;
if (npc.ai[1] <= 0f)
{
flag1 = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0)
{
flag1 = true;
}
if (flag1)
{
npc.life = 0;
npc.HitEffect(0, 30.0);
npc.checkDead();
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<StormWeaverHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
@@ -110,16 +110,15 @@ namespace CalamityMod.NPCs.StormWeaver
Main.dust[num935].noLight = true;
}
}
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
if (Main.player[npc.target].dead)
{
npc.TargetClosest(false);
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -149,14 +148,11 @@ namespace CalamityMod.NPCs.StormWeaver
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+25 -16
View File
@@ -97,23 +97,32 @@ namespace CalamityMod.NPCs.StormWeaver
if (npc.ai[2] > 0f)
npc.realLife = (int)npc.ai[2];
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<StormWeaverHeadNaked>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
+3 -6
View File
@@ -88,14 +88,12 @@ namespace CalamityMod.NPCs.StormWeaver
npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged;
if (!Main.raining && !BossRushEvent.BossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0)
{
CalamityUtils.StartRain();
}
Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
// Get a target
if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active)
@@ -114,11 +112,10 @@ namespace CalamityMod.NPCs.StormWeaver
Main.dust[num935].noLight = true;
}
}
npc.alpha -= 12;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
if (Main.netMode != NetmodeID.MultiplayerClient)
{
+33 -37
View File
@@ -66,39 +66,39 @@ namespace CalamityMod.NPCs.StormWeaver
public override void AI()
{
Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead)
{
npc.TargetClosest(true);
}
npc.velocity.Length();
if (npc.velocity.X < 0f)
{
npc.spriteDirection = -1;
}
else if (npc.velocity.X > 0f)
{
npc.spriteDirection = 1;
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<StormWeaverHead>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
@@ -109,16 +109,15 @@ namespace CalamityMod.NPCs.StormWeaver
Main.dust[num935].noLight = true;
}
}
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
if (Main.player[npc.target].dead)
{
npc.TargetClosest(false);
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -148,14 +147,11 @@ namespace CalamityMod.NPCs.StormWeaver
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+25 -16
View File
@@ -97,23 +97,32 @@ namespace CalamityMod.NPCs.StormWeaver
if (npc.ai[2] > 0f)
npc.realLife = (int)npc.ai[2];
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<StormWeaverHeadNaked>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
if (npc.alpha != 0)
{
+1 -22
View File
@@ -102,7 +102,7 @@ namespace CalamityMod.NPCs.SunkenSea
{
npc.alpha = 0;
}
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f || !NPC.AnyNPCs(ModContent.NPCType<SeaSerpent5>()))
if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 5600f)
{
npc.active = false;
}
@@ -286,26 +286,5 @@ namespace CalamityMod.NPCs.SunkenSea
Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SeaSerpent/SeaSerpentGore1"), 1f);
}
}
public override bool CheckActive()
{
if (npc.timeLeft <= 0 && Main.netMode != NetmodeID.MultiplayerClient)
{
for (int k = (int)npc.ai[0]; k > 0; k = (int)Main.npc[k].ai[0])
{
if (Main.npc[k].active)
{
Main.npc[k].active = false;
if (Main.netMode == NetmodeID.Server)
{
Main.npc[k].life = 0;
Main.npc[k].netSkip = -1;
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0);
}
}
}
}
return true;
}
}
}
+30 -28
View File
@@ -46,37 +46,42 @@ namespace CalamityMod.NPCs.SunkenSea
public override void AI()
{
Lighting.AddLight(npc.Center, (255 - npc.alpha) * 0f / 255f, (255 - npc.alpha) * 0.30f / 255f, (255 - npc.alpha) * 0.30f / 255f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<SeaSerpent1>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -106,14 +111,11 @@ namespace CalamityMod.NPCs.SunkenSea
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+30 -28
View File
@@ -43,37 +43,42 @@ namespace CalamityMod.NPCs.SunkenSea
public override void AI()
{
Lighting.AddLight(npc.Center, (255 - npc.alpha) * 0f / 255f, (255 - npc.alpha) * 0.30f / 255f, (255 - npc.alpha) * 0.30f / 255f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<SeaSerpent1>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -103,14 +108,11 @@ namespace CalamityMod.NPCs.SunkenSea
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+30 -28
View File
@@ -43,37 +43,42 @@ namespace CalamityMod.NPCs.SunkenSea
public override void AI()
{
Lighting.AddLight(npc.Center, (255 - npc.alpha) * 0f / 255f, (255 - npc.alpha) * 0.30f / 255f, (255 - npc.alpha) * 0.30f / 255f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<SeaSerpent1>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -103,14 +108,11 @@ namespace CalamityMod.NPCs.SunkenSea
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}
+30 -28
View File
@@ -43,37 +43,42 @@ namespace CalamityMod.NPCs.SunkenSea
public override void AI()
{
Lighting.AddLight(npc.Center, (255 - npc.alpha) * 0f / 255f, (255 - npc.alpha) * 0.30f / 255f, (255 - npc.alpha) * 0.30f / 255f);
if (npc.ai[2] > 0f)
{
npc.realLife = (int)npc.ai[2];
}
bool flag = false;
if (npc.ai[1] <= 0f)
{
flag = true;
}
else if (Main.npc[(int)npc.ai[1]].life <= 0)
{
flag = true;
}
if (flag)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
}
if (!NPC.AnyNPCs(ModContent.NPCType<SeaSerpent1>()))
{
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
// Check if other segments are still alive, if not, die
bool shouldDespawn = true;
for (int i = 0; i < Main.maxNPCs; i++)
{
if (Main.npc[i].active && Main.npc[i].type == ModContent.NPCType<SeaSerpent1>())
{
shouldDespawn = false;
break;
}
}
if (!shouldDespawn)
{
if (npc.ai[1] > 0f)
shouldDespawn = false;
else if (Main.npc[(int)npc.ai[1]].life > 0)
shouldDespawn = false;
}
if (shouldDespawn)
{
npc.life = 0;
npc.HitEffect(0, 10.0);
npc.checkDead();
npc.active = false;
}
if (Main.npc[(int)npc.ai[1]].alpha < 128)
{
npc.alpha -= 42;
if (npc.alpha < 0)
{
npc.alpha = 0;
}
}
Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
float num191 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2);
float num192 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2);
@@ -103,14 +108,11 @@ namespace CalamityMod.NPCs.SunkenSea
npc.velocity = Vector2.Zero;
npc.position.X = npc.position.X + num191;
npc.position.Y = npc.position.Y + num192;
if (num191 < 0f)
{
npc.spriteDirection = -1;
}
else if (num191 > 0f)
{
npc.spriteDirection = 1;
}
}
}