Пример #1
0
 void applyPrefabs(SchemaItem item, string[] prefabs_keys)
 {
     if (prefabs_keys != null)
     {
         foreach (var prefab_key in prefabs_keys)
         {
             var prefab = (SchemaItem)prefabs[prefab_key];
             applyPrefabs(item, item.apply(prefab));
         }
     }
 }
Пример #2
0
        SchemaItem readItem()
        {
            SchemaItem item = new SchemaItem();

            startObj();
            while (!endObj())
            {
                string key_property = readString();

                if (key_property == "name")
                {
                    item.name = readString();
                }
                else if (key_property == "craft_class")
                {
                    item.craft_type = readString();
                }
                else if (key_property == "used_by_classes")
                {
                    startObj();
                    while (!endObj())
                    {
                        item.addClass(readString());
                        readString();
                    }
                }
                else if (key_property == "static_attrs")
                {
                    startObj();
                    while (!endObj())
                    {
                        if (readString() == "limited quantity item")
                        {
                            item.limited = true;
                        }
                        readString();
                    }
                }
                else if (key_property == "prefab")
                {
                    item.prefabs = readString().Split(' ');
                }
                else
                {
                    skipAny();
                }
            }

            return(item);
        }
Пример #3
0
        static void doCraft()
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine();
            log("Excluding special items, none of the following items will be crafted:");
            foreach (MsgTF.CSOEconItem item in inventory)
            {
                SchemaItem si = schema.get((int)item.def_index);
                if (si != null)
                {
                    bool failed = false;

                    if (item.quality != 6)
                    {
                        if (!failed)
                        {
                            Console.WriteLine("\n#" + item.id + " (" + si.name + "):");
                            si.addUncraftable();
                            failed = true;
                        }
                        Console.WriteLine("\tquality(" + getQualityName(item.quality) + ")");
                    }

                    if (item.def_index == 474)
                    {
                        if (!failed)
                        {
                            Console.WriteLine("\n#" + item.id + " (" + si.name + "):");
                            si.addUncraftable();
                            failed = true;
                        }
                        Console.WriteLine("\tblackslist(sign)");
                    }

                    foreach (var a in item.attribute)
                    {
                        if (!failed)
                        {
                            Console.WriteLine("\n#" + item.id + " (" + si.name + "):");
                            si.addUncraftable();
                            failed = true;
                        }
                        Console.WriteLine("\tattr(" + schema.getAttr((int)a.def_index) + ")");
                    }

                    if (item.origin != 0)
                    {
                        if (!failed)
                        {
                            Console.WriteLine("\n#" + item.id + " (" + si.name + "):");
                            si.addUncraftable();
                            failed = true;
                        }
                        Console.WriteLine("\torigin(" + getOriginName(item.origin) + ")");

                        Console.ForegroundColor = ConsoleColor.Red;
                        if (item.origin == 1)
                        {
                            Console.WriteLine("\tNOTE: ITEM NOT TRADABLE.");
                        }
                        else if (item.origin == 2)
                        {
                            Console.WriteLine("\tNOTE: ITEM NOT CRAFTABLE.");
                        }
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }

                    if (!failed)
                    {
                        si.addCraftable(item.id);
                    }
                }
            }

            Console.WriteLine();
            log("Listing craftables, the following items will be crafted:");
            Console.WriteLine();
            var craftables = schema.getAllCraftables();

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(getClassName(i) + ":");
                var itemset = craftables[i];
                foreach (SchemaItem item in itemset)
                {
                    Console.WriteLine("\t" + item.getCraftableCount() + " X " + item.name);
                }
                if (itemset.Count == 0)
                {
                    Console.WriteLine("\tNone");
                }
            }

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine();
            Console.WriteLine("Ready to craft. Please confirm that you want to craft these items. Make sure");
            Console.WriteLine("your valuable items are in the exclude section, or that their types are not");
            Console.WriteLine("listed in the crafting section. I have tried to filter out your valuable items,");
            Console.WriteLine("but I will take no responsibility for lost items.");
            Console.WriteLine();
            Console.WriteLine("Blastfurnace has not been tested against:");
            Console.WriteLine("\t- Australium weapons");
            Console.WriteLine("\t- Killstreak weapons");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("I WILL TAKE NO RESPONSIBILITY FOR LOST ITEMS.");
            Console.WriteLine("ARE YOU SURE YOU WANT TO CRAFT THE ABOVE ITEMS?");

            confirm();

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine();
            Console.WriteLine("CRAFTING!");
            Console.WriteLine();
            for (int i = 1; i < 10; i++)
            {
                var itemset = craftables[i];

                while (true)
                {
                    string type1 = null;
                    ulong  id1   = 0;

                    foreach (SchemaItem item in itemset)
                    {
                        if (item.getCraftableCount() != 0)
                        {
                            id1   = item.popCraftable();
                            type1 = item.name;
                            break;
                        }
                    }

                    if (type1 == null)
                    {
                        break;
                    }

                    string type2 = null;
                    ulong  id2   = 0;

                    foreach (SchemaItem item in itemset)
                    {
                        if (item.getCraftableCount() != 0)
                        {
                            id2   = item.popCraftable();
                            type2 = item.name;
                            break;
                        }
                    }

                    if (type2 == null)
                    {
                        break;
                    }

                    Console.WriteLine("CRAFT:");
                    Console.WriteLine("\t+" + type1 + "#" + id1);
                    Console.WriteLine("\t+" + type2 + "#" + id2);

                    ClientGCMsg <GCMsgCraftItem> msg = new ClientGCMsg <GCMsgCraftItem>();
                    msg.Body.recipe = 3;
                    msg.Body.items.Add(id1);
                    msg.Body.items.Add(id2);

                    if (!gc.sendMsg(msg, false))
                    {
                        Console.WriteLine("\tFailed to send craft msg!");
                    }
                    Thread.Sleep(1000);
                }
            }

            Console.WriteLine("Done.");
            Console.ReadKey();
        }
Пример #4
0
        public ItemSchema(string source)
        {
            prefabs = new System.Collections.Hashtable();
            weapons = new System.Collections.Hashtable();
            attrs   = new System.Collections.Hashtable();

            this.source = source;

            string title = readString();

            if (title != "items_game")
            {
                throw new Exception("Item schema title incorrect");
            }

            startObj();
            while (!endObj())
            {
                string key = readString();

                if (key == "items")
                {
                    startObj();
                    while (!endObj())
                    {
                        string item_key = readString();
                        int    item_id  = -1;
                        if (item_key != "default")
                        {
                            item_id = int.Parse(item_key);
                        }

                        SchemaItem item = readItem();
                        applyPrefabs(item, item.prefabs);

                        if (item.craft_type == "weapon" && !item.limited)
                        {
                            weapons[item_id] = item;
                        }
                    }
                }
                else if (key == "prefabs")
                {
                    startObj();
                    while (!endObj())
                    {
                        string prefab_key = readString();

                        SchemaItem prefab = readItem();
                        prefabs[prefab_key] = prefab;
                    }
                }
                else if (key == "attributes")
                {
                    startObj();
                    while (!endObj())
                    {
                        int attr_id = int.Parse(readString());

                        startObj();
                        while (!endObj())
                        {
                            string attr_prop_key   = readString();
                            string attr_prop_value = readString();
                            if (attr_prop_key == "name")
                            {
                                attrs[attr_id] = attr_prop_value;
                            }
                        }
                    }
                }
                else
                {
                    skipAny();
                }
            }
        }