示例#1
0
 private static void SetAllowedTypes()
 {
     foreach (int hash in ItemGroup.SubTypesToHashList("Weapon"))
     {
         AllowedItemTypes.Add(hash);
     }
     foreach (int hash in ItemGroup.SubTypesToHashList("Armor"))
     {
         AllowedItemTypes.Add(hash);
     }
     foreach (int hash in ItemGroup.SubTypesToHashList("Offhand"))
     {
         AllowedItemTypes.Add(hash);
     }
     foreach (int hash in ItemGroup.SubTypesToHashList("Jewelry"))
     {
         AllowedItemTypes.Add(hash);
     }
     foreach (int hash in ItemGroup.SubTypesToHashList("Utility"))
     {
         AllowedItemTypes.Add(hash);
     }
     foreach (int hash in ItemGroup.SubTypesToHashList("CraftingPlan"))
     {
         AllowedItemTypes.Add(hash);
     }
     foreach (int hash in TypeHandlers.Keys)
     {
         if (AllowedItemTypes.Contains(hash))
         {
             // already added structure
             continue;
         }
         foreach (int subhash in ItemGroup.SubTypesToHashList(ItemGroup.FromHash(hash).Name))
         {
             if (AllowedItemTypes.Contains(subhash))
             {
                 // already added structure
                 continue;
             }
             AllowedItemTypes.Add(subhash);
         }
     }
 }
示例#2
0
 private void SetInitialValues(ItemTable definition)
 {
     this.ItemDefinition    = definition;
     this.ItemLevel         = definition.ItemLevel;
     this.GBHandle.Type     = (int)GBHandleType.Gizmo;
     this.GBHandle.GBID     = definition.Hash;
     this.ItemType          = ItemGroup.FromHash(definition.ItemType1);
     this.EquipmentSlot     = 0;
     this.InventoryLocation = new Vector2D {
         X = 0, Y = 0
     };
     this.Scale     = 1.0f;
     this.RotationW = 0.0f;
     this.RotationAxis.Set(0.0f, 0.0f, 1.0f);
     this.CurrentState = ItemState.Normal;
     this.Field2       = 0x00000000;
     this.Field7       = 0;
     this.NameSNOId    = -1;   // I think it is ignored anyways - farmy
     this.Field10      = 0x00;
 }
示例#3
0
        public static Type GetItemClass(ItemTable definition)
        {
            Type type = typeof(Item);

            if (GBIDHandlers.ContainsKey(definition.Hash))
            {
                type = GBIDHandlers[definition.Hash];
            }
            else
            {
                foreach (var hash in ItemGroup.HierarchyToHashList(ItemGroup.FromHash(definition.ItemType1)))
                {
                    if (TypeHandlers.ContainsKey(hash))
                    {
                        type = TypeHandlers[hash];
                        break;
                    }
                }
            }

            return(type);
        }
示例#4
0
 public static bool Is2H(ItemTypeTable itemType)
 {
     return(ItemGroup.Is2H(itemType));
 }
示例#5
0
 public static bool IsOffhand(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Offhand"));
 }
示例#6
0
 public static bool IsArmor(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Armor"));
 }
示例#7
0
 public static bool IsWeapon(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Weapon"));
 }
示例#8
0
 public static bool IsDye(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Dye"));
 }
示例#9
0
 public static bool IsJournalOrScroll(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Scroll") || ItemGroup.IsSubType(itemType, "Book"));
 }
示例#10
0
 public static bool IsRuneOrJewel(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Gem") || ItemGroup.IsSubType(itemType, "SpellRune"));
 }
示例#11
0
 public static bool IsAccessory(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Jewelry"));
 }
示例#12
0
 public static bool IsGold(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "Gold"));
 }
示例#13
0
 public static bool IsHealthGlobe(ItemTypeTable itemType)
 {
     return(ItemGroup.IsSubType(itemType, "HealthGlyph"));
 }
