Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CItem::ChangeRareAttributeUnCommon()
- {
- if (GetRareAttrCountUnCommon() == 0)
- return false;
- int cnt = GetRareAttrCountUnCommon();
- for (int i = 0; i < cnt; ++i)
- {
- m_aAttr[12].bType = 0;
- m_aAttr[12].sValue = 0;
- m_aAttr[13].bType = 0;
- m_aAttr[13].sValue = 0;
- m_aAttr[14].bType = 0;
- m_aAttr[14].sValue = 0;
- m_aAttr[15].bType = 0;
- m_aAttr[15].sValue = 0;
- m_aAttr[16].bType = 0;
- m_aAttr[16].sValue = 0;
- }
- if (GetOwner() && GetOwner()->GetDesc())
- LogManager::instance().ItemLog(GetOwner(), this, "SET_UNCOMMON", "");
- else
- LogManager::instance().ItemLog(0, 0, 0, GetID(), "SET_UNCOMMON", "", "", GetOriginalVnum());
- for (int i = 0; i < cnt; ++i)
- {
- AddRareAttributeUnCommon();
- }
- return true;
- }
- bool CItem::AddRareAttributeUnCommon()
- {
- if (GetType() == ITEM_WEAPON && GetSubType() == WEAPON_ARROW)
- return false;
- int count = GetRareAttrCountUnCommon();
- if (count >= 5)
- return false;
- int pos = count + 12;
- TPlayerItemAttribute& attr = m_aAttr[pos];
- int nAttrSet = GetAttributeSetIndex();
- std::vector<int> avail;
- for (int i = 0; i < MAX_APPLY_NUM; ++i)
- {
- const TItemAttrTable& r = g_map_itemRareUnCommon[i];
- if (r.dwApplyIndex != 0 && r.bMaxLevelBySet[nAttrSet] > 0 && HasRareAttrUnCommon(i) != true)
- {
- avail.push_back(i);
- }
- }
- const TItemAttrTable& r = g_map_itemRareUnCommon[avail[number(0, avail.size() - 1)]];
- int nAttrLevel = (rand() % 5) + 1;
- if (nAttrLevel > r.bMaxLevelBySet[nAttrSet])
- nAttrLevel = r.bMaxLevelBySet[nAttrSet];
- attr.bType = r.dwApplyIndex;
- attr.sValue = r.lValues[nAttrLevel - 1];
- UpdatePacket();
- Save();
- const char* pszIP = NULL;
- if (GetOwner() && GetOwner()->GetDesc())
- pszIP = GetOwner()->GetDesc()->GetHostName();
- LogManager::instance().ItemLog(pos, attr.bType, attr.sValue, GetID(), "SET_UNCOMMON", "", pszIP ? pszIP : "", GetOriginalVnum());
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement