More npc iterators
This commit is contained in:
1 parent
77847a7e01
commit
1042ab2393
23 files changed
+93
-115
No files matched your search
@@ -4846,10 +4846,9 @@ namespace CalamityMod.NPCs
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC = Main.npc[j];
|
||||
if (nPC.active && !nPC.buffImmune[BuffType<Plague>()] && npc.Distance(nPC.Center) < 100f && !nPC.dontTakeDamage && nPC.lifeMax > 5 && !nPC.friendly && !nPC.townNPC)
|
||||
if (!nPC.buffImmune[BuffType<Plague>()] && npc.Distance(nPC.Center) < 100f && !nPC.dontTakeDamage && nPC.lifeMax > 5 && !nPC.friendly && !nPC.townNPC)
|
||||
nPC.AddBuff(BuffType<Plague>(), 300);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,13 +292,13 @@ namespace CalamityMod.NPCs.StormWeaver
|
||||
|
||||
if ((double)NPC.position.Y < Main.topWorld + 16f)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].active && (Main.npc[j].type == ModContent.NPCType<StormWeaverBody>()
|
||||
|| Main.npc[j].type == ModContent.NPCType<StormWeaverHead>()
|
||||
|| Main.npc[j].type == ModContent.NPCType<StormWeaverTail>()))
|
||||
if ((n.type == ModContent.NPCType<StormWeaverBody>()
|
||||
|| n.type == ModContent.NPCType<StormWeaverHead>()
|
||||
|| n.type == ModContent.NPCType<StormWeaverTail>()))
|
||||
{
|
||||
Main.npc[j].active = false;
|
||||
n.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,13 +306,13 @@ namespace CalamityMod.NPCs.StormWeaver
|
||||
|
||||
if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 10000f && NPC.life > 0)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].type == ModContent.NPCType<StormWeaverBody>()
|
||||
|| Main.npc[j].type == ModContent.NPCType<StormWeaverHead>()
|
||||
|| Main.npc[j].type == ModContent.NPCType<StormWeaverTail>())
|
||||
if (n.type == ModContent.NPCType<StormWeaverBody>()
|
||||
|| n.type == ModContent.NPCType<StormWeaverHead>()
|
||||
|| n.type == ModContent.NPCType<StormWeaverTail>())
|
||||
{
|
||||
Main.npc[j].active = false;
|
||||
n.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,13 +164,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
|
||||
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == npc.whoAmI)
|
||||
if (n.type == NPCID.CultistBossClone && n.ai[3] == npc.whoAmI)
|
||||
{
|
||||
Main.npc[j].life = 0;
|
||||
Main.npc[j].HitEffect(0, 10.0);
|
||||
Main.npc[j].active = false;
|
||||
n.life = 0;
|
||||
n.HitEffect(0, 10.0);
|
||||
n.active = false;
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
NetMessage.SendData(MessageID.DamageNPC, -1, -1, null, npc.whoAmI, -1f, 0f, 0f, 0, 0, 0);
|
||||
@@ -568,10 +568,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
|
||||
if ((npc.ai[1] == 20f & isCultist) && Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
List<int> list5 = new List<int>();
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].active && Main.npc[j].type == NPCID.CultistBossClone && Main.npc[j].ai[3] == npc.whoAmI)
|
||||
list5.Add(j);
|
||||
if (n.type == NPCID.CultistBossClone && n.ai[3] == npc.whoAmI)
|
||||
list5.Add(n.whoAmI);
|
||||
}
|
||||
|
||||
foreach (int current5 in list5)
|
||||
@@ -825,7 +825,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (n.type == NPCID.CultistBossClone && n.ai[3] == npc.whoAmI)
|
||||
list7.Add(i);
|
||||
list7.Add(n.whoAmI);
|
||||
}
|
||||
|
||||
foreach (int current6 in list7)
|
||||
|
||||
@@ -1726,24 +1726,21 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
|
||||
|
||||
// Fly towards Moon Lord Head and stay away from other True Eyes
|
||||
float freeEyeAccel = 0.5f;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].active)
|
||||
if (n.whoAmI != npc.whoAmI && n.type == npc.type)
|
||||
{
|
||||
if (j != npc.whoAmI && Main.npc[j].type == npc.type)
|
||||
if (Vector2.Distance(npc.Center, n.Center) < 150f)
|
||||
{
|
||||
if (Vector2.Distance(npc.Center, Main.npc[j].Center) < 150f)
|
||||
{
|
||||
if (npc.position.X < Main.npc[j].position.X)
|
||||
npc.velocity.X = npc.velocity.X - freeEyeAccel;
|
||||
else
|
||||
npc.velocity.X = npc.velocity.X + freeEyeAccel;
|
||||
|
||||
if (npc.position.Y < Main.npc[j].position.Y)
|
||||
npc.velocity.Y = npc.velocity.Y - freeEyeAccel;
|
||||
else
|
||||
npc.velocity.Y = npc.velocity.Y + freeEyeAccel;
|
||||
}
|
||||
if (npc.position.X < n.position.X)
|
||||
npc.velocity.X = npc.velocity.X - freeEyeAccel;
|
||||
else
|
||||
npc.velocity.X = npc.velocity.X + freeEyeAccel;
|
||||
|
||||
if (npc.position.Y < n.position.Y)
|
||||
npc.velocity.Y = npc.velocity.Y - freeEyeAccel;
|
||||
else
|
||||
npc.velocity.Y = npc.velocity.Y + freeEyeAccel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,11 +402,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses
|
||||
{
|
||||
int hungryAmt = 0;
|
||||
float[] array = new float[10];
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (hungryAmt < 10 && Main.npc[j].active && Main.npc[j].type == NPCID.TheHungry)
|
||||
if (hungryAmt < 10 && n.type == NPCID.TheHungry)
|
||||
{
|
||||
array[hungryAmt] = Main.npc[j].ai[0];
|
||||
array[hungryAmt] = n.ai[0];
|
||||
hungryAmt++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ namespace CalamityMod.Projectiles.Melee
|
||||
}
|
||||
else if (homeTracker == 1)
|
||||
{
|
||||
int inc;
|
||||
Projectile.rotation -= 0.104719758f;
|
||||
Vector2 projCenter = Projectile.Center;
|
||||
float homingRange = 150f;
|
||||
@@ -76,21 +75,20 @@ namespace CalamityMod.Projectiles.Melee
|
||||
int npcTracker = 0;
|
||||
if (Projectile.ai[1] == 0f)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j = inc + 1)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false))
|
||||
if (n.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
Vector2 npcCenter = Main.npc[j].Center;
|
||||
if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height))
|
||||
Vector2 npcCenter = n.Center;
|
||||
if (Projectile.Distance(npcCenter) < homingRange && Collision.CanHit(new Vector2(Projectile.position.X + (float)(Projectile.width / 2), Projectile.position.Y + (float)(Projectile.height / 2)), 1, 1, n.position, n.width, n.height))
|
||||
{
|
||||
homingRange = Projectile.Distance(npcCenter);
|
||||
projCenter = npcCenter;
|
||||
isHoming = true;
|
||||
npcTracker = j;
|
||||
npcTracker = n.whoAmI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
inc = j;
|
||||
}
|
||||
if (isHoming)
|
||||
{
|
||||
|
||||
@@ -74,21 +74,19 @@ namespace CalamityMod.Projectiles.Melee
|
||||
else
|
||||
{
|
||||
float homingRange = 1000f;
|
||||
int inc;
|
||||
for (int j = 0; j < Main.maxNPCs; j = inc + 1)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false))
|
||||
if (n.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float targetX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
|
||||
float targetY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
|
||||
float targetX = n.position.X + (float)(n.width / 2);
|
||||
float targetY = n.position.Y + (float)(n.height / 2);
|
||||
float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - targetX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - targetY);
|
||||
if (targetDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height))
|
||||
if (targetDist < homingRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height))
|
||||
{
|
||||
homingRange = targetDist;
|
||||
Projectile.ai[0] = (float)j;
|
||||
Projectile.ai[0] = (float)n.whoAmI;
|
||||
}
|
||||
}
|
||||
inc = j;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,10 +69,9 @@ namespace CalamityMod.Projectiles.Pets
|
||||
SoundEngine.PlaySound(SoundID.Zombie15, Projectile.position); //mouse squeak sound
|
||||
|
||||
float radius = 240f; // 15 blocks
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
NPC npc = Main.npc[j];
|
||||
if (npc.active && !npc.dontTakeDamage && Vector2.Distance(Projectile.Center, npc.Center) <= radius)
|
||||
if (!npc.dontTakeDamage && Vector2.Distance(Projectile.Center, npc.Center) <= radius)
|
||||
{
|
||||
if (npc.Calamity().ladHearts <= 0)
|
||||
npc.Calamity().ladHearts = CalamityUtils.SecondsToFrames(9f);
|
||||
|
||||
@@ -60,30 +60,30 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
float projX = Projectile.Center.X;
|
||||
float projY = Projectile.Center.Y;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, Main.npc[j].Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses)
|
||||
if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses)
|
||||
{
|
||||
float npcCenterX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
|
||||
float npcCenterY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
|
||||
float npcCenterX = n.position.X + (float)(n.width / 2);
|
||||
float npcCenterY = n.position.Y + (float)(n.height / 2);
|
||||
float targetDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY);
|
||||
if (targetDist < 600f)
|
||||
{
|
||||
if (Main.npc[j].position.X < projX)
|
||||
if (n.position.X < projX)
|
||||
{
|
||||
Main.npc[j].velocity.X += 0.25f;
|
||||
n.velocity.X += 0.25f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.npc[j].velocity.X -= 0.25f;
|
||||
n.velocity.X -= 0.25f;
|
||||
}
|
||||
if (Main.npc[j].position.Y < projY)
|
||||
if (n.position.Y < projY)
|
||||
{
|
||||
Main.npc[j].velocity.Y += 0.25f;
|
||||
n.velocity.Y += 0.25f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.npc[j].velocity.Y -= 0.25f;
|
||||
n.velocity.Y -= 0.25f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,8 @@ namespace CalamityMod.Projectiles.Rogue
|
||||
float targetDistStore;
|
||||
Vector2 homingPos = Projectile.position;
|
||||
bool isHoming = false;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC2 in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC2 = Main.npc[j];
|
||||
if (nPC2.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center);
|
||||
|
||||
@@ -179,12 +179,12 @@ namespace CalamityMod.Projectiles.Summon
|
||||
float projY = Projectile.position.Y;
|
||||
float homeDistance = 1200f;
|
||||
bool isInRange = false;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false))
|
||||
if (n.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float npcX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
|
||||
float npcY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
|
||||
float npcX = n.position.X + (float)(n.width / 2);
|
||||
float npcY = n.position.Y + (float)(n.height / 2);
|
||||
float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY);
|
||||
if (npcDistance < homeDistance)
|
||||
{
|
||||
|
||||
@@ -111,14 +111,14 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!isInRange)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false))
|
||||
if (n.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float otherNPCX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
|
||||
float otherNPCY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
|
||||
float otherNPCX = n.position.X + (float)(n.width / 2);
|
||||
float otherNPCY = n.position.Y + (float)(n.height / 2);
|
||||
float otherNPCDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - otherNPCX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - otherNPCY);
|
||||
if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height))
|
||||
if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height))
|
||||
{
|
||||
attackRange = otherNPCDist;
|
||||
projX = otherNPCX;
|
||||
|
||||
@@ -103,14 +103,14 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false))
|
||||
if (n.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float otherNPCX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
|
||||
float otherNPCY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
|
||||
float otherNPCX = n.position.X + (float)(n.width / 2);
|
||||
float otherNPCY = n.position.Y + (float)(n.height / 2);
|
||||
float otherNPCDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - otherNPCX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - otherNPCY);
|
||||
if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height))
|
||||
if (otherNPCDist < attackRange && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height))
|
||||
{
|
||||
attackRange = otherNPCDist;
|
||||
projX = otherNPCX;
|
||||
|
||||
@@ -89,9 +89,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
NPC npc = Main.npc[j];
|
||||
if (npc.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float npcX = npc.position.X + (float)(npc.width / 2);
|
||||
|
||||
@@ -117,9 +117,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!chaseNPC)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC npcTarget in Main.ActiveNPCs)
|
||||
{
|
||||
NPC npcTarget = Main.npc[j];
|
||||
if (npcTarget.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float targetDist = Vector2.Distance(npcTarget.Center, Projectile.Center);
|
||||
|
||||
@@ -69,9 +69,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC2 in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC2 = Main.npc[j];
|
||||
if (nPC2.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center);
|
||||
@@ -80,7 +79,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
attackDist = targetDist;
|
||||
projPos = nPC2.Center;
|
||||
canAttack = true;
|
||||
target = j;
|
||||
target = nPC2.whoAmI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC2 in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC2 = Main.npc[j];
|
||||
if (nPC2.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center);
|
||||
|
||||
@@ -106,10 +106,9 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC2 in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC2 = Main.npc[j];
|
||||
if ((nPC2.CanBeChasedBy(Projectile, false) || nPC2.type == NPCID.DukeFishron) && nPC2.active)
|
||||
if (nPC2.CanBeChasedBy(Projectile, false) || nPC2.type == NPCID.DukeFishron)
|
||||
{
|
||||
float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center);
|
||||
if (!canAttack && targetDist < attackRange)
|
||||
@@ -117,7 +116,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
attackRange = targetDist;
|
||||
projPos = nPC2.Center;
|
||||
canAttack = true;
|
||||
targetIndex = j;
|
||||
targetIndex = nPC2.whoAmI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,20 +102,20 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (Main.npc[j].CanBeChasedBy(Projectile, false))
|
||||
if (n.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float npcX = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
|
||||
float npcY = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
|
||||
float npcX = n.position.X + (float)(n.width / 2);
|
||||
float npcY = n.position.Y + (float)(n.height / 2);
|
||||
float npcDist = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcY);
|
||||
if (npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height))
|
||||
if (npcDist < attackDistance && Collision.CanHit(Projectile.position, Projectile.width, Projectile.height, n.position, n.width, n.height))
|
||||
{
|
||||
attackDistance = npcDist;
|
||||
projX = npcX;
|
||||
projY = npcY;
|
||||
canAttack = true;
|
||||
target = j;
|
||||
target = n.whoAmI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +106,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack && !passive)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC2 in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC2 = Main.npc[j];
|
||||
if (nPC2.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float targetDist = Vector2.Distance(nPC2.Center, Projectile.Center);
|
||||
|
||||
@@ -90,9 +90,8 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
if (!canAttack)
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
NPC npc = Main.npc[j];
|
||||
if (npc.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float npcX = npc.position.X + (float)(npc.width / 2);
|
||||
|
||||
@@ -132,9 +132,8 @@ namespace CalamityMod.Projectiles.Typeless
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
foreach (NPC nPC2 in Main.ActiveNPCs)
|
||||
{
|
||||
NPC nPC2 = Main.npc[j];
|
||||
if (nPC2.CanBeChasedBy(Projectile, false))
|
||||
{
|
||||
float npcDist = Vector2.Distance(nPC2.Center, Projectile.Center);
|
||||
|
||||
@@ -71,12 +71,8 @@ namespace CalamityMod.Systems
|
||||
|
||||
Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight);
|
||||
int musicDistance = MusicDistance * 2;
|
||||
for (int j = 0; j < Main.maxNPCs; j++)
|
||||
{
|
||||
NPC npc = Main.npc[j];
|
||||
if (!npc.active)
|
||||
continue;
|
||||
|
||||
foreach (NPC npc in Main.ActiveNPCs)
|
||||
{
|
||||
bool inList = false;
|
||||
if (npc.type == NPCType)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user