1. #include "stdafx.h"
  2. #include "utils.h"
  3. #include "config.h"
  4. #include "char.h"
  5. #include "desc.h"
  6. #include "sectree_manager.h"
  7. #include "packet.h"
  8. #include "protocol.h"
  9. #include "log.h"
  10. #include "skill.h"
  11. #include "unique_item.h"
  12. #include "profiler.h"
  13. #include "marriage.h"
  14. #include "item_addon.h"
  15. #include "dev_log.h"
  16. #include "locale_service.h"
  17. #include "item.h"
  18. #include "item_manager.h"
  19. #include "affect.h"
  20. #include "DragonSoul.h"
  21. #include "buff_on_attributes.h"
  22. #include "belt_inventory_helper.h"
  23. #include "../../common/VnumHelper.h"
  24. #include "../../common/service.h"
  25. CItem::CItem(DWORD dwVnum)
  26. : m_dwVnum(dwVnum), m_bWindow(0), m_dwID(0), m_bEquipped(false), m_dwVID(0), m_wCell(0), m_dwCount(0), m_lFlag(0), m_dwLastOwnerPID(0),
  27. m_bExchanging(false), m_pkDestroyEvent(NULL), m_pkExpireEvent(NULL), m_pkUniqueExpireEvent(NULL),
  28. m_pkTimerBasedOnWearExpireEvent(NULL), m_pkRealTimeExpireEvent(NULL),
  29. m_pkAccessorySocketExpireEvent(NULL), m_pkOwnershipEvent(NULL), m_dwOwnershipPID(0), m_bSkipSave(false), m_isLocked(false),
  30. m_dwMaskVnum(0), m_dwSIGVnum (0)
  31. {
  32. memset( &m_alSockets, 0, sizeof(m_alSockets) );
  33. memset( &m_aAttr, 0, sizeof(m_aAttr) );
  34. }
  35. CItem::~CItem()
  36. {
  37. Destroy();
  38. }
  39. void CItem::Initialize()
  40. {
  41. CEntity::Initialize(ENTITY_ITEM);
  42. #ifdef OFFLINE_SHOP
  43. m_dwRealID = 0;
  44. #endif
  45. m_bWindow = RESERVED_WINDOW;
  46. m_pOwner = NULL;
  47. m_dwID = 0;
  48. m_bEquipped = false;
  49. m_dwVID = m_wCell = m_dwCount = m_lFlag = 0;
  50. m_pProto = NULL;
  51. m_bExchanging = false;
  52. memset(&m_alSockets, 0, sizeof(m_alSockets));
  53. memset(&m_aAttr, 0, sizeof(m_aAttr));
  54. m_pkDestroyEvent = NULL;
  55. m_pkOwnershipEvent = NULL;
  56. m_dwOwnershipPID = 0;
  57. m_pkUniqueExpireEvent = NULL;
  58. m_pkTimerBasedOnWearExpireEvent = NULL;
  59. m_pkRealTimeExpireEvent = NULL;
  60. m_pkAccessorySocketExpireEvent = NULL;
  61. m_bSkipSave = false;
  62. m_dwLastOwnerPID = 0;
  63. }
  64. void CItem::Destroy()
  65. {
  66. event_cancel(&m_pkDestroyEvent);
  67. event_cancel(&m_pkOwnershipEvent);
  68. event_cancel(&m_pkUniqueExpireEvent);
  69. event_cancel(&m_pkTimerBasedOnWearExpireEvent);
  70. event_cancel(&m_pkRealTimeExpireEvent);
  71. event_cancel(&m_pkAccessorySocketExpireEvent);
  72. CEntity::Destroy();
  73. if (GetSectree())
  74. GetSectree()->RemoveEntity(this);
  75. }
  76. EVENTFUNC(item_destroy_event)
  77. {
  78. item_event_info* info = dynamic_cast<item_event_info*>( event->info );
  79. if ( info == NULL )
  80. {
  81. sys_err( "item_destroy_event> <Factor> Null pointer" );
  82. return 0;
  83. }
  84. LPITEM pkItem = info->item;
  85. if (pkItem->GetOwner())
  86. sys_err("item_destroy_event: Owner exist. (item %s owner %s)", pkItem->GetName(), pkItem->GetOwner()->GetName());
  87. pkItem->SetDestroyEvent(NULL);
  88. M2_DESTROY_ITEM(pkItem);
  89. return 0;
  90. }
  91. void CItem::SetDestroyEvent(LPEVENT pkEvent)
  92. {
  93. m_pkDestroyEvent = pkEvent;
  94. }
  95. void CItem::StartDestroyEvent(int iSec)
  96. {
  97. if (m_pkDestroyEvent)
  98. return;
  99. item_event_info* info = AllocEventInfo<item_event_info>();
  100. info->item = this;
  101. SetDestroyEvent(event_create(item_destroy_event, info, PASSES_PER_SEC(iSec)));
  102. }
  103. void CItem::EncodeInsertPacket(LPENTITY ent)
  104. {
  105. LPDESC d;
  106. if (!(d = ent->GetDesc()))
  107. return;
  108. const PIXEL_POSITION & c_pos = GetXYZ();
  109. struct packet_item_ground_add pack;
  110. pack.bHeader = HEADER_GC_ITEM_GROUND_ADD;
  111. pack.x = c_pos.x;
  112. pack.y = c_pos.y;
  113. pack.z = c_pos.z;
  114. pack.dwVnum = GetVnum();
  115. pack.dwVID = m_dwVID;
  116. //pack.count = m_dwCount;
  117. d->Packet(&pack, sizeof(pack));
  118. if (m_pkOwnershipEvent != NULL)
  119. {
  120. item_event_info * info = dynamic_cast<item_event_info *>(m_pkOwnershipEvent->info);
  121. if ( info == NULL )
  122. {
  123. sys_err( "CItem::EncodeInsertPacket> <Factor> Null pointer" );
  124. return;
  125. }
  126. TPacketGCItemOwnership p;
  127. p.bHeader = HEADER_GC_ITEM_OWNERSHIP;
  128. p.dwVID = m_dwVID;
  129. strlcpy(p.szName, info->szOwnerName, sizeof(p.szName));
  130. d->Packet(&p, sizeof(TPacketGCItemOwnership));
  131. }
  132. }
  133. void CItem::EncodeRemovePacket(LPENTITY ent)
  134. {
  135. LPDESC d;
  136. if (!(d = ent->GetDesc()))
  137. return;
  138. struct packet_item_ground_del pack;
  139. pack.bHeader = HEADER_GC_ITEM_GROUND_DEL;
  140. pack.dwVID = m_dwVID;
  141. d->Packet(&pack, sizeof(pack));
  142. sys_log(2, "Item::EncodeRemovePacket %s to %s", GetName(), ((LPCHARACTER) ent)->GetName());
  143. }
  144. void CItem::SetProto(const TItemTable * table)
  145. {
  146. assert(table != NULL);
  147. m_pProto = table;
  148. SetFlag(m_pProto->dwFlags);
  149. }
  150. void CItem::UsePacketEncode(LPCHARACTER ch, LPCHARACTER victim, struct packet_item_use *packet)
  151. {
  152. if (!GetVnum())
  153. return;
  154. packet->header = HEADER_GC_ITEM_USE;
  155. packet->ch_vid = ch->GetVID();
  156. packet->victim_vid = victim->GetVID();
  157. packet->Cell = TItemPos(GetWindow(), m_wCell);
  158. packet->vnum = GetVnum();
  159. }
  160. void CItem::RemoveFlag(long bit)
  161. {
  162. REMOVE_BIT(m_lFlag, bit);
  163. }
  164. void CItem::AddFlag(long bit)
  165. {
  166. SET_BIT(m_lFlag, bit);
  167. }
  168. void CItem::UpdatePacket()
  169. {
  170. if (!m_pOwner || !m_pOwner->GetDesc())
  171. return;
  172. TPacketGCItemUpdate pack;
  173. pack.header = HEADER_GC_ITEM_UPDATE;
  174. pack.Cell = TItemPos(GetWindow(), m_wCell);
  175. pack.count = m_dwCount;
  176. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  177. pack.alSockets[i] = m_alSockets[i];
  178. thecore_memcpy(pack.aAttr, GetAttributes(), sizeof(pack.aAttr));
  179. sys_log(2, "UpdatePacket %s -> %s", GetName(), m_pOwner->GetName());
  180. m_pOwner->GetDesc()->Packet(&pack, sizeof(pack));
  181. }
  182. DWORD CItem::GetCount()
  183. {
  184. if (GetType() == ITEM_ELK) return MIN(m_dwCount, INT_MAX);
  185. else
  186. {
  187. return MIN(m_dwCount, g_bItemCountLimit);
  188. }
  189. }
  190. bool CItem::SetCount(DWORD count)
  191. {
  192. if (GetType() == ITEM_ELK)
  193. {
  194. m_dwCount = MIN(count, INT_MAX);
  195. }
  196. else
  197. {
  198. m_dwCount = MIN(count, g_bItemCountLimit);
  199. }
  200. if (count == 0 && m_pOwner)
  201. {
  202. if (GetSubType() == USE_ABILITY_UP || GetSubType() == USE_POTION || GetVnum() == 70020)
  203. {
  204. LPCHARACTER pOwner = GetOwner();
  205. WORD wCell = GetCell();
  206. RemoveFromCharacter();
  207. if (!IsDragonSoul())
  208. {
  209. LPITEM pItem = pOwner->FindSpecifyItem(GetVnum());
  210. if (NULL != pItem)
  211. {
  212. pOwner->ChainQuickslotItem(pItem, QUICKSLOT_TYPE_ITEM, wCell);
  213. }
  214. else
  215. {
  216. pOwner->SyncQuickslot(QUICKSLOT_TYPE_ITEM, wCell, 255);
  217. }
  218. }
  219. M2_DESTROY_ITEM(this);
  220. }
  221. else
  222. {
  223. if (!IsDragonSoul())
  224. {
  225. m_pOwner->SyncQuickslot(QUICKSLOT_TYPE_ITEM, m_wCell, 255);
  226. }
  227. M2_DESTROY_ITEM(RemoveFromCharacter());
  228. }
  229. return false;
  230. }
  231. UpdatePacket();
  232. Save();
  233. return true;
  234. }
  235. LPITEM CItem::RemoveFromCharacter()
  236. {
  237. if (!m_pOwner)
  238. {
  239. sys_err("Item::RemoveFromCharacter owner null");
  240. return (this);
  241. }
  242. LPCHARACTER pOwner = m_pOwner;
  243. if (m_bEquipped) // 장착되었는가?
  244. {
  245. Unequip();
  246. //pOwner->UpdatePacket();
  247. SetWindow(RESERVED_WINDOW);
  248. Save();
  249. return (this);
  250. }
  251. else
  252. {
  253. if (GetWindow() != SAFEBOX && GetWindow() != MALL)
  254. {
  255. if (IsDragonSoul())
  256. {
  257. if (m_wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  258. sys_err("CItem::RemoveFromCharacter: pos >= DRAGON_SOUL_INVENTORY_MAX_NUM");
  259. else
  260. pOwner->SetItem(TItemPos(m_bWindow, m_wCell), NULL);
  261. }
  262. else
  263. {
  264. TItemPos cell(INVENTORY, m_wCell);
  265. if (false == cell.IsDefaultInventoryPosition() && false == cell.IsBeltInventoryPosition()
  266. #ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
  267. && false == cell.IsSkillBookInventoryPosition() && false == cell.IsUpgradeItemsInventoryPosition()
  268. && false == cell.IsStoneInventoryPosition() && false == cell.IsBoxInventoryPosition()
  269. && false == cell.IsEfsunInventoryPosition() && false == cell.IsCicekInventoryPosition()
  270. #endif
  271. )
  272. sys_err("CItem::RemoveFromCharacter: Invalid Item Position");
  273. else
  274. {
  275. pOwner->SetItem(cell, NULL);
  276. }
  277. }
  278. }
  279. m_pOwner = NULL;
  280. m_wCell = 0;
  281. SetWindow(RESERVED_WINDOW);
  282. #ifdef OFFLINE_SHOP
  283. if(!GetRealID())
  284. #endif
  285. Save();
  286. return (this);
  287. }
  288. }
  289. bool CItem::AddToCharacter(LPCHARACTER ch, TItemPos Cell)
  290. {
  291. assert(GetSectree() == NULL);
  292. assert(m_pOwner == NULL);
  293. WORD pos = Cell.cell;
  294. BYTE window_type = Cell.window_type;
  295. if (INVENTORY == window_type)
  296. {
  297. if (m_wCell >= INVENTORY_MAX_NUM && BELT_INVENTORY_SLOT_START > m_wCell)
  298. {
  299. sys_err("CItem::AddToCharacter: cell overflow: %s to %s cell %d", m_pProto->szName, ch->GetName(), m_wCell);
  300. return false;
  301. }
  302. }
  303. else if (DRAGON_SOUL_INVENTORY == window_type)
  304. {
  305. if (m_wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  306. {
  307. sys_err("CItem::AddToCharacter: cell overflow: %s to %s cell %d", m_pProto->szName, ch->GetName(), m_wCell);
  308. return false;
  309. }
  310. }
  311. if (ch->GetDesc())
  312. m_dwLastOwnerPID = ch->GetPlayerID();
  313. event_cancel(&m_pkDestroyEvent);
  314. ch->SetItem(TItemPos(window_type, pos), this);
  315. m_pOwner = ch;
  316. Save();
  317. return true;
  318. }
  319. LPITEM CItem::RemoveFromGround()
  320. {
  321. if (GetSectree())
  322. {
  323. SetOwnership(NULL);
  324. GetSectree()->RemoveEntity(this);
  325. ViewCleanup();
  326. Save();
  327. }
  328. return (this);
  329. }
  330. bool CItem::AddToGround(long lMapIndex, const PIXEL_POSITION & pos, bool skipOwnerCheck)
  331. {
  332. if (0 == lMapIndex)
  333. {
  334. sys_err("wrong map index argument: %d", lMapIndex);
  335. return false;
  336. }
  337. if (GetSectree())
  338. {
  339. sys_err("sectree already assigned");
  340. return false;
  341. }
  342. if (!skipOwnerCheck && m_pOwner)
  343. {
  344. sys_err("owner pointer not null");
  345. return false;
  346. }
  347. LPSECTREE tree = SECTREE_MANAGER::instance().Get(lMapIndex, pos.x, pos.y);
  348. if (!tree)
  349. {
  350. sys_err("cannot find sectree by %dx%d", pos.x, pos.y);
  351. return false;
  352. }
  353. //tree->Touch();
  354. SetWindow(GROUND);
  355. SetXYZ(pos.x, pos.y, pos.z);
  356. tree->InsertEntity(this);
  357. UpdateSectree();
  358. Save();
  359. return true;
  360. }
  361. bool CItem::DistanceValid(LPCHARACTER ch)
  362. {
  363. if (!GetSectree())
  364. return false;
  365. int iDist = DISTANCE_APPROX(GetX() - ch->GetX(), GetY() - ch->GetY());
  366. if (iDist > 300)
  367. return false;
  368. return true;
  369. }
  370. bool CItem::CanUsedBy(LPCHARACTER ch)
  371. {
  372. // Anti flag check
  373. switch (ch->GetJob())
  374. {
  375. case JOB_WARRIOR:
  376. if (GetAntiFlag() & ITEM_ANTIFLAG_WARRIOR)
  377. return false;
  378. break;
  379. case JOB_ASSASSIN:
  380. if (GetAntiFlag() & ITEM_ANTIFLAG_ASSASSIN)
  381. return false;
  382. break;
  383. case JOB_SHAMAN:
  384. if (GetAntiFlag() & ITEM_ANTIFLAG_SHAMAN)
  385. return false;
  386. break;
  387. case JOB_SURA:
  388. if (GetAntiFlag() & ITEM_ANTIFLAG_SURA)
  389. return false;
  390. break;
  391. }
  392. return true;
  393. }
  394. int CItem::FindEquipCell(LPCHARACTER ch, int iCandidateCell)
  395. {
  396. // 코스츔 아이템(ITEM_COSTUME)은 WearFlag 없어도 됨. (sub type으로 착용위치 구분. 귀찮게 또 wear flag 줄 필요가 있나..)
  397. // 용혼석(ITEM_DS, ITEM_SPECIAL_DS)도 SUB_TYPE으로 구분. 신규 반지, 벨트는 ITEM_TYPE으로 구분 -_-
  398. if ((0 == GetWearFlag() || ITEM_TOTEM == GetType()) && ITEM_COSTUME != GetType() && ITEM_DS != GetType() && ITEM_SPECIAL_DS != GetType() && ITEM_RING != GetType() && ITEM_BELT != GetType())
  399. return -1;
  400. // 용혼석 슬롯을 WEAR로 처리할 수가 없어서(WEAR는 최대 32개까지 가능한데 용혼석을 추가하면 32가 넘는다.)
  401. // 인벤토리의 특정 위치((INVENTORY_MAX_NUM + WEAR_MAX_NUM)부터 (INVENTORY_MAX_NUM + WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX - 1)까지)를
  402. // 용혼석 슬롯으로 정함.
  403. // return 할 때에, INVENTORY_MAX_NUM을 뺀 이유는,
  404. // 본래 WearCell이 INVENTORY_MAX_NUM를 빼고 return 하기 때문.
  405. if (GetType() == ITEM_DS || GetType() == ITEM_SPECIAL_DS)
  406. {
  407. if (iCandidateCell < 0)
  408. {
  409. return WEAR_MAX_NUM + GetSubType();
  410. }
  411. else
  412. {
  413. for (int i = 0; i < DRAGON_SOUL_DECK_MAX_NUM; i++)
  414. {
  415. if (WEAR_MAX_NUM + i * DS_SLOT_MAX + GetSubType() == iCandidateCell)
  416. {
  417. return iCandidateCell;
  418. }
  419. }
  420. return -1;
  421. }
  422. }
  423. else if (GetType() == ITEM_COSTUME)
  424. {
  425. if (GetSubType() == COSTUME_BODY)
  426. return WEAR_COSTUME_BODY;
  427. else if (GetSubType() == COSTUME_HAIR)
  428. return WEAR_COSTUME_HAIR;
  429. }
  430. else if (GetType() == ITEM_BELT)
  431. return WEAR_BELT;
  432. else if (GetWearFlag() & WEARABLE_BODY)
  433. return WEAR_BODY;
  434. else if (GetWearFlag() & WEARABLE_HEAD)
  435. return WEAR_HEAD;
  436. else if (GetWearFlag() & WEARABLE_FOOTS)
  437. return WEAR_FOOTS;
  438. else if (GetWearFlag() & WEARABLE_WRIST)
  439. return WEAR_WRIST;
  440. else if (GetWearFlag() & WEARABLE_WEAPON)
  441. return WEAR_WEAPON;
  442. else if (GetWearFlag() & WEARABLE_SHIELD)
  443. return WEAR_SHIELD;
  444. else if (GetWearFlag() & WEARABLE_NECK)
  445. return WEAR_NECK;
  446. else if (GetWearFlag() & WEARABLE_EAR)
  447. return WEAR_EAR;
  448. else if (GetWearFlag() & WEARABLE_ARROW)
  449. return WEAR_ARROW;
  450. else if (GetWearFlag() & WEARABLE_UNIQUE)
  451. {
  452. if (ch->GetWear(WEAR_UNIQUE1))
  453. return WEAR_UNIQUE2;
  454. else
  455. return WEAR_UNIQUE1;
  456. }
  457. // 수집 퀘스트를 위한 아이템이 박히는곳으로 한번 박히면 절대 –E수 없다.
  458. else if (GetWearFlag() & WEARABLE_ABILITY)
  459. {
  460. if (!ch->GetWear(WEAR_ABILITY1))
  461. {
  462. return WEAR_ABILITY1;
  463. }
  464. else if (!ch->GetWear(WEAR_ABILITY2))
  465. {
  466. return WEAR_ABILITY2;
  467. }
  468. else if (!ch->GetWear(WEAR_ABILITY3))
  469. {
  470. return WEAR_ABILITY3;
  471. }
  472. else if (!ch->GetWear(WEAR_ABILITY4))
  473. {
  474. return WEAR_ABILITY4;
  475. }
  476. else if (!ch->GetWear(WEAR_ABILITY5))
  477. {
  478. return WEAR_ABILITY5;
  479. }
  480. else if (!ch->GetWear(WEAR_ABILITY6))
  481. {
  482. return WEAR_ABILITY6;
  483. }
  484. else if (!ch->GetWear(WEAR_ABILITY7))
  485. {
  486. return WEAR_ABILITY7;
  487. }
  488. else if (!ch->GetWear(WEAR_ABILITY8))
  489. {
  490. return WEAR_ABILITY8;
  491. }
  492. else
  493. {
  494. return -1;
  495. }
  496. }
  497. return -1;
  498. }
  499. void CItem::ModifyPoints(bool bAdd)
  500. {
  501. int accessoryGrade;
  502. // 무기와 갑옷만 소켓을 적용시킨다.
  503. if (false == IsAccessoryForSocket())
  504. {
  505. if (m_pProto->bType == ITEM_WEAPON || m_pProto->bType == ITEM_ARMOR)
  506. {
  507. // 소켓이 속성강화에 사용되는 경우 적용하지 않는다 (ARMOR_WRIST ARMOR_NECK ARMOR_EAR)
  508. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  509. {
  510. DWORD dwVnum;
  511. if ((dwVnum = GetSocket(i)) <= 2)
  512. continue;
  513. TItemTable * p = ITEM_MANAGER::instance().GetTable(dwVnum);
  514. if (!p)
  515. {
  516. sys_err("cannot find table by vnum %u", dwVnum);
  517. continue;
  518. }
  519. if (ITEM_METIN == p->bType)
  520. {
  521. //m_pOwner->ApplyPoint(p->alValues[0], bAdd ? p->alValues[1] : -p->alValues[1]);
  522. for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
  523. {
  524. if (p->aApplies[i].bType == APPLY_NONE)
  525. continue;
  526. if (p->aApplies[i].bType == APPLY_SKILL)
  527. m_pOwner->ApplyPoint(p->aApplies[i].bType, bAdd ? p->aApplies[i].lValue : p->aApplies[i].lValue ^ 0x00800000);
  528. else
  529. m_pOwner->ApplyPoint(p->aApplies[i].bType, bAdd ? p->aApplies[i].lValue : -p->aApplies[i].lValue);
  530. }
  531. }
  532. }
  533. }
  534. accessoryGrade = 0;
  535. }
  536. else
  537. {
  538. accessoryGrade = MIN(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM);
  539. }
  540. for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
  541. {
  542. if (m_pProto->aApplies[i].bType == APPLY_NONE)
  543. continue;
  544. long value = m_pProto->aApplies[i].lValue;
  545. if (m_pProto->aApplies[i].bType == APPLY_SKILL)
  546. {
  547. m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : value ^ 0x00800000);
  548. }
  549. else
  550. {
  551. if (0 != accessoryGrade)
  552. value += MAX(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100);
  553. m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : -value);
  554. }
  555. }
  556. // 초승달의 반지, 할로윈 사탕, 행복의 반지, 영원한 사랑의 펜던트의 경우
  557. // 기존의 하드 코딩으로 강제로 속성을 부여했지만,
  558. // 그 부분을 제거하고 special item group 테이블에서 속성을 부여하도록 변경하였다.
  559. // 하지만 하드 코딩되어있을 때 생성된 아이템이 남아있을 수도 있어서 특수처리 해놓는다.
  560. // 이 아이템들의 경우, 밑에 ITEM_UNIQUE일 때의 처리로 속성이 부여되기 때문에,
  561. // 아이템에 박혀있는 attribute는 적용하지 않고 넘어간다.
  562. if (true == CItemVnumHelper::IsRamadanMoonRing(GetVnum()) || true == CItemVnumHelper::IsHalloweenCandy(GetVnum())
  563. || true == CItemVnumHelper::IsHappinessRing(GetVnum()) || true == CItemVnumHelper::IsLovePendant(GetVnum()))
  564. {
  565. // Do not anything.
  566. }
  567. else
  568. {
  569. for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i)
  570. {
  571. if (GetAttributeType(i))
  572. {
  573. const TPlayerItemAttribute& ia = GetAttribute(i);
  574. if (ia.bType == APPLY_SKILL)
  575. m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : ia.sValue ^ 0x00800000);
  576. else
  577. m_pOwner->ApplyPoint(ia.bType, bAdd ? ia.sValue : -ia.sValue);
  578. }
  579. }
  580. }
  581. switch (m_pProto->bType)
  582. {
  583. case ITEM_PICK:
  584. case ITEM_ROD:
  585. {
  586. if (bAdd)
  587. {
  588. if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON)
  589. m_pOwner->SetPart(PART_WEAPON, GetVnum());
  590. }
  591. else
  592. {
  593. if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON)
  594. m_pOwner->SetPart(PART_WEAPON, 0);
  595. }
  596. }
  597. break;
  598. case ITEM_WEAPON:
  599. {
  600. if (bAdd)
  601. {
  602. if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON)
  603. m_pOwner->SetPart(PART_WEAPON, GetVnum());
  604. }
  605. else
  606. {
  607. if (m_wCell == INVENTORY_MAX_NUM + WEAR_WEAPON)
  608. m_pOwner->SetPart(PART_WEAPON, 0);
  609. }
  610. }
  611. break;
  612. case ITEM_ARMOR:
  613. {
  614. // 코스츔 body를 입고있다면 armor는 벗던 입던 상관 없이 비주얼에 영향을 주면 안 됨.
  615. if (0 != m_pOwner->GetWear(WEAR_COSTUME_BODY))
  616. break;
  617. if (GetSubType() == ARMOR_BODY || GetSubType() == ARMOR_HEAD || GetSubType() == ARMOR_FOOTS || GetSubType() == ARMOR_SHIELD)
  618. {
  619. if (bAdd)
  620. {
  621. if (GetProto()->bSubType == ARMOR_BODY)
  622. m_pOwner->SetPart(PART_MAIN, GetVnum());
  623. }
  624. else
  625. {
  626. if (GetProto()->bSubType == ARMOR_BODY)
  627. m_pOwner->SetPart(PART_MAIN, m_pOwner->GetOriginalPart(PART_MAIN));
  628. }
  629. }
  630. }
  631. break;
  632. // 코스츔 아이템 입었을 때 캐릭터 parts 정보 세팅. 기존 스타일대로 추가함..
  633. case ITEM_COSTUME:
  634. {
  635. DWORD toSetValue = this->GetVnum();
  636. EParts toSetPart = PART_MAX_NUM;
  637. // 갑옷 코스츔
  638. if (GetSubType() == COSTUME_BODY)
  639. {
  640. toSetPart = PART_MAIN;
  641. if (false == bAdd)
  642. {
  643. // 코스츔 갑옷을 벗었을 때 원래 갑옷을 입고 있었다면 그 갑옷으로 look 세팅, 입지 않았다면 default look
  644. const CItem* pArmor = m_pOwner->GetWear(WEAR_BODY);
  645. toSetValue = (NULL != pArmor) ? pArmor->GetVnum() : m_pOwner->GetOriginalPart(PART_MAIN);
  646. }
  647. }
  648. // 헤어 코스츔
  649. else if (GetSubType() == COSTUME_HAIR)
  650. {
  651. toSetPart = PART_HAIR;
  652. // 코스츔 헤어는 shape값을 item proto의 value3에 세팅하도록 함. 특별한 이유는 없고 기존 갑옷(ARMOR_BODY)의 shape값이 프로토의 value3에 있어서 헤어도 같이 value3으로 함.
  653. // [NOTE] 갑옷은 아이템 vnum을 보내고 헤어는 shape(value3)값을 보내는 이유는.. 기존 시스템이 그렇게 되어있음...
  654. toSetValue = (true == bAdd) ? this->GetValue(3) : 0;
  655. }
  656. if (PART_MAX_NUM != toSetPart)
  657. {
  658. m_pOwner->SetPart((BYTE)toSetPart, toSetValue);
  659. m_pOwner->UpdatePacket();
  660. }
  661. }
  662. break;
  663. case ITEM_UNIQUE:
  664. {
  665. if (0 != GetSIGVnum())
  666. {
  667. const CSpecialItemGroup* pItemGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(GetSIGVnum());
  668. if (NULL == pItemGroup)
  669. break;
  670. DWORD dwAttrVnum = pItemGroup->GetAttrVnum(GetVnum());
  671. const CSpecialAttrGroup* pAttrGroup = ITEM_MANAGER::instance().GetSpecialAttrGroup(dwAttrVnum);
  672. if (NULL == pAttrGroup)
  673. break;
  674. for (itertype (pAttrGroup->m_vecAttrs) it = pAttrGroup->m_vecAttrs.begin(); it != pAttrGroup->m_vecAttrs.end(); it++)
  675. {
  676. m_pOwner->ApplyPoint(it->apply_type, bAdd ? it->apply_value : -it->apply_value);
  677. }
  678. }
  679. }
  680. break;
  681. }
  682. }
  683. bool CItem::IsEquipable() const
  684. {
  685. switch (this->GetType())
  686. {
  687. case ITEM_COSTUME:
  688. case ITEM_ARMOR:
  689. case ITEM_WEAPON:
  690. case ITEM_ROD:
  691. case ITEM_PICK:
  692. case ITEM_UNIQUE:
  693. case ITEM_DS:
  694. case ITEM_SPECIAL_DS:
  695. case ITEM_RING:
  696. case ITEM_BELT:
  697. return true;
  698. }
  699. return false;
  700. }
  701. // return false on error state
  702. bool CItem::EquipTo(LPCHARACTER ch, BYTE bWearCell)
  703. {
  704. if (!ch)
  705. {
  706. sys_err("EquipTo: nil character");
  707. return false;
  708. }
  709. // 용혼석 슬롯 index는 WEAR_MAX_NUM 보다 큼.
  710. if (IsDragonSoul())
  711. {
  712. if (bWearCell < WEAR_MAX_NUM || bWearCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
  713. {
  714. sys_err("EquipTo: invalid dragon soul cell (this: #%d %s wearflag: %d cell: %d)", GetOriginalVnum(), GetName(), GetSubType(), bWearCell - WEAR_MAX_NUM);
  715. return false;
  716. }
  717. }
  718. else
  719. {
  720. if (bWearCell >= WEAR_MAX_NUM)
  721. {
  722. sys_err("EquipTo: invalid wear cell (this: #%d %s wearflag: %d cell: %d)", GetOriginalVnum(), GetName(), GetWearFlag(), bWearCell);
  723. return false;
  724. }
  725. }
  726. if (ch->GetWear(bWearCell))
  727. {
  728. sys_err("EquipTo: item already exist (this: #%d %s cell: %d %s)", GetOriginalVnum(), GetName(), bWearCell, ch->GetWear(bWearCell)->GetName());
  729. return false;
  730. }
  731. if (GetOwner())
  732. RemoveFromCharacter();
  733. ch->SetWear(bWearCell, this); // 여기서 패킷 나감
  734. m_pOwner = ch;
  735. m_bEquipped = true;
  736. m_wCell = INVENTORY_MAX_NUM + bWearCell;
  737. #ifndef ENABLE_IMMUNE_FIX
  738. DWORD dwImmuneFlag = 0;
  739. for (int i = 0; i < WEAR_MAX_NUM; ++i)
  740. {
  741. if (m_pOwner->GetWear(i))
  742. {
  743. // m_pOwner->ChatPacket(CHAT_TYPE_INFO, "unequip immuneflag(%u)", m_pOwner->GetWear(i)->m_pProto->dwImmuneFlag); // always 0
  744. SET_BIT(dwImmuneFlag, m_pOwner->GetWear(i)->m_pProto->dwImmuneFlag);
  745. }
  746. }
  747. m_pOwner->SetImmuneFlag(dwImmuneFlag);
  748. #endif
  749. if (IsDragonSoul())
  750. {
  751. DSManager::instance().ActivateDragonSoul(this);
  752. }
  753. else
  754. {
  755. ModifyPoints(true);
  756. StartUniqueExpireEvent();
  757. if (-1 != GetProto()->cLimitTimerBasedOnWearIndex)
  758. StartTimerBasedOnWearExpireEvent();
  759. // ACCESSORY_REFINE
  760. StartAccessorySocketExpireEvent();
  761. // END_OF_ACCESSORY_REFINE
  762. }
  763. ch->BuffOnAttr_AddBuffsFromItem(this);
  764. m_pOwner->ComputeBattlePoints();
  765. m_pOwner->UpdatePacket();
  766. Save();
  767. return (true);
  768. }
  769. bool CItem::Unequip()
  770. {
  771. if (!m_pOwner || GetCell() < INVENTORY_MAX_NUM)
  772. {
  773. // ITEM_OWNER_INVALID_PTR_BUG
  774. sys_err("%s %u m_pOwner %p, GetCell %d",
  775. GetName(), GetID(), get_pointer(m_pOwner), GetCell());
  776. // END_OF_ITEM_OWNER_INVALID_PTR_BUG
  777. return false;
  778. }
  779. if (this != m_pOwner->GetWear(GetCell() - INVENTORY_MAX_NUM))
  780. {
  781. sys_err("m_pOwner->GetWear() != this");
  782. return false;
  783. }
  784. //신규 말 아이템 제거시 처리
  785. if (IsRideItem())
  786. ClearMountAttributeAndAffect();
  787. if (IsDragonSoul())
  788. {
  789. DSManager::instance().DeactivateDragonSoul(this);
  790. }
  791. else
  792. {
  793. ModifyPoints(false);
  794. }
  795. StopUniqueExpireEvent();
  796. if (-1 != GetProto()->cLimitTimerBasedOnWearIndex)
  797. StopTimerBasedOnWearExpireEvent();
  798. // ACCESSORY_REFINE
  799. StopAccessorySocketExpireEvent();
  800. // END_OF_ACCESSORY_REFINE
  801. m_pOwner->BuffOnAttr_RemoveBuffsFromItem(this);
  802. m_pOwner->SetWear(GetCell() - INVENTORY_MAX_NUM, NULL);
  803. #ifndef ENABLE_IMMUNE_FIX
  804. DWORD dwImmuneFlag = 0;
  805. for (int i = 0; i < WEAR_MAX_NUM; ++i)
  806. {
  807. if (m_pOwner->GetWear(i))
  808. {
  809. // m_pOwner->ChatPacket(CHAT_TYPE_INFO, "unequip immuneflag(%u)", m_pOwner->GetWear(i)->m_pProto->dwImmuneFlag); // always 0
  810. SET_BIT(dwImmuneFlag, m_pOwner->GetWear(i)->m_pProto->dwImmuneFlag);
  811. }
  812. }
  813. m_pOwner->SetImmuneFlag(dwImmuneFlag);
  814. #endif
  815. m_pOwner->ComputeBattlePoints();
  816. m_pOwner->UpdatePacket();
  817. m_pOwner = NULL;
  818. m_wCell = 0;
  819. m_bEquipped = false;
  820. return true;
  821. }
  822. long CItem::GetValue(DWORD idx)
  823. {
  824. assert(idx < ITEM_VALUES_MAX_NUM);
  825. return GetProto()->alValues[idx];
  826. }
  827. void CItem::SetExchanging(bool bOn)
  828. {
  829. m_bExchanging = bOn;
  830. }
  831. void CItem::Save()
  832. {
  833. if (m_bSkipSave)
  834. return;
  835. ITEM_MANAGER::instance().DelayedSave(this);
  836. }
  837. bool CItem::CreateSocket(BYTE bSlot, BYTE bGold)
  838. {
  839. assert(bSlot < ITEM_SOCKET_MAX_NUM);
  840. if (m_alSockets[bSlot] != 0)
  841. {
  842. sys_err("Item::CreateSocket : socket already exist %s %d", GetName(), bSlot);
  843. return false;
  844. }
  845. if (bGold)
  846. m_alSockets[bSlot] = 2;
  847. else
  848. m_alSockets[bSlot] = 1;
  849. UpdatePacket();
  850. Save();
  851. return true;
  852. }
  853. void CItem::SetSockets(const long * c_al)
  854. {
  855. thecore_memcpy(m_alSockets, c_al, sizeof(m_alSockets));
  856. Save();
  857. }
  858. void CItem::SetSocket(int i, long v, bool bLog)
  859. {
  860. assert(i < ITEM_SOCKET_MAX_NUM);
  861. m_alSockets[i] = v;
  862. UpdatePacket();
  863. Save();
  864. if (bLog)
  865. {
  866. #ifdef ENABLE_NEWSTUFF
  867. if (g_iDbLogLevel>=LOG_LEVEL_MAX)
  868. #endif
  869. LogManager::instance().ItemLog(i, v, 0, GetID(), "SET_SOCKET", "", "", GetOriginalVnum());
  870. }
  871. }
  872. int CItem::GetGold()
  873. {
  874. if (IS_SET(GetFlag(), ITEM_FLAG_COUNT_PER_1GOLD))
  875. {
  876. if (GetProto()->dwGold == 0)
  877. return GetCount();
  878. else
  879. return GetCount() / GetProto()->dwGold;
  880. }
  881. else
  882. return GetProto()->dwGold;
  883. }
  884. int CItem::GetShopBuyPrice()
  885. {
  886. return GetProto()->dwShopBuyPrice;
  887. }
  888. bool CItem::IsOwnership(LPCHARACTER ch)
  889. {
  890. if (!m_pkOwnershipEvent)
  891. return true;
  892. return m_dwOwnershipPID == ch->GetPlayerID() ? true : false;
  893. }
  894. EVENTFUNC(ownership_event)
  895. {
  896. item_event_info* info = dynamic_cast<item_event_info*>( event->info );
  897. if ( info == NULL )
  898. {
  899. sys_err( "ownership_event> <Factor> Null pointer" );
  900. return 0;
  901. }
  902. LPITEM pkItem = info->item;
  903. pkItem->SetOwnershipEvent(NULL);
  904. TPacketGCItemOwnership p;
  905. p.bHeader = HEADER_GC_ITEM_OWNERSHIP;
  906. p.dwVID = pkItem->GetVID();
  907. p.szName[0] = '\0';
  908. pkItem->PacketAround(&p, sizeof(p));
  909. return 0;
  910. }
  911. void CItem::SetOwnershipEvent(LPEVENT pkEvent)
  912. {
  913. m_pkOwnershipEvent = pkEvent;
  914. }
  915. void CItem::SetOwnership(LPCHARACTER ch, int iSec)
  916. {
  917. if (!ch)
  918. {
  919. if (m_pkOwnershipEvent)
  920. {
  921. event_cancel(&m_pkOwnershipEvent);
  922. m_dwOwnershipPID = 0;
  923. TPacketGCItemOwnership p;
  924. p.bHeader = HEADER_GC_ITEM_OWNERSHIP;
  925. p.dwVID = m_dwVID;
  926. p.szName[0] = '\0';
  927. PacketAround(&p, sizeof(p));
  928. }
  929. return;
  930. }
  931. if (m_pkOwnershipEvent)
  932. return;
  933. if (iSec <= 10)
  934. iSec = 30;
  935. m_dwOwnershipPID = ch->GetPlayerID();
  936. item_event_info* info = AllocEventInfo<item_event_info>();
  937. strlcpy(info->szOwnerName, ch->GetName(), sizeof(info->szOwnerName));
  938. info->item = this;
  939. SetOwnershipEvent(event_create(ownership_event, info, PASSES_PER_SEC(iSec)));
  940. TPacketGCItemOwnership p;
  941. p.bHeader = HEADER_GC_ITEM_OWNERSHIP;
  942. p.dwVID = m_dwVID;
  943. strlcpy(p.szName, ch->GetName(), sizeof(p.szName));
  944. PacketAround(&p, sizeof(p));
  945. }
  946. int CItem::GetSocketCount()
  947. {
  948. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
  949. {
  950. if (GetSocket(i) == 0)
  951. return i;
  952. }
  953. return ITEM_SOCKET_MAX_NUM;
  954. }
  955. bool CItem::AddSocket()
  956. {
  957. int count = GetSocketCount();
  958. if (count == ITEM_SOCKET_MAX_NUM)
  959. return false;
  960. m_alSockets[count] = 1;
  961. return true;
  962. }
  963. void CItem::AlterToSocketItem(int iSocketCount)
  964. {
  965. if (iSocketCount >= ITEM_SOCKET_MAX_NUM)
  966. {
  967. sys_log(0, "Invalid Socket Count %d, set to maximum", ITEM_SOCKET_MAX_NUM);
  968. iSocketCount = ITEM_SOCKET_MAX_NUM;
  969. }
  970. for (int i = 0; i < iSocketCount; ++i)
  971. SetSocket(i, 1);
  972. }
  973. void CItem::AlterToMagicItem()
  974. {
  975. int idx = GetAttributeSetIndex();
  976. if (idx < 0)
  977. return;
  978. // Appeariance Second Third
  979. // Weapon 50 20 5
  980. // Armor 30 10 2
  981. // Acc 20 10 1
  982. int iSecondPct;
  983. int iThirdPct;
  984. switch (GetType())
  985. {
  986. case ITEM_WEAPON:
  987. iSecondPct = 20;
  988. iThirdPct = 5;
  989. break;
  990. case ITEM_ARMOR:
  991. case ITEM_COSTUME:
  992. if (GetSubType() == ARMOR_BODY)
  993. {
  994. iSecondPct = 10;
  995. iThirdPct = 2;
  996. }
  997. else
  998. {
  999. iSecondPct = 10;
  1000. iThirdPct = 1;
  1001. }
  1002. break;
  1003. default:
  1004. return;
  1005. }
  1006. // 100% 확률로 좋은 속성 하나
  1007. PutAttribute(aiItemMagicAttributePercentHigh);
  1008. if (number(1, 100) <= iSecondPct)
  1009. PutAttribute(aiItemMagicAttributePercentLow);
  1010. if (number(1, 100) <= iThirdPct)
  1011. PutAttribute(aiItemMagicAttributePercentLow);
  1012. }
  1013. DWORD CItem::GetRefineFromVnum()
  1014. {
  1015. return ITEM_MANAGER::instance().GetRefineFromVnum(GetVnum());
  1016. }
  1017. int CItem::GetRefineLevel()
  1018. {
  1019. const char* name = GetBaseName();
  1020. char* p = const_cast<char*>(strrchr(name, '+'));
  1021. if (!p)
  1022. return 0;
  1023. int rtn = 0;
  1024. str_to_number(rtn, p+1);
  1025. const char* locale_name = GetName();
  1026. p = const_cast<char*>(strrchr(locale_name, '+'));
  1027. if (p)
  1028. {
  1029. int locale_rtn = 0;
  1030. str_to_number(locale_rtn, p+1);
  1031. if (locale_rtn != rtn)
  1032. {
  1033. sys_err("refine_level_based_on_NAME(%d) is not equal to refine_level_based_on_LOCALE_NAME(%d).", rtn, locale_rtn);
  1034. }
  1035. }
  1036. return rtn;
  1037. }
  1038. bool CItem::IsPolymorphItem()
  1039. {
  1040. return GetType() == ITEM_POLYMORPH;
  1041. }
  1042. EVENTFUNC(unique_expire_event)
  1043. {
  1044. item_event_info* info = dynamic_cast<item_event_info*>( event->info );
  1045. if ( info == NULL )
  1046. {
  1047. sys_err( "unique_expire_event> <Factor> Null pointer" );
  1048. return 0;
  1049. }
  1050. LPITEM pkItem = info->item;
  1051. if (pkItem->GetValue(2) == 0)
  1052. {
  1053. if (pkItem->GetSocket(ITEM_SOCKET_UNIQUE_REMAIN_TIME) <= 1)
  1054. {
  1055. sys_log(0, "UNIQUE_ITEM: expire %s %u", pkItem->GetName(), pkItem->GetID());
  1056. pkItem->SetUniqueExpireEvent(NULL);
  1057. ITEM_MANAGER::instance().RemoveItem(pkItem, "UNIQUE_EXPIRE");
  1058. return 0;
  1059. }
  1060. else
  1061. {
  1062. pkItem->SetSocket(ITEM_SOCKET_UNIQUE_REMAIN_TIME, pkItem->GetSocket(ITEM_SOCKET_UNIQUE_REMAIN_TIME) - 1);
  1063. return PASSES_PER_SEC(60);
  1064. }
  1065. }
  1066. else
  1067. {
  1068. time_t cur = get_global_time();
  1069. if (pkItem->GetSocket(ITEM_SOCKET_UNIQUE_REMAIN_TIME) <= cur)
  1070. {
  1071. pkItem->SetUniqueExpireEvent(NULL);
  1072. ITEM_MANAGER::instance().RemoveItem(pkItem, "UNIQUE_EXPIRE");
  1073. return 0;
  1074. }
  1075. else
  1076. {
  1077. // 게임 내에 시간제 아이템들이 빠릿빠릿하게 사라지지 않는 버그가 있어
  1078. // 수정
  1079. // by rtsummit
  1080. if (pkItem->GetSocket(ITEM_SOCKET_UNIQUE_REMAIN_TIME) - cur < 600)
  1081. return PASSES_PER_SEC(pkItem->GetSocket(ITEM_SOCKET_UNIQUE_REMAIN_TIME) - cur);
  1082. else
  1083. return PASSES_PER_SEC(600);
  1084. }
  1085. }
  1086. }
  1087. // 시간 후불제
  1088. // timer를 시작할 때에 시간 차감하는 것이 아니라,
  1089. // timer가 발화할 때에 timer가 동작한 시간 만큼 시간 차감을 한다.
  1090. EVENTFUNC(timer_based_on_wear_expire_event)
  1091. {
  1092. item_event_info* info = dynamic_cast<item_event_info*>( event->info );
  1093. if ( info == NULL )
  1094. {
  1095. sys_err( "expire_event <Factor> Null pointer" );
  1096. return 0;
  1097. }
  1098. LPITEM pkItem = info->item;
  1099. int remain_time = pkItem->GetSocket(ITEM_SOCKET_REMAIN_SEC) - processing_time/passes_per_sec;
  1100. if (remain_time <= 0)
  1101. {
  1102. sys_log(0, "ITEM EXPIRED : expired %s %u", pkItem->GetName(), pkItem->GetID());
  1103. pkItem->SetTimerBasedOnWearExpireEvent(NULL);
  1104. pkItem->SetSocket(ITEM_SOCKET_REMAIN_SEC, 0);
  1105. // 일단 timer based on wear 용혼석은 시간 다 되었다고 없애지 않는다.
  1106. if (pkItem->IsDragonSoul())
  1107. {
  1108. DSManager::instance().DeactivateDragonSoul(pkItem);
  1109. }
  1110. else
  1111. {
  1112. ITEM_MANAGER::instance().RemoveItem(pkItem, "TIMER_BASED_ON_WEAR_EXPIRE");
  1113. }
  1114. return 0;
  1115. }
  1116. pkItem->SetSocket(ITEM_SOCKET_REMAIN_SEC, remain_time);
  1117. return PASSES_PER_SEC (MIN (60, remain_time));
  1118. }
  1119. void CItem::SetUniqueExpireEvent(LPEVENT pkEvent)
  1120. {
  1121. m_pkUniqueExpireEvent = pkEvent;
  1122. }
  1123. void CItem::SetTimerBasedOnWearExpireEvent(LPEVENT pkEvent)
  1124. {
  1125. m_pkTimerBasedOnWearExpireEvent = pkEvent;
  1126. }
  1127. EVENTFUNC(real_time_expire_event)
  1128. {
  1129. const item_vid_event_info* info = reinterpret_cast<const item_vid_event_info*>(event->info);
  1130. if (NULL == info)
  1131. return 0;
  1132. const LPITEM item = ITEM_MANAGER::instance().FindByVID( info->item_vid );
  1133. if (NULL == item)
  1134. return 0;
  1135. const time_t current = get_global_time();
  1136. if (current > item->GetSocket(0))
  1137. {
  1138. switch (item->GetVnum())
  1139. {
  1140. if(item->IsNewMountItem())
  1141. {
  1142. if (item->GetSocket(2) != 0)
  1143. item->ClearMountAttributeAndAffect();
  1144. }
  1145. break;
  1146. }
  1147. ITEM_MANAGER::instance().RemoveItem(item, "REAL_TIME_EXPIRE");
  1148. return 0;
  1149. }
  1150. return PASSES_PER_SEC(1);
  1151. }
  1152. void CItem::StartRealTimeExpireEvent()
  1153. {
  1154. if (m_pkRealTimeExpireEvent)
  1155. return;
  1156. for (int i=0 ; i < ITEM_LIMIT_MAX_NUM ; i++)
  1157. {
  1158. if (LIMIT_REAL_TIME == GetProto()->aLimits[i].bType || LIMIT_REAL_TIME_START_FIRST_USE == GetProto()->aLimits[i].bType)
  1159. {
  1160. item_vid_event_info* info = AllocEventInfo<item_vid_event_info>();
  1161. info->item_vid = GetVID();
  1162. m_pkRealTimeExpireEvent = event_create( real_time_expire_event, info, PASSES_PER_SEC(1));
  1163. sys_log(0, "REAL_TIME_EXPIRE: StartRealTimeExpireEvent");
  1164. return;
  1165. }
  1166. }
  1167. }
  1168. bool CItem::IsRealTimeItem()
  1169. {
  1170. if(!GetProto())
  1171. return false;
  1172. for (int i=0 ; i < ITEM_LIMIT_MAX_NUM ; i++)
  1173. {
  1174. if (LIMIT_REAL_TIME == GetProto()->aLimits[i].bType)
  1175. return true;
  1176. }
  1177. return false;
  1178. }
  1179. void CItem::StartUniqueExpireEvent()
  1180. {
  1181. if (GetType() != ITEM_UNIQUE)
  1182. return;
  1183. if (m_pkUniqueExpireEvent)
  1184. return;
  1185. //기간제 아이템일 경우 시간제 아이템은 동작하지 않는다
  1186. if (IsRealTimeItem())
  1187. return;
  1188. // HARD CODING
  1189. if (GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
  1190. m_pOwner->ShowAlignment(false);
  1191. int iSec = GetSocket(ITEM_SOCKET_UNIQUE_SAVE_TIME);
  1192. if (iSec == 0)
  1193. iSec = 60;
  1194. else
  1195. iSec = MIN(iSec, 60);
  1196. SetSocket(ITEM_SOCKET_UNIQUE_SAVE_TIME, 0);
  1197. item_event_info* info = AllocEventInfo<item_event_info>();
  1198. info->item = this;
  1199. SetUniqueExpireEvent(event_create(unique_expire_event, info, PASSES_PER_SEC(iSec)));
  1200. }
  1201. // 시간 후불제
  1202. // timer_based_on_wear_expire_event 설명 참조
  1203. void CItem::StartTimerBasedOnWearExpireEvent()
  1204. {
  1205. if (m_pkTimerBasedOnWearExpireEvent)
  1206. return;
  1207. //기간제 아이템일 경우 시간제 아이템은 동작하지 않는다
  1208. if (IsRealTimeItem())
  1209. return;
  1210. if (-1 == GetProto()->cLimitTimerBasedOnWearIndex)
  1211. return;
  1212. int iSec = GetSocket(0);
  1213. // 남은 시간을 분단위로 끊기 위해...
  1214. if (0 != iSec)
  1215. {
  1216. iSec %= 60;
  1217. if (0 == iSec)
  1218. iSec = 60;
  1219. }
  1220. item_event_info* info = AllocEventInfo<item_event_info>();
  1221. info->item = this;
  1222. SetTimerBasedOnWearExpireEvent(event_create(timer_based_on_wear_expire_event, info, PASSES_PER_SEC(iSec)));
  1223. }
  1224. void CItem::StopUniqueExpireEvent()
  1225. {
  1226. if (!m_pkUniqueExpireEvent)
  1227. return;
  1228. if (GetValue(2) != 0) // 게임시간제 이외의 아이템은 UniqueExpireEvent를 중단할 수 없다.
  1229. return;
  1230. // HARD CODING
  1231. if (GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
  1232. m_pOwner->ShowAlignment(true);
  1233. SetSocket(ITEM_SOCKET_UNIQUE_SAVE_TIME, event_time(m_pkUniqueExpireEvent) / passes_per_sec);
  1234. event_cancel(&m_pkUniqueExpireEvent);
  1235. ITEM_MANAGER::instance().SaveSingleItem(this);
  1236. }
  1237. void CItem::StopTimerBasedOnWearExpireEvent()
  1238. {
  1239. if (!m_pkTimerBasedOnWearExpireEvent)
  1240. return;
  1241. int remain_time = GetSocket(ITEM_SOCKET_REMAIN_SEC) - event_processing_time(m_pkTimerBasedOnWearExpireEvent) / passes_per_sec;
  1242. SetSocket(ITEM_SOCKET_REMAIN_SEC, remain_time);
  1243. event_cancel(&m_pkTimerBasedOnWearExpireEvent);
  1244. ITEM_MANAGER::instance().SaveSingleItem(this);
  1245. }
  1246. void CItem::ApplyAddon(int iAddonType)
  1247. {
  1248. CItemAddonManager::instance().ApplyAddonTo(iAddonType, this);
  1249. }
  1250. int CItem::GetSpecialGroup() const
  1251. {
  1252. return ITEM_MANAGER::instance().GetSpecialGroupFromItem(GetVnum());
  1253. }
  1254. //
  1255. // 악세서리 소켓 처리.
  1256. //
  1257. bool CItem::IsAccessoryForSocket()
  1258. {
  1259. return (m_pProto->bType == ITEM_ARMOR && (m_pProto->bSubType == ARMOR_WRIST || m_pProto->bSubType == ARMOR_NECK || m_pProto->bSubType == ARMOR_EAR)) ||
  1260. (m_pProto->bType == ITEM_BELT); // 2013년 2월 새로 추가된 '벨트' 아이템의 경우 기획팀에서 악세서리 소켓 시스템을 그대로 이용하자고 함.
  1261. }
  1262. void CItem::SetAccessorySocketGrade(int iGrade)
  1263. {
  1264. SetSocket(0, MINMAX(0, iGrade, GetAccessorySocketMaxGrade()));
  1265. int iDownTime = aiAccessorySocketDegradeTime[GetAccessorySocketGrade()];
  1266. //if (test_server)
  1267. // iDownTime /= 60;
  1268. SetAccessorySocketDownGradeTime(iDownTime);
  1269. }
  1270. void CItem::SetAccessorySocketMaxGrade(int iMaxGrade)
  1271. {
  1272. SetSocket(1, MINMAX(0, iMaxGrade, ITEM_ACCESSORY_SOCKET_MAX_NUM));
  1273. }
  1274. void CItem::SetAccessorySocketDownGradeTime(DWORD time)
  1275. {
  1276. SetSocket(2, time);
  1277. if (test_server && GetOwner())
  1278. GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s에서 소켓 빠질때까지 남은 시간 %d"), GetName(), time);
  1279. }
  1280. EVENTFUNC(accessory_socket_expire_event)
  1281. {
  1282. item_vid_event_info* info = dynamic_cast<item_vid_event_info*>( event->info );
  1283. if ( info == NULL )
  1284. {
  1285. sys_err( "accessory_socket_expire_event> <Factor> Null pointer" );
  1286. return 0;
  1287. }
  1288. LPITEM item = ITEM_MANAGER::instance().FindByVID(info->item_vid);
  1289. if (item->GetAccessorySocketDownGradeTime() <= 1)
  1290. {
  1291. degrade:
  1292. item->SetAccessorySocketExpireEvent(NULL);
  1293. item->AccessorySocketDegrade();
  1294. return 0;
  1295. }
  1296. else
  1297. {
  1298. int iTime = item->GetAccessorySocketDownGradeTime() - 60;
  1299. if (iTime <= 1)
  1300. goto degrade;
  1301. item->SetAccessorySocketDownGradeTime(iTime);
  1302. if (iTime > 60)
  1303. return PASSES_PER_SEC(60);
  1304. else
  1305. return PASSES_PER_SEC(iTime);
  1306. }
  1307. }
  1308. void CItem::StartAccessorySocketExpireEvent()
  1309. {
  1310. if (!IsAccessoryForSocket())
  1311. return;
  1312. if (m_pkAccessorySocketExpireEvent)
  1313. return;
  1314. if (GetAccessorySocketMaxGrade() == 0)
  1315. return;
  1316. if (GetAccessorySocketGrade() == 0)
  1317. return;
  1318. int iSec = GetAccessorySocketDownGradeTime();
  1319. SetAccessorySocketExpireEvent(NULL);
  1320. if (iSec <= 1)
  1321. iSec = 5;
  1322. else
  1323. iSec = MIN(iSec, 60);
  1324. item_vid_event_info* info = AllocEventInfo<item_vid_event_info>();
  1325. info->item_vid = GetVID();
  1326. SetAccessorySocketExpireEvent(event_create(accessory_socket_expire_event, info, PASSES_PER_SEC(iSec)));
  1327. }
  1328. void CItem::StopAccessorySocketExpireEvent()
  1329. {
  1330. if (!m_pkAccessorySocketExpireEvent)
  1331. return;
  1332. if (!IsAccessoryForSocket())
  1333. return;
  1334. int new_time = GetAccessorySocketDownGradeTime() - (60 - event_time(m_pkAccessorySocketExpireEvent) / passes_per_sec);
  1335. event_cancel(&m_pkAccessorySocketExpireEvent);
  1336. if (new_time <= 1)
  1337. {
  1338. AccessorySocketDegrade();
  1339. }
  1340. else
  1341. {
  1342. SetAccessorySocketDownGradeTime(new_time);
  1343. }
  1344. }
  1345. bool CItem::IsRideItem()
  1346. {
  1347. if (ITEM_UNIQUE == GetType() && UNIQUE_SPECIAL_RIDE == GetSubType())
  1348. return true;
  1349. if (ITEM_UNIQUE == GetType() && UNIQUE_SPECIAL_MOUNT_RIDE == GetSubType())
  1350. return true;
  1351. return false;
  1352. }
  1353. bool CItem::IsRamadanRing()
  1354. {
  1355. if (GetVnum() == UNIQUE_ITEM_RAMADAN_RING)
  1356. return true;
  1357. return false;
  1358. }
  1359. void CItem::ClearMountAttributeAndAffect()
  1360. {
  1361. LPCHARACTER ch = GetOwner();
  1362. ch->RemoveAffect(AFFECT_MOUNT);
  1363. ch->RemoveAffect(AFFECT_MOUNT_BONUS);
  1364. ch->MountVnum(0);
  1365. ch->PointChange(POINT_ST, 0);
  1366. ch->PointChange(POINT_DX, 0);
  1367. ch->PointChange(POINT_HT, 0);
  1368. ch->PointChange(POINT_IQ, 0);
  1369. }
  1370. // fixme
  1371. // 이거 지금은 안쓴데... 근데 혹시나 싶어서 남겨둠.
  1372. // by rtsummit
  1373. bool CItem::IsNewMountItem()
  1374. {
  1375. switch(GetVnum())
  1376. {
  1377. case 76000: case 76001: case 76002: case 76003:
  1378. case 76004: case 76005: case 76006: case 76007:
  1379. case 76008: case 76009: case 76010: case 76011:
  1380. case 76012: case 76013: case 76014:
  1381. return true;
  1382. }
  1383. return false;
  1384. }
  1385. void CItem::SetAccessorySocketExpireEvent(LPEVENT pkEvent)
  1386. {
  1387. m_pkAccessorySocketExpireEvent = pkEvent;
  1388. }
  1389. void CItem::AccessorySocketDegrade()
  1390. {
  1391. if (GetAccessorySocketGrade() > 0)
  1392. {
  1393. LPCHARACTER ch = GetOwner();
  1394. if (ch)
  1395. {
  1396. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s에 박혀있던 보석이 사라집니다."), GetName());
  1397. }
  1398. ModifyPoints(false);
  1399. SetAccessorySocketGrade(GetAccessorySocketGrade()-1);
  1400. ModifyPoints(true);
  1401. int iDownTime = aiAccessorySocketDegradeTime[GetAccessorySocketGrade()];
  1402. if (test_server)
  1403. iDownTime /= 60;
  1404. SetAccessorySocketDownGradeTime(iDownTime);
  1405. if (iDownTime)
  1406. StartAccessorySocketExpireEvent();
  1407. }
  1408. }
  1409. // ring에 item을 박을 수 있는지 여부를 체크해서 리턴
  1410. static const bool CanPutIntoRing(LPITEM ring, LPITEM item)
  1411. {
  1412. //const DWORD vnum = item->GetVnum();
  1413. return false;
  1414. }
  1415. bool CItem::CanPutInto(LPITEM item)
  1416. {
  1417. if (item->GetType() == ITEM_BELT)
  1418. return this->GetSubType() == USE_PUT_INTO_BELT_SOCKET;
  1419. else if(item->GetType() == ITEM_RING)
  1420. return CanPutIntoRing(item, this);
  1421. else if (item->GetType() != ITEM_ARMOR)
  1422. return false;
  1423. DWORD vnum = item->GetVnum();
  1424. struct JewelAccessoryInfo
  1425. {
  1426. DWORD jewel;
  1427. DWORD wrist;
  1428. DWORD neck;
  1429. DWORD ear;
  1430. };
  1431. const static JewelAccessoryInfo infos[] = {
  1432. { 50634, 14420, 16220, 17220 },
  1433. { 50635, 14500, 16500, 17500 },
  1434. { 50636, 14520, 16520, 17520 },
  1435. { 50637, 14540, 16540, 17540 },
  1436. { 50638, 14560, 16560, 17560 },
  1437. { 50639, 14570, 16570, 17570 },
  1438. };
  1439. DWORD item_type = (item->GetVnum() / 10) * 10;
  1440. for (size_t i = 0; i < sizeof(infos) / sizeof(infos[0]); i++)
  1441. {
  1442. const JewelAccessoryInfo& info = infos[i];
  1443. switch(item->GetSubType())
  1444. {
  1445. case ARMOR_WRIST:
  1446. if (info.wrist == item_type)
  1447. {
  1448. if (info.jewel == GetVnum())
  1449. {
  1450. return true;
  1451. }
  1452. else
  1453. {
  1454. return false;
  1455. }
  1456. }
  1457. break;
  1458. case ARMOR_NECK:
  1459. if (info.neck == item_type)
  1460. {
  1461. if (info.jewel == GetVnum())
  1462. {
  1463. return true;
  1464. }
  1465. else
  1466. {
  1467. return false;
  1468. }
  1469. }
  1470. break;
  1471. case ARMOR_EAR:
  1472. if (info.ear == item_type)
  1473. {
  1474. if (info.jewel == GetVnum())
  1475. {
  1476. return true;
  1477. }
  1478. else
  1479. {
  1480. return false;
  1481. }
  1482. }
  1483. break;
  1484. }
  1485. }
  1486. if (item->GetSubType() == ARMOR_WRIST)
  1487. vnum -= 14000;
  1488. else if (item->GetSubType() == ARMOR_NECK)
  1489. vnum -= 16000;
  1490. else if (item->GetSubType() == ARMOR_EAR)
  1491. vnum -= 17000;
  1492. else
  1493. return false;
  1494. DWORD type = vnum / 20;
  1495. if (type < 0 || type > 11)
  1496. {
  1497. type = (vnum - 170) / 20;
  1498. if (50623 + type != GetVnum())
  1499. return false;
  1500. else
  1501. return true;
  1502. }
  1503. else if (item->GetVnum() >= 16210 && item->GetVnum() <= 16219)
  1504. {
  1505. if (50625 != GetVnum())
  1506. return false;
  1507. else
  1508. return true;
  1509. }
  1510. else if (item->GetVnum() >= 16230 && item->GetVnum() <= 16239)
  1511. {
  1512. if (50626 != GetVnum())
  1513. return false;
  1514. else
  1515. return true;
  1516. }
  1517. return 50623 + type == GetVnum();
  1518. }
  1519. // PC_BANG_ITEM_ADD
  1520. bool CItem::IsPCBangItem()
  1521. {
  1522. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  1523. {
  1524. if (m_pProto->aLimits[i].bType == LIMIT_PCBANG)
  1525. return true;
  1526. }
  1527. return false;
  1528. }
  1529. // END_PC_BANG_ITEM_ADD
  1530. bool CItem::CheckItemUseLevel(int nLevel)
  1531. {
  1532. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  1533. {
  1534. if (this->m_pProto->aLimits[i].bType == LIMIT_LEVEL)
  1535. {
  1536. if (this->m_pProto->aLimits[i].lValue > nLevel) return false;
  1537. else return true;
  1538. }
  1539. }
  1540. return true;
  1541. }
  1542. long CItem::FindApplyValue(BYTE bApplyType)
  1543. {
  1544. if (m_pProto == NULL)
  1545. return 0;
  1546. for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
  1547. {
  1548. if (m_pProto->aApplies[i].bType == bApplyType)
  1549. return m_pProto->aApplies[i].lValue;
  1550. }
  1551. return 0;
  1552. }
  1553. void CItem::CopySocketTo(LPITEM pItem)
  1554. {
  1555. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1556. {
  1557. pItem->m_alSockets[i] = m_alSockets[i];
  1558. }
  1559. }
  1560. int CItem::GetAccessorySocketGrade()
  1561. {
  1562. return MINMAX(0, GetSocket(0), GetAccessorySocketMaxGrade());
  1563. }
  1564. int CItem::GetAccessorySocketMaxGrade()
  1565. {
  1566. return MINMAX(0, GetSocket(1), ITEM_ACCESSORY_SOCKET_MAX_NUM);
  1567. }
  1568. int CItem::GetAccessorySocketDownGradeTime()
  1569. {
  1570. return MINMAX(0, GetSocket(2), aiAccessorySocketDegradeTime[GetAccessorySocketGrade()]);
  1571. }
  1572. void CItem::AttrLog()
  1573. {
  1574. const char * pszIP = NULL;
  1575. if (GetOwner() && GetOwner()->GetDesc())
  1576. pszIP = GetOwner()->GetDesc()->GetHostName();
  1577. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1578. {
  1579. if (m_alSockets[i])
  1580. {
  1581. #ifdef ENABLE_NEWSTUFF
  1582. if (g_iDbLogLevel>=LOG_LEVEL_MAX)
  1583. #endif
  1584. LogManager::instance().ItemLog(i, m_alSockets[i], 0, GetID(), "INFO_SOCKET", "", pszIP ? pszIP : "", GetOriginalVnum());
  1585. }
  1586. }
  1587. for (int i = 0; i<ITEM_ATTRIBUTE_MAX_NUM; ++i)
  1588. {
  1589. int type = m_aAttr[i].bType;
  1590. int value = m_aAttr[i].sValue;
  1591. if (type)
  1592. {
  1593. #ifdef ENABLE_NEWSTUFF
  1594. if (g_iDbLogLevel>=LOG_LEVEL_MAX)
  1595. #endif
  1596. LogManager::instance().ItemLog(i, type, value, GetID(), "INFO_ATTR", "", pszIP ? pszIP : "", GetOriginalVnum());
  1597. }
  1598. }
  1599. }
  1600. int CItem::GetLevelLimit()
  1601. {
  1602. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  1603. {
  1604. if (this->m_pProto->aLimits[i].bType == LIMIT_LEVEL)
  1605. {
  1606. return this->m_pProto->aLimits[i].lValue;
  1607. }
  1608. }
  1609. return 0;
  1610. }
  1611. bool CItem::OnAfterCreatedItem()
  1612. {
  1613. // 아이템을 한 번이라도 사용했다면, 그 이후엔 사용 중이지 않아도 시간이 차감되는 방식
  1614. if (-1 != this->GetProto()->cLimitRealTimeFirstUseIndex)
  1615. {
  1616. // Socket1에 아이템의 사용 횟수가 기록되어 있으니, 한 번이라도 사용한 아이템은 타이머를 시작한다.
  1617. if (0 != GetSocket(1))
  1618. {
  1619. StartRealTimeExpireEvent();
  1620. }
  1621. }
  1622. return true;
  1623. }
  1624. #ifdef __AUCTION__
  1625. // 경매장
  1626. // window를 경매장으로 한다.
  1627. bool CItem::MoveToAuction()
  1628. {
  1629. LPCHARACTER owner = GetOwner();
  1630. if (owner == NULL)
  1631. {
  1632. sys_err ("Item those owner is not exist cannot regist in auction");
  1633. return false;
  1634. }
  1635. if (GetWindow() == AUCTION)
  1636. {
  1637. sys_err ("Item is already in auction.");
  1638. }
  1639. SetWindow(AUCTION);
  1640. owner->SetItem(m_bCell, NULL);
  1641. Save();
  1642. ITEM_MANAGER::instance().FlushDelayedSave(this);
  1643. return true;
  1644. }
  1645. void CItem::CopyToRawData (TPlayerItem* new_item)
  1646. {
  1647. if (new_item != NULL)
  1648. return;
  1649. new_item->id = m_dwID;
  1650. new_item->window = m_bWindow;
  1651. new_item->pos = m_bCell;
  1652. new_item->count = m_dwCount;
  1653. new_item->vnum = GetVnum();
  1654. thecore_memcpy (new_item->alSockets, m_alSockets, sizeof (m_alSockets));
  1655. thecore_memcpy (new_item->aAttr, m_aAttr, sizeof (m_aAttr));
  1656. new_item->owner = m_pOwner->GetPlayerID();
  1657. }
  1658. #endif
  1659. bool CItem::IsDragonSoul()
  1660. {
  1661. return GetType() == ITEM_DS;
  1662. }
  1663. int CItem::GiveMoreTime_Per(float fPercent)
  1664. {
  1665. if (IsDragonSoul())
  1666. {
  1667. DWORD duration = DSManager::instance().GetDuration(this);
  1668. DWORD remain_sec = GetSocket(ITEM_SOCKET_REMAIN_SEC);
  1669. DWORD given_time = fPercent * duration / 100u;
  1670. if (remain_sec == duration)
  1671. return false;
  1672. if ((given_time + remain_sec) >= duration)
  1673. {
  1674. SetSocket(ITEM_SOCKET_REMAIN_SEC, duration);
  1675. return duration - remain_sec;
  1676. }
  1677. else
  1678. {
  1679. SetSocket(ITEM_SOCKET_REMAIN_SEC, given_time + remain_sec);
  1680. return given_time;
  1681. }
  1682. }
  1683. // 우선 용혼석에 관해서만 하도록 한다.
  1684. else
  1685. return 0;
  1686. }
  1687. int CItem::GiveMoreTime_Fix(DWORD dwTime)
  1688. {
  1689. if (IsDragonSoul())
  1690. {
  1691. DWORD duration = DSManager::instance().GetDuration(this);
  1692. DWORD remain_sec = GetSocket(ITEM_SOCKET_REMAIN_SEC);
  1693. if (remain_sec == duration)
  1694. return false;
  1695. if ((dwTime + remain_sec) >= duration)
  1696. {
  1697. SetSocket(ITEM_SOCKET_REMAIN_SEC, duration);
  1698. return duration - remain_sec;
  1699. }
  1700. else
  1701. {
  1702. SetSocket(ITEM_SOCKET_REMAIN_SEC, dwTime + remain_sec);
  1703. return dwTime;
  1704. }
  1705. }
  1706. // 우선 용혼석에 관해서만 하도록 한다.
  1707. else
  1708. return 0;
  1709. }
  1710. int CItem::GetDuration()
  1711. {
  1712. if(!GetProto())
  1713. return -1;
  1714. for (int i=0 ; i < ITEM_LIMIT_MAX_NUM ; i++)
  1715. {
  1716. if (LIMIT_REAL_TIME == GetProto()->aLimits[i].bType)
  1717. return GetProto()->aLimits[i].lValue;
  1718. }
  1719. if (GetProto()->cLimitTimerBasedOnWearIndex >= 0)
  1720. {
  1721. BYTE cLTBOWI = GetProto()->cLimitTimerBasedOnWearIndex;
  1722. return GetProto()->aLimits[cLTBOWI].lValue;
  1723. }
  1724. return -1;
  1725. }
  1726. bool CItem::IsSameSpecialGroup(const LPITEM item) const
  1727. {
  1728. // 서로 VNUM이 같다면 같은 그룹인 것으로 간주
  1729. if (this->GetVnum() == item->GetVnum())
  1730. return true;
  1731. if (GetSpecialGroup() && (item->GetSpecialGroup() == GetSpecialGroup()))
  1732. return true;
  1733. return false;
  1734. }
  1735. #ifdef ENABLE_SPLIT_INVENTORY_SYSTEM
  1736. bool CItem::IsSkillBook()
  1737. {
  1738. return (GetVnum() == 50300);
  1739. }
  1740. bool CItem::IsUpgradeItem()
  1741. {
  1742. switch (GetVnum())
  1743. {
  1744. case 30003:
  1745. case 30004:
  1746. case 30005:
  1747. case 30006:
  1748. case 30007:
  1749. case 30008:
  1750. case 30009:
  1751. case 30010:
  1752. case 30011:
  1753. case 30014:
  1754. case 30015:
  1755. case 30016:
  1756. case 30017:
  1757. case 30018:
  1758. case 30019:
  1759. case 30021:
  1760. case 30022:
  1761. case 30023:
  1762. case 30025:
  1763. case 30027:
  1764. case 30028:
  1765. case 30030:
  1766. case 30031:
  1767. case 30032:
  1768. case 30033:
  1769. case 30034:
  1770. case 30035:
  1771. case 30037:
  1772. case 30038:
  1773. case 30039:
  1774. case 30040:
  1775. case 30041:
  1776. case 30042:
  1777. case 30045:
  1778. case 30046:
  1779. case 30047:
  1780. case 30048:
  1781. case 30049:
  1782. case 30050:
  1783. case 30051:
  1784. case 30052:
  1785. case 30053:
  1786. case 30055:
  1787. case 30056:
  1788. case 30057:
  1789. case 30058:
  1790. case 30059:
  1791. case 30060:
  1792. case 30061:
  1793. case 30067:
  1794. case 30069:
  1795. case 30070:
  1796. case 30071:
  1797. case 30072:
  1798. case 30073:
  1799. case 30074:
  1800. case 30075:
  1801. case 30076:
  1802. case 30077:
  1803. case 30078:
  1804. case 30079:
  1805. case 30080:
  1806. case 30081:
  1807. case 30082:
  1808. case 30083:
  1809. case 30084:
  1810. case 30085:
  1811. case 30086:
  1812. case 30087:
  1813. case 30088:
  1814. case 30089:
  1815. case 30090:
  1816. case 30091:
  1817. case 30092:
  1818. case 30192:
  1819. case 30193:
  1820. case 30194:
  1821. case 30195:
  1822. case 30196:
  1823. case 30197:
  1824. case 30198:
  1825. case 30199:
  1826. case 30500:
  1827. case 30501:
  1828. case 30502:
  1829. case 30503:
  1830. case 30504:
  1831. case 30505:
  1832. case 30506:
  1833. case 30507:
  1834. case 30508:
  1835. case 30509:
  1836. case 30510:
  1837. case 30511:
  1838. case 30512:
  1839. case 30513:
  1840. case 30514:
  1841. case 30515:
  1842. case 30516:
  1843. case 30517:
  1844. case 30518:
  1845. case 30519:
  1846. case 30520:
  1847. case 30521:
  1848. case 30522:
  1849. case 30523:
  1850. case 30524:
  1851. case 30525:
  1852. case 30600:
  1853. case 30601:
  1854. case 30602:
  1855. case 30603:
  1856. case 30604:
  1857. case 30605:
  1858. case 30606:
  1859. case 30607:
  1860. case 30608:
  1861. case 30609:
  1862. case 30610:
  1863. case 30611:
  1864. case 30612:
  1865. case 30614:
  1866. case 30615:
  1867. case 30616:
  1868. case 30617:
  1869. case 30618:
  1870. case 30619:
  1871. case 30620:
  1872. case 30621:
  1873. case 30622:
  1874. case 30623:
  1875. case 30624:
  1876. case 30625:
  1877. case 30626:
  1878. case 30627:
  1879. case 30628:
  1880. case 30629:
  1881. case 27992:
  1882. case 27993:
  1883. case 27994:
  1884. case 71123:
  1885. case 71129:
  1886. case 31108:
  1887. case 31109:
  1888. case 31110:
  1889. case 31111:
  1890. case 31112:
  1891. case 31113:
  1892. case 31114:
  1893. case 31115:
  1894. case 31117:
  1895. case 31118:
  1896. case 31120:
  1897. case 31121:
  1898. case 31122:
  1899. case 31123:
  1900. case 31124:
  1901. case 31125:
  1902. case 31126:
  1903. case 31127:
  1904. case 31128:
  1905. case 31129:
  1906. case 31130:
  1907. case 31131:
  1908. case 31132:
  1909. case 31133:
  1910. case 31134:
  1911. case 31135:
  1912. case 31136:
  1913. case 31137:
  1914. case 31138:
  1915. case 31144:
  1916. case 31145:
  1917. case 31146:
  1918. case 31148:
  1919. case 31149:
  1920. case 31196:
  1921. case 31197:
  1922. case 31198:
  1923. case 31199:
  1924. case 31200:
  1925. case 31201:
  1926. case 31202:
  1927. case 31203:
  1928. case 31204:
  1929. case 31205:
  1930. case 31206:
  1931. case 31207:
  1932. case 31208:
  1933. case 31209:
  1934. case 31210:
  1935. case 31211:
  1936. case 31212:
  1937. case 31213:
  1938. case 31372:
  1939. case 31378:
  1940. case 31380:
  1941. case 244120:
  1942. case 244121:
  1943. return true;
  1944. }
  1945. return false;
  1946. }
  1947. bool CItem::IsStone()
  1948. {
  1949. return GetType() == ITEM_METIN;
  1950. }
  1951. bool CItem::IsBox()
  1952. {
  1953. return GetType() == ITEM_GIFTBOX
  1954. && GetVnum() != 50187 && GetVnum() != 50188 && GetVnum() != 50189
  1955. && GetVnum() != 50190 && GetVnum() != 50191 && GetVnum() != 50192
  1956. && GetVnum() != 50193 && GetVnum() != 50194 && GetVnum() != 50195
  1957. && GetVnum() != 50196 && GetVnum() != 50197 && GetVnum() != 50255
  1958. && GetVnum() != 50256 && GetVnum() != 50257 && GetVnum() != 50258
  1959. && GetVnum() != 50259 && GetVnum() != 50260 && GetVnum() != 51504
  1960. && GetVnum() != 51510;
  1961. }
  1962. bool CItem::IsEfsun()
  1963. {
  1964. switch (GetVnum())
  1965. {
  1966. case 71084:
  1967. case 71085:
  1968. case 70024:
  1969. case 72304:
  1970. case 76015:
  1971. case 39004:
  1972. case 39028:
  1973. case 39029:
  1974. case 71151:
  1975. case 71152:
  1976. case 76023:
  1977. case 76024:
  1978. return true;
  1979. }
  1980. return false;
  1981. }
  1982. bool CItem::IsCicek()
  1983. {
  1984. switch (GetVnum())
  1985. {
  1986. case 50721:
  1987. case 50722:
  1988. case 50723:
  1989. case 50724:
  1990. case 50725:
  1991. case 50726:
  1992. case 50727:
  1993. case 50728:
  1994. return true;
  1995. }
  1996. return false;
  1997. }
  1998. #endif