Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. bool CItem::ChangeRareAttributeUnCommon()
  2. {
  3. if (GetRareAttrCountUnCommon() == 0)
  4. return false;
  5.  
  6. int cnt = GetRareAttrCountUnCommon();
  7.  
  8. for (int i = 0; i < cnt; ++i)
  9. {
  10. m_aAttr[12].bType = 0;
  11. m_aAttr[12].sValue = 0;
  12. m_aAttr[13].bType = 0;
  13. m_aAttr[13].sValue = 0;
  14. m_aAttr[14].bType = 0;
  15. m_aAttr[14].sValue = 0;
  16. m_aAttr[15].bType = 0;
  17. m_aAttr[15].sValue = 0;
  18. m_aAttr[16].bType = 0;
  19. m_aAttr[16].sValue = 0;
  20. }
  21.  
  22. if (GetOwner() && GetOwner()->GetDesc())
  23. LogManager::instance().ItemLog(GetOwner(), this, "SET_UNCOMMON", "");
  24. else
  25. LogManager::instance().ItemLog(0, 0, 0, GetID(), "SET_UNCOMMON", "", "", GetOriginalVnum());
  26.  
  27. for (int i = 0; i < cnt; ++i)
  28. {
  29. AddRareAttributeUnCommon();
  30. }
  31.  
  32. return true;
  33. }
  34. bool CItem::AddRareAttributeUnCommon()
  35. {
  36. if (GetType() == ITEM_WEAPON && GetSubType() == WEAPON_ARROW)
  37. return false;
  38.  
  39. int count = GetRareAttrCountUnCommon();
  40.  
  41. if (count >= 5)
  42. return false;
  43.  
  44. int pos = count + 12;
  45. TPlayerItemAttribute& attr = m_aAttr[pos];
  46.  
  47. int nAttrSet = GetAttributeSetIndex();
  48. std::vector<int> avail;
  49.  
  50. for (int i = 0; i < MAX_APPLY_NUM; ++i)
  51. {
  52. const TItemAttrTable& r = g_map_itemRareUnCommon[i];
  53.  
  54. if (r.dwApplyIndex != 0 && r.bMaxLevelBySet[nAttrSet] > 0 && HasRareAttrUnCommon(i) != true)
  55. {
  56. avail.push_back(i);
  57. }
  58. }
  59.  
  60. const TItemAttrTable& r = g_map_itemRareUnCommon[avail[number(0, avail.size() - 1)]];
  61.  
  62. int nAttrLevel = (rand() % 5) + 1;
  63.  
  64. if (nAttrLevel > r.bMaxLevelBySet[nAttrSet])
  65. nAttrLevel = r.bMaxLevelBySet[nAttrSet];
  66.  
  67. attr.bType = r.dwApplyIndex;
  68. attr.sValue = r.lValues[nAttrLevel - 1];
  69.  
  70. UpdatePacket();
  71.  
  72. Save();
  73.  
  74. const char* pszIP = NULL;
  75.  
  76. if (GetOwner() && GetOwner()->GetDesc())
  77. pszIP = GetOwner()->GetDesc()->GetHostName();
  78.  
  79. LogManager::instance().ItemLog(pos, attr.bType, attr.sValue, GetID(), "SET_UNCOMMON", "", pszIP ? pszIP : "", GetOriginalVnum());
  80. return true;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement