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 Player target() { Player player = ArchaeaNPC.FindClosest(npc, false, 1000); if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(Main.player[Main.myPlayer]); } }
internal Player target() { Player player = ArchaeaNPC.FindClosest(npc, maxRange, 2048); if (player != null) { maxRange = false; 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 Player target() { Player player = ArchaeaNPC.FindClosest(npc, true); 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, firstTarget); firstTarget = false; if (player != null && player.active && !player.dead) { npc.target = player.whoAmI; return(player); } else { return(Main.player[npc.target]); } }
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 void AI() { int attackTime = 180 + 90 * maxAttacks; if (timer++ > 60 + attackTime) { timer = 0; } ArchaeaNPC.SlowDown(ref npc.velocity, 0.1f); if (!init) { npc.target = ArchaeaNPC.FindClosest(npc, true).whoAmI; SyncNPC(npc.position.X, npc.position.Y); dustType = 6; var dusts = ArchaeaNPC.DustSpread(npc.Center, 1, 1, dustType, 10); foreach (Dust d in dusts) { d.noGravity = true; } init = true; } if (!fade) { if (npc.alpha > 0) { npc.alpha -= 255 / 60; } } else { if (npc.alpha < 255) { npc.alpha += 255 / 50; } else { timer = attackTime + 50; move = ArchaeaNPC.FindAny(npc, npcTarget, true); if (move != Vector2.Zero) { SyncNPC(move.X, move.Y); var dusts = ArchaeaNPC.DustSpread(npc.Center - new Vector2(npc.width / 4, npc.height / 4), npc.width / 2, npc.height / 2, dustType, 10, 2.4f); foreach (Dust d in dusts) { d.noGravity = true; } fade = false; timer = 0; } } } if (timer > 180 && timer <= attackTime) { OrbGrow(); if (timer >= 180 + 60 && timer % 90 == 0) { Attack(); } } if (timer >= attackTime) { fade = true; } else { fade = false; } }
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); } }
private bool SinglePlayerAI() { if (timer++ > elapse) { timer = 0; } ArchaeaNPC.SlowDown(ref npc.velocity); switch (pattern) { case PatternID.JustSpawned: npc.target = ArchaeaNPC.FindClosest(npc, true).whoAmI; if (JustSpawned()) { goto case PatternID.FadeIn; } break; case PatternID.FadeIn: pattern = PatternID.FadeIn; if (npc.alpha > 0) { npc.alpha -= 5; break; } else { goto case PatternID.Idle; } case PatternID.FadeOut: pattern = PatternID.FadeOut; if (npc.alpha < 255) { npc.immortal = true; npc.alpha += 5; break; } goto case PatternID.Teleport; case PatternID.Teleport: pattern = PatternID.Teleport; move = ArchaeaNPC.FindAny(npc, npcTarget); if (move != Vector2.Zero) { SyncNPC(move.X, move.Y); Teleport(); hasAttacked = false; goto case PatternID.FadeIn; } break; case PatternID.Idle: pattern = PatternID.Idle; npc.immortal = false; if (timer % elapse == 0 && Main.rand.Next(3) == 0) { if (!hasAttacked) { hasAttacked = true; goto case PatternID.Attack; } else { goto case PatternID.FadeOut; } } return(false); case PatternID.Attack: pattern = PatternID.Attack; if (PreAttack()) { if (attacks > 0) { Attack(); } attacks++; } if (attacks > maxAttacks) { pattern = PatternID.Idle; attacks = 0; } return(true); } if (oldPattern != pattern) { SyncNPC(npc.position.X, npc.position.Y); } oldPattern = pattern; return(false); }
public override void AI() { time++; if (!init) { int i = (int)npc.position.X / 16; int j = (int)npc.position.Y / 16; if (ArchaeaWorld.Inbounds(i, j) && Main.tile[i, j].wall != ArchaeaWorld.skyBrickWall) { newPosition = ArchaeaNPC.FindAny(npc, ArchaeaNPC.FindClosest(npc, true), true, 800); if (newPosition != Vector2.Zero) { npc.netUpdate = true; init = true; } } } if (newPosition != Vector2.Zero && ai == Idle) { npc.position = newPosition; } if (time > 150) { if (npc.alpha > 12) { npc.alpha -= 12; } else { npc.alpha = 0; } } if (npc.target == 255) { if (npc.life < npc.lifeMax) { npc.TargetClosest(); } return; } if (time > 300) { time = 0; ai = Attack; } if (time == 240) { tracking = npcTarget.Center; } if (ai == Attack) { npc.velocity += ArchaeaNPC.AngleToSpeed(npc.AngleTo(tracking), rushSpeed); ai = Activated; npc.netUpdate = true; } else { ArchaeaNPC.SlowDown(ref npc.velocity, 0.2f); if (time % 45 == 0 && time != 0) { npc.velocity = Vector2.Zero; } } if (npc.velocity.X >= npc.oldVelocity.X || npc.velocity.X < npc.oldVelocity.X || npc.velocity.Y >= npc.oldVelocity.Y || npc.velocity.Y < npc.oldVelocity.Y) { npc.netUpdate = true; } if (npc.Center.X <= npcTarget.Center.X) { float angle = (float)Math.Round(Math.PI * 0.2f, 1); if (npc.rotation > angle) { npc.rotation -= rotateSpeed; } else { npc.rotation += rotateSpeed; } } else { float angle = (float)Math.Round((Math.PI * 0.2f) * -1, 1); if (npc.rotation > angle) { npc.rotation -= rotateSpeed; } else { npc.rotation += rotateSpeed; } } if (ai == Idle && npc.Distance(npcTarget.Center) < 64f) { ArchaeaNPC.DustSpread(npc.position, npc.width, npc.height, DustID.Stone, 5, 1.2f); npc.TargetClosest(); ai = Activated; npc.netUpdate = true; } }