Example #1
0
        private void _Poll()
        {
            int rank = Bot.Player.Rank;

            if (rank > _lastRank && _lastRank != -1)
            {
                using (FlashArray <object> skills = FlashObject <object> .Create("world.actions.active").ToArray())
                {
                    int k = 0;
                    foreach (FlashObject <object> skill in skills)
                    {
                        using (FlashObject <long> ts = skill.GetChild <long>("ts"))
                            ts.Value = _lastSkills[k++].LastUse;
                    }
                }
            }
            _lastRank   = rank;
            _lastSkills = Bot.Player.Skills;
            if (_provider?.ShouldUseSkill(Bot) == true)
            {
                int skill = _provider.GetNextSkill(Bot, out SkillMode mode);
                switch (mode)
                {
                case SkillMode.Optimistic:
                    if (Bot.Player.CanUseSkill(skill))
                    {
                        Bot.Player.UseSkill(skill);
                    }
                    break;

                case SkillMode.Wait:
                    if (skill != -1)
                    {
                        Bot.Wait.ForTrue(() => Bot.Player.CanUseSkill(skill), SkillTimeout, SkillTimer);
                        Bot.Player.UseSkill(skill);
                    }
                    break;
                }
            }
            else if (_provider?.ShouldUseSkill(Bot) == null)
            {
                _provider.GetNextSkill(Bot, out SkillMode mode);
            }
        }
Example #2
0
        /// <summary>
        /// Buys the specified item from the currently loaded shop.
        /// </summary>
        /// <param name="name">The name of the item to buy.</param>
        public void BuyItem(string name)
        {
            int             index;
            List <ShopItem> items = ShopItems;

            if (IsShopLoaded && (index = items.FindIndex(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) > -1)
            {
                if (Bot.Options.SafeTimings)
                {
                    Bot.Wait.ForActionCooldown(ScriptWait.GameActions.BuyItem);
                    Bot.Wait.ItemBuyEvent.Reset();
                }
                ExpandoObject item;
                using (FlashArray <ExpandoObject> fItems = FlashObject <ExpandoObject> .Create("world.shopinfo.items").ToArray())
                    using (FlashObject <ExpandoObject> fItem = fItems.Get(index))
                        item = fItem.Value;
                Bot.CallGameFunction("world.sendBuyItemRequest", item);
                if (Bot.Options.SafeTimings)
                {
                    Bot.Wait.ForItemBuy();
                }
            }
        }