TShelby

C++ | Allow Copy Bonus In Cube | Metin2

Aug 31st, 2018
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 KB | None | 0 0
  1. ### Cube.cpp
  2.  
  3. //Search :
  4.     this->gold = 0;
  5.  
  6. //Add after :
  7. #ifdef ENABLE_CUBE_RENEWAL
  8.     this->allowCopyAttr = false;
  9. #endif
  10.  
  11.  
  12. //Search:
  13.         else TOKEN("gold")
  14.         {
  15.             cube_data->gold = value1;
  16.         }
  17.  
  18.  
  19. //Add after :
  20.  
  21. #ifdef ENABLE_CUBE_RENEWAL
  22.         else TOKEN("allow_copy")
  23.         {
  24.             cube_data->allowCopyAttr = (value1 == 1 ? true : false);
  25.         }
  26. #endif
  27.  
  28. //Search in : bool Cube_make (LPCHARACTER ch)
  29.     LPITEM  new_item;
  30.  
  31. Add after :
  32.  
  33. #ifdef ENABLE_CUBE_RENEWAL
  34.     DWORD copyAttr[ITEM_ATTRIBUTE_MAX_NUM][2];
  35. #endif
  36.  
  37. //Search :
  38. CUBE_VALUE  *reward_value = cube_proto->reward_value();
  39.  
  40. //Add after:
  41. #ifdef ENABLE_CUBE_RENEWAL
  42.     for (int i=0; i<CUBE_MAX_NUM; ++i)
  43.     {
  44.         if (NULL==items[i]) continue;
  45.  
  46.         if (items[i]->GetType() == ITEM_WEAPON || items[i]->GetType() == ITEM_ARMOR)
  47.         {
  48.             bool hasElement = false;
  49.             for (int j = 0; j < cube_proto->item.size(); ++j)
  50.             {
  51.                 if(cube_proto->item[j].vnum == items[i]->GetVnum())
  52.                 {
  53.                     hasElement = true;
  54.                     break;
  55.                 }
  56.             }
  57.            
  58.             if(hasElement == false)
  59.                 continue;
  60.            
  61.             for (int a = 0; a < ITEM_ATTRIBUTE_MAX_NUM; a++)
  62.             {
  63.                 copyAttr[a][0] = items[i]->GetAttributeType(a);
  64.                 copyAttr[a][1] = items[i]->GetAttributeValue(a);
  65.             }
  66.  
  67.             break;
  68.         }
  69.        
  70.         continue;
  71.     }
  72. #endif
  73.  
  74. //Search:
  75. new_item = ch->AutoGiveItem(reward_value->vnum, reward_value->count);
  76.  
  77. //Add after:
  78.  
  79. #ifdef ENABLE_CUBE_RENEWAL
  80.         if (cube_proto->allowCopyAttr == true && copyAttr != NULL)
  81.         {
  82.             new_item->ClearAttribute();
  83.            
  84.             for (int a = 0; a < ITEM_ATTRIBUTE_MAX_NUM; a++)
  85.             {
  86.                 new_item->SetForceAttribute(a, copyAttr[a][0], copyAttr[a][1]);
  87.             }
  88.         }
  89. #endif
  90.  
  91.  
  92.  
  93. ###cube.h
  94.  
  95. //Search in : struct CUBE_DATA
  96.  
  97.     int                     percent;
  98.     unsigned int            gold;
  99.  
  100. //Add after :
  101.  
  102. #ifdef ENABLE_CUBE_RENEWAL
  103.     bool                    allowCopyAttr;
  104. #endif
  105.  
  106.  
  107. ###service.h
  108. /Add:
  109.  
  110. #define ENABLE_CUBE_RENEWAL
  111.  
  112.  
  113. Example in cube.txt
  114. section    
  115. npc 20378  
  116. item    11299   1
  117. item    30509   10
  118. item    30516   10
  119. item    30514   10
  120. allow_copy  1
  121. reward  20000   1
  122. gold    100000 
  123. percent 60 
  124. end
Add Comment
Please, Sign In to add comment