Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MechSpawn()

static bool Terraria.NPC.MechSpawn ( float x,
float y,
int type )
inlinestatic

Definition at line 1561 of file NPC.cs.

1562 {
1563 int num = 0;
1564 int num2 = 0;
1565 int num3 = 0;
1566 for (int i = 0; i < 200; i++)
1567 {
1568 if (!Main.npc[i].active)
1569 {
1570 continue;
1571 }
1572 bool flag = false;
1573 if (Main.npc[i].type == type)
1574 {
1575 flag = true;
1576 }
1577 else if (type == 74 || type == 297 || type == 298)
1578 {
1579 if (Main.npc[i].type == 74 || Main.npc[i].type == 297 || Main.npc[i].type == 298)
1580 {
1581 flag = true;
1582 }
1583 }
1584 else if (type == 46 || type == 540 || type == 303 || type == 337)
1585 {
1586 if (Main.npc[i].type == 46 || Main.npc[i].type == 540 || Main.npc[i].type == 303 || Main.npc[i].type == 337)
1587 {
1588 flag = true;
1589 }
1590 }
1591 else if (type == 362 || type == 364)
1592 {
1593 if (Main.npc[i].type == 362 || Main.npc[i].type == 363 || Main.npc[i].type == 364 || Main.npc[i].type == 365)
1594 {
1595 flag = true;
1596 }
1597 }
1598 else if (type == 602)
1599 {
1600 if (Main.npc[i].type == 602 || Main.npc[i].type == 603)
1601 {
1602 flag = true;
1603 }
1604 }
1605 else if (type == 608)
1606 {
1607 if (Main.npc[i].type == 608 || Main.npc[i].type == 609)
1608 {
1609 flag = true;
1610 }
1611 }
1612 else if (type == 616 || type == 617)
1613 {
1614 if (Main.npc[i].type == 616 || Main.npc[i].type == 617)
1615 {
1616 flag = true;
1617 }
1618 }
1619 else if (type == 55 && Main.npc[i].type == 230)
1620 {
1621 flag = true;
1622 }
1623 else if (NPCID.Sets.IsDragonfly[type] && NPCID.Sets.IsDragonfly[Main.npc[i].type])
1624 {
1625 flag = true;
1626 }
1627 if (flag)
1628 {
1629 num++;
1630 Vector2 vector = new Vector2(x, y);
1631 float num4 = Main.npc[i].position.X - vector.X;
1632 float num5 = Main.npc[i].position.Y - vector.Y;
1633 float num6 = (float)Math.Sqrt(num4 * num4 + num5 * num5);
1634 if (num6 < 200f)
1635 {
1636 num2++;
1637 }
1638 if (num6 < 600f)
1639 {
1640 num3++;
1641 }
1642 }
1643 }
1644 if (num2 >= 3 || num3 >= 6 || num >= 10)
1645 {
1646 return false;
1647 }
1648 return true;
1649 }
static double Sqrt(double d)
static bool[] IsDragonfly
Definition NPCID.cs:4164
int type
Definition NPC.cs:445

References Terraria.ID.NPCID.Sets.IsDragonfly, Terraria.Main.npc, System.Math.Sqrt(), Terraria.NPC.type, and Microsoft.Xna.Framework.Graphics.Vector2.