1. ACMD(do_add_new_attribute)
  2. {
  3. std::vector<std::string> vecArgs;
  4. split_argument(argument,vecArgs);
  5. if (vecArgs.size() < 7)
  6. {
  7. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_UNKNOWN_ARGUMENT"));
  8. return;
  9. }
  10. int sourceItemPos, targetItemPos, attrtype0, attrtype1, attrtype2, attrtype3, attrtype4;
  11. str_to_number(sourceItemPos, vecArgs[1].c_str());
  12. str_to_number(targetItemPos, vecArgs[2].c_str());
  13. str_to_number(attrtype0, vecArgs[3].c_str());
  14. str_to_number(attrtype1, vecArgs[4].c_str());
  15. str_to_number(attrtype2, vecArgs[5].c_str());
  16. str_to_number(attrtype3, vecArgs[6].c_str());
  17. str_to_number(attrtype4, vecArgs[7].c_str());
  18. LPITEM item = ch->GetInventoryItem(targetItemPos);
  19. if (!item)
  20. {
  21. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_CANNOT_FIND_ITEM"));
  22. return;
  23. }
  24. if (item->GetType() != ITEM_WEAPON && item->GetType() != ITEM_ARMOR)
  25. {
  26. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_COSTUME"));
  27. return;
  28. }
  29. if (item->IsEquipped())
  30. {
  31. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_EQUIPPED"));
  32. return;
  33. }
  34. if (item->IsExchanging())
  35. {
  36. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_EXCHANGING"));
  37. return;
  38. }
  39. if (ch->CountSpecifyItem(71051) < 1)
  40. {
  41. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_ENOUGH_NEW_ATTRIBUTE"));
  42. return;
  43. }
  44. if (ch->GetAttributeCount > 0)
  45. {
  46. ch->ChatPacket(CHAT_TYPE_INFO, "Kadim efsun nesnesini kullanabilmen için efsun olmamalıdır.")
  47. return;
  48. }
  49. TItemTable const * pProto = item->GetProto();
  50. bool addontype = false;
  51. if (pProto && pProto->sAddonType)
  52. addontype = true;
  53. int attrtype0prob = number(1,5), attrtype1prob = number(1,5), attrtype2prob = number(1,5), attrtype3prob = number(1,5), attrtype4prob = number(1,5);
  54. bool error = false;
  55. if (addontype == false)
  56. {
  57. if (attrtype0 == attrtype1 || attrtype0 == attrtype2 || attrtype0 == attrtype3 || attrtype0 == attrtype4 || attrtype0 == item->GetAttributeType(5))
  58. error = true;
  59. if (attrtype1 == attrtype0 || attrtype1 == attrtype2 || attrtype1 == attrtype3 || attrtype1 == attrtype4 || attrtype1 == item->GetAttributeType(5))
  60. error = true;
  61. if (attrtype2 == attrtype0 || attrtype2 == attrtype1 || attrtype2 == attrtype3 || attrtype2 == attrtype4 || attrtype2 == item->GetAttributeType(5))
  62. error = true;
  63. if (attrtype3 == attrtype0 || attrtype3 == attrtype1 || attrtype3 == attrtype2 || attrtype3 == attrtype4 || attrtype3 == item->GetAttributeType(5))
  64. error = true;
  65. if (item->GetAttributeType(5) == attrtype0 || item->GetAttributeType(5) == attrtype1 || item->GetAttributeType(5) == attrtype2 || item->GetAttributeType(5) == attrtype3 || item->GetAttributeType(5) == attrtype4)
  66. error = true;
  67. }
  68. for (int i=0; i < 5; ++i)
  69. {
  70. if (addontype == false)
  71. {
  72. if (item->GetAttributeType(i) == attrtype0 && i != 0)
  73. error = true;
  74. if (item->GetAttributeType(i) == attrtype1 && i != 1)
  75. error = true;
  76. if (item->GetAttributeType(i) == attrtype2 && i != 2)
  77. error = true;
  78. if (item->GetAttributeType(i) == attrtype3 && i != 3)
  79. error = true;
  80. if (item->GetAttributeType(i) == attrtype3 && i != 4)
  81. error = true;
  82. }
  83. }
  84. if (error)
  85. {
  86. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_ERROR"));
  87. return;
  88. }
  89. if (addontype == false)
  90. {
  91. item->AddNewAttr(0, attrtype0, attrtype0prob);
  92. item->AddNewAttr(1, attrtype1, attrtype1prob);
  93. item->AddNewAttr(2, attrtype2, attrtype2prob);
  94. item->AddNewAttr(3, attrtype3, attrtype3prob);
  95. item->AddNewAttr(4, attrtype4, attrtype4prob);
  96. }
  97. ch->RemoveSpecifyItem(71051, 1);
  98. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_SUCCESS_ATTR"));
  99. }