Example #1
0
        public override void Attack()
        {
            int a = Projectile.NewProjectile(npc.Center, ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, npcTarget) + compensate, 4f), ProjectileID.Fireball, 10, 1f);

            Main.projectile[a].timeLeft    = 300;
            Main.projectile[a].hostile     = true;
            Main.projectile[a].friendly    = false;
            Main.projectile[a].tileCollide = false;
        }
Example #2
0
        public bool canSee()
        {
            Vector2 line;

            for (float k = 0; k < npc.Distance(target().position); k += 0.5f)
            {
                line = npc.Center + ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, target()), k);
                int  i    = (int)line.X / 16;
                int  j    = (int)line.Y / 16;
                Tile tile = Main.tile[i, j];
                if (tile.active() && Main.tileSolid[tile.type])
                {
                    return(false);
                }
            }
            return(true);
        }
Example #3
0
        public static void DiggerPartsAI(NPC npc, NPC part, float speed, ref float acc)
        {
            Vector2 connect = ArchaeaNPC.AngleBased(new Vector2(part.position.X, part.position.Y + part.height / 2), part.rotation, part.width);

            npc.rotation = ArchaeaNPC.AngleTo(npc.Center, part.Center);
            if (Vector2.Distance(part.Center, npc.Center) > npc.width * 1.2f)
            {
                if (!npc.Hitbox.Contains(connect.ToPoint()))
                {
                    acc = 0.60f;
                }
                else
                {
                    acc += 0.01f;
                }
                Clamp(acc, 0.6f, 1f, out acc);
                npc.Center += ArchaeaNPC.AngleToSpeed(npc.rotation, speed * acc);
            }
        }
Example #4
0
 protected bool Initialize()
 {
     if (!begin)
     {
         body    = new int[8];
         body[0] = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, bodyType, 0, npc.whoAmI);
         for (int k = 1; k < body.Length - 1; k++)
         {
             body[k] = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, bodyType, 0, body[k - 1], npc.whoAmI);
         }
         body[7]   = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, tailType, 0, body[6], npc.whoAmI);
         npc.ai[0] = Main.npc[body[7]].whoAmI;
         for (int l = 0; l < body.Length; l++)
         {
             NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, body[l]);
         }
         follow   = FindAny(bounds);
         rotateTo = ArchaeaNPC.AngleTo(npc.Center, npc.Center + follow);
         begin    = true;
     }
     return(begin);
 }
Example #5
0
        public void Attack()
        {
            int proj = Projectile.NewProjectile(npc.Center + new Vector2(npc.width * 0.35f * npc.direction, -4f), ArchaeaNPC.AngleToSpeed(ArchaeaNPC.AngleTo(npc, npcTarget) + compensate, 4f), ProjectileID.Fireball, 10, 1f);

            Main.projectile[proj].timeLeft    = 300;
            Main.projectile[proj].friendly    = false;
            Main.projectile[proj].tileCollide = false;
            scale = 0.2f;
        }
Example #6
0
 protected void NextDirection(Vector2 chase)
 {
     follow   = chase;
     rotateTo = ArchaeaNPC.AngleTo(npc.Center, npc.Center + follow);
 }
Example #7
0
        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;
            }
        }