Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public override bool JustSpawned()
 {
     if (!init)
     {
         flip = Main.rand.Next(2) == 0;
         SyncNPC();
         init = true;
     }
     if (npc.life < npc.lifeMax || (Main.mouseRight && npc.Hitbox.Contains(Main.MouseWorld.ToPoint()) && ArchaeaNPC.WithinRange(target.position, new Rectangle(npc.Hitbox.X - 75, npc.Hitbox.Y - 75, 150, 150))))
     {
         pattern   = Pattern.Attack;
         activated = true;
         SyncNPC();
     }
     return(activated);
 }