Пример #1
0
        private static bool CanGambleItems(int bloodshardcount)
        {
            var definedItemList =
                ValidGambleItems.Where(i => FunkyTownRunPlugin.PluginSettings.BloodShardGambleItems.HasFlag(i)).ToList();

            foreach (var i in definedItemList)
            {
                if (GetGambleItemPrice(i) <= bloodshardcount)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        internal static bool GamblingRunOverlord(object ret)
        {        //Should we gamble?
            if (ZetaDia.Me.IsParticipatingInTieredLootRun &&
                (FunkyGame.Bounty.ActiveQuests.ContainsKey(BountyCache.ADVENTUREMODE_RIFTID) &&
                 (FunkyGame.Bounty.ActiveQuests[BountyCache.ADVENTUREMODE_RIFTID].Step != 34 && FunkyGame.Bounty.ActiveQuests[BountyCache.ADVENTUREMODE_RIFTID].Step != 10)))
            {
                return(false);
            }

            if (FunkyTownRunPlugin.PluginSettings.EnableBloodShardGambling && FunkyGame.AdventureMode &&
                !FunkyTownRunPlugin.PluginSettings.BloodShardGambleItems.Equals(BloodShardGambleItems.None) &&
                ValidGambleItems.Any(i => FunkyTownRunPlugin.PluginSettings.BloodShardGambleItems.HasFlag(i)))
            {
                Backpack.UpdateItemList();

                //If we still have any items (not potions or protected) then we don't start behavior yet.
                foreach (var item in Backpack.CacheItemList.Values.Where(thisitem => !ItemManager.Current.ItemIsProtected(thisitem.ACDItem)))
                {
                    if (item.ThisDBItemType != ItemType.Potion && (!FunkyTownRunPlugin.RunningTrinity || item.ThisDBItemType != ItemType.HoradricCache))
                    {
                        return(false);
                    }
                }

                int  currentBloodShardCount = ZetaDia.CPlayer.BloodshardCount;
                bool anyGambleItems         = CanGambleItems(currentBloodShardCount);
                //Alternative hero switch already occured.. lets gamble!
                if (fBaseXtensions.Behaviors.CharacterControl.AltHeroGamblingEnabled && anyGambleItems)
                {
                    return(true);
                }

                if (currentBloodShardCount >= FunkyTownRunPlugin.PluginSettings.MinimumBloodShards && anyGambleItems)
                {
                    return(!FunkyTownRunPlugin.PluginSettings.UseAltGambling);
                }
            }

            return(false);
        }
Пример #3
0
        internal static RunStatus GamblingInteraction(object ret)
        {
            if (FunkyGame.GameIsInvalid)
            {
                ActionsChecked = false;
                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)");
                return(RunStatus.Failure);
            }

            BotMain.StatusText = "Town run: Gambling Interaction";

            UIElement uie = UI.Game.BloodShardVendorMainDialog;

            if (!(uie != null && uie.IsValid && uie.IsVisible))
            {
                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Gambling UI Dialog Not Visible!");
                return(RunStatus.Failure);
            }
            if (!UIElements.InventoryWindow.IsVisible)
            {
                Backpack.InventoryBackPackToggle(true);
                return(RunStatus.Running);
            }



            int CurrentBloodShardCount = ZetaDia.CPlayer.BloodshardCount;

            if (CurrentBloodShardCount < 5)
            {
                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Gambling Behavior Finished.");
                return(RunStatus.Success);
            }

            //set default
            if (LastBloodShardCount == 0 && LastBloodShardCount != CurrentBloodShardCount)
            {
                LastBloodShardCount = CurrentBloodShardCount;
            }

            //Check if we should find a new item type to gamble for..
            if (nextItemType.Equals(BloodShardGambleItems.None) || GetGambleItemPrice(nextItemType) > CurrentBloodShardCount)
            {
                nextItemType = BloodShardGambleItems.None;

                //Generate our list of item types.
                List <BloodShardGambleItems> freshList = ValidGambleItems.Where(t => FunkyTownRunPlugin.PluginSettings.BloodShardGambleItems.HasFlag(t)).ToList();

                //Find next item type!
                while (freshList.Count > 0)
                {
                    Random r = new Random();

                    int curListCount = freshList.Count;
                    int index        = r.Next(0, curListCount);

                    BloodShardGambleItems itemtype = freshList[index];
                    if (FunkyTownRunPlugin.PluginSettings.BloodShardGambleItems.HasFlag(itemtype) && GetGambleItemPrice(itemtype) <= CurrentBloodShardCount)
                    {
                        nextItemType = itemtype;
                        FunkyTownRunPlugin.DBLog.DebugFormat("Next Item Type: {0}", nextItemType);
                        break;
                    }

                    freshList.RemoveAt(index);
                }
            }

            if (nextItemType.Equals(BloodShardGambleItems.None))
            {
                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Gambling Behavior Finished -- No Valid Item Types Returned.");
                return(RunStatus.Success);
            }


            if (!PurchasedItem)
            {
                //Waiting..
                if (!Delay.Test(2))
                {
                    return(RunStatus.Running);
                }

                //Retrieve the DynamicID based on our type selection
                int dynamicID = GetGambleItemDynamicID(nextItemType);
                if (dynamicID == -1)
                {
                    //Error!?
                    FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Gambling Behavior Item DynamicID was not found!");
                    return(RunStatus.Success);
                }

                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Buying Item {0}", nextItemType);
                ZetaDia.Actors.Me.Inventory.BuyItem(dynamicID);
                PurchasedItem = true;
                return(RunStatus.Running);
            }



            if (LastBloodShardCount != CurrentBloodShardCount)
            {
                LastBloodShardCount = CurrentBloodShardCount;
                if (FunkyGame.CurrentStats != null)
                {
                    FunkyGame.CurrentStats.CurrentProfile.ItemsGambled++;
                }
                //FunkyTownRunPlugin.TownRunStats.ItemsGambled++;
            }
            else if (ZetaDia.Me.Inventory.NumFreeBackpackSlots < 3)
            {
                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Gambling Behavior Finished -- Backpack Is Nearly Full!");
                return(RunStatus.Success);
            }


            //Reset
            PurchasedItem = false;
            nextItemType  = BloodShardGambleItems.None;

            return(RunStatus.Running);
        }