void Item::ApplyRandomProperties( bool apply ) { // apply random properties if( m_uint32Values[ITEM_FIELD_RANDOM_PROPERTIES_ID] != 0 ) { if( int32( m_uint32Values[ITEM_FIELD_RANDOM_PROPERTIES_ID] ) > 0 ) // Random Property { ItemRandomPropertiesEntry* rp= dbcItemRandomProperties.LookupEntry( m_uint32Values[ITEM_FIELD_RANDOM_PROPERTIES_ID] ); if(rp == NULL) return; int32 Slot; for( int k = 0; k < 3; k++ ) { if( rp->spells[k] != 0 ) { EnchantEntry* ee = dbcEnchant.LookupEntry( rp->spells[k] ); Slot = HasEnchantment( ee->Id ); if( Slot < 0 ) { Slot = FindFreeEnchantSlot( ee, 1 ); AddEnchantment( ee, 0, false, apply, true, Slot ); } else if( apply ) ApplyEnchantmentBonus( Slot, true ); } } } else { ItemRandomSuffixEntry* rs = dbcItemRandomSuffix.LookupEntry( abs( int( m_uint32Values[ITEM_FIELD_RANDOM_PROPERTIES_ID] ) ) ); if(rs == NULL) return; int32 Slot; for( uint32 k = 0; k < 3; ++k ) { if( rs->enchantments[k] != 0 ) { EnchantEntry* ee = dbcEnchant.LookupEntry( rs->enchantments[k] ); Slot = HasEnchantment( ee->Id ); if( Slot < 0 ) { Slot = FindFreeEnchantSlot( ee, 2 ); AddEnchantment( ee, 0, false, apply, true, Slot, rs->prefixes[k] ); } else if( apply ) ApplyEnchantmentBonus( Slot, true ); } } } } }
void Item::ApplyRandomProperties(bool apply) { // apply random properties if (GetItemRandomPropertyId() != 0) { if (int32(GetItemRandomPropertyId()) > 0) { RandomProps* rp = dbcRandomProps.LookupEntry(GetItemRandomPropertyId()); int32 Slot; for (int k = 0; k < 3; k++) { if (rp->spells[k] != 0) { EnchantEntry* ee = dbcEnchant.LookupEntry(rp->spells[k]); Slot = HasEnchantment(ee->Id); if (Slot < 0) { Slot = FindFreeEnchantSlot(ee, 1); AddEnchantment(ee, 0, false, apply, true, Slot); } else if (apply) ApplyEnchantmentBonus(Slot, true); } } } else { ItemRandomSuffixEntry* rs = dbcItemRandomSuffix.LookupEntry(abs(int(GetItemRandomPropertyId()))); int32 Slot; for (uint32 k = 0; k < 3; ++k) { if (rs->enchantments[k] != 0) { EnchantEntry* ee = dbcEnchant.LookupEntry(rs->enchantments[k]); Slot = HasEnchantment(ee->Id); if (Slot < 0) { Slot = FindFreeEnchantSlot(ee, 2); AddEnchantment(ee, 0, false, apply, true, Slot, rs->prefixes[k]); } else if (apply) ApplyEnchantmentBonus(Slot, true); } } } } }