示例#14
0
        public Item(GS.Map.World world, ItemTable definition)
            : base(world, definition.SNOActor)
        {
            this.ItemDefinition = definition;

            this.GBHandle.Type     = (int)GBHandleType.Gizmo;
            this.GBHandle.GBID     = definition.Hash;
            this.ItemType          = ItemGroup.FromHash(definition.ItemType1);
            this.EquipmentSlot     = 0;
            this.InventoryLocation = new Vector2D {
                X = 0, Y = 0
            };
            this.Scale     = 1.0f;
            this.RotationW = 0.0f;
            this.RotationAxis.Set(0.0f, 0.0f, 1.0f);
            this.CurrentState = ItemState.Normal;
            this.Field2       = 0x00000000;
            this.Field7       = 0;
            this.NameSNOId    = -1;   // I think it is ignored anyways - farmy
            this.Field10      = 0x00;

            this.ItemLevel = definition.ItemLevel;

            // level requirement
            // Attributes[GameAttribute.Requirement, 38] = definition.RequiredLevel;

            Attributes[GameAttribute.Item_Quality_Level] = 1;
            if (Item.IsArmor(this.ItemType) || Item.IsWeapon(this.ItemType) || Item.IsOffhand(this.ItemType))
            {
                Attributes[GameAttribute.Item_Quality_Level] = RandomHelper.Next(6);
            }
            if (this.ItemType.Flags.HasFlag(ItemFlags.AtLeastMagical) && Attributes[GameAttribute.Item_Quality_Level] < 3)
            {
                Attributes[GameAttribute.Item_Quality_Level] = 3;
            }

            Attributes[GameAttribute.ItemStackQuantityLo] = 1;
            Attributes[GameAttribute.Seed] = RandomHelper.Next(); //unchecked((int)2286800181);

            RandomGenerator = new ItemRandomHelper(Attributes[GameAttribute.Seed]);
            RandomGenerator.Next();
            if (Item.IsArmor(this.ItemType))
            {
                RandomGenerator.Next(); // next value is used but unknown if armor
            }
            RandomGenerator.ReinitSeed();

            ApplyWeaponSpecificOptions(definition);
            ApplyArmorSpecificOptions(definition);
            ApplyDurability(definition);
            ApplySkills(definition);
            ApplyAttributeSpecifier(definition);

            int affixNumber = 1;

            if (Attributes[GameAttribute.Item_Quality_Level] >= 3)
            {
                affixNumber = Attributes[GameAttribute.Item_Quality_Level] - 2;
            }
            AffixGenerator.Generate(this, affixNumber);
        }
示例#15
0
        public static void Generate(Item item, int affixesCount)
        {
            if (!Item.IsWeapon(item.ItemType) &&
                !Item.IsArmor(item.ItemType) &&
                !Item.IsOffhand(item.ItemType) &&
                !Item.IsAccessory(item.ItemType))
            {
                return;
            }

            var itemTypes       = ItemGroup.HierarchyToHashList(item.ItemType);
            int itemQualityMask = 1 << item.Attributes[GameAttribute.Item_Quality_Level];

            var filteredList = AffixList.Where(a =>
                                               a.QualityMask.HasFlag((QualityMask)itemQualityMask) &&
                                               itemTypes.ContainsAtLeastOne(a.ItemGroup) &&
                                               a.AffixLevel <= item.ItemLevel);

            Dictionary <int, AffixTable> bestDefinitions = new Dictionary <int, AffixTable>();

            foreach (var affix in filteredList)
            {
                bestDefinitions[affix.AffixFamily0] = affix;
            }

            var selectedGroups = bestDefinitions.Values.OrderBy(x => RandomHelper.Next()).Take(affixesCount);

            foreach (var def in selectedGroups)
            {
                if (def != null)
                {
                    //Logger.Debug("Generating affix " + def.Name + " (aLvl:" + def.AffixLevel + ")");
                    item.AffixList.Add(new Affix(def.Hash));
                    foreach (var effect in def.AttributeSpecifier)
                    {
                        if (effect.AttributeId > 0)
                        {
                            float result;
                            if (FormulaScript.Evaluate(effect.Formula.ToArray(), item.RandomGenerator, out result))
                            {
                                //Logger.Debug("Randomized value for attribute " + GameAttribute.Attributes[effect.AttributeId].Name + " is " + result);

                                if (GameAttribute.Attributes[effect.AttributeId] is GameAttributeF)
                                {
                                    var attr = GameAttribute.Attributes[effect.AttributeId] as GameAttributeF;
                                    if (effect.SNOParam != -1)
                                    {
                                        item.Attributes[attr, effect.SNOParam] += result;
                                    }
                                    else
                                    {
                                        item.Attributes[attr] += result;
                                    }
                                }
                                else if (GameAttribute.Attributes[effect.AttributeId] is GameAttributeI)
                                {
                                    var attr = GameAttribute.Attributes[effect.AttributeId] as GameAttributeI;
                                    if (effect.SNOParam != -1)
                                    {
                                        item.Attributes[attr, effect.SNOParam] += (int)result;
                                    }
                                    else
                                    {
                                        item.Attributes[attr] += (int)result;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }