public Player target() { Player player = ArchaeaNPC.FindClosest(npc, findClosest); if (player != null && npc.Distance(player.position) < range) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public Player target() { Player player = ArchaeaNPC.FindClosest(npc); if (player != null) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
public virtual Player nearbyPlayer() { Player player = ArchaeaNPC.FindClosest(npc, false); if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(npcTarget); } }
public override bool PreAI() { target = ArchaeaNPC.FindClosest(npc, false); if (target != null && (!target.active || target.dead)) { targeted = false; } if (target == null) { return(false); } if (Main.mouseRight && npc.Hitbox.Contains(Main.MouseWorld.ToPoint()) && ArchaeaNPC.WithinRange(target.position, new Rectangle(npc.Hitbox.X - 300, npc.Hitbox.Y - 200, 600, 400))) { targeted = true; } npc.immortal = !targeted; npc.target = target.whoAmI; if (!targeted) { return(false); } return(true); }
public override bool PreAI() { if (timer++ > interval) { timer = 0; } if (npc.velocity.Y == 0f && !npc.wet && Collision.SolidCollision(npc.position, npc.width, npc.height + 8)) { npc.velocity = Vector2.Zero; } target = ArchaeaNPC.FindClosest(npc, true); if (target == null) { DefaultActions(); return(false); } inRange = ArchaeaNPC.WithinRange(target.position, ArchaeaNPC.defaultBounds(npc)); switch (pattern) { case Pattern.JustSpawned: if (JustSpawned()) { goto case Pattern.Idle; } return(false); case Pattern.Idle: pattern = Pattern.Idle; if (inRange) { goto case Pattern.Active; } DefaultActions(150, flip); return(true); case Pattern.Active: if (inRange) { if (Hurt()) { goto case Pattern.Attack; } } else if (timer % interval / 4 == 0) { counter++; } if (counter > maxAggro) { counter = 0; goto case Pattern.Idle; } Active(); return(true); case Pattern.Attack: Attack(); return(true); default: return(false); } }