public override void AI() { bool exists = false; int Berramyr = 0; for (int i = 0; i < Main.npc.Length - 1; i++) { if (Main.npc[i].type == mod.NPCType("Berramyr")) { Berramyr = i; exists = true; break; } } if (Main.npc[Berramyr].life < 1 || !exists) { npc.life -= npc.life; npc.checkDead(); } double deg = (double)npc.ai[0]; double rad = deg * (Math.PI / 180); double dist = 150; if (npc.ai[2] == 0) { npc.position.X = Main.npc[Berramyr].Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; npc.position.Y = Main.npc[Berramyr].Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; } if (npc.ai[2] == 1) { npc.position.Y = Main.npc[Berramyr].Center.Y - (npc.height / 2); npc.position.X = npc.ai[3]; for (int i = 0; i < 255; i++) { Player p = Main.player[i]; if (p.active && !p.dead) { if (p.position.X < npc.position.X) { p.position = p.oldPosition; } } } } if (npc.ai[2] == 2) { MNPC.entrapment(npc, Berramyr, rad); } npc.ai[0] += 1f; npc.netUpdate = true; }
public override void AI() { bool exists = false; int Berramyr = 0; for (int i = 0; i < Main.npc.Length - 1; i++) { if (Main.npc[i].type == mod.NPCType("Berramyr")) { Berramyr = i; exists = true; break; } } if (Main.npc[Berramyr].life < 1 || !exists) { npc.life -= npc.life; npc.checkDead(); } double deg = (double)npc.ai[0]; double rad = deg * (Math.PI / 180); double dist = 150; npc.position.X = Main.npc[Berramyr].Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; npc.position.Y = Main.npc[Berramyr].Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; if (npc.ai[2] == 1) { if (npc.ai[0] % 30 == 0) { for (int i = 225; i <= 315; i += 15) { float shotAngle = (float)(i * (Math.PI / 180)); float speedY = (float)Math.Sin(shotAngle) * 10f; float speedX = (float)Math.Cos(shotAngle) * 10f; int proj1 = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, speedX, -speedY, mod.ProjectileType("Berrabullet"), 10, 0f, Main.myPlayer, 0f, 0f); Main.projectile[proj1].timeLeft = 9999; Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 11); } } } if (npc.ai[2] == 2) { MNPC.entrapment(npc, Berramyr, rad); } npc.ai[0] += 1f; npc.netUpdate = true; }
public override void AI() { bool exists = false; bool hasFired = false; int Berramyr = 0; int friendProjCount = 0; for (int i = 0; i < Main.npc.Length - 1; i++) { if (Main.npc[i].type == mod.NPCType("Berramyr")) { Berramyr = i; exists = true; break; } } if (Main.npc[Berramyr].life < 1 || !exists) { npc.life -= npc.life; npc.checkDead(); } if (!npc.dontTakeDamage) { for (int i = 0; i < 255; i++) { Player p = Main.player[i]; if (p.channel) { p.channel = false; } } for (int i = 0; i < 1000; i++) { Projectile p = Main.projectile[i]; if (p.friendly && p.active && !p.melee && !p.minion) { if (npc.ai[0] % 300 == 0 && !hasFired) { float shootToX = p.Center.X - npc.Center.X; float shootToY = p.Center.Y - npc.Center.Y; float distance = (float)Math.Sqrt((double)(shootToX * shootToX + shootToY * shootToY)); float speed = 10f / distance; shootToX *= speed; shootToY *= speed; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, shootToX, shootToY, mod.ProjectileType("Lyndwave"), 0, 0, Main.myPlayer, 0f, 0f); hasFired = true; } friendProjCount++; } } if (friendProjCount > 5) { for (int i = 0; i < 1000; i++) { Projectile p = Main.projectile[i]; if (p.friendly && p.active && !p.melee && !p.minion) { p.aiStyle = -2; p.penetrate = 1; p.tileCollide = true; } } } } double deg = (double)npc.ai[0]; double rad = deg * (Math.PI / 180); double dist = 150; if (npc.ai[2] == 0) { npc.position.X = Main.npc[Berramyr].Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; npc.position.Y = Main.npc[Berramyr].Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; } if (npc.ai[2] == 1) { npc.position.Y = Main.npc[Berramyr].Center.Y - (npc.height / 2); npc.position.X = npc.ai[3]; for (int i = 0; i < 255; i++) { Player p = Main.player[i]; if (p.active && !p.dead) { if (p.position.X > npc.position.X) { p.position = p.oldPosition; } } } } if (npc.ai[2] == 2) { MNPC.entrapment(npc, Berramyr, rad); } npc.ai[0] += 1f; npc.netUpdate = true; }