示例#1
0
        public override void AI()
        {
            projectile.scale = 1f;
            //CONFIG INFO
            int range = 22;               //How many tiles away the projectile targets NPCs
            //TARGET NEAREST NPC WITHIN RANGE
            float lowestDist = float.MaxValue;
            NPC   target     = new NPC();

            if (projectile.OwnerMinionAttackTargetNPC != null && projectile.Distance(projectile.OwnerMinionAttackTargetNPC.Center) / 16 < range)
            {
                target = projectile.OwnerMinionAttackTargetNPC;
            }

            else
            {
                for (int i = 0; i < 200; ++i)
                {
                    NPC npc = Main.npc[i];
                    //if npc is a valid target (active, not friendly, and not a critter)
                    if (npc.active && npc.CanBeChasedBy(projectile) && !npc.friendly)
                    {
                        //if npc is within 50 blocks
                        float dist = projectile.Distance(npc.Center);
                        if (dist / 16 < range)
                        {
                            //if npc is closer than closest found npc
                            if (dist < lowestDist)
                            {
                                lowestDist = dist;

                                //target this npc
                                target = npc;
                                projectile.netUpdate = true;
                            }
                        }
                    }
                }
            }


            projectile.frameCounter++;
            if (target.CanBeChasedBy(this))
            {
                float num395 = Main.mouseTextColor / 200f - 0.35f;
                num395          *= 0.3f;
                projectile.scale = num395 + 0.85f;
                if (projectile.frameCounter >= 6f)
                {
                    projectile.frame        = (projectile.frame + 1) % Main.projFrames[projectile.type];
                    projectile.frameCounter = 0;
                    if (projectile.frame >= 8)
                    {
                        projectile.frame = 0;

                        Vector2 vel = ArcVelocityHelper.GetArcVel(projectile.Center, target.Center, .4325f, 100, heightabovetarget: 20);
                        for (int i = 0; i < 25; i++)
                        {
                            Dust dust = Dust.NewDustDirect(projectile.Center - Vector2.UnitY * 5, projectile.width, projectile.height, ModContent.DustType <Dusts.Blood>(), 0f, -2f, 0, default, .85f);
 private void FireMissle(NPC target)
 {
     if (target != default)
     {
         Vector2 vel = ArcVelocityHelper.GetArcVel(projectile.Center, target.Center, 0.25f, 300, 600);
         Projectile.NewProjectile(projectile.Center, vel, ModContent.ProjectileType <JetwelderJumperMissle>(), projectile.damage * 2, projectile.knockBack, player.whoAmI, target.whoAmI);
     }
 }