Пример #1
0
        public override void AI()
        {
            NPCID npcid = new NPCID();

            if (npcid.Equals(17))
            {
                projectile.damage = 1;
            }
            else
            {
                projectile.damage = 1;
            }
            projectile.rotation += 90f;

            if (projectile.alpha > 70)
            {
                projectile.alpha -= 15;
                if (projectile.alpha < 70)
                {
                    projectile.alpha = 70;
                }
            }
            if (projectile.localAI[0] == 0f)
            {
                AdjustMagnitude(ref projectile.velocity);
                projectile.localAI[0] = 1f;
            }
            Vector2 move     = Vector2.Zero;
            float   distance = 400f;
            bool    target   = false;

            for (int k = 0; k < 200; k++)
            {
                if (Main.npc[k].active && !Main.npc[k].dontTakeDamage && !Main.npc[k].friendly && Main.npc[k].lifeMax > 5)
                {
                    Vector2 newMove    = Main.npc[k].Center - projectile.Center;
                    float   distanceTo = (float)Math.Sqrt(newMove.X * newMove.X + newMove.Y * newMove.Y);
                    if (distanceTo < distance)
                    {
                        move     = newMove;
                        distance = distanceTo;
                        target   = true;
                    }
                }
            }
            if (target)
            {
                AdjustMagnitude(ref move);
                projectile.velocity = (10 * projectile.velocity + move) / 11f;
                AdjustMagnitude(ref projectile.velocity);
            }
            if (projectile.alpha <= 100)
            {
                int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("SpectreDust"));
                Main.dust[dust].velocity /= 2f;
            }
        }