1. ### Cube.cpp
  2. //Search :
  3. this->gold = 0;
  4. //Add after :
  5. #ifdef ENABLE_CUBE_RENEWAL
  6. this->allowCopyAttr = false;
  7. #endif
  8. //Search:
  9. else TOKEN("gold")
  10. {
  11. cube_data->gold = value1;
  12. }
  13. //Add after :
  14. #ifdef ENABLE_CUBE_RENEWAL
  15. else TOKEN("allow_copy")
  16. {
  17. cube_data->allowCopyAttr = (value1 == 1 ? true : false);
  18. }
  19. #endif
  20. //Search in : bool Cube_make (LPCHARACTER ch)
  21. LPITEM new_item;
  22. Add after :
  23. #ifdef ENABLE_CUBE_RENEWAL
  24. DWORD copyAttr[ITEM_ATTRIBUTE_MAX_NUM][2];
  25. #endif
  26. //Search :
  27. CUBE_VALUE *reward_value = cube_proto->reward_value();
  28. //Add after:
  29. #ifdef ENABLE_CUBE_RENEWAL
  30. for (int i=0; i<CUBE_MAX_NUM; ++i)
  31. {
  32. if (NULL==items[i]) continue;
  33. if (items[i]->GetType() == ITEM_WEAPON || items[i]->GetType() == ITEM_ARMOR)
  34. {
  35. bool hasElement = false;
  36. for (int j = 0; j < cube_proto->item.size(); ++j)
  37. {
  38. if(cube_proto->item[j].vnum == items[i]->GetVnum())
  39. {
  40. hasElement = true;
  41. break;
  42. }
  43. }
  44. if(hasElement == false)
  45. continue;
  46. for (int a = 0; a < ITEM_ATTRIBUTE_MAX_NUM; a++)
  47. {
  48. copyAttr[a][0] = items[i]->GetAttributeType(a);
  49. copyAttr[a][1] = items[i]->GetAttributeValue(a);
  50. }
  51. break;
  52. }
  53. continue;
  54. }
  55. #endif
  56. //Search:
  57. new_item = ch->AutoGiveItem(reward_value->vnum, reward_value->count);
  58. //Add after:
  59. #ifdef ENABLE_CUBE_RENEWAL
  60. if (cube_proto->allowCopyAttr == true && copyAttr != NULL)
  61. {
  62. new_item->ClearAttribute();
  63. for (int a = 0; a < ITEM_ATTRIBUTE_MAX_NUM; a++)
  64. {
  65. new_item->SetForceAttribute(a, copyAttr[a][0], copyAttr[a][1]);
  66. }
  67. }
  68. #endif
  69. ###cube.h
  70. //Search in : struct CUBE_DATA
  71. int percent;
  72. unsigned int gold;
  73. //Add after :
  74. #ifdef ENABLE_CUBE_RENEWAL
  75. bool allowCopyAttr;
  76. #endif
  77. ###service.h
  78. /Add:
  79. #define ENABLE_CUBE_RENEWAL
  80. Example in cube.txt
  81. section
  82. npc 20378
  83. item 11299 1
  84. item 30509 10
  85. item 30516 10
  86. item 30514 10
  87. allow_copy 1
  88. reward 20000 1
  89. gold 100000
  90. percent 60
  91. end