void UpdateItemSuffixFactor() { uint suffixFactor = ItemEnchantment.GenerateEnchSuffixFactor(GetEntry()); if (GetItemSuffixFactor() == suffixFactor) { return; } SetValue <uint>(ItemFields.PropertySeed, suffixFactor); }
public static int GenerateItemRandomPropertyId(uint item_id) { ItemTemplate itemProto = Cypher.ObjMgr.GetItemTemplate(item_id); if (itemProto == null) { return(0); } // item must have one from this field values not null if it can have random enchantments if (itemProto.RandomProperty == 0 && itemProto.RandomSuffix == 0) { return(0); } // item can have not null only one from field values if (itemProto.RandomProperty != 0 && itemProto.RandomSuffix != 0) { Log.outError("Item template {0} have RandomProperty == {1} and RandomSuffix == {2}, but must have one from field =0", itemProto.ItemId, itemProto.RandomProperty, itemProto.RandomSuffix); return(0); } // RandomProperty case if (itemProto.RandomProperty != 0) { uint randomPropId = ItemEnchantment.GetItemEnchantMod((int)itemProto.RandomProperty); ItemRandomPropertiesEntry random_id = DBCStorage.ItemRandomPropertiesStorage.LookupByKey(randomPropId); if (random_id == null) { Log.outError("Enchantment id #{0} used but it doesn't have records in 'ItemRandomProperties.dbc'", randomPropId); return(0); } return((int)random_id.ID); } // RandomSuffix case else { uint randomPropId = ItemEnchantment.GetItemEnchantMod((int)itemProto.RandomSuffix); ItemRandomSuffixEntry random_id = DBCStorage.ItemRandomSuffixStorage.LookupByKey(randomPropId); if (random_id == null) { Log.outError("Enchantment id #{0} used but it doesn't have records in sItemRandomSuffixStore.", randomPropId); return(0); } return(-(int)random_id.ID); } }