Skip to content

Commit ea41228

Browse files
committed
Core/Items: Extract GetRandomPropertyPoints logic from GenerateEnchSuffixFactor
(cherry picked from commit 6437084)
1 parent 3a1b269 commit ea41228

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

‎src/server/game/Entities/Item/ItemEnchantmentMgr.cpp‎

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -174,72 +174,67 @@ uint32 GenerateEnchSuffixFactor(uint32 item_id)
174174
if (!itemProto->RandomSuffix)
175175
return 0;
176176

177-
RandPropPointsEntry const* randomProperty = sRandPropPointsStore.LookupEntry(itemProto->ItemLevel);
178-
if (!randomProperty)
179-
return 0;
177+
return GetRandomPropertyPoints(itemProto->ItemLevel, itemProto->Quality, itemProto->InventoryType);
178+
}
180179

181-
uint32 suffixFactor;
182-
switch (itemProto->InventoryType)
180+
uint32 GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType)
181+
{
182+
uint32 propIndex;
183+
184+
switch (inventoryType)
183185
{
184-
// Items of that type don`t have points
185-
case INVTYPE_NON_EQUIP:
186-
case INVTYPE_BAG:
187-
case INVTYPE_TABARD:
188-
case INVTYPE_AMMO:
189-
case INVTYPE_QUIVER:
190-
case INVTYPE_RELIC:
191-
return 0;
192-
// Select point coefficient
193186
case INVTYPE_HEAD:
194187
case INVTYPE_BODY:
195188
case INVTYPE_CHEST:
196189
case INVTYPE_LEGS:
197190
case INVTYPE_2HWEAPON:
198191
case INVTYPE_ROBE:
199-
suffixFactor = 0;
192+
propIndex = 0;
200193
break;
201194
case INVTYPE_SHOULDERS:
202195
case INVTYPE_WAIST:
203196
case INVTYPE_FEET:
204197
case INVTYPE_HANDS:
205198
case INVTYPE_TRINKET:
206-
suffixFactor = 1;
199+
propIndex = 1;
207200
break;
208201
case INVTYPE_NECK:
209202
case INVTYPE_WRISTS:
210203
case INVTYPE_FINGER:
211204
case INVTYPE_SHIELD:
212205
case INVTYPE_CLOAK:
213206
case INVTYPE_HOLDABLE:
214-
suffixFactor = 2;
207+
propIndex = 2;
215208
break;
216209
case INVTYPE_WEAPON:
217210
case INVTYPE_WEAPONMAINHAND:
218211
case INVTYPE_WEAPONOFFHAND:
219-
suffixFactor = 3;
212+
propIndex = 3;
220213
break;
221214
case INVTYPE_RANGED:
222215
case INVTYPE_THROWN:
223216
case INVTYPE_RANGEDRIGHT:
224-
suffixFactor = 4;
217+
propIndex = 4;
225218
break;
226219
default:
227220
return 0;
228221
}
229-
// Select rare/epic modifier
230-
switch (itemProto->Quality)
222+
223+
RandPropPointsEntry const* randPropPointsEntry = sRandPropPointsStore.LookupEntry(itemLevel);
224+
if (!randPropPointsEntry)
225+
return 0;
226+
227+
switch (quality)
231228
{
232229
case ITEM_QUALITY_UNCOMMON:
233-
return randomProperty->Good[suffixFactor];
230+
return randPropPointsEntry->Good[propIndex];
234231
case ITEM_QUALITY_RARE:
235-
return randomProperty->Superior[suffixFactor];
232+
return randPropPointsEntry->Superior[propIndex];
236233
case ITEM_QUALITY_EPIC:
237-
return randomProperty->Epic[suffixFactor];
238-
case ITEM_QUALITY_LEGENDARY:
239-
case ITEM_QUALITY_ARTIFACT:
240-
return 0; // not have random properties
234+
return randPropPointsEntry->Epic[propIndex];
241235
default:
242236
break;
243237
}
238+
244239
return 0;
245240
}

‎src/server/game/Entities/Item/ItemEnchantmentMgr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ TC_GAME_API void LoadRandomEnchantmentsTable();
2424
TC_GAME_API int32 GenerateItemRandomPropertyId(uint32 item_id);
2525
TC_GAME_API uint32 GetItemEnchantMod(int32 entry);
2626
TC_GAME_API uint32 GenerateEnchSuffixFactor(uint32 item_id);
27+
TC_GAME_API uint32 GetRandomPropertyPoints(uint32 itemLevel, uint32 quality, uint32 inventoryType);
2728

2829
#endif

0 commit comments

Comments
 (0)