Пример #1
0
        public override void AI()
        {
            Player       player    = Main.player[projectile.owner];
            LocustPlayer modPlayer = player.GetModPlayer <LocustPlayer>();

            if (player.dead || !player.active)
            {
                modPlayer.Locusts = false;
            }

            if (modPlayer.Locusts)
            {
                projectile.timeLeft = 2;
            }

            NPC   target       = null;
            float maxdist      = 600;
            NPC   miniontarget = projectile.OwnerMinionAttackTargetNPC;

            if (miniontarget != null && miniontarget.CanBeChasedBy(this) && CanHit(projectile.Center, miniontarget.Center) && CanHit(player.Center, miniontarget.Center) &&
                miniontarget.Distance(projectile.Center) <= maxdist && miniontarget.Distance(player.Center) <= maxdist * 3)
            {
                target = miniontarget;
            }

            else
            {
                var validtargets = Main.npc.Where(x => x != null && x.CanBeChasedBy(this) && CanHit(projectile.Center, x.Center) && CanHit(player.Center, x.Center) &&
                                                  x.Distance(projectile.Center) <= maxdist && x.Distance(player.Center) <= maxdist * 2);

                foreach (NPC npc in validtargets)
                {
                    if (npc.Distance(projectile.Center) <= maxdist)
                    {
                        maxdist = npc.Distance(projectile.Center);
                        target  = npc;
                    }
                }
            }

            if (target == null)
            {
                IdleMovement(player);
            }
            else
            {
                TargettingBehavior(player, target);
            }

            UpdateFrame((int)MathHelper.Clamp(projectile.velocity.Length(), 10, 20));
            projectile.rotation = projectile.velocity.ToRotation();
        }
Пример #2
0
        public override void Update(Player player, ref int buffIndex)
        {
            LocustPlayer Player = player.GetModPlayer <LocustPlayer>();

            if (player.ownedProjectileCounts[ModContent.ProjectileType <LocustBig>()] > 0)
            {
                Player.Locusts = true;
            }

            if (!Player.Locusts)
            {
                player.DelBuff(buffIndex);
                buffIndex--;
                return;
            }

            player.buffTime[buffIndex] = 18000;
        }