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
+1 -1
View File
@@ -554,7 +554,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
// RandomProperty case // RandomProperty case
if (itemProto->RandomProperty) if (itemProto->RandomProperty)
{ {
int32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty); uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
ItemRandomPropertiesEntry const *random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId); ItemRandomPropertiesEntry const *random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
if (!random_id) if (!random_id)
{ {
+14 -3
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()) if (tab == RandomItemEnch.end())
{ {
+1 -1
View File
@@ -24,7 +24,7 @@
#include "Common.h" #include "Common.h"
void LoadRandomEnchantmentsTable(); void LoadRandomEnchantmentsTable();
uint32 GetItemEnchantMod(uint32 entry); uint32 GetItemEnchantMod(int32 entry);
uint32 GenerateEnchSuffixFactor(uint32 item_id); uint32 GenerateEnchSuffixFactor(uint32 item_id);
#endif #endif
+1 -1
View File
@@ -570,7 +570,7 @@ struct ItemPrototype
int32 Material; // id from Material.dbc int32 Material; // id from Material.dbc
uint32 Sheath; uint32 Sheath;
int32 RandomProperty; // id from ItemRandomProperties.dbc int32 RandomProperty; // id from ItemRandomProperties.dbc
uint32 RandomSuffix; // id from ItemRandomSuffix.dbc int32 RandomSuffix; // id from ItemRandomSuffix.dbc
uint32 Block; uint32 Block;
uint32 ItemSet; // id from ItemSet.dbc uint32 ItemSet; // id from ItemSet.dbc
uint32 MaxDurability; uint32 MaxDurability;