Guest User

function

a guest
Nov 3rd, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
  2. {
  3. // °³ÀλóÁ¡À» ¿¬ »óÅ¿¡¼´Â ¾ÆÀÌÅÛÀ» µå·ÓÇÏÁö ¾Ê´Â´Ù.
  4. if (GetMyShop())
  5. return;
  6.  
  7. if (false == LC_IsYMIR())
  8. {
  9. if (GetLevel() < 50)
  10. return;
  11. }
  12.  
  13. if (CBattleArena::instance().IsBattleArenaMap(GetMapIndex()) == true)
  14. {
  15. return;
  16. }
  17.  
  18. struct TItemDropPenalty * table = &aItemDropPenalty_kor[0];
  19.  
  20. if (GetLevel() < 10)
  21. return;
  22.  
  23. int iAlignIndex;
  24.  
  25. if (GetRealAlignment() >= 120000)
  26. iAlignIndex = 0;
  27. else if (GetRealAlignment() >= 80000)
  28. iAlignIndex = 1;
  29. else if (GetRealAlignment() >= 40000)
  30. iAlignIndex = 2;
  31. else if (GetRealAlignment() >= 10000)
  32. iAlignIndex = 3;
  33. else if (GetRealAlignment() >= 0)
  34. iAlignIndex = 4;
  35. else if (GetRealAlignment() > -40000)
  36. iAlignIndex = 5;
  37. else if (GetRealAlignment() > -80000)
  38. iAlignIndex = 6;
  39. else if (GetRealAlignment() > -120000)
  40. iAlignIndex = 7;
  41. else
  42. iAlignIndex = 8;
  43.  
  44. std::vector<std::pair<LPITEM, int> > vec_item;
  45. LPITEM pkItem;
  46. int i;
  47. bool isDropAllEquipments = false;
  48.  
  49. TItemDropPenalty & r = table[iAlignIndex];
  50. sys_log(0, "%s align %d inventory_pct %d equip_pct %d", GetName(), iAlignIndex, r.iInventoryPct, r.iEquipmentPct);
  51.  
  52. bool bDropInventory = r.iInventoryPct >= number(1, 1000);
  53. bool bDropEquipment = r.iEquipmentPct >= number(1, 100);
  54. bool bDropAntiDropUniqueItem = false;
  55.  
  56. if ((bDropInventory || bDropEquipment) && IsEquipUniqueItem(UNIQUE_ITEM_SKIP_ITEM_DROP_PENALTY))
  57. {
  58. bDropInventory = false;
  59. bDropEquipment = false;
  60. bDropAntiDropUniqueItem = true;
  61. }
  62. // @fixme198 BEGIN
  63. if (bDropInventory || bDropEquipment) {
  64. if (pkkiller)
  65. pkKiller->SetExchangeTime();
  66. SetExchangeTime();
  67. }
  68. // @fixme198 END
  69. if (bDropInventory) // Drop Inventory
  70. {
  71. std::vector<BYTE> vec_bSlots;
  72.  
  73. for (i = 0; i < INVENTORY_MAX_NUM; ++i)
  74. if (GetInventoryItem(i))
  75. vec_bSlots.push_back(i);
  76.  
  77. if (!vec_bSlots.empty())
  78. {
  79. random_shuffle(vec_bSlots.begin(), vec_bSlots.end());
  80.  
  81. int iQty = MIN(vec_bSlots.size(), r.iInventoryQty);
  82.  
  83. if (iQty)
  84. iQty = number(1, iQty);
  85.  
  86. for (i = 0; i < iQty; ++i)
  87. {
  88. pkItem = GetInventoryItem(vec_bSlots[i]);
  89.  
  90. if (IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_PKDROP))
  91. continue;
  92.  
  93. SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);
  94. vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), INVENTORY));
  95. }
  96. }
  97. else if (iAlignIndex == 8)
  98. isDropAllEquipments = true;
  99. }
  100.  
  101. if (bDropEquipment) // Drop Equipment
  102. {
  103. std::vector<BYTE> vec_bSlots;
  104.  
  105. for (i = 0; i < WEAR_MAX_NUM; ++i)
  106. if (GetWear(i))
  107. vec_bSlots.push_back(i);
  108.  
  109. if (!vec_bSlots.empty())
  110. {
  111. random_shuffle(vec_bSlots.begin(), vec_bSlots.end());
  112. int iQty;
  113.  
  114. if (isDropAllEquipments)
  115. iQty = vec_bSlots.size();
  116. else
  117. iQty = MIN(vec_bSlots.size(), number(1, r.iEquipmentQty));
  118.  
  119. if (iQty)
  120. iQty = number(1, iQty);
  121.  
  122. for (i = 0; i < iQty; ++i)
  123. {
  124. pkItem = GetWear(vec_bSlots[i]);
  125.  
  126. if (IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_PKDROP))
  127. continue;
  128.  
  129. SyncQuickslot(QUICKSLOT_TYPE_ITEM, vec_bSlots[i], 255);
  130. vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), EQUIPMENT));
  131. }
  132. }
  133. }
  134.  
  135. if (bDropAntiDropUniqueItem)
  136. {
  137. LPITEM pkItem;
  138.  
  139. pkItem = GetWear(WEAR_UNIQUE1);
  140.  
  141. if (pkItem && pkItem->GetVnum() == UNIQUE_ITEM_SKIP_ITEM_DROP_PENALTY)
  142. {
  143. SyncQuickslot(QUICKSLOT_TYPE_ITEM, WEAR_UNIQUE1, 255);
  144. vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), EQUIPMENT));
  145. }
  146.  
  147. pkItem = GetWear(WEAR_UNIQUE2);
  148.  
  149. if (pkItem && pkItem->GetVnum() == UNIQUE_ITEM_SKIP_ITEM_DROP_PENALTY)
  150. {
  151. SyncQuickslot(QUICKSLOT_TYPE_ITEM, WEAR_UNIQUE2, 255);
  152. vec_item.push_back(std::make_pair(pkItem->RemoveFromCharacter(), EQUIPMENT));
  153. }
  154. }
  155.  
  156. {
  157. PIXEL_POSITION pos;
  158. pos.x = GetX();
  159. pos.y = GetY();
  160.  
  161. unsigned int i;
  162.  
  163. for (i = 0; i < vec_item.size(); ++i)
  164. {
  165. LPITEM item = vec_item[i].first;
  166. int window = vec_item[i].second;
  167.  
  168. item->AddToGround(GetMapIndex(), pos);
  169. item->StartDestroyEvent();
  170.  
  171. sys_log(0, "DROP_ITEM_PK: %s %d %d from %s", item->GetName(), pos.x, pos.y, GetName());
  172. LogManager::instance().ItemLog(this, item, "DEAD_DROP", (window == INVENTORY) ? "INVENTORY" : ((window == EQUIPMENT) ? "EQUIPMENT" : ""));
  173.  
  174. pos.x = GetX() + number(-7, 7) * 20;
  175. #ifdef PENALTY_DUPE_DROP_FIX
  176. SetPenaltyWarpTime();
  177. #endif
  178. pos.y = GetY() + number(-7, 7) * 20;
  179. }
  180. }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment