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); } }
public override void AI() { if (!Inbounds() || (!inGround && !moveThroughAir)) { NextDirection(new Vector2(0, npc.height * -1)); return; } switch (ai) { case Reset: NextDirection(FindAny(bounds)); cycle = 0; leaps = 0; break; case JustSpawned: if (StartDigging()) { goto case DigAround; } break; case Idle: ai = Idle; if (npc.Distance(target().position) < range || (time++ > interval / 4 && time != 0)) { time = 0; move = FindAny(bounds); goto case DigAround; } break; case DigAround: ai = DigAround; Digging(); if (time++ > interval / 2 && time != 0) { move = FindAny(bounds); cycle++; time = 0; } if (npc.Hitbox.Contains(follow.ToPoint())) { move = FindAny(bounds); } if (move != Vector2.Zero) { follow = move; NextDirection(follow); } if (cycle > 2) { cycle = 0; if (npc.Distance(target().position) < range) { goto case ChasePlayer; } else { goto case Idle; } } break; case ChasePlayer: ai = ChasePlayer; if (!ArchaeaNPC.defaultBounds(target()).Contains(npc.Hitbox)) { rotateTo = direction ? ArchaeaNPC.AngleTo(npc, target()) : ArchaeaNPC.AngleTo(npc, target()) * -1; } if (time++ % interval / 2 == 0 && time != 0) { cycle++; } if (!InGround(npc.Center)) { leaps++; } if (npc.Hitbox.Intersects(target().Hitbox) || cycle > 12 || leaps > 60) { ai = DigAround; goto case Reset; } break; } }