Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CItem::PutAttributeWithLevel(BYTE bLevel)
- {
- int iAttributeSet = GetAttributeSetIndex();
- if (iAttributeSet < 0)
- return;
- if (bLevel > ITEM_ATTRIBUTE_MAX_LEVEL)
- return;
- std::vector<int> avail;
- int total = 0;
- for (int i = 0; i < MAX_APPLY_NUM; ++i)
- {
- const TItemAttrTable & r = g_map_itemAttr[i];
- if (r.bMaxLevelBySet[iAttributeSet] && !HasAttr(i))
- {
- avail.push_back(i);
- total += r.dwProb;
- }
- }
- unsigned int prob = number(1, total);
- int attr_idx = APPLY_NONE;
- for (DWORD i = 0; i < avail.size(); ++i)
- {
- const TItemAttrTable & r = g_map_itemAttr[avail[i]];
- if (prob <= r.dwProb)
- {
- attr_idx = avail[i];
- break;
- }
- prob -= r.dwProb;
- }
- if (!attr_idx)
- {
- sys_err("Cannot put item attribute %d %d", iAttributeSet, bLevel);
- return;
- }
- const TItemAttrTable & r = g_map_itemAttr[attr_idx];
- if (bLevel > r.bMaxLevelBySet[iAttributeSet])
- bLevel = r.bMaxLevelBySet[iAttributeSet];
- AddAttr(attr_idx, bLevel);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement