Add support to set RandomProperty / RandomSuffix to -1 in item_template

--HG--
branch : trunk
This commit is contained in:
Spp
2010-05-04 17:51:11 +02:00
parent 5b4647dcf4
commit 390f11078f
4 changed files with 17 additions and 6 deletions

View File

@@ -554,7 +554,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
// RandomProperty case
if (itemProto->RandomProperty)
{
int32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
ItemRandomPropertiesEntry const *random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
if (!random_id)
{

View File

@@ -86,11 +86,22 @@ void LoadRandomEnchantmentsTable()
}
}
uint32 GetItemEnchantMod(uint32 entry)
uint32 GetItemEnchantMod(int32 entry)
{
if (!entry) return 0;
if (!entry)
return 0;
EnchantmentStore::const_iterator tab = RandomItemEnch.find(entry);
EnchantmentStore::const_iterator tab;
if (entry == -1)
{
tab = RandomItemEnch.begin();
entry = urand(1, RandomItemEnch.size()) - 1;
for (uint32 i = 0; i < entry; ++i)
++tab;
}
else
tab = RandomItemEnch.find(entry);
if (tab == RandomItemEnch.end())
{

View File

@@ -24,7 +24,7 @@
#include "Common.h"
void LoadRandomEnchantmentsTable();
uint32 GetItemEnchantMod(uint32 entry);
uint32 GetItemEnchantMod(int32 entry);
uint32 GenerateEnchSuffixFactor(uint32 item_id);
#endif

View File

@@ -570,7 +570,7 @@ struct ItemPrototype
int32 Material; // id from Material.dbc
uint32 Sheath;
int32 RandomProperty; // id from ItemRandomProperties.dbc
uint32 RandomSuffix; // id from ItemRandomSuffix.dbc
int32 RandomSuffix; // id from ItemRandomSuffix.dbc
uint32 Block;
uint32 ItemSet; // id from ItemSet.dbc
uint32 MaxDurability;