private static void SetAllowedTypes() { foreach (int hash in ItemGroup.SubTypesToHashList("Weapon")) { AllowedWeaponTypes.Add(hash); AllowedItemTypes.Add(hash); } foreach (int hash in ItemGroup.SubTypesToHashList("Armor")) { AllowedArmorTypes.Add(hash); 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); } } }
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; }
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); }
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); var tmpAttr = GameAttribute.Attributes[effect.AttributeId]; var attrName = tmpAttr.Name; 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; } } } } } } } }
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); }
public static bool Is2H(ItemTypeTable itemType) { return(ItemGroup.Is2H(itemType)); }
public static bool IsOffhand(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Offhand")); }
public static bool IsArmor(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Armor")); }
public static bool IsWeapon(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Weapon")); }
public static bool IsDye(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Dye")); }
public static bool IsJournalOrScroll(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Scroll") || ItemGroup.IsSubType(itemType, "Book")); }
public static bool IsRuneOrJewel(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Gem") || ItemGroup.IsSubType(itemType, "SpellRune")); }
public static bool IsAccessory(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Jewelry")); }
public static bool IsGold(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "Gold")); }
public static bool IsHealthGlobe(ItemTypeTable itemType) { return(ItemGroup.IsSubType(itemType, "HealthGlyph")); }