예제 #1
0
        public static void SmeltReclaimed(Bot bot)
        {
            List <ulong> recs = new List <ulong>();

            bot.GetInventory();
            Inventory.Item[] items = bot.MyInventory.Items;
            for (int i = 0; i < items.Length; i++)
            {
                Inventory.Item item = items[i];
                if (recs.Count == 1)
                {
                    break;
                }
                if (item.Defindex == 5001 && !recs.Contains(item.Id))
                {
                    recs.Add(item.Id);
                }
            }
            if (recs.Count == 1)
            {
                Crafting.CraftItems(bot, ECraftingRecipe.SmeltReclaimed, recs.ToArray());
            }
        }
예제 #2
0
        public static void CraftReclaimed(Bot bot)
        {
            List <ulong> scraps = new List <ulong>();

            bot.GetInventory();
            Inventory.Item[] items = bot.MyInventory.Items;
            for (int i = 0; i < items.Length; i++)
            {
                Inventory.Item item = items[i];
                if (scraps.Count == 3)
                {
                    break;
                }
                if (item.Defindex == 5000 && !scraps.Contains(item.Id))
                {
                    scraps.Add(item.Id);
                }
            }
            if (scraps.Count == 3)
            {
                Crafting.CraftItems(bot, ECraftingRecipe.CombineScrap, scraps.ToArray());
            }
        }
        public void KeybankMethod()
        {
            if (bot.CurrentGame != 440)
            {
                LaunchGame();
                Thread.Sleep(2000);
            }
            int loopcount = 0;

            Monitor.Enter(this);

            try
            {
                while (loopcount <= 2)
                {
                    List <ulong> Recs   = new List <ulong>();
                    List <ulong> Scraps = new List <ulong>();
                    List <ulong> Refs   = new List <ulong>();

                    Inventory MyInventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey());
                    if (MyInventory == null)
                    {
                        bot.log.Error("Could not fetch own inventory via Steam API");
                        Monitor.PulseAll(this.lck);
                        return;
                    }

                    foreach (Inventory.Item item in MyInventory.Items)
                    {
                        if (item.Defindex == 5000)
                        {
                            Scraps.Add(item.Id);
                        }
                        else if (item.Defindex == 5001)
                        {
                            Recs.Add(item.Id);
                        }
                        else if (item.Defindex == 5002)
                        {
                            Refs.Add(item.Id);
                        }
                    }
                    List <CraftingPair> pairs = new List <CraftingPair>();

                    while (Scraps.Count >= 6)
                    {
                        CraftingPair crPair = new CraftingPair(CraftingType.CombineMetal);
                        crPair.SetItem(Scraps[0]);
                        crPair.SetItem(Scraps[1]);
                        crPair.SetItem(Scraps[2]);
                        Scraps.RemoveRange(0, 3);
                        pairs.Add(crPair);
                    }
                    foreach (CraftingPair pair in pairs)
                    {
                        Crafting.CraftItems(bot, pair.GetItems());
                        Thread.Sleep(100);
                        // bot.log.Success("I THINK I CRAFTED REC FROM SCRAP");
                        //CraftResponceCallback callback = Craft(ECraftingRecipie.CombineScrap, pair.GetItems());
                        //if (callback != null)
                        //{
                        //    foreach (long itemID in callback.GetItems())
                        //    {
                        //        Recs.Add((ulong)itemID);
                        //    }
                        //    bot.log.Success("Scrap combined into rec!");
                        //}
                    }
                    pairs.Clear();

                    if (Recs.Count < 8 && Refs.Count >= 1)
                    {
                        Crafting.CraftItems(bot, Refs[0]);
                        Refs.RemoveAt(0);
                        Thread.Sleep(100);
                        //CraftResponceCallback callback = Craft(ECraftingRecipie.SmeltRefined, new long[] { (long)Refs[0] });
                        //if (callback != null)
                        //{
                        //    Refs.RemoveAt(0);
                        //    foreach (var item in callback.GetItems())
                        //    {
                        //        Recs.Add((ulong)item);
                        //    }
                        //    bot.log.Success("Ref smelted to recs!");
                        //}
                    }

                    while (Recs.Count >= 8)
                    {
                        //Console.WriteLine("Trying to craft REF");
                        Crafting.CraftItems(bot, new ulong[] { Recs[0], Recs[1], Recs[2] });
                        Recs.RemoveRange(0, 3);
                        Thread.Sleep(100);
                        //CraftResponceCallback callback = Craft(ECraftingRecipie.CombineReclaimed, new long[] { (long)Recs[0], (long)Recs[1], (long)Recs[2] });
                        //if (callback != null)
                        //{
                        //    Recs.RemoveRange(0, 3);
                        //    foreach (var item in callback.GetItems())
                        //    {
                        //        Refs.Add((ulong)item);
                        //    }
                        //    bot.log.Success("Rec combined to ref!");
                        //}
                    }

                    if (Scraps.Count < 4)
                    {
                        Crafting.CraftItems(bot, Recs[0]);
                        Recs.RemoveAt(0);
                        Thread.Sleep(100);
                        //CraftResponceCallback callback = Craft(ECraftingRecipie.SmeltReclaimed, new long[] { (long)Recs[0] });
                        //if (callback != null)
                        //{
                        //    Recs.RemoveAt(0);
                        //    foreach (var item in callback.GetItems())
                        //    {
                        //        Scraps.Add((ulong)item);
                        //    }
                        //    bot.log.Success("Rec smelted to scraps!");
                        //}
                    }
                    loopcount = 6;
                }
            }
            catch
            {
            }
            finally
            {
                ExitGame();
                Monitor.Exit(this);
                bStarted = false;
            }
        }
        public void CompactMetal()
        {
            if (bot.CurrentGame != 440)
            {
                LaunchGame();
                Thread.Sleep(2000);
            }
            int loopcount   = 0;
            int ScrapToKeep = 10;

            Monitor.Enter(this);

            while (loopcount <= 1)
            {
                List <ulong> Recs   = new List <ulong>();
                List <ulong> Scraps = new List <ulong>();
                List <ulong> Refs   = new List <ulong>();

                Inventory MyInventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey());
                if (MyInventory == null)
                {
                    bot.log.Error("Could not fetch own inventory via Steam API");
                    Monitor.PulseAll(this.lck);
                    return;
                }

                foreach (Inventory.Item item in MyInventory.Items)
                {
                    if (item.Defindex == 5000)
                    {
                        Scraps.Add(item.Id);
                    }
                    else if (item.Defindex == 5001)
                    {
                        Recs.Add(item.Id);
                    }
                    else if (item.Defindex == 5002)
                    {
                        Refs.Add(item.Id);
                    }
                }

                while (Scraps.Count - ScrapToKeep >= 3)
                {
                    Crafting.CraftItems(bot, Scraps[0], Scraps[1], Scraps[2]);
                    Scraps.RemoveRange(0, 3);
                    Thread.Sleep(100);
                    //CraftResponceCallback callback = Craft(ECraftingRecipie.CombineScrap, new long[] { (long)Scraps[0], (long)Scraps[1], (long)Scraps[2] });
                    //if (callback != null)
                    //{
                    //    Scraps.RemoveRange(0, 3);
                    //    foreach (var item in callback.GetItems())
                    //    {
                    //        Recs.Add((ulong)item);
                    //    }
                    //    bot.log.Success("rec created from scrap!");
                    //}
                }

                while (Recs.Count >= 3)
                {
                    Crafting.CraftItems(bot, Recs[0], Recs[1], Recs[2]);
                    Recs.RemoveRange(0, 3);
                    Thread.Sleep(100);
                    //CraftResponceCallback callback = Craft(ECraftingRecipie.CombineReclaimed, new long[] { (long)Recs[0], (long)Recs[1], (long)Recs[2] });
                    //if (callback != null)
                    //{
                    //    Recs.RemoveRange(0, 3);
                    //    foreach (var item in callback.GetItems())
                    //    {
                    //        Refs.Add((ulong)item);
                    //    }
                    //    bot.log.Success("ref created from rec!");
                    //}
                }
                loopcount++;
            }
            ExitGame();
            Monitor.Exit(this);
            bStarted = false;
        }
        public void MetalToScrapMethod()
        {
            if (bot.CurrentGame != 440)
            {
                LaunchGame();
                Thread.Sleep(2000);
            }
            int loopcount = 0;

            Monitor.Enter(this.lck);
            while (loopcount <= 1)
            {
                List <ulong> refs        = new List <ulong>();
                List <ulong> recs        = new List <ulong>();
                Inventory    MyInventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey());
                if (MyInventory == null)
                {
                    bot.log.Error("Could not fetch own inventory via Steam API");
                    Monitor.PulseAll(this.lck);
                    return;
                }

                foreach (Inventory.Item item in MyInventory.Items)
                {
                    if (item.Defindex == 5001)
                    {
                        recs.Add(item.Id);
                    }
                    else if (item.Defindex == 5002)
                    {
                        refs.Add(item.Id);
                    }
                }

                while (refs.Count > 0)
                {
                    Crafting.CraftItems(bot, refs[0]);
                    refs.RemoveAt(0);
                    Thread.Sleep(100);
                    //CraftResponceCallback callback = Craft(ECraftingRecipie.SmeltRefined, new long[] { (long)refs[0] });
                    //if (callback != null)
                    //{
                    //    refs.RemoveAt(0);
                    //    foreach (long itemID in callback.GetItems())
                    //    {
                    //        recs.Add((ulong)itemID);
                    //    }
                    //    bot.log.Success("Refined smelted into reclaimed!");
                    //}
                }

                while (recs.Count > 0)
                {
                    Crafting.CraftItems(bot, recs[0]);
                    recs.RemoveAt(0);
                    Thread.Sleep(100);
                    //CraftResponceCallback callback = Craft(ECraftingRecipie.SmeltReclaimed, new long[] { (long)recs[0] });
                    //if (callback != null)
                    //{
                    //    recs.RemoveAt(0);
                    //    bot.log.Success("Reclaimed smelted into scrap!");
                    //}
                }
                loopcount++;
            }
            ExitGame();
            Monitor.Exit(this.lck);
            bStarted = false;
        }
        public void HatbankMethod()
        {
            if (bot.CurrentGame != 440)
            {
                LaunchGame();
                Thread.Sleep(2000);
            }
            int loopcount = 0;

            Monitor.Enter(this.lck);
            while (loopcount <= 1)
            {
                Inventory MyInventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey());
                if (MyInventory == null)
                {
                    bot.log.Error("Could not fetch own inventory via Steam API");
                    Monitor.PulseAll(this.lck);
                    return;
                }

                List <ulong> scraps = new List <ulong>();
                List <ulong> recs   = new List <ulong>();
                List <ulong> refs   = new List <ulong>();

                foreach (Inventory.Item item in MyInventory.Items)
                {
                    if (item.Defindex == 5000)
                    {
                        scraps.Add(item.Id);
                    }
                    else if (item.Defindex == 5001)
                    {
                        recs.Add(item.Id);
                    }
                    else if (item.Defindex == 5002)
                    {
                        refs.Add(item.Id);
                    }
                }

                while (scraps.Count >= 3)
                {
                    Crafting.CraftItems(bot, scraps[0], scraps[1], scraps[2]);
                    scraps.RemoveRange(0, 3);
                    Thread.Sleep(100);
                    //CraftResponceCallback callback = Craft(ECraftingRecipie.CombineScrap, new long[] { (long)scraps[0], (long)scraps[1], (long)scraps[2] });
                    //if (callback != null)
                    //{
                    //    scraps.RemoveRange(0, 3);
                    //    foreach (var item in callback.GetItems())
                    //    {
                    //        recs.Add((ulong)item);
                    //    }
                    //    bot.log.Success("scrap made into rec!");
                    //}
                }

                if (recs.Count < 12 && refs.Count >= 1)
                {
                    Crafting.CraftItems(bot, refs[0]);
                    refs.RemoveAt(0);
                    Thread.Sleep(100);

                    //CraftResponceCallback callback = Craft(ECraftingRecipie.SmeltRefined, new long[] { (long)refs[0] });
                    //if (callback != null)
                    //{
                    //    refs.RemoveAt(0);
                    //    foreach (var item in callback.GetItems())
                    //    {
                    //        recs.Add((ulong)item);
                    //    }
                    //    bot.log.Success("Ref smelted to recs!");
                    //}
                }

                //while (recs.Count > 14)
                //{
                //    CraftResponceCallback callback = Craft(ECraftingRecipie.CombineReclaimed, new long[] { (long)recs[0], (long)recs[1], (long)recs[2] });
                //    if (callback != null)
                //    {
                //        recs.RemoveRange(0, 3);
                //        foreach (var item in callback.GetItems())
                //        {
                //            refs.Add((ulong)item);
                //        }
                //        bot.log.Success("Rec combined to ref!");
                //    }
                //}

                //while (scraps.Count < 8 && recs.Count > 1)
                //{
                //    CraftResponceCallback callback = Craft(ECraftingRecipie.SmeltReclaimed, new long[] { (long)recs[0] });
                //    if (callback != null)
                //    {
                //        recs.RemoveAt(0);
                //        foreach (var item in callback.GetItems())
                //        {
                //            scraps.Add((ulong)item);
                //        }
                //        bot.log.Success("Rec smelted to scrap!");
                //    }
                //}
                loopcount++;
            }

            ExitGame();
            Monitor.Exit(this.lck);
            bStarted = false;
        }
        //public void OnCraft(CraftResponceCallback responce)
        //{
        //    this.responce = responce;
        //    CraftedItem = true;
        //}

        //private CraftResponceCallback Scrap(long item1, long item2)
        //{
        //    return Craft(ECraftingRecipie.SmeltClassWeapon, new long[] { item1, item2 });
        //}

        //private CraftResponceCallback Craft(ECraftingRecipie recipie, long[] items)
        //{
        //    if (!InGame)
        //    {
        //        try
        //        {
        //            LaunchGame();
        //            Thread.Sleep(50);
        //            while (!InGame)
        //            {
        //                Thread.Sleep(100);
        //            }
        //        }
        //        catch (ThreadInterruptedException e)
        //        {
        //            bot.log.Error(e.StackTrace);
        //        }
        //    }
        //    CraftedItem = false;
        //    bot.SteamGameCoordinator.Craft(recipie, items);
        //    Thread.Sleep(50);
        //    while (!CraftedItem)
        //    {
        //        Thread.Sleep(100);
        //    }
        //    return responce;
        //}

        public void ScrapbankMethod()
        {
            if (bot.CurrentGame != 440)
            {
                LaunchGame();
                Thread.Sleep(2000);
            }
            int loopcount = 0;

            Monitor.Enter(this.lck);
            while (loopcount < 1)
            {
                Inventory MyInventory = Inventory.FetchInventory(bot.SteamClient.SteamID.ConvertToUInt64(), bot.GetAPIKey());
                if (MyInventory == null)
                {
                    bot.log.Error("Could not fetch own inventory via Steam API");
                    Monitor.PulseAll(this.lck);
                    return;
                }

                List <ulong> scraps = new List <ulong>();
                List <ulong> recs   = new List <ulong>();
                List <ulong> refs   = new List <ulong>();
                Dictionary <string, List <ulong> > weapons = new Dictionary <string, List <ulong> >();

                //uShort = defindex ulong = id
                Schema schema = Schema.FetchSchema(bot.GetAPIKey());

                #region Counting

                foreach (Inventory.Item item in MyInventory.Items)
                {
                    Schema.Item schemaItem = schema.GetItem(item.Defindex);
                    if (item.Defindex == 5000)
                    {
                        scraps.Add(item.Id);
                    }
                    else if (item.Defindex == 5001)
                    {
                        recs.Add(item.Id);
                    }
                    else if (item.Defindex == 5002)
                    {
                        refs.Add(item.Id);
                    }
                    else
                    {
                        if (schemaItem.CraftMaterialType == "weapon" && !item.IsNotCraftable && !item.IsNotTradeable)
                        {
                            if (!weapons.ContainsKey(schemaItem.UsableByClasses[0]))
                            {
                                weapons.Add(schemaItem.UsableByClasses[0], new List <ulong>());
                            }
                            weapons[schemaItem.UsableByClasses[0]].Add(item.Id);
                        }
                    }
                }

                #endregion Counting

                #region Getting Craft Pairs

                List <string>       Defindex = new List <string>();
                List <CraftingPair> craftingpairs = new List <CraftingPair>();
                ulong item1, item2;
                foreach (KeyValuePair <string, List <ulong> > pair in weapons)
                {
                    item1 = 0;
                    item2 = 0;
                    Defindex.Clear();
                    foreach (ulong id in pair.Value)
                    {
                        Inventory.Item item       = MyInventory.GetItem(id);
                        Schema.Item    schemaItem = schema.GetItem(item.Defindex);

                        if (Defindex.Contains(schemaItem.ItemName) && !bot.dReserved.ContainsKey(item.Id))
                        {
                            if (item1 == 0)
                            {
                                item1 = item.Id;
                            }
                            else if (item2 == 0)
                            {
                                item2 = item.Id;
                                CraftingPair crPair = new CraftingPair(CraftingType.ScrapbankSmeltWeps);
                                crPair.SetItem(item1);
                                crPair.SetItem(item2);
                                craftingpairs.Add(crPair);
                                item1 = 0;
                                item2 = 0;
                            }
                        }
                        else
                        {
                            Defindex.Add(schemaItem.ItemName);
                        }
                    }
                }

                #endregion Getting Craft Pairs

                #region Crafting

                foreach (CraftingPair pair in craftingpairs)
                {
                    Crafting.CraftItems(bot, pair.Item1, pair.Item2);
                    Thread.Sleep(100);
                    //CraftResponceCallback callback = Scrap((long)pair.Item1, (long)pair.Item2);
                    //if (callback != null)
                    //{
                    //    foreach (long itemID in callback.GetItems())
                    //    {
                    //        scraps.Add((ulong)itemID);
                    //    }
                    //    bot.log.Success("Item crafted into scrap!");
                    //}
                }

                while (refs.Count > 0)
                {
                    Crafting.CraftItems(bot, refs[0]);
                    Thread.Sleep(100);
                    refs.RemoveAt(0);

                    //CraftResponceCallback callback = Craft(ECraftingRecipie.Unknown, new long[] { (long)refs[0] });
                    //if (callback != null)
                    //{
                    //    refs.RemoveAt(0);
                    //    foreach (long itemID in callback.GetItems())
                    //    {
                    //        recs.Add((ulong)itemID);
                    //    }
                    //    bot.log.Success("Refined smelted into reclaimed!");
                    //}
                }

                while (recs.Count > 0)
                {
                    Crafting.CraftItems(bot, recs[0]);
                    Thread.Sleep(100);
                    recs.RemoveAt(0);

                    //CraftResponceCallback callback = Craft(ECraftingRecipie.Unknown, new long[] { (long)recs[0] });
                    //if (callback != null)
                    //{
                    //    recs.RemoveAt(0);
                    //    foreach (long itemID in callback.GetItems())
                    //    {
                    //        scraps.Add((ulong)itemID);
                    //    }
                    //    bot.log.Success("Reclaimed smelted into scrap!");
                    //}
                }

                #endregion Crafting
                loopcount++;
            }
            ExitGame();
            Monitor.Exit(this.lck);
            bStarted = false;
        }
예제 #8
0
파일: Bot.cs 프로젝트: einsteinsci/SteamBot
        public void DoCraftingIfNeeded()
        {
            GetInventory();
            SetGamePlaying(440);

            while (MyInventory == null)
            {
                Log.Debug("MyInventory is null for some reason.");
                Thread.Sleep(2000);
            }

            bool didSomething = false;

            do
            {
                int totalScrap = 0, totalRec = 0;
                foreach (Inventory.Item item in MyInventory.Items)
                {
                    if (item.Defindex == TF2Value.SCRAP_DEFINDEX)
                    {
                        totalScrap++;
                    }
                    else if (item.Defindex == TF2Value.RECLAIMED_DEFINDEX)
                    {
                        totalRec++;
                    }
                }

                if (totalScrap > 4)
                {
                    List <ulong> assets = _getAssetIDsInBackpack(TF2Value.SCRAP_DEFINDEX, 3);
                    Crafting.CraftItems(this, ECraftingRecipe.CombineScrap, assets.ToArray());
                    Log.Debug("Crafted scrap into reclaimed.");
                    didSomething = true;
                }

                if (totalScrap < 2)
                {
                    List <ulong> assets = _getAssetIDsInBackpack(TF2Value.RECLAIMED_DEFINDEX, 1);
                    Crafting.CraftItems(this, ECraftingRecipe.SmeltReclaimed, assets.ToArray());
                    Log.Debug("Smelted reclaimed into scrap.");
                    didSomething = true;
                }

                if (totalRec > 4)
                {
                    List <ulong> assets = _getAssetIDsInBackpack(TF2Value.RECLAIMED_DEFINDEX, 3);
                    Crafting.CraftItems(this, ECraftingRecipe.CombineReclaimed, assets.ToArray());
                    Log.Debug("Crafted reclaimed into refined.");
                    didSomething = true;
                }

                if (totalRec < 2)
                {
                    List <ulong> assets = _getAssetIDsInBackpack(TF2Value.REFINED_DEFINDEX, 1);
                    Crafting.CraftItems(this, ECraftingRecipe.SmeltRefined, assets.ToArray());
                    Log.Debug("Smelted refined into reclaimed.");
                    didSomething = true;
                }

                Thread.Sleep(1000);
                SetGamePlaying(0);
                GetInventory();
            } while (didSomething);
        }