Beispiel #1
0
    void OnItemClick(ListCell cell)
    {
        UICraftItemCell craftItem = cell as UICraftItemCell;

        if (craftItem == null)
        {
            Debug.LogError("CraftWnd.OnItemClick error");
            return;
        }
        if (craftItem.formula == null || craftItem.formula.rawMats == null)
        {
            for (int i = 0; i < CraftFormula.maxRawMatSorts; i++)
            {
                matSlot[i].SetMaterial(null, 0);
            }
            productSlot.SetMaterial(null, 0);
        }

        for (int i = 0; i < CraftFormula.maxRawMatSorts; i++)
        {
            if (craftItem.formula.rawMats[i] != null)
            {
                ItemType matType = ItemTypeTable.GetItemType(craftItem.formula.rawMats[i].id);
                matSlot[i].SetMaterial(matType, craftItem.formula.rawMats[i].amount);
            }
            else
            {
                matSlot[i].SetMaterial(null, 0);
            }
            ItemType productType = ItemTypeTable.GetItemType(craftItem.formula.outputId);
            productSlot.SetMaterial(productType, craftItem.formula.outputAmount);
        }
        selCraftItem = craftItem;
        ShowMatEnough();
    }
Beispiel #2
0
        /// <summary>
        /// Checks if Item can be equipped at that slot. Handels equipment for Two-Handed-Weapons.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="equipmentSlot"></param>
        /// <returns></returns>
        private bool IsValidEquipmentRequest(Item item, int equipmentSlot)
        {
            ItemTypeTable type = item.ItemType;

            if (equipmentSlot == (int)EquipmentSlotId.Main_Hand)
            {
                // useful for 1hand + shield switching, this is to avoid shield to be go to main hand
                if (!Item.IsWeapon(type))
                {
                    return(false);
                }

                if (Item.Is2H(type))
                {
                    Item itemOffHand = _equipment.GetEquipment(EquipmentSlotId.Off_Hand);
                    if (itemOffHand != null)
                    {
                        _equipment.UnequipItem(itemOffHand);
                        if (!_inventoryGrid.AddItem(itemOffHand))
                        {
                            _equipment.EquipItem(itemOffHand, (int)EquipmentSlotId.Off_Hand);
                            return(false);
                        }
                        AcceptMoveRequest(itemOffHand);
                    }
                }
            }
            else if (equipmentSlot == (int)EquipmentSlotId.Off_Hand)
            {
                Item itemMainHand = _equipment.GetEquipment(EquipmentSlotId.Main_Hand);
                if (Item.Is2H(type))
                {
                    //remove object first to make room for possible unequiped item
                    _inventoryGrid.RemoveItem(item);

                    if (itemMainHand != null)
                    {
                        _equipment.UnequipItem(itemMainHand);
                        _inventoryGrid.AddItem(itemMainHand);
                        AcceptMoveRequest(itemMainHand);
                    }

                    _equipment.EquipItem(item, (int)EquipmentSlotId.Main_Hand);
                    AcceptMoveRequest(item);

                    SendVisualInventory(this._owner);
                    // All equipment commands are executed. the original EquipmentRequest is invalid at this moment
                    return(false);
                }

                if (itemMainHand != null)
                {
                    if (Item.Is2H(itemMainHand.ItemType))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #3
0
        // generates a random item from given type category.
        // we can also set a difficulty mode parameter here, but it seems current db doesnt have nightmare or hell-mode items with valid snoId's /raist.
        public static Item GenerateRandom(Mooege.Core.GS.Actors.Actor player, ItemTypeTable type)
        {
            var itemDefinition = GetRandom(Items.Values
                                           .Where(def => ItemGroup
                                                  .HierarchyToHashList(ItemGroup.FromHash(def.ItemType1)).Contains(type.Hash)).ToList());

            return(CreateItem(player, itemDefinition));
        }
Beispiel #4
0
        public static ItemTypeTable FromHash(int hash)
        {
            ItemTypeTable result = null;

            if (ItemTypes.TryGetValue(hash, out result))
            {
                return(result);
            }
            return(null);
        }
Beispiel #5
0
        public List <IItemAttributeCreator> Create(ItemTypeTable itemType)
        {
            var creatorList = new List <IItemAttributeCreator> {
                new DefaultAttributeCreator()
            };

            //if (Item.IsWeapon(itemType)) creatorList.Add(new WeaponAttributeCreator());
            //else if (Item.IsPotion(itemType))  creatorList.Add(new PotionAttributeCreator());

            return(creatorList);
        }
Beispiel #6
0
        public static List <int> HierarchyToHashList(ItemTypeTable itemType)
        {
            List <int> result = new List <int>();
            var        types  = HierarchyToList(itemType);

            foreach (var type in types)
            {
                result.Add(type.Hash);
            }
            return(result);
        }
Beispiel #7
0
    static Item GenItem(int id, uint amount, GenItemLvl level = GenItemLvl.Normal)
    {
        Item     item = null;
        ItemType type = ItemTypeTable.GetItemType(id);

        if (type != null)
        {
            if (type.weaponId != 0)
            {
                item = new Item(type, amount);
            }
        }
        return(item);
    }
Beispiel #8
0
        public static List <ItemTypeTable> HierarchyToList(ItemTypeTable itemType)
        {
            List <ItemTypeTable> result = new List <ItemTypeTable>();
            var curType = itemType;

            if (curType != null)
            {
                result.Add(curType);
                while (curType.ParentType != -1)
                {
                    curType = ItemTypes[curType.ParentType];
                    result.Add(curType);
                }
            }
            return(result);
        }
Beispiel #9
0
    public void SetContent(object content)
    {
        formula = content as CraftFormula;
        if (formula == null)
        {
            Debug.LogError("ItemCell.SetContent >> content error");
            return;
        }

        Image imgIcon = transform.FindChild("Icon").GetComponent <Image>();
        Text  txtName = transform.FindChild("Name").GetComponent <Text>();

        ItemType type = ItemTypeTable.GetItemType(formula.outputId);

        imgIcon.sprite = Resources.Load <Sprite>("ItemIcon/" + type.icon);
        imgIcon.SetNativeSize();
        txtName.text = type.itemName;
    }
Beispiel #10
0
        public static List <int> SubTypesToHashList(string name)
        {
            List <int>    result   = new List <int>();
            ItemTypeTable rootType = FromString(name);

            if (rootType != null)
            {
                result.Add(rootType.Hash);
                for (int i = 0; i < result.Count; ++i)
                {
                    foreach (var type in ItemTypes.Values)
                    {
                        if (type.ParentType == result[i])
                        {
                            result.Add(type.Hash);
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #11
0
        public static bool IsSubType(ItemTypeTable type, int rootTypeHash)
        {
            if (type == null)
            {
                return(false);
            }

            if (type.Hash == rootTypeHash)
            {
                return(true);
            }
            var curType = type;

            while (curType.ParentType != -1)
            {
                curType = ItemTypes[curType.ParentType];
                if (curType.Hash == rootTypeHash)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #12
0
 public static bool IsOffhand(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Offhand"));
 }
Beispiel #13
0
 public static bool IsArmor(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Armor"));
 }
Beispiel #14
0
 public static bool IsWeapon(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Weapon"));
 }
Beispiel #15
0
 public static bool IsDye(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Dye"));
 }
Beispiel #16
0
 public static bool IsJournalOrScroll(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Scroll") || ItemGroup.IsSubType(itemType, "Book"));
 }
Beispiel #17
0
 public static bool IsRuneOrJewel(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Gem") || ItemGroup.IsSubType(itemType, "SpellRune"));
 }
Beispiel #18
0
 public static bool IsAccessory(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Jewelry"));
 }
Beispiel #19
0
 public static bool Is2H(ItemTypeTable itemType)
 {
     return(ItemGroup.Is2H(itemType));
 }
Beispiel #20
0
 public Item(int id, uint a)
 {
     this.id     = id;
     this._type  = ItemTypeTable.GetItemType(id);
     this.amount = a;
 }
        private void AddTableContent()
        {
            // Classes
            IRowElement Sorceress = ClassTable.InsertRow(false, "Sorceress");

            if (Sorceress != null)
            {
                IRowElement Barbarian   = ClassTable.InsertRow(false, "Barbarian");
                IRowElement Necromancer = ClassTable.InsertRow(false, "Necromancer");

                // Start stats
                StartStatsTable.InsertRow(false, Sorceress.Id, 5, 10, 5, 30);
                StartStatsTable.InsertRow(false, Barbarian.Id, 15, 5, 25, 5);
                StartStatsTable.InsertRow(false, Necromancer.Id, 10, 15, 10, 15);

                // - - - Skills
                // Sorceress
                IRowElement SkillsTable_S1 = SkillsTable.InsertRow(false, "spell1", 5, 5, 0, 20, 0, 2, 2, "Skill1", "Skill1", Sorceress.Id);
                IRowElement SkillsTable_S2 = SkillsTable.InsertRow(false, "spell2", 10, 10, 0, 25, 0, 2, 2, "Skill2", "Skill2", Sorceress.Id);
                IRowElement SkillsTable_S3 = SkillsTable.InsertRow(false, "spell3", 20, 20, 0, 10, 0, 2, 2, "Skill3", "Skill3", Sorceress.Id);
                // Barbarian
                IRowElement SkillsTable_B1 = SkillsTable.InsertRow(false, "attack1", 5, 1, 0, 2, 1, 2, 2, "Skill4", "Skill4", Barbarian.Id);
                IRowElement SkillsTable_B2 = SkillsTable.InsertRow(false, "attack2", 10, 2, 0, 4, 1, 2, 2, "Skill5", "Skill5", Barbarian.Id);
                IRowElement SkillsTable_B3 = SkillsTable.InsertRow(false, "attack3", 20, 3, 0, 5, 1, 2, 2, "Skill6", "Skill6", Barbarian.Id);
                // Necromancer
                IRowElement SkillsTable_N1 = SkillsTable.InsertRow(false, "summon1", 5, 5, 0, 20, 0, 2, 2, "Skill7", "Skill7", Necromancer.Id);
                IRowElement SkillsTable_N2 = SkillsTable.InsertRow(false, "summon2", 10, 10, 0, 25, 0, 2, 2, "Skill8", "Skill8", Necromancer.Id);
                IRowElement SkillsTable_N3 = SkillsTable.InsertRow(false, "summon3", 20, 20, 0, 10, 0, 2, 2, "Skill9", "Skill9", Necromancer.Id);

                // - - - SkillTree
                IRowElement SkillTreesTable_S1 = SkillTreesTable.InsertRow(false, Sorceress.Id, "Fires");
                IRowElement SkillTreesTable_B1 = SkillTreesTable.InsertRow(false, Barbarian.Id, "Melee");
                IRowElement SkillTreesTable_N1 = SkillTreesTable.InsertRow(false, Necromancer.Id, "Summon");

                // - - - SkillTreesTable
                // Sorceress
                IRowElement SkillTreeSlotsTable_S1 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_S1.Id, SkillTreesTable_S1.Id, 1, 1);
                IRowElement SkillTreeSlotsTable_S2 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_S2.Id, SkillTreesTable_S1.Id, 1, 2);
                IRowElement SkillTreeSlotsTable_S3 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_S3.Id, SkillTreesTable_S1.Id, 2, 1);
                // Barbarian
                IRowElement SkillTreeSlotsTable_B1 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_B1.Id, SkillTreesTable_B1.Id, 1, 1);
                IRowElement SkillTreeSlotsTable_B2 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_B2.Id, SkillTreesTable_B1.Id, 2, 1);
                IRowElement SkillTreeSlotsTable_B3 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_B3.Id, SkillTreesTable_B1.Id, 2, 2);
                // Necromancer
                IRowElement SkillTreeSlotsTable_N1 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_N1.Id, SkillTreesTable_N1.Id, 1, 1);
                IRowElement SkillTreeSlotsTable_N2 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_N2.Id, SkillTreesTable_N1.Id, 3, 1);
                IRowElement SkillTreeSlotsTable_N3 = SkillTreeSlotsTable.InsertRow(false, SkillsTable_N3.Id, SkillTreesTable_N1.Id, 3, 2);

                // - - - SkillRequired
                // Sorceress
                SkillRequiredTable.InsertRow(false, SkillsTable_S1.Id, SkillTreeSlotsTable_S3.Id, 3);
                // Barbarian
                SkillRequiredTable.InsertRow(false, SkillsTable_B2.Id, SkillTreeSlotsTable_B3.Id, 3);
                // Necromancer
                SkillRequiredTable.InsertRow(false, SkillsTable_N2.Id, SkillTreeSlotsTable_N3.Id, 3);

                // - - - ItemType
                IRowElement itemType_Sword  = ItemTypeTable.InsertRow(false, "Sword");
                IRowElement itemType_Axe    = ItemTypeTable.InsertRow(false, "Axe");
                IRowElement itemType_Wand   = ItemTypeTable.InsertRow(false, "Wand");
                IRowElement itemType_Chest  = ItemTypeTable.InsertRow(false, "Chest");
                IRowElement itemType_Helmet = ItemTypeTable.InsertRow(false, "Helmet");
                IRowElement itemType_Boots  = ItemTypeTable.InsertRow(false, "Boots");
                IRowElement itemType_Gloves = ItemTypeTable.InsertRow(false, "Gloves");

                // - - - Items
                #region items
                IRowElement item_Sword01 = ItemsTable.InsertRow(false,
                                                                // ItemTypeID
                                                                itemType_Sword.Id,
                                                                // Level
                                                                1,
                                                                // Defense
                                                                0,
                                                                // MinDamage
                                                                2,
                                                                // MaxDamage
                                                                4,
                                                                // Strength
                                                                2,
                                                                // Dexterity
                                                                0,
                                                                // Virality
                                                                0,
                                                                // Energy
                                                                0,
                                                                // Health
                                                                0,
                                                                // Mana
                                                                0,
                                                                // Icon ID
                                                                "Pixel",
                                                                // Display ID
                                                                "Pixel",
                                                                // Description
                                                                "this is Sword",
                                                                // Gold
                                                                5
                                                                );

                IRowElement item_Axe01 = ItemsTable.InsertRow(false,
                                                              // ItemTypeID
                                                              itemType_Axe.Id,
                                                              // Level
                                                              2,
                                                              // Defense
                                                              0,
                                                              // MinDamage
                                                              5,
                                                              // MaxDamage
                                                              10,
                                                              // Strength
                                                              2,
                                                              // Dexterity
                                                              0,
                                                              // Virality
                                                              0,
                                                              // Energy
                                                              0,
                                                              // Health
                                                              50,
                                                              // Mana
                                                              0,
                                                              // Icon ID
                                                              "Pixel",
                                                              // Display ID
                                                              "Pixel",
                                                              // Description
                                                              "this is Axe",
                                                              // Gold
                                                              5
                                                              );

                IRowElement item_Wand01 = ItemsTable.InsertRow(false,
                                                               // ItemTypeID
                                                               itemType_Wand.Id,
                                                               // Level
                                                               1,
                                                               // Defense
                                                               0,
                                                               // MinDamage
                                                               1,
                                                               // MaxDamage
                                                               8,
                                                               // Strength
                                                               2,
                                                               // Dexterity
                                                               0,
                                                               // Virality
                                                               0,
                                                               // Energy
                                                               4,
                                                               // Health
                                                               0,
                                                               // Mana
                                                               0,
                                                               // Icon ID
                                                               "Pixel",
                                                               // Display ID
                                                               "Pixel",
                                                               // Description
                                                               "this is Wand",
                                                               // Gold
                                                               5
                                                               );
                #endregion


                // - - - Test Zone
                IRowElement userTest = UsersTable.InsertRow(false, "1", "1", "1", "1", 1);

                IRowElement heroTest01     = HeroesTable.InsertRow(false, userTest.Id, Sorceress.Id, "Test Hero S");
                IRowElement herosaveTest01 = HeroesSaveTable.InsertRow(false, heroTest01.Id, 1, 1, 1, 0, 0);
                IRowElement savestats01    = StatsSaveTable.InsertRow(false, herosaveTest01.Id, 0, 0, 0, 0);

                IRowElement heroTest02     = HeroesTable.InsertRow(false, userTest.Id, Barbarian.Id, "Test Hero B");
                IRowElement herosaveTest02 = HeroesSaveTable.InsertRow(false, heroTest02.Id, 1, 1, 1, 0, 0);
                IRowElement savestats02    = StatsSaveTable.InsertRow(false, herosaveTest02.Id, 0, 0, 0, 0);
            }
        }
Beispiel #22
0
 public static bool Is2H(ItemTypeTable type)
 {
     return((type.Array[0] & 0x400) != 0);
 }
Beispiel #23
0
        private static ItemTable GetRandom(List <ItemTable> pool, Player player)
        {
            var       found          = false;
            ItemTable itemDefinition = null;

            //if (player.Toon.Class == ToonClass.Monk)
            while (!found)
            {
                itemDefinition = pool[RandomHelper.Next(0, pool.Count() - 1)];

                if (itemDefinition.SNOActor == -1)
                {
                    continue;
                }

                // if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue != 0)) return itemDefinition; // testing books /xsochor
                // if (itemDefinition.ItemType1 != StringHashHelper.HashItemName("Book")) continue; // testing books /xsochor
                // if (!ItemGroup.SubTypesToHashList("SpellRune").Contains(itemDefinition.ItemType1)) continue; // testing spellrunes /xsochor

                if (itemDefinition.Name.ToLower().Contains("gold"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("healthglobe"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("_104"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("pvp"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("unique"))
                {
                    if (player != null)
                    {
                        if (player.Attributes[GameAttribute.Skill, 30476] == 1)
                        {
                            int Percent = RandomHelper.Next(0, 1000);
                            if (Percent < 880)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            int Percent = RandomHelper.Next(0, 1000);
                            if (Percent < 980)
                            {
                                continue;
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                if (itemDefinition.Name.ToLower().Contains("dye"))
                {
                    if (player != null)
                    {
                        if (player.Attributes[GameAttribute.Skill, 30476] == 1)
                        {
                            int Percent = RandomHelper.Next(0, 1000);
                            if (Percent < 880)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            int Percent = RandomHelper.Next(0, 1000);
                            if (Percent < 980)
                            {
                                continue;
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                if (itemDefinition.Name.ToLower().Contains("crafted"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("test"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("debug"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("missing"))
                {
                    continue;                                                    //I believe I've seen a missing item before, may have been affix though. //Wetwlly
                }
                if ((itemDefinition.ItemType1 == StringHashHelper.HashItemName("Book")) && (itemDefinition.BaseGoldValue == 0))
                {
                    continue;                                                                                                             // i hope it catches all lore with npc spawned /xsochor
                }
                //if (itemDefinition.Name.Contains("Debug"))  continue;
                //if (itemDefinition.Quality == ItemTable.ItemQuality.Invalid) continue;
                if (itemDefinition.Name.Contains("StaffOfCow"))
                {
                    continue;
                }
                if (itemDefinition.Name.Contains("NephalemCube"))
                {
                    continue;
                }
                if (itemDefinition.Name.Contains("BladeoftheAncients"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("book"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("staffofcow"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("angelwings"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("journal"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("lore"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("craftingplan"))
                {
                    continue;
                }
                if (itemDefinition.Name.ToLower().Contains("set"))
                {
                    continue;
                }
                if (itemDefinition.Name.Contains("TalismanUnlock"))
                {
                    continue;
                }
                if (itemDefinition.Name.Contains("StoneOfRecall"))
                {
                    continue;
                }

                if (!GBIDHandlers.ContainsKey(itemDefinition.Hash) &&
                    !AllowedItemTypes.Contains(itemDefinition.ItemType1))
                {
                    continue;
                }

                if (player != null)
                {
                    if (player.Toon.Level <= 60)
                    {
                        if (itemDefinition.RequiredLevel < player.Toon.Level - 3 || itemDefinition.RequiredLevel > player.Toon.Level + 1)
                        {
                            continue;
                        }
                    }

                    if (AllowedArmorTypes.Contains(itemDefinition.Hash) || AllowedWeaponTypes.Contains(itemDefinition.Hash))
                    {
                        ItemTypeTable Type = ItemGroup.FromHash(itemDefinition.ItemType1);
                        switch (player.Toon.Class)
                        {
                        case LogNet.Toons.ToonClass.Barbarian:
                            if (Type.Flags.HasFlag(ItemFlags.Barbarian) & RandomHelper.Next(0, 100) > 40)
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }

                        case LogNet.Toons.ToonClass.DemonHunter:
                            if (Type.Flags.HasFlag(ItemFlags.DemonHunter) & RandomHelper.Next(0, 100) > 40)
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }

                        case LogNet.Toons.ToonClass.Monk:
                            if (Type.Flags.HasFlag(ItemFlags.Monk) & RandomHelper.Next(0, 100) > 40)
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }

                        case LogNet.Toons.ToonClass.WitchDoctor:
                            if (Type.Flags.HasFlag(ItemFlags.WitchDoctor) & RandomHelper.Next(0, 100) > 40)
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }

                        case LogNet.Toons.ToonClass.Wizard:
                            if (Type.Flags.HasFlag(ItemFlags.Wizard) & RandomHelper.Next(0, 100) > 40)
                            {
                                break;
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }
                found = true;
            }

            return(itemDefinition);
        }
Beispiel #24
0
 public static bool IsSubType(ItemTypeTable type, string rootTypeName)
 {
     return(IsSubType(type, StringHashHelper.HashItemName(rootTypeName)));
 }
Beispiel #25
0
 public Item(SerializationInfo info, StreamingContext context)
 {
     this.id     = (int)info.GetValue("id", typeof(int));
     this.amount = (uint)info.GetValue("amount", typeof(uint));
     this._type  = ItemTypeTable.GetItemType(id);
 }
Beispiel #26
0
 public static bool IsHealthGlobe(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "HealthGlyph"));
 }
Beispiel #27
0
 public static bool IsGold(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Gold"));
 }
Beispiel #28
0
        static void Main(string[] args)
        {
            LogManager.Enabled = true;
            LogManager.AttachLogTarget(new ConsoleTarget(Logger.Level.Trace, Logger.Level.Fatal, false));

            #region Scenes

            using (FileStream navStream = new FileStream("NavCells.bin", FileMode.Create, FileAccess.Write))
            {
                using (BinaryWriter navWriter = new BinaryWriter(navStream))
                {
                    var scenes = MPQStorage.Data.Assets[SNOGroup.Scene];

                    foreach (Asset asset in scenes.Values)
                    {
                        Scene scene = asset.Data as Scene;

                        navWriter.Write(asset.SNOId);
                        navWriter.Write(scene.NavZone.NavCells.Count);

                        foreach (Scene.NavCell cell in scene.NavZone.NavCells)
                        {
                            navWriter.Write(cell.Min.X);
                            navWriter.Write(cell.Min.Y);
                            navWriter.Write(cell.Min.Z);
                            navWriter.Write(cell.Max.X);
                            navWriter.Write(cell.Max.Y);
                            navWriter.Write(cell.Max.Z);
                            navWriter.Write((int)cell.Flags);
                        }
                    }
                }
            }

            #endregion Scenes

            #region Experience

            List <ExperienceTable> xpTable = null;
            foreach (Asset asset in MPQStorage.Data.Assets[SNOGroup.GameBalance].Values)
            {
                if (((GameBalance)asset.Data).Experience.Count > 0)
                {
                    xpTable = ((GameBalance)asset.Data).Experience;
                    break;
                }
            }

            using (StreamWriter xpWriter = new StreamWriter("Experience.cs"))
            {
                xpWriter.WriteLine("using System;");
                xpWriter.WriteLine();
                xpWriter.WriteLine("namespace libdiablo3.Api");
                xpWriter.WriteLine("{");
                xpWriter.WriteLine("    public static class Experience");
                xpWriter.WriteLine("    {");
                xpWriter.WriteLine("        public static int[] Levels =");
                xpWriter.WriteLine("        {");

                int prevXP = 0;
                for (int i = 0; i < xpTable.Count; i++)
                {
                    int xp = xpTable[i].Exp - prevXP;
                    prevXP = xpTable[i].Exp;
                    xpWriter.WriteLine("            " + xp + ", // " + i);
                }

                xpWriter.WriteLine("        };");
                xpWriter.WriteLine("    }");
                xpWriter.WriteLine("}");
                xpWriter.WriteLine();
            }

            #endregion Experience

            #region Item Types

            Dictionary <int, ItemTable>     items     = new Dictionary <int, ItemTable>();
            Dictionary <int, ItemTypeTable> itemTypes = new Dictionary <int, ItemTypeTable>();

            foreach (Asset asset in MPQStorage.Data.Assets[SNOGroup.GameBalance].Values)
            {
                GameBalance gb = asset.Data as GameBalance;
                foreach (ItemTable item in gb.Item)
                {
                    items.Add(item.Hash, item);
                }
                foreach (ItemTypeTable itemType in gb.ItemType)
                {
                    itemTypes.Add(itemType.Hash, itemType);
                }
            }

            using (StreamWriter itemWriter = new StreamWriter("ItemDefinitions.cs"))
            {
                itemWriter.WriteLine("using System;");
                itemWriter.WriteLine("using System.Collections.Generic;");
                itemWriter.WriteLine();
                itemWriter.WriteLine("namespace libdiablo3.Api");
                itemWriter.WriteLine("{");
                itemWriter.WriteLine("    public static class ItemDefinitions");
                itemWriter.WriteLine("    {");
                itemWriter.WriteLine("        public static readonly Dictionary<int, ItemDefinition> Definitions = new Dictionary<int, ItemDefinition>");
                itemWriter.WriteLine("        {");

                foreach (KeyValuePair <int, ItemTable> kvp in items)
                {
                    ItemTable item = kvp.Value;
                    itemWriter.WriteLine("            {{ {0}, new ItemDefinition({1}, {2}, {3}, {4}, {5}, {6}, {7}) }},", kvp.Key,
                                         (int)item.Quality, item.ItemLevel, item.RequiredLevel, item.BaseGoldValue, item.MaxSockets, item.MaxStackAmount, item.ItemType1);
                }

                itemWriter.WriteLine("        };");
                itemWriter.WriteLine("    }");
                itemWriter.WriteLine("}");
                itemWriter.WriteLine();
            }

            using (StreamWriter itemWriter = new StreamWriter("ItemTypes.cs"))
            {
                itemWriter.WriteLine("using System;");
                itemWriter.WriteLine("using System.Collections.Generic;");
                itemWriter.WriteLine();
                itemWriter.WriteLine("namespace libdiablo3.Api");
                itemWriter.WriteLine("{");
                itemWriter.WriteLine("    public static class ItemTypes");
                itemWriter.WriteLine("    {");
                itemWriter.WriteLine("        public static readonly Dictionary<int, ItemType> Types = new Dictionary<int, ItemType>");
                itemWriter.WriteLine("        {");

                foreach (KeyValuePair <int, ItemTypeTable> kvp in itemTypes)
                {
                    ItemTypeTable type = kvp.Value;
                    itemWriter.WriteLine("            {{ {0}, new ItemType(\"{1}\", {2}, {3}, {4}) }},",
                                         kvp.Key, type.Name, type.Hash, type.ParentType, (int)type.Flags);
                }

                itemWriter.WriteLine("        };");
                itemWriter.WriteLine("    }");
                itemWriter.WriteLine("}");
                itemWriter.WriteLine();
            }

            #endregion Item Types

            using (StreamWriter enumWriter = new StreamWriter("ActorName.cs"))
            {
                enumWriter.WriteLine("using System;");
                enumWriter.WriteLine();
                enumWriter.WriteLine("namespace libdiablo3.Api");
                enumWriter.WriteLine("{");
                enumWriter.WriteLine("    public enum ActorName");
                enumWriter.WriteLine("    {");

                using (StreamWriter templateWriter = new StreamWriter("ActorTemplates.cs"))
                {
                    templateWriter.WriteLine("using System;");
                    templateWriter.WriteLine("using System.Collections.Generic;");
                    templateWriter.WriteLine();
                    templateWriter.WriteLine("namespace libdiablo3.Api");
                    templateWriter.WriteLine("{");
                    templateWriter.WriteLine("    public static class ActorTemplates");
                    templateWriter.WriteLine("    {");
                    templateWriter.WriteLine("        public static readonly Dictionary<int, Actor> Actors = new Dictionary<int, Actor>");
                    templateWriter.WriteLine("        {");

                    var actors   = MPQStorage.Data.Assets[SNOGroup.Actor];
                    var monsters = MPQStorage.Data.Assets[SNOGroup.Monster];

                    foreach (Asset asset in actors.Values)
                    {
                        Actor actor = asset.Data as Actor;

                        string sanitizedName = asset.Name.Replace('\'', '_').Replace(' ', '_').Replace('-', '_').Replace('(', '_').Replace(')', '_');
                        enumWriter.WriteLine("        {0} = {1},", sanitizedName, actor.Header.SNOId);

                        switch (actor.Type)
                        {
                        case ActorType.Gizmo:
                            WriteGizmoActor(templateWriter, actor);
                            break;

                        case ActorType.Item:
                            WriteItemActor(templateWriter, actor);
                            break;

                        case ActorType.Monster:
                            WriteMonsterActor(templateWriter, actor, monsters);
                            break;

                        case ActorType.Player:
                            WritePlayerActor(templateWriter, actor);
                            break;

                        case ActorType.AxeSymbol:
                        case ActorType.ClientEffect:
                        case ActorType.Critter:
                        case ActorType.CustomBrain:
                        case ActorType.Enviroment:
                        case ActorType.Invalid:
                        case ActorType.Projectile:
                        case ActorType.ServerProp:
                        default:
                            WriteDefaultActor(templateWriter, actor);
                            break;
                        }
                    }

                    templateWriter.WriteLine("        };");
                    templateWriter.WriteLine("    }");
                    templateWriter.WriteLine("}");
                    templateWriter.WriteLine();
                }

                enumWriter.WriteLine("    }");
                enumWriter.WriteLine("}");
                enumWriter.WriteLine();
            }

            Console.WriteLine("Done writing .cs files");
        }