R8Sentinel

char.cpp

Nov 19th, 2017
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 254.03 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. #include <stack>
  4.  
  5. #include "utils.h"
  6. #include "config.h"
  7. #include "char.h"
  8. #include "char_manager.h"
  9. #include "item_manager.h"
  10. #include "desc.h"
  11. #include "desc_client.h"
  12. #include "desc_manager.h"
  13. #include "packet.h"
  14. #include "affect.h"
  15. #include "skill.h"
  16. #include "start_position.h"
  17. #include "mob_manager.h"
  18. #include "db.h"
  19. #include "log.h"
  20. #include "vector.h"
  21. #include "buffer_manager.h"
  22. #include "questmanager.h"
  23. #include "fishing.h"
  24. #include "party.h"
  25. #include "dungeon.h"
  26. #include "refine.h"
  27. #include "unique_item.h"
  28. #include "war_map.h"
  29. #include "xmas_event.h"
  30. #include "marriage.h"
  31. #include "monarch.h"
  32. #include "polymorph.h"
  33. #include "blend_item.h"
  34. #include "castle.h"
  35. #include "BattleArena.h"
  36. #include "arena.h"
  37. #include "dev_log.h"
  38. #include "pcbang.h"
  39. #include "threeway_war.h"
  40.  
  41. #include "safebox.h"
  42. #include "shop.h"
  43.  
  44. #include "../../common/VnumHelper.h"
  45. #include "DragonSoul.h"
  46. #include "buff_on_attributes.h"
  47. #include "belt_inventory_helper.h"
  48. #ifdef __MELEY_LAIR_DUNGEON__
  49. #include "MeleyLair.h"
  50. #endif
  51. #include "offline_shop.h"
  52. #include "offlineshop_manager.h"
  53. #include "offlineshop_config.h"
  54.  
  55. #ifdef NEW_PET_SYSTEM
  56. #include "New_PetSystem.h"
  57. #endif
  58.  
  59. //auction_temp
  60. #ifdef __AUCTION__
  61. #include "auction_manager.h"
  62. #endif
  63.  
  64. const int ITEM_BROKEN_METIN_VNUM = 28960;
  65. extern int TasBasmaOrani;
  66.  
  67. // CHANGE_ITEM_ATTRIBUTES
  68. const DWORD CHARACTER::msc_dwDefaultChangeItemAttrCycle = 10;
  69. const char CHARACTER::msc_szLastChangeItemAttrFlag[] = "Item.LastChangeItemAttr";
  70. const char CHARACTER::msc_szChangeItemAttrCycleFlag[] = "change_itemattr_cycle";
  71. // END_OF_CHANGE_ITEM_ATTRIBUTES
  72. const BYTE g_aBuffOnAttrPoints[] = { POINT_ENERGY, POINT_COSTUME_ATTR_BONUS };
  73.  
  74. struct FFindStone
  75. {
  76. std::map<DWORD, LPCHARACTER> m_mapStone;
  77.  
  78. void operator()(LPENTITY pEnt)
  79. {
  80. if (pEnt->IsType(ENTITY_CHARACTER) == true)
  81. {
  82. LPCHARACTER pChar = (LPCHARACTER)pEnt;
  83.  
  84. if (pChar->IsStone() == true)
  85. {
  86. m_mapStone[(DWORD)pChar->GetVID()] = pChar;
  87. }
  88. }
  89. }
  90. };
  91.  
  92.  
  93. //귀환부, 귀환기억부, 결혼반지
  94. static bool IS_SUMMON_ITEM(int vnum)
  95. {
  96. switch (vnum)
  97. {
  98. case 22000:
  99. case 22010:
  100. case 22011:
  101. case 22020:
  102. case ITEM_MARRIAGE_RING:
  103. return true;
  104. }
  105.  
  106. return false;
  107. }
  108.  
  109. static bool IS_MONKEY_DUNGEON(int map_index)
  110. {
  111. switch (map_index)
  112. {
  113. case 5:
  114. case 25:
  115. case 45:
  116. case 108:
  117. case 109:
  118. return true;;
  119. }
  120.  
  121. return false;
  122. }
  123.  
  124. bool IS_SUMMONABLE_ZONE(int map_index)
  125. {
  126. // 몽키던전
  127. if (IS_MONKEY_DUNGEON(map_index))
  128. return false;
  129. // 성
  130. if (IS_CASTLE_MAP(map_index))
  131. return false;
  132.  
  133. switch (map_index)
  134. {
  135. case 66 : // 사귀타워
  136. case 71 : // 거미 던전 2층
  137. case 72 : // 천의 동굴
  138. case 73 : // 천의 동굴 2층
  139. case 193 : // 거미 던전 2-1층
  140. #if 0
  141. case 184 : // 천의 동굴(신수)
  142. case 185 : // 천의 동굴 2층(신수)
  143. case 186 : // 천의 동굴(천조)
  144. case 187 : // 천의 동굴 2층(천조)
  145. case 188 : // 천의 동굴(진노)
  146. case 189 : // 천의 동굴 2층(진노)
  147. #endif
  148. // case 206 : // 아귀동굴
  149. case 216 : // 아귀동굴
  150. case 217 : // 거미 던전 3층
  151. case 208 : // 천의 동굴 (용방)
  152. return false;
  153. }
  154.  
  155. if (CBattleArena::IsBattleArenaMap(map_index)) return false;
  156.  
  157. // 모든 private 맵으론 워프 불가능
  158. if (map_index > 10000) return false;
  159.  
  160. return true;
  161. }
  162.  
  163. bool IS_BOTARYABLE_ZONE(int nMapIndex)
  164. {
  165. switch (nMapIndex)
  166. {
  167. case 1 :
  168. case 3 :
  169. case 21 :
  170. case 23 :
  171. case 41 :
  172. case 43 :
  173. return true;
  174. }
  175.  
  176. return false;
  177. }
  178.  
  179. // item socket 이 프로토타입과 같은지 체크 -- by mhh
  180. static bool FN_check_item_socket(LPITEM item)
  181. {
  182. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  183. {
  184. if (item->GetSocket(i) != item->GetProto()->alSockets[i])
  185. return false;
  186. }
  187.  
  188. return true;
  189. }
  190.  
  191. // item socket 복사 -- by mhh
  192. static void FN_copy_item_socket(LPITEM dest, LPITEM src)
  193. {
  194. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  195. {
  196. dest->SetSocket(i, src->GetSocket(i));
  197. }
  198. }
  199. static bool FN_check_item_sex(LPCHARACTER ch, LPITEM item)
  200. {
  201. // 남자 금지
  202. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_MALE))
  203. {
  204. if (SEX_MALE==GET_SEX(ch))
  205. return false;
  206. }
  207. // 여자금지
  208. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_FEMALE))
  209. {
  210. if (SEX_FEMALE==GET_SEX(ch))
  211. return false;
  212. }
  213.  
  214. return true;
  215. }
  216.  
  217.  
  218. /////////////////////////////////////////////////////////////////////////////
  219. // ITEM HANDLING
  220. /////////////////////////////////////////////////////////////////////////////
  221. bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver)
  222. {
  223. if (!bSkipObserver)
  224. if (m_bIsObserver)
  225. return false;
  226.  
  227. if (GetMyShop())
  228. return false;
  229.  
  230. if (!bSkipCheckRefine)
  231. if (m_bUnderRefine)
  232. return false;
  233.  
  234. if (IsCubeOpen() || NULL != DragonSoul_RefineWindow_GetOpener())
  235. return false;
  236.  
  237. if (IsWarping())
  238. return false;
  239.  
  240. #ifdef __SASH_SYSTEM__
  241. if ((m_bSashCombination) || (m_bSashAbsorption))
  242. return false;
  243. #endif
  244.  
  245. #ifdef __CHANGELOOK_SYSTEM__
  246. if (m_bChangeLook)
  247. return false;
  248. #endif
  249.  
  250. if (IsAttrTransferOpen())
  251. return false;
  252.  
  253. return true;
  254. }
  255.  
  256. LPITEM CHARACTER::GetInventoryItem(WORD wCell) const
  257. {
  258. return GetItem(TItemPos(INVENTORY, wCell));
  259. }
  260. LPITEM CHARACTER::GetItem(TItemPos Cell) const
  261. {
  262. if (!IsValidItemPosition(Cell))
  263. return NULL;
  264. WORD wCell = Cell.cell;
  265. BYTE window_type = Cell.window_type;
  266. switch (window_type)
  267. {
  268. case INVENTORY:
  269. case EQUIPMENT:
  270. if (wCell >= INVENTORY_AND_EQUIP_SLOT_MAX)
  271. {
  272. sys_err("CHARACTER::GetInventoryItem: invalid item cell %d", wCell);
  273. return NULL;
  274. }
  275. return m_pointsInstant.pItems[wCell];
  276. case DRAGON_SOUL_INVENTORY:
  277. if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  278. {
  279. sys_err("CHARACTER::GetInventoryItem: invalid DS item cell %d", wCell);
  280. return NULL;
  281. }
  282. return m_pointsInstant.pDSItems[wCell];
  283.  
  284. default:
  285. return NULL;
  286. }
  287. return NULL;
  288. }
  289.  
  290. #ifdef __HIGHLIGHT_SYSTEM__
  291. void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem, bool isHighLight)
  292. #else
  293. void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
  294. #endif
  295. {
  296. WORD wCell = Cell.cell;
  297. BYTE window_type = Cell.window_type;
  298. if ((unsigned long)((CItem*)pItem) == 0xff || (unsigned long)((CItem*)pItem) == 0xffffffff)
  299. {
  300. sys_err("!!! FATAL ERROR !!! item == 0xff (char: %s cell: %u)", GetName(), wCell);
  301. core_dump();
  302. return;
  303. }
  304.  
  305. if (pItem && pItem->GetOwner())
  306. {
  307. assert(!"GetOwner exist");
  308. return;
  309. }
  310. // 기본 인벤토리
  311. switch(window_type)
  312. {
  313. case INVENTORY:
  314. case EQUIPMENT:
  315. {
  316. if (wCell >= INVENTORY_AND_EQUIP_SLOT_MAX)
  317. {
  318. sys_err("CHARACTER::SetItem: invalid item cell %d", wCell);
  319. return;
  320. }
  321.  
  322. LPITEM pOld = m_pointsInstant.pItems[wCell];
  323.  
  324. if (pOld)
  325. {
  326. if (wCell < INVENTORY_MAX_NUM)
  327. {
  328. for (int i = 0; i < pOld->GetSize(); ++i)
  329. {
  330. int p = wCell + (i * 5);
  331.  
  332. if (p >= INVENTORY_MAX_NUM)
  333. continue;
  334.  
  335. if (m_pointsInstant.pItems[p] && m_pointsInstant.pItems[p] != pOld)
  336. continue;
  337.  
  338. m_pointsInstant.bItemGrid[p] = 0;
  339. }
  340. }
  341. else
  342. m_pointsInstant.bItemGrid[wCell] = 0;
  343. }
  344.  
  345. if (pItem)
  346. {
  347. if (wCell < INVENTORY_MAX_NUM)
  348. {
  349. for (int i = 0; i < pItem->GetSize(); ++i)
  350. {
  351. int p = wCell + (i * 5);
  352.  
  353. if (p >= INVENTORY_MAX_NUM)
  354. continue;
  355.  
  356. // wCell + 1 로 하는 것은 빈곳을 체크할 때 같은
  357. // 아이템은 예외처리하기 위함
  358. m_pointsInstant.bItemGrid[p] = wCell + 1;
  359. }
  360. }
  361. else
  362. m_pointsInstant.bItemGrid[wCell] = wCell + 1;
  363. }
  364.  
  365. m_pointsInstant.pItems[wCell] = pItem;
  366. }
  367. break;
  368. // 용혼석 인벤토리
  369. case DRAGON_SOUL_INVENTORY:
  370. {
  371. LPITEM pOld = m_pointsInstant.pDSItems[wCell];
  372.  
  373. if (pOld)
  374. {
  375. if (wCell < DRAGON_SOUL_INVENTORY_MAX_NUM)
  376. {
  377. for (int i = 0; i < pOld->GetSize(); ++i)
  378. {
  379. int p = wCell + (i * DRAGON_SOUL_BOX_COLUMN_NUM);
  380.  
  381. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  382. continue;
  383.  
  384. if (m_pointsInstant.pDSItems[p] && m_pointsInstant.pDSItems[p] != pOld)
  385. continue;
  386.  
  387. m_pointsInstant.wDSItemGrid[p] = 0;
  388. }
  389. }
  390. else
  391. m_pointsInstant.wDSItemGrid[wCell] = 0;
  392. }
  393.  
  394. if (pItem)
  395. {
  396. if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  397. {
  398. sys_err("CHARACTER::SetItem: invalid DS item cell %d", wCell);
  399. return;
  400. }
  401.  
  402. if (wCell < DRAGON_SOUL_INVENTORY_MAX_NUM)
  403. {
  404. for (int i = 0; i < pItem->GetSize(); ++i)
  405. {
  406. int p = wCell + (i * DRAGON_SOUL_BOX_COLUMN_NUM);
  407.  
  408. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  409. continue;
  410.  
  411. // wCell + 1 로 하는 것은 빈곳을 체크할 때 같은
  412. // 아이템은 예외처리하기 위함
  413. m_pointsInstant.wDSItemGrid[p] = wCell + 1;
  414. }
  415. }
  416. else
  417. m_pointsInstant.wDSItemGrid[wCell] = wCell + 1;
  418. }
  419.  
  420. m_pointsInstant.pDSItems[wCell] = pItem;
  421. }
  422. break;
  423. default:
  424. sys_err ("Invalid Inventory type %d", window_type);
  425. return;
  426. }
  427.  
  428. if (GetDesc())
  429. {
  430. // 확장 아이템: 서버에서 아이템 플래그 정보를 보낸다
  431. if (pItem)
  432. {
  433. TPacketGCItemSet pack;
  434. pack.header = HEADER_GC_ITEM_SET;
  435. pack.Cell = Cell;
  436.  
  437. pack.count = pItem->GetCount();
  438. #ifdef __CHANGELOOK_SYSTEM__
  439. pack.transmutation = pItem->GetTransmutation();
  440. #endif
  441. pack.bind = pItem->GetBind();
  442. pack.vnum = pItem->GetVnum();
  443. pack.flags = pItem->GetFlag();
  444. pack.anti_flags = pItem->GetAntiFlag();
  445. #ifdef __HIGHLIGHT_SYSTEM__
  446. if (isHighLight)
  447. pack.highlight = true;
  448. else
  449. pack.highlight = (Cell.window_type == DRAGON_SOUL_INVENTORY);
  450. #else
  451. pack.highlight = (Cell.window_type == DRAGON_SOUL_INVENTORY);
  452. #endif
  453.  
  454. thecore_memcpy(pack.alSockets, pItem->GetSockets(), sizeof(pack.alSockets));
  455. thecore_memcpy(pack.aAttr, pItem->GetAttributes(), sizeof(pack.aAttr));
  456.  
  457. GetDesc()->Packet(&pack, sizeof(TPacketGCItemSet));
  458. }
  459. else
  460. {
  461. TPacketGCItemDelDeprecated pack;
  462. pack.header = HEADER_GC_ITEM_DEL;
  463. pack.Cell = Cell;
  464. pack.count = 0;
  465. #ifdef __CHANGELOOK_SYSTEM__
  466. pack.transmutation = 0;
  467. #endif
  468. pack.bind = 0;
  469. pack.vnum = 0;
  470. memset(pack.alSockets, 0, sizeof(pack.alSockets));
  471. memset(pack.aAttr, 0, sizeof(pack.aAttr));
  472.  
  473. GetDesc()->Packet(&pack, sizeof(TPacketGCItemDelDeprecated));
  474. }
  475. }
  476.  
  477. if (pItem)
  478. {
  479. pItem->SetCell(this, wCell);
  480. switch (window_type)
  481. {
  482. case INVENTORY:
  483. case EQUIPMENT:
  484. if ((wCell < INVENTORY_MAX_NUM) || (BELT_INVENTORY_SLOT_START <= wCell && BELT_INVENTORY_SLOT_END > wCell))
  485. pItem->SetWindow(INVENTORY);
  486. else
  487. pItem->SetWindow(EQUIPMENT);
  488. break;
  489. case DRAGON_SOUL_INVENTORY:
  490. pItem->SetWindow(DRAGON_SOUL_INVENTORY);
  491. break;
  492. }
  493. }
  494. }
  495.  
  496. LPITEM CHARACTER::GetWear(BYTE bCell) const
  497. {
  498. // > WEAR_MAX_NUM : 용혼석 슬롯들.
  499. if (bCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
  500. {
  501. sys_err("CHARACTER::GetWear: invalid wear cell %d", bCell);
  502. return NULL;
  503. }
  504.  
  505. return m_pointsInstant.pItems[INVENTORY_MAX_NUM + bCell];
  506. }
  507.  
  508. void CHARACTER::SetWear(BYTE bCell, LPITEM item)
  509. {
  510. // > WEAR_MAX_NUM : 용혼석 슬롯들.
  511. if (bCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
  512. {
  513. sys_err("CHARACTER::SetItem: invalid item cell %d", bCell);
  514. return;
  515. }
  516.  
  517. #ifdef __HIGHLIGHT_SYSTEM__
  518. SetItem(TItemPos (INVENTORY, INVENTORY_MAX_NUM + bCell), item, false);
  519. #else
  520. SetItem(TItemPos (INVENTORY, INVENTORY_MAX_NUM + bCell), item);
  521. #endif
  522.  
  523. if (!item && bCell == WEAR_WEAPON)
  524. {
  525. // 귀검 사용 시 벗는 것이라면 효과를 없애야 한다.
  526. if (IsAffectFlag(AFF_GWIGUM))
  527. RemoveAffect(SKILL_GWIGEOM);
  528.  
  529. if (IsAffectFlag(AFF_GEOMGYEONG))
  530. RemoveAffect(SKILL_GEOMKYUNG);
  531. }
  532. }
  533.  
  534. void CHARACTER::ClearItem()
  535. {
  536. int i;
  537. LPITEM item;
  538.  
  539. for (i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
  540. {
  541. if ((item = GetInventoryItem(i)))
  542. {
  543. item->SetSkipSave(true);
  544. ITEM_MANAGER::instance().FlushDelayedSave(item);
  545.  
  546. item->RemoveFromCharacter();
  547. M2_DESTROY_ITEM(item);
  548.  
  549. SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
  550. }
  551. }
  552. for (i = 0; i < DRAGON_SOUL_INVENTORY_MAX_NUM; ++i)
  553. {
  554. if ((item = GetItem(TItemPos(DRAGON_SOUL_INVENTORY, i))))
  555. {
  556. item->SetSkipSave(true);
  557. ITEM_MANAGER::instance().FlushDelayedSave(item);
  558.  
  559. item->RemoveFromCharacter();
  560. M2_DESTROY_ITEM(item);
  561. }
  562. }
  563. }
  564.  
  565. bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) const
  566. {
  567. switch (Cell.window_type)
  568. {
  569. case INVENTORY:
  570. {
  571. BYTE bCell = Cell.cell;
  572.  
  573. // bItemCell은 0이 false임을 나타내기 위해 + 1 해서 처리한다.
  574. // 따라서 iExceptionCell에 1을 더해 비교한다.
  575. ++iExceptionCell;
  576.  
  577. if (Cell.IsBeltInventoryPosition())
  578. {
  579. LPITEM beltItem = GetWear(WEAR_BELT);
  580.  
  581. if (NULL == beltItem)
  582. return false;
  583.  
  584. if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
  585. return false;
  586.  
  587. if (m_pointsInstant.bItemGrid[bCell])
  588. {
  589. if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)
  590. return true;
  591.  
  592. return false;
  593. }
  594.  
  595. if (bSize == 1)
  596. return true;
  597.  
  598. }
  599. else if (bCell >= INVENTORY_MAX_NUM)
  600. return false;
  601.  
  602. if (m_pointsInstant.bItemGrid[bCell])
  603. {
  604. if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)
  605. {
  606. if (bSize == 1)
  607. return true;
  608.  
  609. int j = 1;
  610. BYTE bPage = bCell / (INVENTORY_MAX_NUM / 4);
  611.  
  612. do
  613. {
  614. BYTE p = bCell + (5 * j);
  615.  
  616. if (p >= INVENTORY_MAX_NUM)
  617. return false;
  618.  
  619. if (p / (INVENTORY_MAX_NUM / 4) != bPage)
  620. return false;
  621.  
  622. if (m_pointsInstant.bItemGrid[p])
  623. if (m_pointsInstant.bItemGrid[p] != iExceptionCell)
  624. return false;
  625. }
  626. while (++j < bSize);
  627.  
  628. return true;
  629. }
  630. else
  631. return false;
  632. }
  633.  
  634. // 크기가 1이면 한칸을 차지하는 것이므로 그냥 리턴
  635. if (1 == bSize)
  636. return true;
  637. else
  638. {
  639. int j = 1;
  640. BYTE bPage = bCell / (INVENTORY_MAX_NUM / 4);
  641.  
  642. do
  643. {
  644. BYTE p = bCell + (5 * j);
  645.  
  646. if (p >= INVENTORY_MAX_NUM)
  647. return false;
  648.  
  649. if (p / (INVENTORY_MAX_NUM / 4) != bPage)
  650. return false;
  651.  
  652. if (m_pointsInstant.bItemGrid[p])
  653. if (m_pointsInstant.bItemGrid[p] != iExceptionCell)
  654. return false;
  655. }
  656. while (++j < bSize);
  657.  
  658. return true;
  659. }
  660. }
  661. break;
  662. case DRAGON_SOUL_INVENTORY:
  663. {
  664. WORD wCell = Cell.cell;
  665. if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  666. return false;
  667.  
  668. // bItemCell은 0이 false임을 나타내기 위해 + 1 해서 처리한다.
  669. // 따라서 iExceptionCell에 1을 더해 비교한다.
  670. iExceptionCell++;
  671.  
  672. if (m_pointsInstant.wDSItemGrid[wCell])
  673. {
  674. if (m_pointsInstant.wDSItemGrid[wCell] == iExceptionCell)
  675. {
  676. if (bSize == 1)
  677. return true;
  678.  
  679. int j = 1;
  680.  
  681. do
  682. {
  683. int p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
  684.  
  685. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  686. return false;
  687.  
  688. if (m_pointsInstant.wDSItemGrid[p])
  689. if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
  690. return false;
  691. }
  692. while (++j < bSize);
  693.  
  694. return true;
  695. }
  696. else
  697. return false;
  698. }
  699.  
  700. // 크기가 1이면 한칸을 차지하는 것이므로 그냥 리턴
  701. if (1 == bSize)
  702. return true;
  703. else
  704. {
  705. int j = 1;
  706.  
  707. do
  708. {
  709. int p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
  710.  
  711. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  712. return false;
  713.  
  714. if (m_pointsInstant.bItemGrid[p])
  715. if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
  716. return false;
  717. }
  718. while (++j < bSize);
  719.  
  720. return true;
  721. }
  722. }
  723. }
  724. }
  725.  
  726. int CHARACTER::GetEmptyInventory(BYTE size) const
  727. {
  728. // NOTE: 현재 이 함수는 아이템 지급, 획득 등의 행위를 할 때 인벤토리의 빈 칸을 찾기 위해 사용되고 있는데,
  729. // 벨트 인벤토리는 특수 인벤토리이므로 검사하지 않도록 한다. (기본 인벤토리: INVENTORY_MAX_NUM 까지만 검사)
  730. for ( int i = 0; i < INVENTORY_MAX_NUM; ++i)
  731. if (IsEmptyItemGrid(TItemPos (INVENTORY, i), size))
  732. return i;
  733. return -1;
  734. }
  735.  
  736. int CHARACTER::GetEmptyDragonSoulInventory(LPITEM pItem) const
  737. {
  738. if (NULL == pItem || !pItem->IsDragonSoul())
  739. return -1;
  740. if (!DragonSoul_IsQualified())
  741. {
  742. return -1;
  743. }
  744. BYTE bSize = pItem->GetSize();
  745. WORD wBaseCell = DSManager::instance().GetBasePosition(pItem);
  746.  
  747. if (WORD_MAX == wBaseCell)
  748. return -1;
  749.  
  750. for (int i = 0; i < DRAGON_SOUL_BOX_SIZE; ++i)
  751. if (IsEmptyItemGrid(TItemPos(DRAGON_SOUL_INVENTORY, i + wBaseCell), bSize))
  752. return i + wBaseCell;
  753.  
  754. return -1;
  755. }
  756.  
  757. void CHARACTER::CopyDragonSoulItemGrid(std::vector<WORD>& vDragonSoulItemGrid) const
  758. {
  759. vDragonSoulItemGrid.resize(DRAGON_SOUL_INVENTORY_MAX_NUM);
  760.  
  761. std::copy(m_pointsInstant.wDSItemGrid, m_pointsInstant.wDSItemGrid + DRAGON_SOUL_INVENTORY_MAX_NUM, vDragonSoulItemGrid.begin());
  762. }
  763.  
  764. int CHARACTER::CountEmptyInventory() const
  765. {
  766. int count = 0;
  767.  
  768. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  769. if (GetInventoryItem(i))
  770. count += GetInventoryItem(i)->GetSize();
  771.  
  772. return (INVENTORY_MAX_NUM - count);
  773. }
  774.  
  775. void TransformRefineItem(LPITEM pkOldItem, LPITEM pkNewItem)
  776. {
  777. // ACCESSORY_REFINE
  778. if (pkOldItem->IsAccessoryForSocket())
  779. {
  780. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  781. {
  782. pkNewItem->SetSocket(i, pkOldItem->GetSocket(i));
  783. }
  784. //pkNewItem->StartAccessorySocketExpireEvent();
  785. }
  786. // END_OF_ACCESSORY_REFINE
  787. else
  788. {
  789. // 여기서 깨진석이 자동적으로 청소 됨
  790. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  791. {
  792. if (!pkOldItem->GetSocket(i))
  793. break;
  794. else
  795. pkNewItem->SetSocket(i, 1);
  796. }
  797.  
  798. // 소켓 설정
  799. int slot = 0;
  800.  
  801. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  802. {
  803. long socket = pkOldItem->GetSocket(i);
  804.  
  805. if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
  806. pkNewItem->SetSocket(slot++, socket);
  807. }
  808.  
  809. }
  810.  
  811. // 매직 아이템 설정
  812. pkOldItem->CopyAttributeTo(pkNewItem);
  813. }
  814.  
  815. void NotifyRefineSuccess(LPCHARACTER ch, LPITEM item, const char* way)
  816. {
  817. if (NULL != ch && item != NULL)
  818. {
  819. ch->ChatPacket(CHAT_TYPE_COMMAND, "RefineSuceeded");
  820.  
  821. LogManager::instance().RefineLog(ch->GetPlayerID(), item->GetName(), item->GetID(), item->GetRefineLevel(), 1, way);
  822. }
  823. }
  824.  
  825. void NotifyRefineFail(LPCHARACTER ch, LPITEM item, const char* way, int success = 0)
  826. {
  827. if (NULL != ch && NULL != item)
  828. {
  829. ch->ChatPacket(CHAT_TYPE_COMMAND, "RefineFailed");
  830.  
  831. LogManager::instance().RefineLog(ch->GetPlayerID(), item->GetName(), item->GetID(), item->GetRefineLevel(), success, way);
  832. }
  833. }
  834.  
  835. void CHARACTER::SetRefineNPC(LPCHARACTER ch)
  836. {
  837. if ( ch != NULL )
  838. {
  839. m_dwRefineNPCVID = ch->GetVID();
  840. }
  841. else
  842. {
  843. m_dwRefineNPCVID = 0;
  844. }
  845. }
  846.  
  847. bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
  848. {
  849. if (!CanHandleItem(true))
  850. {
  851. ClearRefineMode();
  852. return false;
  853. }
  854.  
  855. //개량 시간제한 : upgrade_refine_scroll.quest 에서 개량후 5분이내에 일반 개량을
  856. //진행할수 없음
  857. if (quest::CQuestManager::instance().GetEventFlag("update_refine_time") != 0)
  858. {
  859. if (get_global_time() < quest::CQuestManager::instance().GetEventFlag("update_refine_time") + (60 * 5))
  860. {
  861. sys_log(0, "can't refine %d %s", GetPlayerID(), GetName());
  862. return false;
  863. }
  864. }
  865.  
  866. const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
  867.  
  868. if (!prt)
  869. return false;
  870.  
  871. DWORD result_vnum = item->GetRefinedVnum();
  872.  
  873. // REFINE_COST
  874. int cost = ComputeRefineFee(prt->cost);
  875.  
  876. int RefineChance = GetQuestFlag("main_quest_lv7.refine_chance");
  877.  
  878. if (RefineChance > 0)
  879. {
  880. if (!item->CheckItemUseLevel(20) || item->GetType() != ITEM_WEAPON)
  881. {
  882. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("무료 개량 기회는 20 이하의 무기만 가능합니다"));
  883. return false;
  884. }
  885.  
  886. cost = 0;
  887. SetQuestFlag("main_quest_lv7.refine_chance", RefineChance - 1);
  888. }
  889. // END_OF_REFINE_COST
  890.  
  891. if (result_vnum == 0)
  892. {
  893. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 개량할 수 없습니다."));
  894. return false;
  895. }
  896.  
  897. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TUNING)
  898. return false;
  899.  
  900. TItemTable * pProto = ITEM_MANAGER::instance().GetTable(item->GetRefinedVnum());
  901.  
  902. if (!pProto)
  903. {
  904. sys_err("DoRefine NOT GET ITEM PROTO %d", item->GetRefinedVnum());
  905. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 개량할 수 없습니다."));
  906. return false;
  907. }
  908.  
  909. // REFINE_COST
  910. if (GetGold() < cost)
  911. {
  912. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개량을 하기 위한 돈이 부족합니다."));
  913. return false;
  914. }
  915.  
  916. if (!bMoneyOnly && !RefineChance)
  917. {
  918. for (int i = 0; i < prt->material_count; ++i)
  919. {
  920. if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
  921. {
  922. if (test_server)
  923. {
  924. ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
  925. }
  926. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개량을 하기 위한 재료가 부족합니다."));
  927. return false;
  928. }
  929. }
  930.  
  931. for (int i = 0; i < prt->material_count; ++i)
  932. RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
  933. }
  934.  
  935. int prob = number(1, 100);
  936.  
  937. if (IsRefineThroughGuild() || bMoneyOnly)
  938. prob -= 10;
  939.  
  940. // END_OF_REFINE_COST
  941.  
  942. if (prob <= prt->prob)
  943. {
  944. // 성공! 모든 아이템이 사라지고, 같은 속성의 다른 아이템 획득
  945. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_vnum, 1, 0, false);
  946.  
  947. if (pkNewItem)
  948. {
  949. ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
  950. LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
  951.  
  952. BYTE bCell = item->GetCell();
  953.  
  954. // DETAIL_REFINE_LOG
  955. NotifyRefineSuccess(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
  956. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -cost);
  957. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
  958. EffectPacket(SE_GECTI);
  959. // END_OF_DETAIL_REFINE_LOG
  960.  
  961. pkNewItem->SetTransmutation(item->GetTransmutation());
  962.  
  963. pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
  964. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  965.  
  966. sys_log(0, "Refine Success %d", cost);
  967. pkNewItem->AttrLog();
  968. //PointChange(POINT_GOLD, -cost);
  969. sys_log(0, "PayPee %d", cost);
  970. PayRefineFee(cost);
  971. sys_log(0, "PayPee End %d", cost);
  972. }
  973. else
  974. {
  975. // DETAIL_REFINE_LOG
  976. // 아이템 생성에 실패 -> 개량 실패로 간주
  977. sys_err("cannot create item %u", result_vnum);
  978. NotifyRefineFail(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
  979. // END_OF_DETAIL_REFINE_LOG
  980. }
  981. }
  982. else
  983. {
  984. // 실패! 모든 아이템이 사라짐.
  985. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -cost);
  986. NotifyRefineFail(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
  987. item->AttrLog();
  988. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE FAIL)");
  989. EffectPacket(SE_YANDI);
  990.  
  991. //PointChange(POINT_GOLD, -cost);
  992. PayRefineFee(cost);
  993. }
  994.  
  995. return true;
  996. }
  997.  
  998. enum enum_RefineScrolls
  999. {
  1000. CHUKBOK_SCROLL = 0,
  1001. HYUNIRON_CHN = 1, // 중국에서만 사용
  1002. YONGSIN_SCROLL = 2,
  1003. MUSIN_SCROLL = 3,
  1004. YAGONG_SCROLL = 4,
  1005. MEMO_SCROLL = 5,
  1006. BDRAGON_SCROLL = 6,
  1007. SOULP_SCROLL = 9,
  1008. };
  1009.  
  1010. bool CHARACTER::DoRefineWithScroll(LPITEM item)
  1011. {
  1012. if (!CanHandleItem(true))
  1013. {
  1014. ClearRefineMode();
  1015. return false;
  1016. }
  1017.  
  1018. ClearRefineMode();
  1019.  
  1020. //개량 시간제한 : upgrade_refine_scroll.quest 에서 개량후 5분이내에 일반 개량을
  1021. //진행할수 없음
  1022. if (quest::CQuestManager::instance().GetEventFlag("update_refine_time") != 0)
  1023. {
  1024. if (get_global_time() < quest::CQuestManager::instance().GetEventFlag("update_refine_time") + (60 * 5))
  1025. {
  1026. sys_log(0, "can't refine %d %s", GetPlayerID(), GetName());
  1027. return false;
  1028. }
  1029. }
  1030.  
  1031. const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
  1032.  
  1033. if (!prt)
  1034. return false;
  1035.  
  1036. LPITEM pkItemScroll;
  1037.  
  1038. // 개량서 체크
  1039. if (m_iRefineAdditionalCell < 0)
  1040. return false;
  1041.  
  1042. pkItemScroll = GetInventoryItem(m_iRefineAdditionalCell);
  1043.  
  1044. if (!pkItemScroll)
  1045. return false;
  1046.  
  1047. if (!(pkItemScroll->GetType() == ITEM_USE && pkItemScroll->GetSubType() == USE_TUNING))
  1048. return false;
  1049.  
  1050. if (pkItemScroll->GetVnum() == item->GetVnum())
  1051. return false;
  1052.  
  1053. DWORD result_vnum = item->GetRefinedVnum();
  1054. DWORD result_fail_vnum = item->GetRefineFromVnum();
  1055.  
  1056. if (result_vnum == 0)
  1057. {
  1058. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 개량할 수 없습니다."));
  1059. return false;
  1060. }
  1061.  
  1062. // MUSIN_SCROLL
  1063. if (pkItemScroll->GetValue(0) == MUSIN_SCROLL)
  1064. {
  1065. if (item->GetRefineLevel() >= 4)
  1066. {
  1067. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 개량서로 더 이상 개량할 수 없습니다."));
  1068. return false;
  1069. }
  1070. }
  1071. // END_OF_MUSIC_SCROLL
  1072.  
  1073. else if (pkItemScroll->GetValue(0) == MEMO_SCROLL)
  1074. {
  1075. if (item->GetRefineLevel() != pkItemScroll->GetValue(1))
  1076. {
  1077. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 개량서로 개량할 수 없습니다."));
  1078. return false;
  1079. }
  1080. }
  1081. else if (pkItemScroll->GetValue(0) == BDRAGON_SCROLL)
  1082. {
  1083. if (item->GetType() != ITEM_METIN || item->GetRefineLevel() != 4)
  1084. {
  1085. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템으로 개량할 수 없습니다."));
  1086. return false;
  1087. }
  1088. }
  1089. else if (pkItemScroll->GetValue(0) == SOULP_SCROLL)
  1090. {
  1091. if (item->GetLevelLimit() > pkItemScroll->GetValue(1))
  1092. {
  1093. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not use soul scroll this item."));
  1094. return false;
  1095. }
  1096. }
  1097.  
  1098. TItemTable * pProto = ITEM_MANAGER::instance().GetTable(item->GetRefinedVnum());
  1099.  
  1100. if (!pProto)
  1101. {
  1102. sys_err("DoRefineWithScroll NOT GET ITEM PROTO %d", item->GetRefinedVnum());
  1103. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 개량할 수 없습니다."));
  1104. return false;
  1105. }
  1106.  
  1107. if (GetGold() < prt->cost)
  1108. {
  1109. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개량을 하기 위한 돈이 부족합니다."));
  1110. return false;
  1111. }
  1112.  
  1113. for (int i = 0; i < prt->material_count; ++i)
  1114. {
  1115. if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
  1116. {
  1117. if (test_server)
  1118. {
  1119. ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
  1120. }
  1121. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개량을 하기 위한 재료가 부족합니다."));
  1122. return false;
  1123. }
  1124. }
  1125.  
  1126. for (int i = 0; i < prt->material_count; ++i)
  1127. RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
  1128.  
  1129. int prob = number(1, 100);
  1130. int success_prob = prt->prob;
  1131. bool bDestroyWhenFail = false;
  1132.  
  1133. const char* szRefineType = "SCROLL";
  1134.  
  1135. if (pkItemScroll->GetValue(0) == HYUNIRON_CHN ||
  1136. pkItemScroll->GetValue(0) == YONGSIN_SCROLL ||
  1137. pkItemScroll->GetValue(0) == YAGONG_SCROLL) // 현철, 용신의 축복서, 야공의 비전서 처리
  1138. {
  1139. const char hyuniron_prob[9] = { 100, 75, 65, 55, 45, 40, 35, 25, 20 };
  1140. // const char hyuniron_prob_euckr[9] = { 100, 75, 65, 55, 45, 40, 35, 30, 25 };
  1141.  
  1142. const char yagong_prob[9] = { 100, 100, 90, 80, 70, 60, 50, 30, 20 };
  1143. // const char yagong_prob_euckr[9] = { 100, 100, 90, 80, 70, 60, 50, 40, 30 };
  1144.  
  1145. if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
  1146. {
  1147. success_prob = hyuniron_prob[MINMAX(0, item->GetRefineLevel(), 8)];
  1148. }
  1149. else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
  1150. {
  1151. success_prob = yagong_prob[MINMAX(0, item->GetRefineLevel(), 8)];
  1152. }
  1153. else if (pkItemScroll->GetValue(0) == HYUNIRON_CHN) {} // @fixme121
  1154. else
  1155. {
  1156. sys_err("REFINE : Unknown refine scroll item. Value0: %d", pkItemScroll->GetValue(0));
  1157. }
  1158.  
  1159. if (test_server)
  1160. {
  1161. ChatPacket(CHAT_TYPE_INFO, "[Only Test] Success_Prob %d, RefineLevel %d ", success_prob, item->GetRefineLevel());
  1162. }
  1163. if (pkItemScroll->GetValue(0) == HYUNIRON_CHN) // 현철은 아이템이 부서져야 한다.
  1164. bDestroyWhenFail = true;
  1165.  
  1166. // DETAIL_REFINE_LOG
  1167. if (pkItemScroll->GetValue(0) == HYUNIRON_CHN)
  1168. {
  1169. szRefineType = "HYUNIRON";
  1170. }
  1171. else if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
  1172. {
  1173. szRefineType = "GOD_SCROLL";
  1174. }
  1175. else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
  1176. {
  1177. szRefineType = "YAGONG_SCROLL";
  1178. }
  1179. // END_OF_DETAIL_REFINE_LOG
  1180. }
  1181.  
  1182. // DETAIL_REFINE_LOG
  1183. if (pkItemScroll->GetValue(0) == MUSIN_SCROLL) // 무신의 축복서는 100% 성공 (+4까지만)
  1184. {
  1185. success_prob = 100;
  1186.  
  1187. szRefineType = "MUSIN_SCROLL";
  1188. }
  1189. // END_OF_DETAIL_REFINE_LOG
  1190. else if (pkItemScroll->GetValue(0) == MEMO_SCROLL)
  1191. {
  1192. success_prob = 100;
  1193. szRefineType = "MEMO_SCROLL";
  1194. }
  1195. else if (pkItemScroll->GetValue(0) == BDRAGON_SCROLL)
  1196. {
  1197. success_prob = 80;
  1198. szRefineType = "BDRAGON_SCROLL";
  1199. }
  1200. else if (pkItemScroll->GetValue(0) == SOULP_SCROLL)
  1201. {
  1202. success_prob = pkItemScroll->GetValue(2);
  1203. szRefineType = "SOULP_SCROLL";
  1204. }
  1205.  
  1206. pkItemScroll->SetCount(pkItemScroll->GetCount() - 1);
  1207.  
  1208. if (prob <= success_prob)
  1209. {
  1210. // 성공! 모든 아이템이 사라지고, 같은 속성의 다른 아이템 획득
  1211. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_vnum, 1, 0, false);
  1212.  
  1213. if (pkNewItem)
  1214. {
  1215. ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
  1216. LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
  1217.  
  1218. BYTE bCell = item->GetCell();
  1219.  
  1220. NotifyRefineSuccess(this, item, szRefineType);
  1221. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -prt->cost);
  1222. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
  1223. EffectPacket(SE_GECTI);
  1224. pkNewItem->SetTransmutation(item->GetTransmutation());
  1225. pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
  1226. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  1227. pkNewItem->AttrLog();
  1228. //PointChange(POINT_GOLD, -prt->cost);
  1229. PayRefineFee(prt->cost);
  1230. }
  1231. else
  1232. {
  1233. // 아이템 생성에 실패 -> 개량 실패로 간주
  1234. sys_err("cannot create item %u", result_vnum);
  1235. NotifyRefineFail(this, item, szRefineType);
  1236. }
  1237. }
  1238. else if (!bDestroyWhenFail && result_fail_vnum)
  1239. {
  1240. // 실패! 모든 아이템이 사라지고, 같은 속성의 낮은 등급의 아이템 획득
  1241. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_fail_vnum, 1, 0, false);
  1242.  
  1243. if (pkNewItem)
  1244. {
  1245. ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
  1246. LogManager::instance().ItemLog(this, pkNewItem, "REFINE FAIL", pkNewItem->GetName());
  1247.  
  1248. BYTE bCell = item->GetCell();
  1249. pkNewItem->SetTransmutation(item->GetTransmutation());
  1250. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -prt->cost);
  1251. NotifyRefineFail(this, item, szRefineType, -1);
  1252. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE FAIL)");
  1253. EffectPacket(SE_YANDI);
  1254.  
  1255. pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
  1256. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  1257.  
  1258. pkNewItem->AttrLog();
  1259.  
  1260. //PointChange(POINT_GOLD, -prt->cost);
  1261. PayRefineFee(prt->cost);
  1262. }
  1263. else
  1264. {
  1265. // 아이템 생성에 실패 -> 개량 실패로 간주
  1266. sys_err("cannot create item %u", result_fail_vnum);
  1267. NotifyRefineFail(this, item, szRefineType);
  1268. }
  1269. }
  1270. else
  1271. {
  1272. NotifyRefineFail(this, item, szRefineType); // 개량시 아이템 사라지지 않음
  1273.  
  1274. PayRefineFee(prt->cost);
  1275. }
  1276.  
  1277. return true;
  1278. }
  1279.  
  1280. bool CHARACTER::RefineInformation(BYTE bCell, BYTE bType, int iAdditionalCell)
  1281. {
  1282. if (bCell > INVENTORY_MAX_NUM)
  1283. return false;
  1284.  
  1285. LPITEM item = GetInventoryItem(bCell);
  1286.  
  1287. if (!item)
  1288. return false;
  1289.  
  1290. // REFINE_COST
  1291. if (bType == REFINE_TYPE_MONEY_ONLY && !GetQuestFlag("deviltower_zone.can_refine"))
  1292. {
  1293. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("사귀 타워 완료 보상은 한번까지 사용가능합니다."));
  1294. return false;
  1295. }
  1296. // END_OF_REFINE_COST
  1297.  
  1298. TPacketGCRefineInformation p;
  1299.  
  1300. p.header = HEADER_GC_REFINE_INFORMATION;
  1301. p.pos = bCell;
  1302. p.src_vnum = item->GetVnum();
  1303. p.result_vnum = item->GetRefinedVnum();
  1304. p.type = bType;
  1305.  
  1306. if (p.result_vnum == 0)
  1307. {
  1308. sys_err("RefineInformation p.result_vnum == 0");
  1309. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 개량할 수 없습니다."));
  1310. return false;
  1311. }
  1312.  
  1313. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TUNING)
  1314. {
  1315. if (bType == 0)
  1316. {
  1317. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 이 방식으로는 개량할 수 없습니다."));
  1318. return false;
  1319. }
  1320. else
  1321. {
  1322. LPITEM itemScroll = GetInventoryItem(iAdditionalCell);
  1323. if (!itemScroll || item->GetVnum() == itemScroll->GetVnum())
  1324. {
  1325. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("같은 개량서를 합칠 수는 없습니다."));
  1326. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("축복의 서와 현철을 합칠 수 있습니다."));
  1327. return false;
  1328. }
  1329. }
  1330. }
  1331.  
  1332. CRefineManager & rm = CRefineManager::instance();
  1333.  
  1334. const TRefineTable* prt = rm.GetRefineRecipe(item->GetRefineSet());
  1335.  
  1336. if (!prt)
  1337. {
  1338. sys_err("RefineInformation NOT GET REFINE SET %d", item->GetRefineSet());
  1339. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 개량할 수 없습니다."));
  1340. return false;
  1341. }
  1342.  
  1343. // REFINE_COST
  1344.  
  1345. //MAIN_QUEST_LV7
  1346. if (GetQuestFlag("main_quest_lv7.refine_chance") > 0)
  1347. {
  1348. // 일본은 제외
  1349. if (!item->CheckItemUseLevel(20) || item->GetType() != ITEM_WEAPON)
  1350. {
  1351. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("무료 개량 기회는 20 이하의 무기만 가능합니다"));
  1352. return false;
  1353. }
  1354. p.cost = 0;
  1355. }
  1356. else
  1357. p.cost = ComputeRefineFee(prt->cost);
  1358.  
  1359. //END_MAIN_QUEST_LV7
  1360. p.prob = prt->prob;
  1361. if (bType == REFINE_TYPE_MONEY_ONLY)
  1362. {
  1363. p.material_count = 0;
  1364. memset(p.materials, 0, sizeof(p.materials));
  1365. }
  1366. else
  1367. {
  1368. p.material_count = prt->material_count;
  1369. thecore_memcpy(&p.materials, prt->materials, sizeof(prt->materials));
  1370. }
  1371. // END_OF_REFINE_COST
  1372.  
  1373. GetDesc()->Packet(&p, sizeof(TPacketGCRefineInformation));
  1374.  
  1375. SetRefineMode(iAdditionalCell);
  1376. return true;
  1377. }
  1378.  
  1379. bool CHARACTER::RefineItem(LPITEM pkItem, LPITEM pkTarget)
  1380. {
  1381. if (!CanHandleItem())
  1382. return false;
  1383.  
  1384. if (pkItem->GetSubType() == USE_TUNING)
  1385. {
  1386. // XXX 성능, 소켓 개량서는 사라졌습니다...
  1387. // XXX 성능개량서는 축복의 서가 되었다!
  1388. // MUSIN_SCROLL
  1389. if (pkItem->GetValue(0) == MUSIN_SCROLL)
  1390. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_MUSIN, pkItem->GetCell());
  1391. // END_OF_MUSIN_SCROLL
  1392. else if (pkItem->GetValue(0) == HYUNIRON_CHN)
  1393. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_HYUNIRON, pkItem->GetCell());
  1394. else if (pkItem->GetValue(0) == BDRAGON_SCROLL)
  1395. {
  1396. if (pkTarget->GetRefineSet() != 702) return false;
  1397. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_BDRAGON, pkItem->GetCell());
  1398. }
  1399. else
  1400. {
  1401. if (pkTarget->GetRefineSet() == 501) return false;
  1402. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_SCROLL, pkItem->GetCell());
  1403. }
  1404. }
  1405. else if (pkItem->GetSubType() == USE_DETACHMENT && IS_SET(pkTarget->GetFlag(), ITEM_FLAG_REFINEABLE))
  1406. {
  1407. LogManager::instance().ItemLog(this, pkTarget, "USE_DETACHMENT", pkTarget->GetName());
  1408.  
  1409. bool bHasMetinStone = false;
  1410.  
  1411. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
  1412. {
  1413. long socket = pkTarget->GetSocket(i);
  1414. if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
  1415. {
  1416. bHasMetinStone = true;
  1417. break;
  1418. }
  1419. }
  1420.  
  1421. if (bHasMetinStone)
  1422. {
  1423. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1424. {
  1425. long socket = pkTarget->GetSocket(i);
  1426. if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
  1427. {
  1428. AutoGiveItem(socket);
  1429. //TItemTable* pTable = ITEM_MANAGER::instance().GetTable(pkTarget->GetSocket(i));
  1430. //pkTarget->SetSocket(i, pTable->alValues[2]);
  1431. // 깨진돌로 대체해준다
  1432. pkTarget->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
  1433. }
  1434. }
  1435. pkItem->SetCount(pkItem->GetCount() - 1);
  1436. return true;
  1437. }
  1438. else
  1439. {
  1440. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("빼낼 수 있는 메틴석이 없습니다."));
  1441. return false;
  1442. }
  1443. }
  1444.  
  1445. return false;
  1446. }
  1447.  
  1448. EVENTFUNC(kill_campfire_event)
  1449. {
  1450. char_event_info* info = dynamic_cast<char_event_info*>( event->info );
  1451.  
  1452. if ( info == NULL )
  1453. {
  1454. sys_err( "kill_campfire_event> <Factor> Null pointer" );
  1455. return 0;
  1456. }
  1457.  
  1458. LPCHARACTER ch = info->ch;
  1459.  
  1460. if (ch == NULL) { // <Factor>
  1461. return 0;
  1462. }
  1463. ch->m_pkMiningEvent = NULL;
  1464. M2_DESTROY_CHARACTER(ch);
  1465. return 0;
  1466. }
  1467.  
  1468. bool CHARACTER::GiveRecallItem(LPITEM item)
  1469. {
  1470. int idx = GetMapIndex();
  1471. int iEmpireByMapIndex = -1;
  1472.  
  1473. if (idx < 20)
  1474. iEmpireByMapIndex = 1;
  1475. else if (idx < 40)
  1476. iEmpireByMapIndex = 2;
  1477. else if (idx < 60)
  1478. iEmpireByMapIndex = 3;
  1479. else if (idx < 10000)
  1480. iEmpireByMapIndex = 0;
  1481.  
  1482. switch (idx)
  1483. {
  1484. case 66:
  1485. case 216:
  1486. iEmpireByMapIndex = -1;
  1487. break;
  1488. }
  1489.  
  1490. if (iEmpireByMapIndex && GetEmpire() != iEmpireByMapIndex)
  1491. {
  1492. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("기억해 둘 수 없는 위치 입니다."));
  1493. return false;
  1494. }
  1495.  
  1496. int pos;
  1497.  
  1498. if (item->GetCount() == 1) // 아이템이 하나라면 그냥 셋팅.
  1499. {
  1500. item->SetSocket(0, GetX());
  1501. item->SetSocket(1, GetY());
  1502. }
  1503. else if ((pos = GetEmptyInventory(item->GetSize())) != -1) // 그렇지 않다면 다른 인벤토리 슬롯을 찾는다.
  1504. {
  1505. LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), 1);
  1506.  
  1507. if (NULL != item2)
  1508. {
  1509. item2->SetSocket(0, GetX());
  1510. item2->SetSocket(1, GetY());
  1511. item2->AddToCharacter(this, TItemPos(INVENTORY, pos));
  1512.  
  1513. item->SetCount(item->GetCount() - 1);
  1514. }
  1515. }
  1516. else
  1517. {
  1518. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지품에 빈 공간이 없습니다."));
  1519. return false;
  1520. }
  1521.  
  1522. return true;
  1523. }
  1524.  
  1525. void CHARACTER::ProcessRecallItem(LPITEM item)
  1526. {
  1527. int idx;
  1528.  
  1529. if ((idx = SECTREE_MANAGER::instance().GetMapIndex(item->GetSocket(0), item->GetSocket(1))) == 0)
  1530. return;
  1531.  
  1532. int iEmpireByMapIndex = -1;
  1533.  
  1534. if (idx < 20)
  1535. iEmpireByMapIndex = 1;
  1536. else if (idx < 40)
  1537. iEmpireByMapIndex = 2;
  1538. else if (idx < 60)
  1539. iEmpireByMapIndex = 3;
  1540. else if (idx < 10000)
  1541. iEmpireByMapIndex = 0;
  1542.  
  1543. switch (idx)
  1544. {
  1545. case 66:
  1546. case 216:
  1547. iEmpireByMapIndex = -1;
  1548. break;
  1549. // 악룡군도 일때
  1550. case 301:
  1551. case 302:
  1552. case 303:
  1553. case 304:
  1554. if( GetLevel() < 90 )
  1555. {
  1556. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템의 레벨 제한보다 레벨이 낮습니다."));
  1557. return;
  1558. }
  1559. else
  1560. break;
  1561. }
  1562.  
  1563. if (iEmpireByMapIndex && GetEmpire() != iEmpireByMapIndex)
  1564. {
  1565. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("기억된 위치가 타제국에 속해 있어서 귀환할 수 없습니다."));
  1566. item->SetSocket(0, 0);
  1567. item->SetSocket(1, 0);
  1568. }
  1569. else
  1570. {
  1571. sys_log(1, "Recall: %s %d %d -> %d %d", GetName(), GetX(), GetY(), item->GetSocket(0), item->GetSocket(1));
  1572. WarpSet(item->GetSocket(0), item->GetSocket(1));
  1573. item->SetCount(item->GetCount() - 1);
  1574. }
  1575. }
  1576.  
  1577. void CHARACTER::__OpenPrivateShop()
  1578. {
  1579. unsigned bodyPart = GetPart(PART_MAIN);
  1580. switch (bodyPart)
  1581. {
  1582. case 0:
  1583. case 1:
  1584. case 2:
  1585. ChatPacket(CHAT_TYPE_COMMAND, "OpenPrivateShop");
  1586. break;
  1587. default:
  1588. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("갑옷을 벗어야 개인 상점을 열 수 있습니다."));
  1589. break;
  1590. }
  1591. }
  1592.  
  1593. void CHARACTER::__OpenOfflineShop()
  1594. {
  1595. // If character is dead, return false
  1596. if (IsDead())
  1597. {
  1598. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Dead man can not open offline shop"));
  1599. return;
  1600. }
  1601.  
  1602. if (GetLevel() < g_bMinLevel)
  1603. {
  1604. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ct_icin_yeterli_seviyede_degilsin"), g_bMinLevel);
  1605. return;
  1606. }
  1607.  
  1608. if (IsSashCombinationOpen())
  1609. {
  1610. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kombinasyon_penceresi_acik"));
  1611. return;
  1612. }
  1613.  
  1614. if (IsSashAbsorptionOpen())
  1615. {
  1616. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("bonus_emis_penceresi_acik"));
  1617. return;
  1618. }
  1619.  
  1620. if (IsAttrTransferOpen())
  1621. {
  1622. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kostum_bonus_transfer_pencersi_acik"));
  1623. return;
  1624. }
  1625.  
  1626. // If character is exchanging with someone, return false
  1627. if (GetExchange())
  1628. {
  1629. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are exchanging with someone. At first close to the window!"));
  1630. return;
  1631. }
  1632.  
  1633. // If character has a private shop, return false
  1634. if (GetMyShop())
  1635. {
  1636. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You had open private shop. At first you must be close this private shop!"));
  1637. return;
  1638. }
  1639.  
  1640. // If character is look at one offline shop, return false
  1641. if (GetOfflineShop())
  1642. {
  1643. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't open offline shop because you are already look at one offline shop."));
  1644. return;
  1645. }
  1646.  
  1647. // If cube window is open, return false
  1648. if (IsCubeOpen())
  1649. {
  1650. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't open offline shop because your cube window is open"));
  1651. return;
  1652. }
  1653.  
  1654. // If character's safebox is open, return false
  1655. if (IsOpenSafebox())
  1656. {
  1657. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't open offline shop because your safebox window is open!"));
  1658. return;
  1659. }
  1660.  
  1661. // If character's shop window is open, return false
  1662. if (GetShop())
  1663. {
  1664. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't open offline shop because your shop window is open!"));
  1665. return;
  1666. }
  1667.  
  1668. // Send the command to client.
  1669. ChatPacket(CHAT_TYPE_COMMAND, "OpenOfflineShop");
  1670. }
  1671.  
  1672. // MYSHOP_PRICE_LIST
  1673. #ifdef ENABLE_CHEQUE_SYSTEM
  1674. void CHARACTER::SendMyShopPriceListCmd(DWORD dwItemVnum, DWORD dwItemPrice, DWORD dwItemPriceCheque)
  1675. #else
  1676. void CHARACTER::SendMyShopPriceListCmd(DWORD dwItemVnum, DWORD dwItemPrice)
  1677. #endif
  1678. {
  1679. char szLine[256];
  1680. #ifdef ENABLE_CHEQUE_SYSTEM
  1681. snprintf(szLine, sizeof(szLine), "MyShopPriceList %u %u %u", dwItemVnum, dwItemPrice, dwItemPriceCheque);
  1682. #else
  1683. snprintf(szLine, sizeof(szLine), "MyShopPriceList %u %u", dwItemVnum, dwItemPrice);
  1684. #endif
  1685. ChatPacket(CHAT_TYPE_COMMAND, szLine);
  1686. sys_log(0, szLine);
  1687. }
  1688.  
  1689. //
  1690. // DB 캐시로 부터 받은 리스트를 User 에게 전송하고 상점을 열라는 커맨드를 보낸다.
  1691. //
  1692. void CHARACTER::UseSilkBotaryReal(const TPacketMyshopPricelistHeader* p)
  1693. {
  1694. const TItemPriceInfo* pInfo = (const TItemPriceInfo*)(p + 1);
  1695.  
  1696. #ifdef ENABLE_CHEQUE_SYSTEM
  1697. if (!p->byCount)
  1698. SendMyShopPriceListCmd(1, 0, 0);
  1699. else {
  1700. for (int idx = 0; idx < p->byCount; idx++)
  1701. SendMyShopPriceListCmd(pInfo[ idx ].dwVnum, pInfo[ idx ].dwPrice, pInfo[ idx ].dwPriceCheque);
  1702. }
  1703. #else
  1704. if (!p->byCount)
  1705. SendMyShopPriceListCmd(1, 0);
  1706. else {
  1707. for (int idx = 0; idx < p->byCount; idx++)
  1708. SendMyShopPriceListCmd(pInfo[ idx ].dwVnum, pInfo[ idx ].dwPrice);
  1709. }
  1710. #endif
  1711.  
  1712. __OpenPrivateShop();
  1713. }
  1714.  
  1715. //
  1716. // 이번 접속 후 처음 상점을 Open 하는 경우 리스트를 Load 하기 위해 DB 캐시에 가격정보 리스트 요청 패킷을 보낸다.
  1717. // 이후부터는 바로 상점을 열라는 응답을 보낸다.
  1718. //
  1719. void CHARACTER::UseSilkBotary(void)
  1720. {
  1721. if (m_bNoOpenedShop) {
  1722. DWORD dwPlayerID = GetPlayerID();
  1723. db_clientdesc->DBPacket(HEADER_GD_MYSHOP_PRICELIST_REQ, GetDesc()->GetHandle(), &dwPlayerID, sizeof(DWORD));
  1724. m_bNoOpenedShop = false;
  1725. } else {
  1726. __OpenPrivateShop();
  1727. }
  1728. }
  1729. // END_OF_MYSHOP_PRICE_LIST
  1730.  
  1731.  
  1732. int CalculateConsume(LPCHARACTER ch)
  1733. {
  1734. static const int WARP_NEED_LIFE_PERCENT = 30;
  1735. static const int WARP_MIN_LIFE_PERCENT = 10;
  1736. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  1737. int consumeLife = 0;
  1738. {
  1739. // CheckNeedLifeForWarp
  1740. const int curLife = ch->GetHP();
  1741. const int needPercent = WARP_NEED_LIFE_PERCENT;
  1742. const int needLife = ch->GetMaxHP() * needPercent / 100;
  1743. if (curLife < needLife)
  1744. {
  1745. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("남은 생명력 양이 모자라 사용할 수 없습니다."));
  1746. return -1;
  1747. }
  1748.  
  1749. consumeLife = needLife;
  1750.  
  1751.  
  1752. // CheckMinLifeForWarp: 독에 의해서 죽으면 안되므로 생명력 최소량는 남겨준다
  1753. const int minPercent = WARP_MIN_LIFE_PERCENT;
  1754. const int minLife = ch->GetMaxHP() * minPercent / 100;
  1755. if (curLife - needLife < minLife)
  1756. consumeLife = curLife - minLife;
  1757.  
  1758. if (consumeLife < 0)
  1759. consumeLife = 0;
  1760. }
  1761. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  1762. return consumeLife;
  1763. }
  1764.  
  1765. int CalculateConsumeSP(LPCHARACTER lpChar)
  1766. {
  1767. static const int NEED_WARP_SP_PERCENT = 30;
  1768.  
  1769. const int curSP = lpChar->GetSP();
  1770. const int needSP = lpChar->GetMaxSP() * NEED_WARP_SP_PERCENT / 100;
  1771.  
  1772. if (curSP < needSP)
  1773. {
  1774. lpChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("남은 정신력 양이 모자라 사용할 수 없습니다."));
  1775. return -1;
  1776. }
  1777.  
  1778. return needSP;
  1779. }
  1780.  
  1781. #ifdef ENABLE_YMIR_AFFECT_FIX
  1782. bool CHARACTER::CheckTimeUsed(LPITEM item)
  1783. {
  1784. switch (item->GetVnum())
  1785. {
  1786. /****************
  1787. * Type = 27 -> ITEM_BLEND (Delete the other case you do not want for check)
  1788. */
  1789. case 50821: case 50822: case 50823: case 50824: case 50825: case 50826:
  1790.  
  1791. /****************
  1792. * SubType = 7 -> USE_ABILITY_UP (Delete the other case you do not want for check)
  1793. */
  1794. case 27866: case 27868: case 27870: case 27873: case 39026: case 50093: case 50094:
  1795. case 50123: case 50801: case 50802: case 50817: case 50818: case 50819: case 50820:
  1796. /****************
  1797. * SubType = 8 -> USE_AFFECT (Delete the other case you do not want for check)
  1798. */
  1799. case 39010: case 39017: case 39018: case 39019: case 39020: case 39024: case 39025:
  1800. case 39031: case 50813: case 50814: case 71014: case 71015: case 71016: case 71017:
  1801. case 71027: case 71028: case 71029: case 71030: case 71034: case 71044: case 71045:
  1802. case 71101: case 71102: case 71153: case 71154: case 71155: case 71156: case 72025:
  1803. case 72026: case 72027: case 72031: case 72032: case 72033: case 72034: case 72035:
  1804. case 72036: case 72037: case 72038: case 72039: case 72040: case 72041: case 72042:
  1805. case 72046: case 72047: case 72048: case 72312: case 72313: case 72501: case 72502:
  1806. case 76003: case 76017: case 76018:
  1807.  
  1808. int pGetTime[] = {10}; // Set timer for how you need a long after you login for can use item
  1809. int pGetFlag = GetQuestFlag("item.last_time"); // Get questflag where him set from input_login.cpp (Not change)
  1810. const char* pGetMessage[] = {"|cFFc9ff00|H|h[%s] |cFFd0ffcc|H|hkullanabilmek icin |cFFec03e2|H|h[%u] |cFFd0ffcc|H|hsaniye beklemelisin."}; // Get message when you use time so fast
  1811.  
  1812. if (pGetFlag) // Initializate questflag on item
  1813. {
  1814. if (get_global_time() < pGetFlag + pGetTime[0]) // Initializate to get a + second for questflag
  1815. {
  1816. ChatPacket(CHAT_TYPE_INFO, pGetMessage[0], item->GetName(), pGetTime[0]); // Get message
  1817. return false; // Return false if you use the item quicker than those seconds
  1818. }
  1819. }
  1820. break;
  1821. }
  1822. return true;
  1823. }
  1824. #endif
  1825.  
  1826. bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
  1827. {
  1828. int iLimitRealtimeStartFirstUseFlagIndex = -1;
  1829. int iLimitTimerBasedOnWearFlagIndex = -1;
  1830.  
  1831. WORD wDestCell = DestCell.cell;
  1832. BYTE bDestInven = DestCell.window_type;
  1833. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  1834. {
  1835. long limitValue = item->GetProto()->aLimits[i].lValue;
  1836.  
  1837. switch (item->GetProto()->aLimits[i].bType)
  1838. {
  1839. case LIMIT_LEVEL:
  1840. if (GetLevel() < limitValue)
  1841. {
  1842. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템의 레벨 제한보다 레벨이 낮습니다."));
  1843. return false;
  1844. }
  1845. break;
  1846.  
  1847. case LIMIT_REAL_TIME_START_FIRST_USE:
  1848. iLimitRealtimeStartFirstUseFlagIndex = i;
  1849. break;
  1850.  
  1851. case LIMIT_TIMER_BASED_ON_WEAR:
  1852. iLimitTimerBasedOnWearFlagIndex = i;
  1853. break;
  1854. }
  1855. }
  1856.  
  1857. if (test_server)
  1858. {
  1859. sys_log(0, "USE_ITEM %s, Inven %d, Cell %d, ItemType %d, SubType %d", item->GetName(), bDestInven, wDestCell, item->GetType(), item->GetSubType());
  1860. }
  1861.  
  1862. if ( CArenaManager::instance().IsLimitedItem( GetMapIndex(), item->GetVnum() ) == true )
  1863. {
  1864. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  1865. return false;
  1866. }
  1867.  
  1868. if (item->GetVnum() == 55009) {
  1869. int number1461 = number(55010,55027);//item kodları
  1870. AutoGiveItem(number1461);
  1871. item->SetCount(item->GetCount() - 1);
  1872. }
  1873.  
  1874. // 아이템 최초 사용 이후부터는 사용하지 않아도 시간이 차감되는 방식 처리.
  1875. if (-1 != iLimitRealtimeStartFirstUseFlagIndex)
  1876. {
  1877. // 한 번이라도 사용한 아이템인지 여부는 Socket1을 보고 판단한다. (Socket1에 사용횟수 기록)
  1878. if (0 == item->GetSocket(1))
  1879. {
  1880. // 사용가능시간은 Default 값으로 Limit Value 값을 사용하되, Socket0에 값이 있으면 그 값을 사용하도록 한다. (단위는 초)
  1881. long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[iLimitRealtimeStartFirstUseFlagIndex].lValue;
  1882.  
  1883. if (0 == duration)
  1884. duration = 60 * 60 * 24 * 7;
  1885.  
  1886. item->SetSocket(0, time(0) + duration);
  1887. item->StartRealTimeExpireEvent();
  1888. }
  1889.  
  1890. if (false == item->IsEquipped())
  1891. item->SetSocket(1, item->GetSocket(1) + 1);
  1892. }
  1893.  
  1894. #ifdef NEW_PET_SYSTEM
  1895. if (item->GetVnum() == 55001) {
  1896.  
  1897. LPITEM item2;
  1898.  
  1899. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  1900. return false;
  1901.  
  1902. if (item2->IsExchanging())
  1903. return false;
  1904.  
  1905. if (item2->GetVnum() > 55706 || item2->GetVnum() < 55701)
  1906. return false;
  1907.  
  1908. char szQuery1[1024];
  1909. snprintf(szQuery1, sizeof(szQuery1), "SELECT duration ,tduration FROM new_petsystem WHERE id = %lu ", item2->GetID());
  1910. std::auto_ptr<SQLMsg> pmsg2(DBManager::instance().DirectQuery(szQuery1));
  1911.  
  1912. if (pmsg2->Get()->uiNumRows > 0) {
  1913. if (GetNewPetSystem()->IsActivePet()){ChatPacket(CHAT_TYPE_INFO,LC_TEXT("PSS_PETI_GONDER"));return false;}
  1914. MYSQL_ROW row = mysql_fetch_row(pmsg2->Get()->pSQLResult);
  1915. int suankiDuration=atoi(row[1])-atoi(row[0]);
  1916. //ChatPacket(CHAT_TYPE_INFO,"%d",suankiDuration);
  1917. if(suankiDuration<1){
  1918. ChatPacket(CHAT_TYPE_INFO,LC_TEXT("PET_ZATEN_DINC"));
  1919. return false;}
  1920. if (atoi(row[0])>0){
  1921. DBManager::instance().DirectQuery("UPDATE new_petsystem SET duration =(tduration) WHERE id = %d", item2->GetID());
  1922. ChatPacket(CHAT_TYPE_INFO,LC_TEXT("PROTEIN_1"));
  1923. }
  1924. else{
  1925. DBManager::instance().DirectQuery("UPDATE new_petsystem SET duration =(tduration/2) WHERE id = %d", item2->GetID());
  1926. ChatPacket(CHAT_TYPE_INFO,LC_TEXT("PROTEIN_2"));
  1927. }
  1928. item->SetCount(item->GetCount() - 1);
  1929. return true;
  1930. }
  1931. else
  1932. return false;
  1933. }
  1934.  
  1935. if (item->GetVnum() >= 55701 && item->GetVnum() <= 55706) {
  1936. LPITEM item2;
  1937.  
  1938. if (item2 = GetItem(DestCell)) {
  1939. if (item2->GetVnum() == 55002)
  1940. {
  1941. if(item2->GetAttributeValue(0) > 0)
  1942. {
  1943. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cutia are deja un animalut inauntru."));
  1944. }
  1945. else if (item->GetAttributeValue(3) == 0)
  1946. {
  1947. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("pet_bu_halde_konulamaz."));
  1948. return false;
  1949. }
  1950. else
  1951. {
  1952. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  1953. return false;
  1954.  
  1955. if (item2->IsExchanging())
  1956. return false;
  1957.  
  1958. if (GetNewPetSystem()->IsActivePet())
  1959. {
  1960. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to unsummon your pet first."));
  1961. return false;
  1962. }
  1963.  
  1964. for (int b = 0; b < 3; b++)
  1965. {
  1966. item2->SetForceAttribute(b, 1, item->GetAttributeValue(b));
  1967. }
  1968.  
  1969. item2->SetForceAttribute(3, 1, item->GetAttributeValue(3));
  1970. item2->SetForceAttribute(4, 1, item->GetAttributeValue(4));
  1971. //Pet Yas Bugu Fixi//
  1972. item2->SetForceAttribute(5, 1, item->GetAttributeValue(5));
  1973. //Pet Yas Bugu Fixi//
  1974. DWORD vnum1 = item->GetVnum()-55700;
  1975. item2->SetSocket(2, vnum1);
  1976. item2->SetSocket(1, item->GetSocket(1));
  1977. //ChatPacket(CHAT_TYPE_INFO, "Pet %d %d %d //// %d %d %d",item->GetAttributeValue(0),item->GetAttributeValue(1),item->GetAttributeValue(2),item2->GetAttributeValue(0),item2->GetAttributeValue(1),item2->GetAttributeValue(2));
  1978. DBManager::instance().DirectQuery("UPDATE new_petsystem SET id =%d WHERE id = %d", item2->GetID(), item->GetID());
  1979. ITEM_MANAGER::instance().RemoveItem(item);
  1980. return true;
  1981. }
  1982. }
  1983. }
  1984. }
  1985.  
  1986.  
  1987. if (item->GetVnum() == 55002 && item->GetAttributeValue(0) > 0) {
  1988.  
  1989. int pos = GetEmptyInventory(item->GetSize());
  1990. if(pos == -1)
  1991. {
  1992. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You don't have enought space."));
  1993. return false;
  1994. }
  1995.  
  1996. if(GetLevel() < item->GetSocket(1))
  1997. {
  1998. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("pet leveli senin levelinden buyuk"));
  1999. return false;
  2000. }
  2001.  
  2002. if (item->IsExchanging())
  2003. return false;
  2004. DWORD vnum2 = 55700+item->GetSocket(2);
  2005. LPITEM item2 = AutoGiveItem(vnum2, 1);
  2006. for (int b = 0; b < 3; b++) {
  2007. item2->SetForceAttribute(b, 1, item->GetAttributeValue(b));
  2008. }
  2009. item2->SetForceAttribute(3, 1, item->GetAttributeValue(3));
  2010. item2->SetForceAttribute(4, 1, item->GetAttributeValue(4));
  2011. //Pet Yas Bugu Fixi//
  2012. item2->SetForceAttribute(5, 1, item->GetAttributeValue(5));
  2013. //Pet Yas Bugu Fixi//
  2014. item2->SetSocket(1,item->GetSocket(1));
  2015. //ChatPacket(CHAT_TYPE_INFO, "Pet1 %d %d %d",item->GetAttributeValue(0),item->GetAttributeValue(1),item->GetAttributeValue(2));
  2016. DBManager::instance().DirectQuery("UPDATE new_petsystem SET id =%d WHERE id = %d", item2->GetID(), item->GetID());
  2017. ITEM_MANAGER::instance().RemoveItem(item);
  2018. return true;
  2019.  
  2020. }
  2021. #endif
  2022.  
  2023. switch (item->GetType())
  2024. {
  2025. case ITEM_HAIR:
  2026. return ItemProcess_Hair(item, wDestCell);
  2027.  
  2028. case ITEM_POLYMORPH:
  2029. return ItemProcess_Polymorph(item);
  2030.  
  2031. case ITEM_QUEST:
  2032. if (GetArena() != NULL || IsObserverMode() == true)
  2033. {
  2034. if (item->GetVnum() == 50051 || item->GetVnum() == 50052 || item->GetVnum() == 50053)
  2035. {
  2036. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  2037. return false;
  2038. }
  2039. }
  2040.  
  2041. if (!IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE | ITEM_FLAG_QUEST_USE_MULTIPLE))
  2042. {
  2043. if (item->GetSIGVnum() == 0)
  2044. {
  2045. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  2046. }
  2047. else
  2048. {
  2049. quest::CQuestManager::instance().SIGUse(GetPlayerID(), item->GetSIGVnum(), item, false);
  2050. }
  2051. }
  2052. break;
  2053.  
  2054. case ITEM_CAMPFIRE:
  2055. {
  2056. float fx, fy;
  2057. GetDeltaByDegree(GetRotation(), 100.0f, &fx, &fy);
  2058.  
  2059. LPSECTREE tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy));
  2060.  
  2061. if (!tree)
  2062. {
  2063. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("모닥불을 피울 수 없는 지점입니다."));
  2064. return false;
  2065. }
  2066.  
  2067. if (tree->IsAttr((long)(GetX()+fx), (long)(GetY()+fy), ATTR_WATER))
  2068. {
  2069. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물 속에 모닥불을 피울 수 없습니다."));
  2070. return false;
  2071. }
  2072.  
  2073. if (GetMapIndex() == 113)
  2074. {
  2075. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_MAPDA_ATES_YAKAMASSIN"));
  2076. return false;
  2077. }
  2078.  
  2079. int son_ates = GetQuestFlag("kamp.ates");
  2080. if (get_global_time() - son_ates < 60)
  2081. {
  2082. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("60_SANIYE_BEKLE"));
  2083. return false;
  2084. }
  2085.  
  2086. SetQuestFlag("kamp.ates", get_global_time());
  2087.  
  2088. LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy), 0, false, number(0, 359));
  2089.  
  2090. char_event_info* info = AllocEventInfo<char_event_info>();
  2091.  
  2092. info->ch = campfire;
  2093.  
  2094. campfire->m_pkMiningEvent = event_create(kill_campfire_event, info, PASSES_PER_SEC(40));
  2095.  
  2096. item->SetCount(item->GetCount() - 1);
  2097. }
  2098. break;
  2099.  
  2100. case ITEM_UNIQUE:
  2101. {
  2102. switch (item->GetSubType())
  2103. {
  2104. case USE_ABILITY_UP:
  2105. {
  2106. #ifdef ENABLE_YMIR_AFFECT_FIX
  2107. if ((CheckTimeUsed(item) == false))
  2108. {
  2109. return false;
  2110. }
  2111. #endif
  2112. switch (item->GetValue(0))
  2113. {
  2114. case APPLY_MOV_SPEED:
  2115. EffectPacket(SE_DXUP_PURPLE); //purple potion
  2116. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true, true);
  2117. break;
  2118.  
  2119. case APPLY_ATT_SPEED:
  2120. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true, true);
  2121. EffectPacket(SE_SPEEDUP_GREEN); //green potion
  2122. break;
  2123.  
  2124. case APPLY_STR:
  2125. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ST, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2126. break;
  2127.  
  2128. case APPLY_DEX:
  2129. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_DX, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2130. break;
  2131.  
  2132. case APPLY_CON:
  2133. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_HT, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2134. break;
  2135.  
  2136. case APPLY_INT:
  2137. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_IQ, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2138. break;
  2139.  
  2140. case APPLY_CAST_SPEED:
  2141. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_CASTING_SPEED, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2142. break;
  2143.  
  2144. case APPLY_RESIST_MAGIC:
  2145. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_RESIST_MAGIC, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2146. break;
  2147.  
  2148. case APPLY_ATT_GRADE_BONUS:
  2149. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_GRADE_BONUS,
  2150. item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2151. break;
  2152.  
  2153. case APPLY_DEF_GRADE_BONUS:
  2154. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_DEF_GRADE_BONUS,
  2155. item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2156. break;
  2157. }
  2158. }
  2159.  
  2160. if (GetDungeon())
  2161. GetDungeon()->UsePotion(this);
  2162.  
  2163. if (GetWarMap())
  2164. GetWarMap()->UsePotion(this, item);
  2165.  
  2166. item->SetCount(item->GetCount() - 1);
  2167. break;
  2168.  
  2169. default:
  2170. {
  2171. if (item->GetSubType() == USE_SPECIAL)
  2172. {
  2173. sys_log(0, "ITEM_UNIQUE: USE_SPECIAL %u", item->GetVnum());
  2174.  
  2175. switch (item->GetVnum())
  2176. {
  2177. case 71049: // 비단보따리
  2178. if (LC_IsYMIR() == true || LC_IsKorea() == true)
  2179. {
  2180. if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
  2181. {
  2182. UseSilkBotary();
  2183. }
  2184. else
  2185. {
  2186. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개인 상점을 열 수 없는 지역입니다"));
  2187. }
  2188. }
  2189. else
  2190. {
  2191. UseSilkBotary();
  2192. }
  2193. break;
  2194. }
  2195. }
  2196. else
  2197. {
  2198. if (!item->IsEquipped())
  2199. EquipItem(item);
  2200. else
  2201. UnequipItem(item);
  2202. UpdatePacket();
  2203. }
  2204. }
  2205. break;
  2206. }
  2207. }
  2208. break;
  2209.  
  2210. case ITEM_COSTUME:
  2211. case ITEM_WEAPON:
  2212. case ITEM_ARMOR:
  2213. case ITEM_ROD:
  2214. case ITEM_RING: // 신규 반지 아이템
  2215. case ITEM_BELT: // 신규 벨트 아이템
  2216. // MINING
  2217. case ITEM_PICK:
  2218. // END_OF_MINING
  2219. if (!item->IsEquipped())
  2220. EquipItem(item);
  2221. else
  2222. UnequipItem(item);
  2223. break;
  2224. // 착용하지 않은 용혼석은 사용할 수 없다.
  2225. // 정상적인 클라라면, 용혼석에 관하여 item use 패킷을 보낼 수 없다.
  2226. // 용혼석 착용은 item move 패킷으로 한다.
  2227. // 착용한 용혼석은 추출한다.
  2228. case ITEM_DS:
  2229. {
  2230. if (!item->IsEquipped())
  2231. return false;
  2232. return DSManager::instance().PullOut(this, NPOS, item);
  2233. break;
  2234. }
  2235. case ITEM_SPECIAL_DS:
  2236. if (!item->IsEquipped())
  2237. EquipItem(item);
  2238. else
  2239. UnequipItem(item);
  2240. break;
  2241.  
  2242. case ITEM_FISH:
  2243. {
  2244. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  2245. {
  2246. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  2247. return false;
  2248. }
  2249.  
  2250. if (item->GetSubType() == FISH_ALIVE)
  2251. fishing::UseFish(this, item);
  2252. }
  2253. break;
  2254.  
  2255. case ITEM_TREASURE_BOX:
  2256. {
  2257. return false;
  2258. //ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("열쇠로 잠겨 있어서 열리지 않는것 같다. 열쇠를 구해보자."));
  2259. }
  2260. break;
  2261.  
  2262. case ITEM_TREASURE_KEY:
  2263. {
  2264. LPITEM item2;
  2265.  
  2266. if (!GetItem(DestCell) || !(item2 = GetItem(DestCell)))
  2267. return false;
  2268.  
  2269. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  2270. return false;
  2271.  
  2272. if (item2->GetType() != ITEM_TREASURE_BOX)
  2273. {
  2274. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("열쇠로 여는 물건이 아닌것 같다."));
  2275. return false;
  2276. }
  2277.  
  2278. if (item->GetValue(0) == item2->GetValue(0))
  2279. {
  2280. //ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("열쇠는 맞으나 아이템 주는 부분 구현이 안되었습니다."));
  2281. DWORD dwBoxVnum = item2->GetVnum();
  2282. std::vector <DWORD> dwVnums;
  2283. std::vector <DWORD> dwCounts;
  2284. std::vector <LPITEM> item_gets(0);
  2285. int count = 0;
  2286.  
  2287. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  2288. {
  2289. ITEM_MANAGER::instance().RemoveItem(item);
  2290. ITEM_MANAGER::instance().RemoveItem(item2);
  2291.  
  2292. for (int i = 0; i < count; i++){
  2293. switch (dwVnums[i])
  2294. {
  2295. case CSpecialItemGroup::GOLD:
  2296. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈 %d 냥을 획득했습니다."), dwCounts[i]);
  2297. break;
  2298. case CSpecialItemGroup::EXP:
  2299. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 부터 신비한 빛이 나옵니다."));
  2300. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d의 경험치를 획득했습니다."), dwCounts[i]);
  2301. break;
  2302. case CSpecialItemGroup::MOB:
  2303. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 몬스터가 나타났습니다!"));
  2304. break;
  2305. case CSpecialItemGroup::SLOW:
  2306. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 빨간 연기를 들이마시자 움직이는 속도가 느려졌습니다!"));
  2307. break;
  2308. case CSpecialItemGroup::DRAIN_HP:
  2309. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자가 갑자기 폭발하였습니다! 생명력이 감소했습니다."));
  2310. break;
  2311. case CSpecialItemGroup::POISON:
  2312. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 녹색 연기를 들이마시자 독이 온몸으로 퍼집니다!"));
  2313. break;
  2314. case CSpecialItemGroup::BLEED:
  2315. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 녹색 연기를 들이마시자 독이 온몸으로 퍼집니다!"));
  2316. break;
  2317. case CSpecialItemGroup::MOB_GROUP:
  2318. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 몬스터가 나타났습니다!"));
  2319. break;
  2320. default:
  2321. if (item_gets[i])
  2322. {
  2323. if (dwCounts[i] > 1)
  2324. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 %s 가 %d 개 나왔습니다."), item_gets[i]->GetName(), dwCounts[i]);
  2325. else
  2326. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 %s 가 나왔습니다."), item_gets[i]->GetName());
  2327.  
  2328. }
  2329. }
  2330. }
  2331. }
  2332. else
  2333. {
  2334. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("열쇠가 맞지 않는 것 같다."));
  2335. return false;
  2336. }
  2337. }
  2338. else
  2339. {
  2340. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("열쇠가 맞지 않는 것 같다."));
  2341. return false;
  2342. }
  2343. }
  2344. break;
  2345.  
  2346. case ITEM_GIFTBOX:
  2347. {
  2348. DWORD dwBoxVnum = item->GetVnum();
  2349. std::vector <DWORD> dwVnums;
  2350. std::vector <DWORD> dwCounts;
  2351. std::vector <LPITEM> item_gets(0);
  2352. int count = 0;
  2353.  
  2354. if (dwBoxVnum == 50033 && LC_IsYMIR()) // 알수없는 상자
  2355. {
  2356. if (GetLevel() < 15)
  2357. {
  2358. ChatPacket(CHAT_TYPE_INFO, "15레벨 이하에서는 사용할 수 없습니다.");
  2359. return false;
  2360. }
  2361. }
  2362.  
  2363. if( (dwBoxVnum > 51500 && dwBoxVnum < 52000) || (dwBoxVnum >= 50255 && dwBoxVnum <= 50260) ) // 용혼원석들
  2364. {
  2365. if( !(this->DragonSoul_IsQualified()) )
  2366. {
  2367. ChatPacket(CHAT_TYPE_INFO,LC_TEXT("먼저 용혼석 퀘스트를 완료하셔야 합니다."));
  2368. return false;
  2369. }
  2370. }
  2371.  
  2372. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  2373. {
  2374. item->SetCount(item->GetCount()-1);
  2375.  
  2376. for (int i = 0; i < count; i++){
  2377. switch (dwVnums[i])
  2378. {
  2379. case CSpecialItemGroup::GOLD:
  2380. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈 %d 냥을 획득했습니다."), dwCounts[i]);
  2381. break;
  2382. case CSpecialItemGroup::EXP:
  2383. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 부터 신비한 빛이 나옵니다."));
  2384. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d의 경험치를 획득했습니다."), dwCounts[i]);
  2385. break;
  2386. case CSpecialItemGroup::MOB:
  2387. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 몬스터가 나타났습니다!"));
  2388. break;
  2389. case CSpecialItemGroup::SLOW:
  2390. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 빨간 연기를 들이마시자 움직이는 속도가 느려졌습니다!"));
  2391. break;
  2392. case CSpecialItemGroup::DRAIN_HP:
  2393. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자가 갑자기 폭발하였습니다! 생명력이 감소했습니다."));
  2394. break;
  2395. case CSpecialItemGroup::POISON:
  2396. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 녹색 연기를 들이마시자 독이 온몸으로 퍼집니다!"));
  2397. break;
  2398. case CSpecialItemGroup::BLEED:
  2399. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 녹색 연기를 들이마시자 독이 온몸으로 퍼집니다!"));
  2400. break;
  2401. case CSpecialItemGroup::MOB_GROUP:
  2402. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 몬스터가 나타났습니다!"));
  2403. break;
  2404. default:
  2405. if (item_gets[i])
  2406. {
  2407. if (dwCounts[i] > 1)
  2408. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 %s 가 %d 개 나왔습니다."), item_gets[i]->GetName(), dwCounts[i]);
  2409. else
  2410. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 %s 가 나왔습니다."), item_gets[i]->GetName());
  2411. }
  2412. }
  2413. }
  2414. }
  2415. else
  2416. {
  2417. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("아무것도 얻을 수 없었습니다."));
  2418. return false;
  2419. }
  2420. }
  2421. break;
  2422.  
  2423. case ITEM_SKILLFORGET:
  2424. {
  2425. if (!item->GetSocket(0))
  2426. {
  2427. ITEM_MANAGER::instance().RemoveItem(item);
  2428. return false;
  2429. }
  2430.  
  2431. DWORD dwVnum = item->GetSocket(0);
  2432.  
  2433. if (SkillLevelDown(dwVnum))
  2434. {
  2435. ITEM_MANAGER::instance().RemoveItem(item);
  2436. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("스킬 레벨을 내리는데 성공하였습니다."));
  2437. }
  2438. else
  2439. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("스킬 레벨을 내릴 수 없습니다."));
  2440. }
  2441. break;
  2442.  
  2443. case ITEM_SKILLBOOK:
  2444. {
  2445. if (IsPolymorphed())
  2446. {
  2447. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  2448. return false;
  2449. }
  2450.  
  2451. DWORD dwVnum = 0;
  2452.  
  2453. if (item->GetVnum() == 50300)
  2454. {
  2455. dwVnum = item->GetSocket(0);
  2456. }
  2457. else
  2458. {
  2459. // 새로운 수련서는 value 0 에 스킬 번호가 있으므로 그것을 사용.
  2460. dwVnum = item->GetValue(0);
  2461. }
  2462.  
  2463. if (0 == dwVnum)
  2464. {
  2465. ITEM_MANAGER::instance().RemoveItem(item);
  2466.  
  2467. return false;
  2468. }
  2469.  
  2470. if (true == LearnSkillByBook(dwVnum))
  2471. {
  2472. item->SetCount(item->GetCount() - 1);
  2473.  
  2474. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  2475.  
  2476. if (distribution_test_server)
  2477. iReadDelay /= 3;
  2478.  
  2479. SetSkillNextReadTime(dwVnum, get_global_time() + iReadDelay);
  2480. }
  2481. }
  2482. break;
  2483.  
  2484. case ITEM_USE:
  2485. {
  2486. if (item->GetVnum() > 50800 && item->GetVnum() <= 50820)
  2487. {
  2488. if (test_server)
  2489. sys_log (0, "ADD addtional effect : vnum(%d) subtype(%d)", item->GetOriginalVnum(), item->GetSubType());
  2490.  
  2491. int affect_type = AFFECT_EXP_BONUS_EURO_FREE;
  2492. int apply_type = aApplyInfo[item->GetValue(0)].bPointType;
  2493. int apply_value = item->GetValue(2);
  2494. int apply_duration = item->GetValue(1);
  2495.  
  2496. switch (item->GetSubType())
  2497. {
  2498. case USE_ABILITY_UP:
  2499. #ifdef ENABLE_YMIR_AFFECT_FIX
  2500. if ((CheckTimeUsed(item) == false))
  2501. {
  2502. return false;
  2503. }
  2504. #endif
  2505. if (FindAffect(affect_type, apply_type))
  2506. {
  2507. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
  2508. return false;
  2509. }
  2510.  
  2511. {
  2512. switch (item->GetValue(0))
  2513. {
  2514. case APPLY_MOV_SPEED:
  2515. AddAffect(affect_type, apply_type, apply_value, AFF_MOV_SPEED_POTION, apply_duration, 0, true, true);
  2516. break;
  2517.  
  2518. case APPLY_ATT_SPEED:
  2519. AddAffect(affect_type, apply_type, apply_value, AFF_ATT_SPEED_POTION, apply_duration, 0, true, true);
  2520. break;
  2521.  
  2522. case APPLY_STR:
  2523. case APPLY_DEX:
  2524. case APPLY_CON:
  2525. case APPLY_INT:
  2526. case APPLY_CAST_SPEED:
  2527. case APPLY_RESIST_MAGIC:
  2528. case APPLY_ATT_GRADE_BONUS:
  2529. case APPLY_DEF_GRADE_BONUS:
  2530. AddAffect(affect_type, apply_type, apply_value, 0, apply_duration, 0, true, true);
  2531. break;
  2532. }
  2533. }
  2534.  
  2535. if (GetDungeon())
  2536. GetDungeon()->UsePotion(this);
  2537.  
  2538. if (GetWarMap())
  2539. GetWarMap()->UsePotion(this, item);
  2540.  
  2541. item->SetCount(item->GetCount() - 1);
  2542. break;
  2543.  
  2544. case USE_AFFECT :
  2545. {
  2546. #ifdef ENABLE_YMIR_AFFECT_FIX
  2547. if ((CheckTimeUsed(item) == false))
  2548. {
  2549. return false;
  2550. }
  2551. #endif
  2552. if (FindAffect(AFFECT_EXP_BONUS_EURO_FREE, aApplyInfo[item->GetValue(1)].bPointType))
  2553. {
  2554. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
  2555. }
  2556. else
  2557. {
  2558. // PC_BANG_ITEM_ADD
  2559. if (item->IsPCBangItem() == true)
  2560. {
  2561. // PC방인지 체크해서 처리
  2562. if (CPCBangManager::instance().IsPCBangIP(GetDesc()->GetHostName()) == false)
  2563. {
  2564. // PC방이 아님!
  2565. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 PC방에서만 사용할 수 있습니다."));
  2566. return false;
  2567. }
  2568. }
  2569. // END_PC_BANG_ITEM_ADD
  2570.  
  2571. AddAffect(AFFECT_EXP_BONUS_EURO_FREE, aApplyInfo[item->GetValue(1)].bPointType, item->GetValue(2), 0, item->GetValue(3), 0, false, true);
  2572. item->SetCount(item->GetCount() - 1);
  2573. }
  2574. }
  2575. break;
  2576.  
  2577. case USE_POTION_NODELAY:
  2578. {
  2579. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  2580. {
  2581. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
  2582. {
  2583. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  2584. return false;
  2585. }
  2586.  
  2587. switch (item->GetVnum())
  2588. {
  2589. case 70020 :
  2590. case 71018 :
  2591. case 71019 :
  2592. case 71020 :
  2593. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
  2594. {
  2595. if (m_nPotionLimit <= 0)
  2596. {
  2597. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("사용 제한량을 초과하였습니다."));
  2598. return false;
  2599. }
  2600. }
  2601. break;
  2602.  
  2603. default :
  2604. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  2605. return false;
  2606. break;
  2607. }
  2608. }
  2609.  
  2610. bool used = false;
  2611.  
  2612. if (item->GetValue(0) != 0) // HP 절대값 회복
  2613. {
  2614. if (GetHP() < GetMaxHP())
  2615. {
  2616. PointChange(POINT_HP, item->GetValue(0) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  2617. EffectPacket(SE_HPUP_RED);
  2618. used = TRUE;
  2619. }
  2620. }
  2621.  
  2622. if (item->GetValue(1) != 0) // SP 절대값 회복
  2623. {
  2624. if (GetSP() < GetMaxSP())
  2625. {
  2626. PointChange(POINT_SP, item->GetValue(1) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  2627. EffectPacket(SE_SPUP_BLUE);
  2628. used = TRUE;
  2629. }
  2630. }
  2631.  
  2632. if (item->GetValue(3) != 0) // HP % 회복
  2633. {
  2634. if (GetHP() < GetMaxHP())
  2635. {
  2636. PointChange(POINT_HP, item->GetValue(3) * GetMaxHP() / 100);
  2637. EffectPacket(SE_HPUP_RED);
  2638. used = TRUE;
  2639. }
  2640. }
  2641.  
  2642. if (item->GetValue(4) != 0) // SP % 회복
  2643. {
  2644. if (GetSP() < GetMaxSP())
  2645. {
  2646. PointChange(POINT_SP, item->GetValue(4) * GetMaxSP() / 100);
  2647. EffectPacket(SE_SPUP_BLUE);
  2648. used = TRUE;
  2649. }
  2650. }
  2651.  
  2652. if (used)
  2653. {
  2654. if (item->GetVnum() == 50085 || item->GetVnum() == 50086)
  2655. {
  2656. if (test_server)
  2657. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("월병 또는 종자 를 사용하였습니다"));
  2658. SetUseSeedOrMoonBottleTime();
  2659. }
  2660. if (GetDungeon())
  2661. GetDungeon()->UsePotion(this);
  2662.  
  2663. if (GetWarMap())
  2664. GetWarMap()->UsePotion(this, item);
  2665.  
  2666. m_nPotionLimit--;
  2667.  
  2668. //RESTRICT_USE_SEED_OR_MOONBOTTLE
  2669. item->SetCount(item->GetCount() - 1);
  2670. //END_RESTRICT_USE_SEED_OR_MOONBOTTLE
  2671. }
  2672. }
  2673. break;
  2674. }
  2675.  
  2676. return true;
  2677. }
  2678.  
  2679.  
  2680. if (item->GetVnum() >= 27863 && item->GetVnum() <= 27883)
  2681. {
  2682. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  2683. {
  2684. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  2685. return false;
  2686. }
  2687. }
  2688.  
  2689. if (test_server)
  2690. {
  2691. sys_log (0, "USE_ITEM %s Type %d SubType %d vnum %d", item->GetName(), item->GetType(), item->GetSubType(), item->GetOriginalVnum());
  2692. }
  2693.  
  2694. switch (item->GetSubType())
  2695. {
  2696. case USE_TIME_CHARGE_PER:
  2697. {
  2698. LPITEM pDestItem = GetItem(DestCell);
  2699. if (NULL == pDestItem)
  2700. {
  2701. return false;
  2702. }
  2703. // 우선 용혼석에 관해서만 하도록 한다.
  2704. if (pDestItem->IsDragonSoul())
  2705. {
  2706. int ret;
  2707. char buf[128];
  2708. if (item->GetVnum() == DRAGON_HEART_VNUM)
  2709. {
  2710. ret = pDestItem->GiveMoreTime_Per((float)item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
  2711. }
  2712. else
  2713. {
  2714. ret = pDestItem->GiveMoreTime_Per((float)item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  2715. }
  2716. if (ret > 0)
  2717. {
  2718. if (item->GetVnum() == DRAGON_HEART_VNUM)
  2719. {
  2720. sprintf(buf, "Inc %ds by item{VN:%d SOC%d:%d}", ret, item->GetVnum(), ITEM_SOCKET_CHARGING_AMOUNT_IDX, item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
  2721. }
  2722. else
  2723. {
  2724. sprintf(buf, "Inc %ds by item{VN:%d VAL%d:%d}", ret, item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  2725. }
  2726.  
  2727. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d초 만큼 충전되었습니다."), ret);
  2728. item->SetCount(item->GetCount() - 1);
  2729. LogManager::instance().ItemLog(this, item, "DS_CHARGING_SUCCESS", buf);
  2730. return true;
  2731. }
  2732. else
  2733. {
  2734. if (item->GetVnum() == DRAGON_HEART_VNUM)
  2735. {
  2736. sprintf(buf, "No change by item{VN:%d SOC%d:%d}", item->GetVnum(), ITEM_SOCKET_CHARGING_AMOUNT_IDX, item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
  2737. }
  2738. else
  2739. {
  2740. sprintf(buf, "No change by item{VN:%d VAL%d:%d}", item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  2741. }
  2742.  
  2743. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("충전할 수 없습니다."));
  2744. LogManager::instance().ItemLog(this, item, "DS_CHARGING_FAILED", buf);
  2745. return false;
  2746. }
  2747. }
  2748. else
  2749. return false;
  2750. }
  2751. break;
  2752. case USE_TIME_CHARGE_FIX:
  2753. {
  2754. LPITEM pDestItem = GetItem(DestCell);
  2755. if (NULL == pDestItem)
  2756. {
  2757. return false;
  2758. }
  2759. // 우선 용혼석에 관해서만 하도록 한다.
  2760. if (pDestItem->IsDragonSoul())
  2761. {
  2762. int ret = pDestItem->GiveMoreTime_Fix(item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  2763. char buf[128];
  2764. if (ret)
  2765. {
  2766. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d초 만큼 충전되었습니다."), ret);
  2767. sprintf(buf, "Increase %ds by item{VN:%d VAL%d:%d}", ret, item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  2768. LogManager::instance().ItemLog(this, item, "DS_CHARGING_SUCCESS", buf);
  2769. item->SetCount(item->GetCount() - 1);
  2770. return true;
  2771. }
  2772. else
  2773. {
  2774. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("충전할 수 없습니다."));
  2775. sprintf(buf, "No change by item{VN:%d VAL%d:%d}", item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  2776. LogManager::instance().ItemLog(this, item, "DS_CHARGING_FAILED", buf);
  2777. return false;
  2778. }
  2779. }
  2780. else
  2781. return false;
  2782. }
  2783. break;
  2784. case USE_SPECIAL:
  2785.  
  2786. switch (item->GetVnum())
  2787. {
  2788. //크리스마스 란주
  2789. case ITEM_NOG_POCKET:
  2790. {
  2791. /*
  2792. 란주능력치 : item_proto value 의미
  2793. 이동속도 value 1
  2794. 공격력 value 2
  2795. 경험치 value 3
  2796. 지속시간 value 0 (단위 초)
  2797.  
  2798. */
  2799. if (FindAffect(AFFECT_NOG_ABILITY))
  2800. {
  2801. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
  2802. return false;
  2803. }
  2804. long time = item->GetValue(0);
  2805. long moveSpeedPer = item->GetValue(1);
  2806. long attPer = item->GetValue(2);
  2807. long expPer = item->GetValue(3);
  2808. AddAffect(AFFECT_NOG_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true);
  2809. AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
  2810. AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true);
  2811. item->SetCount(item->GetCount() - 1);
  2812. }
  2813. break;
  2814.  
  2815. //라마단용 사탕
  2816. case ITEM_RAMADAN_CANDY:
  2817. {
  2818. /*
  2819. 사탕능력치 : item_proto value 의미
  2820. 이동속도 value 1
  2821. 공격력 value 2
  2822. 경험치 value 3
  2823. 지속시간 value 0 (단위 초)
  2824.  
  2825. */
  2826. if (FindAffect(AFFECT_RAMADAN_ABILITY)) // @fixme61
  2827. {
  2828. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_ETKI_DEVAM_EDIYOR"));
  2829. return false;
  2830. }
  2831. long time = item->GetValue(0);
  2832. long moveSpeedPer = item->GetValue(1);
  2833. long attPer = item->GetValue(2);
  2834. long expPer = item->GetValue(3);
  2835. AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true);
  2836. AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
  2837. AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true);
  2838. item->SetCount(item->GetCount() - 1);
  2839. }
  2840. break;
  2841. case ITEM_MARRIAGE_RING:
  2842. {
  2843. marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID());
  2844. if (pMarriage)
  2845. {
  2846. if (pMarriage->ch1 != NULL)
  2847. {
  2848. if (CArenaManager::instance().IsArenaMap(pMarriage->ch1->GetMapIndex()) == true)
  2849. {
  2850. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  2851. break;
  2852. }
  2853. }
  2854.  
  2855. if (pMarriage->ch2 != NULL)
  2856. {
  2857. if (CArenaManager::instance().IsArenaMap(pMarriage->ch2->GetMapIndex()) == true)
  2858. {
  2859. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  2860. break;
  2861. }
  2862. }
  2863.  
  2864. int consumeSP = CalculateConsumeSP(this);
  2865.  
  2866. if (consumeSP < 0)
  2867. return false;
  2868.  
  2869. PointChange(POINT_SP, -consumeSP, false);
  2870.  
  2871. WarpToPID(pMarriage->GetOther(GetPlayerID()));
  2872. }
  2873. else
  2874. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("결혼 상태가 아니면 결혼반지를 사용할 수 없습니다."));
  2875. }
  2876. break;
  2877.  
  2878. //기존 용기의 망토
  2879. case UNIQUE_ITEM_CAPE_OF_COURAGE:
  2880. //라마단 보상용 용기의 망토
  2881. case 70057:
  2882. case REWARD_BOX_UNIQUE_ITEM_CAPE_OF_COURAGE:
  2883. AggregateMonster();
  2884. item->SetCount(item->GetCount()-1);
  2885. break;
  2886.  
  2887. case UNIQUE_ITEM_WHITE_FLAG:
  2888. ForgetMyAttacker();
  2889. item->SetCount(item->GetCount()-1);
  2890. break;
  2891.  
  2892. case UNIQUE_ITEM_TREASURE_BOX:
  2893. break;
  2894.  
  2895. case 30093:
  2896. case 30094:
  2897. case 30095:
  2898. case 30096:
  2899. // 복주머니
  2900. {
  2901. const int MAX_BAG_INFO = 26;
  2902. static struct LuckyBagInfo
  2903. {
  2904. DWORD count;
  2905. int prob;
  2906. DWORD vnum;
  2907. } b1[MAX_BAG_INFO] =
  2908. {
  2909. { 1000, 302, 1 },
  2910. { 10, 150, 27002 },
  2911. { 10, 75, 27003 },
  2912. { 10, 100, 27005 },
  2913. { 10, 50, 27006 },
  2914. { 10, 80, 27001 },
  2915. { 10, 50, 27002 },
  2916. { 10, 80, 27004 },
  2917. { 10, 50, 27005 },
  2918. { 1, 10, 50300 },
  2919. { 1, 6, 92 },
  2920. { 1, 2, 132 },
  2921. { 1, 6, 1052 },
  2922. { 1, 2, 1092 },
  2923. { 1, 6, 2082 },
  2924. { 1, 2, 2122 },
  2925. { 1, 6, 3082 },
  2926. { 1, 2, 3122 },
  2927. { 1, 6, 5052 },
  2928. { 1, 2, 5082 },
  2929. { 1, 6, 7082 },
  2930. { 1, 2, 7122 },
  2931. { 1, 1, 11282 },
  2932. { 1, 1, 11482 },
  2933. { 1, 1, 11682 },
  2934. { 1, 1, 11882 },
  2935. };
  2936.  
  2937. struct LuckyBagInfo b2[MAX_BAG_INFO] =
  2938. {
  2939. { 1000, 302, 1 },
  2940. { 10, 150, 27002 },
  2941. { 10, 75, 27002 },
  2942. { 10, 100, 27005 },
  2943. { 10, 50, 27005 },
  2944. { 10, 80, 27001 },
  2945. { 10, 50, 27002 },
  2946. { 10, 80, 27004 },
  2947. { 10, 50, 27005 },
  2948. { 1, 10, 50300 },
  2949. { 1, 6, 92 },
  2950. { 1, 2, 132 },
  2951. { 1, 6, 1052 },
  2952. { 1, 2, 1092 },
  2953. { 1, 6, 2082 },
  2954. { 1, 2, 2122 },
  2955. { 1, 6, 3082 },
  2956. { 1, 2, 3122 },
  2957. { 1, 6, 5052 },
  2958. { 1, 2, 5082 },
  2959. { 1, 6, 7082 },
  2960. { 1, 2, 7122 },
  2961. { 1, 1, 11282 },
  2962. { 1, 1, 11482 },
  2963. { 1, 1, 11682 },
  2964. { 1, 1, 11882 },
  2965. };
  2966.  
  2967. LuckyBagInfo * bi = NULL;
  2968. bi = b1;
  2969.  
  2970. int pct = number(1, 1000);
  2971.  
  2972. int i;
  2973. for (i=0;i<MAX_BAG_INFO;i++)
  2974. {
  2975. if (pct <= bi[i].prob)
  2976. break;
  2977. pct -= bi[i].prob;
  2978. }
  2979. if (i>=MAX_BAG_INFO)
  2980. return false;
  2981.  
  2982. if (bi[i].vnum == 50300)
  2983. {
  2984. // 스킬수련서는 특수하게 준다.
  2985. GiveRandomSkillBook();
  2986. }
  2987. else if (bi[i].vnum == 1)
  2988. {
  2989. PointChange(POINT_GOLD, 1000, true);
  2990. }
  2991. else
  2992. {
  2993. AutoGiveItem(bi[i].vnum, bi[i].count);
  2994. }
  2995. ITEM_MANAGER::instance().RemoveItem(item);
  2996. }
  2997. break;
  2998.  
  2999. case 50004: // 이벤트용 감지기
  3000. {
  3001. if (item->GetSocket(0))
  3002. {
  3003. item->SetSocket(0, item->GetSocket(0) + 1);
  3004. }
  3005. else
  3006. {
  3007. // 처음 사용시
  3008. int iMapIndex = GetMapIndex();
  3009.  
  3010. PIXEL_POSITION pos;
  3011.  
  3012. if (SECTREE_MANAGER::instance().GetRandomLocation(iMapIndex, pos, 700))
  3013. {
  3014. item->SetSocket(0, 1);
  3015. item->SetSocket(1, pos.x);
  3016. item->SetSocket(2, pos.y);
  3017. }
  3018. else
  3019. {
  3020. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 곳에선 이벤트용 감지기가 동작하지 않는것 같습니다."));
  3021. return false;
  3022. }
  3023. }
  3024.  
  3025. int dist = 0;
  3026. float distance = (DISTANCE_SQRT(GetX()-item->GetSocket(1), GetY()-item->GetSocket(2)));
  3027.  
  3028. if (distance < 1000.0f)
  3029. {
  3030. // 발견!
  3031. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이벤트용 감지기가 신비로운 빛을 내며 사라집니다."));
  3032.  
  3033. // 사용횟수에 따라 주는 아이템을 다르게 한다.
  3034. struct TEventStoneInfo
  3035. {
  3036. DWORD dwVnum;
  3037. int count;
  3038. int prob;
  3039. };
  3040. const int EVENT_STONE_MAX_INFO = 15;
  3041. TEventStoneInfo info_10[EVENT_STONE_MAX_INFO] =
  3042. {
  3043. { 27001, 10, 8 },
  3044. { 27004, 10, 6 },
  3045. { 27002, 10, 12 },
  3046. { 27005, 10, 12 },
  3047. { 27100, 1, 9 },
  3048. { 27103, 1, 9 },
  3049. { 27101, 1, 10 },
  3050. { 27104, 1, 10 },
  3051. { 27999, 1, 12 },
  3052.  
  3053. { 25040, 1, 4 },
  3054.  
  3055. { 27410, 1, 0 },
  3056. { 27600, 1, 0 },
  3057. { 25100, 1, 0 },
  3058.  
  3059. { 50001, 1, 0 },
  3060. { 50003, 1, 1 },
  3061. };
  3062. TEventStoneInfo info_7[EVENT_STONE_MAX_INFO] =
  3063. {
  3064. { 27001, 10, 1 },
  3065. { 27004, 10, 1 },
  3066. { 27004, 10, 9 },
  3067. { 27005, 10, 9 },
  3068. { 27100, 1, 5 },
  3069. { 27103, 1, 5 },
  3070. { 27101, 1, 10 },
  3071. { 27104, 1, 10 },
  3072. { 27999, 1, 14 },
  3073.  
  3074. { 25040, 1, 5 },
  3075.  
  3076. { 27410, 1, 5 },
  3077. { 27600, 1, 5 },
  3078. { 25100, 1, 5 },
  3079.  
  3080. { 50001, 1, 0 },
  3081. { 50003, 1, 5 },
  3082.  
  3083. };
  3084. TEventStoneInfo info_4[EVENT_STONE_MAX_INFO] =
  3085. {
  3086. { 27001, 10, 0 },
  3087. { 27004, 10, 0 },
  3088. { 27002, 10, 0 },
  3089. { 27005, 10, 0 },
  3090. { 27100, 1, 0 },
  3091. { 27103, 1, 0 },
  3092. { 27101, 1, 0 },
  3093. { 27104, 1, 0 },
  3094. { 27999, 1, 25 },
  3095.  
  3096. { 25040, 1, 0 },
  3097.  
  3098. { 27410, 1, 0 },
  3099. { 27600, 1, 0 },
  3100. { 25100, 1, 15 },
  3101.  
  3102. { 50001, 1, 10 },
  3103. { 50003, 1, 50 },
  3104.  
  3105. };
  3106.  
  3107. {
  3108. TEventStoneInfo* info;
  3109. if (item->GetSocket(0) <= 4)
  3110. info = info_4;
  3111. else if (item->GetSocket(0) <= 7)
  3112. info = info_7;
  3113. else
  3114. info = info_10;
  3115.  
  3116. int prob = number(1, 100);
  3117.  
  3118. for (int i = 0; i < EVENT_STONE_MAX_INFO; ++i)
  3119. {
  3120. if (!info[i].prob)
  3121. continue;
  3122.  
  3123. if (prob <= info[i].prob)
  3124. {
  3125. if (info[i].dwVnum == 50001)
  3126. {
  3127. DWORD * pdw = M2_NEW DWORD[2];
  3128.  
  3129. pdw[0] = info[i].dwVnum;
  3130. pdw[1] = info[i].count;
  3131.  
  3132. // 추첨서는 소켓을 설정한다
  3133. DBManager::instance().ReturnQuery(QID_LOTTO, GetPlayerID(), pdw,
  3134. "INSERT INTO lotto_list VALUES(0, 'server%s', %u, NOW())",
  3135. get_table_postfix(), GetPlayerID());
  3136. }
  3137. else
  3138. AutoGiveItem(info[i].dwVnum, info[i].count);
  3139.  
  3140. break;
  3141. }
  3142. prob -= info[i].prob;
  3143. }
  3144. }
  3145.  
  3146. char chatbuf[CHAT_MAX_LEN + 1];
  3147. int len = snprintf(chatbuf, sizeof(chatbuf), "StoneDetect %u 0 0", (DWORD)GetVID());
  3148.  
  3149. if (len < 0 || len >= (int) sizeof(chatbuf))
  3150. len = sizeof(chatbuf) - 1;
  3151.  
  3152. ++len; // \0 문자까지 보내기
  3153.  
  3154. TPacketGCChat pack_chat;
  3155. pack_chat.header = HEADER_GC_CHAT;
  3156. pack_chat.size = sizeof(TPacketGCChat) + len;
  3157. pack_chat.type = CHAT_TYPE_COMMAND;
  3158. pack_chat.id = 0;
  3159. pack_chat.bEmpire = GetDesc()->GetEmpire();
  3160. //pack_chat.id = vid;
  3161.  
  3162. TEMP_BUFFER buf;
  3163. buf.write(&pack_chat, sizeof(TPacketGCChat));
  3164. buf.write(chatbuf, len);
  3165.  
  3166. PacketAround(buf.read_peek(), buf.size());
  3167.  
  3168. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (DETECT_EVENT_STONE) 1");
  3169. return true;
  3170. }
  3171. else if (distance < 20000)
  3172. dist = 1;
  3173. else if (distance < 70000)
  3174. dist = 2;
  3175. else
  3176. dist = 3;
  3177.  
  3178. // 많이 사용했으면 사라진다.
  3179. const int STONE_DETECT_MAX_TRY = 10;
  3180. if (item->GetSocket(0) >= STONE_DETECT_MAX_TRY)
  3181. {
  3182. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이벤트용 감지기가 흔적도 없이 사라집니다."));
  3183. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (DETECT_EVENT_STONE) 0");
  3184. AutoGiveItem(27002);
  3185. return true;
  3186. }
  3187.  
  3188. if (dist)
  3189. {
  3190. char chatbuf[CHAT_MAX_LEN + 1];
  3191. int len = snprintf(chatbuf, sizeof(chatbuf),
  3192. "StoneDetect %u %d %d",
  3193. (DWORD)GetVID(), dist, (int)GetDegreeFromPositionXY(GetX(), item->GetSocket(2), item->GetSocket(1), GetY()));
  3194.  
  3195. if (len < 0 || len >= (int) sizeof(chatbuf))
  3196. len = sizeof(chatbuf) - 1;
  3197.  
  3198. ++len; // \0 문자까지 보내기
  3199.  
  3200. TPacketGCChat pack_chat;
  3201. pack_chat.header = HEADER_GC_CHAT;
  3202. pack_chat.size = sizeof(TPacketGCChat) + len;
  3203. pack_chat.type = CHAT_TYPE_COMMAND;
  3204. pack_chat.id = 0;
  3205. pack_chat.bEmpire = GetDesc()->GetEmpire();
  3206. //pack_chat.id = vid;
  3207.  
  3208. TEMP_BUFFER buf;
  3209. buf.write(&pack_chat, sizeof(TPacketGCChat));
  3210. buf.write(chatbuf, len);
  3211.  
  3212. PacketAround(buf.read_peek(), buf.size());
  3213. }
  3214.  
  3215. }
  3216. break;
  3217.  
  3218. case 27989: // 영석감지기
  3219. case 76006: // 선물용 영석감지기
  3220. {
  3221. LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap(GetMapIndex());
  3222.  
  3223. if (pMap != NULL)
  3224. {
  3225. item->SetSocket(0, item->GetSocket(0) + 1);
  3226.  
  3227. FFindStone f;
  3228.  
  3229. // <Factor> SECTREE::for_each -> SECTREE::for_each_entity
  3230. pMap->for_each(f);
  3231.  
  3232. if (f.m_mapStone.size() > 0)
  3233. {
  3234. std::map<DWORD, LPCHARACTER>::iterator stone = f.m_mapStone.begin();
  3235.  
  3236. DWORD max = UINT_MAX;
  3237. LPCHARACTER pTarget = stone->second;
  3238.  
  3239. while (stone != f.m_mapStone.end())
  3240. {
  3241. DWORD dist = (DWORD)DISTANCE_SQRT(GetX()-stone->second->GetX(), GetY()-stone->second->GetY());
  3242.  
  3243. if (dist != 0 && max > dist)
  3244. {
  3245. max = dist;
  3246. pTarget = stone->second;
  3247. }
  3248. stone++;
  3249. }
  3250.  
  3251. if (pTarget != NULL)
  3252. {
  3253. int val = 3;
  3254.  
  3255. if (max < 10000) val = 2;
  3256. else if (max < 70000) val = 1;
  3257.  
  3258. ChatPacket(CHAT_TYPE_COMMAND, "StoneDetect %u %d %d", (DWORD)GetVID(), val,
  3259. (int)GetDegreeFromPositionXY(GetX(), pTarget->GetY(), pTarget->GetX(), GetY()));
  3260. }
  3261. else
  3262. {
  3263. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("감지기를 작용하였으나 감지되는 영석이 없습니다."));
  3264. }
  3265. }
  3266. else
  3267. {
  3268. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("감지기를 작용하였으나 감지되는 영석이 없습니다."));
  3269. }
  3270.  
  3271. if (item->GetSocket(0) >= 200)
  3272. {
  3273. ChatPacket(CHAT_TYPE_COMMAND, "StoneDetect %u 0 0", (DWORD)GetVID());
  3274. ITEM_MANAGER::instance().RemoveItem(item);
  3275. }
  3276. }
  3277. break;
  3278. }
  3279. break;
  3280.  
  3281. case 27996: // 독병
  3282. item->SetCount(item->GetCount() - 1);
  3283. AttackedByPoison(NULL); // @warme008
  3284. break;
  3285.  
  3286. case 27124: // New Item Bandage for Bleed
  3287. RemoveBleeding();
  3288. break;
  3289.  
  3290. case 27987: // 조개
  3291. // 50 돌조각 47990
  3292. // 30 꽝
  3293. // 10 백진주 47992
  3294. // 7 청진주 47993
  3295. // 3 피진주 47994
  3296. {
  3297. item->SetCount(item->GetCount() - 1);
  3298.  
  3299. int r = number(1, 100);
  3300.  
  3301. if (r <= 50)
  3302. {
  3303. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("조개에서 돌조각이 나왔습니다."));
  3304. AutoGiveItem(27990);
  3305. }
  3306. else
  3307. {
  3308. const int prob_table_gb2312[] =
  3309. {
  3310. 95, 97, 99
  3311. };
  3312.  
  3313. const int * prob_table = prob_table_gb2312;
  3314.  
  3315. if (r <= prob_table[0])
  3316. {
  3317. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("조개가 흔적도 없이 사라집니다."));
  3318. }
  3319. else if (r <= prob_table[1])
  3320. {
  3321. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("조개에서 백진주가 나왔습니다."));
  3322. AutoGiveItem(27992);
  3323. }
  3324. else if (r <= prob_table[2])
  3325. {
  3326. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("조개에서 청진주가 나왔습니다."));
  3327. AutoGiveItem(27993);
  3328. }
  3329. else
  3330. {
  3331. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("조개에서 피진주가 나왔습니다."));
  3332. AutoGiveItem(27994);
  3333. }
  3334. }
  3335. }
  3336. break;
  3337.  
  3338. case 71013: // 축제용폭죽
  3339. CreateFly(number(FLY_FIREWORK1, FLY_FIREWORK6), this);
  3340. item->SetCount(item->GetCount() - 1);
  3341. break;
  3342.  
  3343. case 50100: // 폭죽
  3344. case 50101:
  3345. case 50102:
  3346. case 50103:
  3347. case 50104:
  3348. case 50105:
  3349. case 50106:
  3350. CreateFly(item->GetVnum() - 50100 + FLY_FIREWORK1, this);
  3351. item->SetCount(item->GetCount() - 1);
  3352. break;
  3353.  
  3354. case 50200: // 보따리
  3355. if (LC_IsYMIR() == true || LC_IsKorea() == true)
  3356. {
  3357. if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
  3358. {
  3359. __OpenPrivateShop();
  3360. item->SetCount(item->GetCount() - 1);
  3361. }
  3362. else
  3363. {
  3364. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개인 상점을 열 수 없는 지역입니다"));
  3365. }
  3366. }
  3367. else
  3368. {
  3369. __OpenPrivateShop();
  3370. }
  3371. break;
  3372.  
  3373. case 50299: // cevrimdisi tezgah
  3374. if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
  3375. {
  3376. __OpenOfflineShop();
  3377. }
  3378. else
  3379. {
  3380. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't open offline shop in this place!"));
  3381. }
  3382. break;
  3383.  
  3384. case fishing::FISH_MIND_PILL_VNUM:
  3385. AddAffect(AFFECT_FISH_MIND_PILL, POINT_NONE, 0, AFF_FISH_MIND, 20*60, 0, true);
  3386. item->SetCount(item->GetCount() - 1);
  3387. break;
  3388.  
  3389. case 50301: // 통솔력 수련서
  3390. case 50302:
  3391. case 50303:
  3392. {
  3393. if (IsPolymorphed() == true)
  3394. {
  3395. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑 중에는 능력을 올릴 수 없습니다."));
  3396. return false;
  3397. }
  3398.  
  3399. int lv = GetSkillLevel(SKILL_LEADERSHIP);
  3400.  
  3401. if (lv < item->GetValue(0))
  3402. {
  3403. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 책은 너무 어려워 이해하기가 힘듭니다."));
  3404. return false;
  3405. }
  3406.  
  3407. if (lv >= item->GetValue(1))
  3408. {
  3409. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 책은 아무리 봐도 도움이 될 것 같지 않습니다."));
  3410. return false;
  3411. }
  3412.  
  3413. if (LearnSkillByBook(SKILL_LEADERSHIP))
  3414. {
  3415. ITEM_MANAGER::instance().RemoveItem(item);
  3416.  
  3417. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3418. if (distribution_test_server) iReadDelay /= 3;
  3419.  
  3420. SetSkillNextReadTime(SKILL_LEADERSHIP, get_global_time() + iReadDelay);
  3421. }
  3422. }
  3423. break;
  3424.  
  3425. case 50304: // 연계기 수련서
  3426. case 50305:
  3427. case 50306:
  3428. {
  3429. if (IsPolymorphed())
  3430. {
  3431. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  3432. return false;
  3433.  
  3434. }
  3435. if (GetSkillLevel(SKILL_COMBO) == 0 && GetLevel() < 30)
  3436. {
  3437. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("레벨 30이 되기 전에는 습득할 수 있을 것 같지 않습니다."));
  3438. return false;
  3439. }
  3440.  
  3441. if (GetSkillLevel(SKILL_COMBO) == 1 && GetLevel() < 50)
  3442. {
  3443. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("레벨 50이 되기 전에는 습득할 수 있을 것 같지 않습니다."));
  3444. return false;
  3445. }
  3446.  
  3447. if (GetSkillLevel(SKILL_COMBO) >= 2)
  3448. {
  3449. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("연계기는 더이상 수련할 수 없습니다."));
  3450. return false;
  3451. }
  3452.  
  3453. int iPct = item->GetValue(0);
  3454.  
  3455. if (LearnSkillByBook(SKILL_COMBO, iPct))
  3456. {
  3457. ITEM_MANAGER::instance().RemoveItem(item);
  3458.  
  3459. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3460. if (distribution_test_server) iReadDelay /= 3;
  3461.  
  3462. SetSkillNextReadTime(SKILL_COMBO, get_global_time() + iReadDelay);
  3463. }
  3464. }
  3465. break;
  3466. case 50311: // 언어 수련서
  3467. case 50312:
  3468. case 50313:
  3469. {
  3470. if (IsPolymorphed())
  3471. {
  3472. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  3473. return false;
  3474.  
  3475. }
  3476. DWORD dwSkillVnum = item->GetValue(0);
  3477. int iPct = MINMAX(0, item->GetValue(1), 100);
  3478. if (GetSkillLevel(dwSkillVnum)>=20 || dwSkillVnum-SKILL_LANGUAGE1+1 == GetEmpire())
  3479. {
  3480. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 완벽하게 알아들을 수 있는 언어이다."));
  3481. return false;
  3482. }
  3483.  
  3484. if (LearnSkillByBook(dwSkillVnum, iPct))
  3485. {
  3486. ITEM_MANAGER::instance().RemoveItem(item);
  3487.  
  3488. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3489. if (distribution_test_server) iReadDelay /= 3;
  3490.  
  3491. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  3492. }
  3493. }
  3494. break;
  3495.  
  3496. case 50061 : // 일본 말 소환 스킬 수련서
  3497. {
  3498. if (IsPolymorphed())
  3499. {
  3500. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  3501. return false;
  3502.  
  3503. }
  3504. DWORD dwSkillVnum = item->GetValue(0);
  3505. int iPct = MINMAX(0, item->GetValue(1), 100);
  3506.  
  3507. if (GetSkillLevel(dwSkillVnum) >= 10)
  3508. {
  3509. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 수련할 수 없습니다."));
  3510. return false;
  3511. }
  3512.  
  3513. if (LearnSkillByBook(dwSkillVnum, iPct))
  3514. {
  3515. ITEM_MANAGER::instance().RemoveItem(item);
  3516.  
  3517. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3518. if (distribution_test_server) iReadDelay /= 3;
  3519.  
  3520. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  3521. }
  3522. }
  3523. break;
  3524.  
  3525. case 50314: case 50315: case 50316: // 변신 수련서
  3526. case 50323: case 50324: // 증혈 수련서
  3527. case 50325: case 50326: // 철통 수련서
  3528. {
  3529. if (IsPolymorphed() == true)
  3530. {
  3531. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑 중에는 능력을 올릴 수 없습니다."));
  3532. return false;
  3533. }
  3534.  
  3535. int iSkillLevelLowLimit = item->GetValue(0);
  3536. int iSkillLevelHighLimit = item->GetValue(1);
  3537. int iPct = MINMAX(0, item->GetValue(2), 100);
  3538. int iLevelLimit = item->GetValue(3);
  3539. DWORD dwSkillVnum = 0;
  3540.  
  3541. switch (item->GetVnum())
  3542. {
  3543. case 50314: case 50315: case 50316:
  3544. dwSkillVnum = SKILL_POLYMORPH;
  3545. break;
  3546.  
  3547. case 50323: case 50324:
  3548. dwSkillVnum = SKILL_ADD_HP;
  3549. break;
  3550.  
  3551. case 50325: case 50326:
  3552. dwSkillVnum = SKILL_RESIST_PENETRATE;
  3553. break;
  3554.  
  3555. default:
  3556. return false;
  3557. }
  3558.  
  3559. if (0 == dwSkillVnum)
  3560. return false;
  3561.  
  3562. if (GetLevel() < iLevelLimit)
  3563. {
  3564. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 책을 읽으려면 레벨을 더 올려야 합니다."));
  3565. return false;
  3566. }
  3567.  
  3568. if (GetSkillLevel(dwSkillVnum) >= 40)
  3569. {
  3570. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 수련할 수 없습니다."));
  3571. return false;
  3572. }
  3573.  
  3574. if (GetSkillLevel(dwSkillVnum) < iSkillLevelLowLimit)
  3575. {
  3576. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 책은 너무 어려워 이해하기가 힘듭니다."));
  3577. return false;
  3578. }
  3579.  
  3580. if (GetSkillLevel(dwSkillVnum) >= iSkillLevelHighLimit)
  3581. {
  3582. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 책으로는 더 이상 수련할 수 없습니다."));
  3583. return false;
  3584. }
  3585.  
  3586. if (LearnSkillByBook(dwSkillVnum, iPct))
  3587. {
  3588. ITEM_MANAGER::instance().RemoveItem(item);
  3589.  
  3590. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3591. if (distribution_test_server) iReadDelay /= 3;
  3592.  
  3593. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  3594. }
  3595. }
  3596. break;
  3597.  
  3598. case 50902:
  3599. case 50903:
  3600. case 50904:
  3601. {
  3602. if (IsPolymorphed())
  3603. {
  3604. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  3605. return false;
  3606.  
  3607. }
  3608. DWORD dwSkillVnum = SKILL_CREATE;
  3609. int iPct = MINMAX(0, item->GetValue(1), 100);
  3610.  
  3611. if (GetSkillLevel(dwSkillVnum)>=40)
  3612. {
  3613. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 수련할 수 없습니다."));
  3614. return false;
  3615. }
  3616.  
  3617. if (LearnSkillByBook(dwSkillVnum, iPct))
  3618. {
  3619. ITEM_MANAGER::instance().RemoveItem(item);
  3620.  
  3621. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3622. if (distribution_test_server) iReadDelay /= 3;
  3623.  
  3624. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  3625.  
  3626. if (test_server)
  3627. {
  3628. ChatPacket(CHAT_TYPE_INFO, "[TEST_SERVER] Success to learn skill ");
  3629. }
  3630. }
  3631. else
  3632. {
  3633. if (test_server)
  3634. {
  3635. ChatPacket(CHAT_TYPE_INFO, "[TEST_SERVER] Failed to learn skill ");
  3636. }
  3637. }
  3638. }
  3639. break;
  3640.  
  3641. // MINING
  3642. case ITEM_MINING_SKILL_TRAIN_BOOK:
  3643. {
  3644. if (IsPolymorphed())
  3645. {
  3646. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  3647. return false;
  3648.  
  3649. }
  3650. DWORD dwSkillVnum = SKILL_MINING;
  3651. int iPct = MINMAX(0, item->GetValue(1), 100);
  3652.  
  3653. if (GetSkillLevel(dwSkillVnum)>=40)
  3654. {
  3655. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 수련할 수 없습니다."));
  3656. return false;
  3657. }
  3658.  
  3659. if (LearnSkillByBook(dwSkillVnum, iPct))
  3660. {
  3661. ITEM_MANAGER::instance().RemoveItem(item);
  3662.  
  3663. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3664. if (distribution_test_server) iReadDelay /= 3;
  3665.  
  3666. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  3667. }
  3668. }
  3669. break;
  3670. // END_OF_MINING
  3671.  
  3672. case ITEM_HORSE_SKILL_TRAIN_BOOK:
  3673. {
  3674. if (IsPolymorphed())
  3675. {
  3676. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변신중에는 책을 읽을수 없습니다."));
  3677. return false;
  3678.  
  3679. }
  3680. DWORD dwSkillVnum = SKILL_HORSE;
  3681. int iPct = MINMAX(0, item->GetValue(1), 100);
  3682.  
  3683. if (GetLevel() < 50)
  3684. {
  3685. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아직 승마 스킬을 수련할 수 있는 레벨이 아닙니다."));
  3686. return false;
  3687. }
  3688.  
  3689. if (!test_server && get_global_time() < GetSkillNextReadTime(dwSkillVnum))
  3690. {
  3691. if (FindAffect(AFFECT_SKILL_NO_BOOK_DELAY))
  3692. {
  3693. // 주안술서 사용중에는 시간 제한 무시
  3694. RemoveAffect(AFFECT_SKILL_NO_BOOK_DELAY);
  3695. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("주안술서를 통해 주화입마에서 빠져나왔습니다."));
  3696. }
  3697. else
  3698. {
  3699. SkillLearnWaitMoreTimeMessage(GetSkillNextReadTime(dwSkillVnum) - get_global_time());
  3700. return false;
  3701. }
  3702. }
  3703.  
  3704. if (GetPoint(POINT_HORSE_SKILL) >= 20 ||
  3705. GetSkillLevel(SKILL_HORSE_WILDATTACK) + GetSkillLevel(SKILL_HORSE_CHARGE) + GetSkillLevel(SKILL_HORSE_ESCAPE) >= 60 ||
  3706. GetSkillLevel(SKILL_HORSE_WILDATTACK_RANGE) + GetSkillLevel(SKILL_HORSE_CHARGE) + GetSkillLevel(SKILL_HORSE_ESCAPE) >= 60)
  3707. {
  3708. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 승마 수련서를 읽을 수 없습니다."));
  3709. return false;
  3710. }
  3711.  
  3712. if (number(1, 100) <= iPct)
  3713. {
  3714. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("승마 수련서를 읽어 승마 스킬 포인트를 얻었습니다."));
  3715. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("얻은 포인트로는 승마 스킬의 레벨을 올릴 수 있습니다."));
  3716. PointChange(POINT_HORSE_SKILL, 1);
  3717.  
  3718. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3719. if (distribution_test_server) iReadDelay /= 3;
  3720.  
  3721. if (!test_server)
  3722. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  3723. }
  3724. else
  3725. {
  3726. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("승마 수련서 이해에 실패하였습니다."));
  3727. }
  3728.  
  3729. ITEM_MANAGER::instance().RemoveItem(item);
  3730. }
  3731. break;
  3732.  
  3733. case 70102: // 선두
  3734. case 70103: // 선두
  3735. {
  3736. if (GetAlignment() >= 0)
  3737. return false;
  3738.  
  3739. int delta = MIN(-GetAlignment(), item->GetValue(0));
  3740.  
  3741. sys_log(0, "%s ALIGNMENT ITEM %d", GetName(), delta);
  3742.  
  3743. UpdateAlignment(delta);
  3744. item->SetCount(item->GetCount() - 1);
  3745.  
  3746. if (delta / 10 > 0)
  3747. {
  3748. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("마음이 맑아지는군. 가슴을 짓누르던 무언가가 좀 가벼워진 느낌이야."));
  3749. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("선악치가 %d 증가하였습니다."), delta/10);
  3750. }
  3751. }
  3752. break;
  3753.  
  3754. case 71107: // 천도복숭아
  3755. {
  3756. int val = item->GetValue(0);
  3757. int interval = item->GetValue(1);
  3758. quest::PC* pPC = quest::CQuestManager::instance().GetPC(GetPlayerID());
  3759. int last_use_time = pPC->GetFlag("mythical_peach.last_use_time");
  3760.  
  3761. if (get_global_time() - last_use_time < interval * 60 * 60)
  3762. {
  3763. if (test_server == false)
  3764. {
  3765. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아직 사용할 수 없습니다."));
  3766. return false;
  3767. }
  3768. else
  3769. {
  3770. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("테스트 서버 시간제한 통과"));
  3771. }
  3772. }
  3773.  
  3774. if (GetAlignment() == 200000)
  3775. {
  3776. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("선악치를 더 이상 올릴 수 없습니다."));
  3777. return false;
  3778. }
  3779.  
  3780. if (200000 - GetAlignment() < val * 10)
  3781. {
  3782. val = (200000 - GetAlignment()) / 10;
  3783. }
  3784.  
  3785. int old_alignment = GetAlignment() / 10;
  3786.  
  3787. UpdateAlignment(val*10);
  3788.  
  3789. item->SetCount(item->GetCount()-1);
  3790. pPC->SetFlag("mythical_peach.last_use_time", get_global_time());
  3791.  
  3792. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("마음이 맑아지는군. 가슴을 짓누르던 무언가가 좀 가벼워진 느낌이야."));
  3793. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("선악치가 %d 증가하였습니다."), val);
  3794.  
  3795. char buf[256 + 1];
  3796. snprintf(buf, sizeof(buf), "%d %d", old_alignment, GetAlignment() / 10);
  3797. LogManager::instance().CharLog(this, val, "MYTHICAL_PEACH", buf);
  3798. }
  3799. break;
  3800.  
  3801. case 71109: // 탈석서
  3802. case 72719:
  3803. {
  3804. LPITEM item2;
  3805.  
  3806. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  3807. return false;
  3808.  
  3809. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  3810. return false;
  3811.  
  3812. if (item2->GetSocketCount() == 0)
  3813. return false;
  3814.  
  3815. if (item2->IsEquipped())
  3816. return false;
  3817.  
  3818. switch( item2->GetType() )
  3819. {
  3820. case ITEM_WEAPON:
  3821. break;
  3822. case ITEM_ARMOR:
  3823. switch (item2->GetSubType())
  3824. {
  3825. case ARMOR_EAR:
  3826. case ARMOR_WRIST:
  3827. case ARMOR_NECK:
  3828. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("빼낼 영석이 없습니다"));
  3829. return false;
  3830. }
  3831. break;
  3832.  
  3833. default:
  3834. return false;
  3835. }
  3836.  
  3837. std::stack<long> socket;
  3838.  
  3839. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  3840. socket.push(item2->GetSocket(i));
  3841.  
  3842. int idx = ITEM_SOCKET_MAX_NUM - 1;
  3843.  
  3844. while (socket.size() > 0)
  3845. {
  3846. if (socket.top() > 2 && socket.top() != ITEM_BROKEN_METIN_VNUM)
  3847. break;
  3848.  
  3849. idx--;
  3850. socket.pop();
  3851. }
  3852.  
  3853. if (socket.size() == 0)
  3854. {
  3855. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("빼낼 영석이 없습니다"));
  3856. return false;
  3857. }
  3858.  
  3859. LPITEM pItemReward = AutoGiveItem(socket.top());
  3860.  
  3861. if (pItemReward != NULL)
  3862. {
  3863. item2->SetSocket(idx, 1);
  3864.  
  3865. char buf[256+1];
  3866. snprintf(buf, sizeof(buf), "%s(%u) %s(%u)",
  3867. item2->GetName(), item2->GetID(), pItemReward->GetName(), pItemReward->GetID());
  3868. LogManager::instance().ItemLog(this, item, "USE_DETACHMENT_ONE", buf);
  3869.  
  3870. item->SetCount(item->GetCount() - 1);
  3871. }
  3872. }
  3873. break;
  3874.  
  3875. case 70201: // 탈색제
  3876. case 70202: // 염색약(흰색)
  3877. case 70203: // 염색약(금색)
  3878. case 70204: // 염색약(빨간색)
  3879. case 70205: // 염색약(갈색)
  3880. case 70206: // 염색약(검은색)
  3881. {
  3882. // NEW_HAIR_STYLE_ADD
  3883. if (GetPart(PART_HAIR) >= 1001)
  3884. {
  3885. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("현재 헤어스타일에서는 염색과 탈색이 불가능합니다."));
  3886. }
  3887. // END_NEW_HAIR_STYLE_ADD
  3888. else
  3889. {
  3890. quest::CQuestManager& q = quest::CQuestManager::instance();
  3891. quest::PC* pPC = q.GetPC(GetPlayerID());
  3892.  
  3893. if (pPC)
  3894. {
  3895. int last_dye_level = pPC->GetFlag("dyeing_hair.last_dye_level");
  3896.  
  3897. if (last_dye_level == 0 ||
  3898. last_dye_level+3 <= GetLevel() ||
  3899. item->GetVnum() == 70201)
  3900. {
  3901. SetPart(PART_HAIR, item->GetVnum() - 70201);
  3902.  
  3903. if (item->GetVnum() == 70201)
  3904. pPC->SetFlag("dyeing_hair.last_dye_level", 0);
  3905. else
  3906. pPC->SetFlag("dyeing_hair.last_dye_level", GetLevel());
  3907.  
  3908. item->SetCount(item->GetCount() - 1);
  3909. UpdatePacket();
  3910. }
  3911. else
  3912. {
  3913. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d 레벨이 되어야 다시 염색하실 수 있습니다."), last_dye_level+3);
  3914. }
  3915. }
  3916. }
  3917. }
  3918. break;
  3919.  
  3920. case ITEM_NEW_YEAR_GREETING_VNUM:
  3921. {
  3922. DWORD dwBoxVnum = ITEM_NEW_YEAR_GREETING_VNUM;
  3923. std::vector <DWORD> dwVnums;
  3924. std::vector <DWORD> dwCounts;
  3925. std::vector <LPITEM> item_gets;
  3926. int count = 0;
  3927.  
  3928. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  3929. {
  3930. for (int i = 0; i < count; i++)
  3931. {
  3932. if (dwVnums[i] == CSpecialItemGroup::GOLD)
  3933. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈 %d 냥을 획득했습니다."), dwCounts[i]);
  3934. }
  3935.  
  3936. item->SetCount(item->GetCount() - 1);
  3937. }
  3938. }
  3939. break;
  3940.  
  3941. case ITEM_VALENTINE_ROSE:
  3942. case ITEM_VALENTINE_CHOCOLATE:
  3943. {
  3944. DWORD dwBoxVnum = item->GetVnum();
  3945. std::vector <DWORD> dwVnums;
  3946. std::vector <DWORD> dwCounts;
  3947. std::vector <LPITEM> item_gets(0);
  3948. int count = 0;
  3949.  
  3950.  
  3951. if (((item->GetVnum() == ITEM_VALENTINE_ROSE) && (SEX_MALE==GET_SEX(this))) ||
  3952. ((item->GetVnum() == ITEM_VALENTINE_CHOCOLATE) && (SEX_FEMALE==GET_SEX(this))))
  3953. {
  3954. // 성별이 맞지않아 쓸 수 없다.
  3955. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("성별이 맞지않아 이 아이템을 열 수 없습니다."));
  3956. return false;
  3957. }
  3958.  
  3959.  
  3960. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  3961. item->SetCount(item->GetCount()-1);
  3962. }
  3963. break;
  3964.  
  3965. case ITEM_WHITEDAY_CANDY:
  3966. case ITEM_WHITEDAY_ROSE:
  3967. {
  3968. DWORD dwBoxVnum = item->GetVnum();
  3969. std::vector <DWORD> dwVnums;
  3970. std::vector <DWORD> dwCounts;
  3971. std::vector <LPITEM> item_gets(0);
  3972. int count = 0;
  3973.  
  3974.  
  3975. if (((item->GetVnum() == ITEM_WHITEDAY_CANDY) && (SEX_MALE==GET_SEX(this))) ||
  3976. ((item->GetVnum() == ITEM_WHITEDAY_ROSE) && (SEX_FEMALE==GET_SEX(this))))
  3977. {
  3978. // 성별이 맞지않아 쓸 수 없다.
  3979. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("성별이 맞지않아 이 아이템을 열 수 없습니다."));
  3980. return false;
  3981. }
  3982.  
  3983.  
  3984. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  3985. item->SetCount(item->GetCount()-1);
  3986. }
  3987. break;
  3988.  
  3989. case 50011: // 월광보합
  3990. {
  3991. DWORD dwBoxVnum = 50011;
  3992. std::vector <DWORD> dwVnums;
  3993. std::vector <DWORD> dwCounts;
  3994. std::vector <LPITEM> item_gets(0);
  3995. int count = 0;
  3996.  
  3997. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  3998. {
  3999. for (int i = 0; i < count; i++)
  4000. {
  4001. char buf[50 + 1];
  4002. snprintf(buf, sizeof(buf), "%u %u", dwVnums[i], dwCounts[i]);
  4003. LogManager::instance().ItemLog(this, item, "MOONLIGHT_GET", buf);
  4004.  
  4005. //ITEM_MANAGER::instance().RemoveItem(item);
  4006. item->SetCount(item->GetCount() - 1);
  4007.  
  4008. switch (dwVnums[i])
  4009. {
  4010. case CSpecialItemGroup::GOLD:
  4011. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈 %d 냥을 획득했습니다."), dwCounts[i]);
  4012. break;
  4013.  
  4014. case CSpecialItemGroup::EXP:
  4015. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 부터 신비한 빛이 나옵니다."));
  4016. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d의 경험치를 획득했습니다."), dwCounts[i]);
  4017. break;
  4018.  
  4019. case CSpecialItemGroup::MOB:
  4020. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 몬스터가 나타났습니다!"));
  4021. break;
  4022.  
  4023. case CSpecialItemGroup::SLOW:
  4024. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 빨간 연기를 들이마시자 움직이는 속도가 느려졌습니다!"));
  4025. break;
  4026.  
  4027. case CSpecialItemGroup::DRAIN_HP:
  4028. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자가 갑자기 폭발하였습니다! 생명력이 감소했습니다."));
  4029. break;
  4030.  
  4031. case CSpecialItemGroup::POISON:
  4032. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 녹색 연기를 들이마시자 독이 온몸으로 퍼집니다!"));
  4033. break;
  4034.  
  4035. case CSpecialItemGroup::BLEED:
  4036. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 나온 녹색 연기를 들이마시자 독이 온몸으로 퍼집니다!"));
  4037. break;
  4038.  
  4039. case CSpecialItemGroup::MOB_GROUP:
  4040. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 몬스터가 나타났습니다!"));
  4041. break;
  4042.  
  4043. default:
  4044. if (item_gets[i])
  4045. {
  4046. if (dwCounts[i] > 1)
  4047. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 %s 가 %d 개 나왔습니다."), item_gets[i]->GetName(), dwCounts[i]);
  4048. else
  4049. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상자에서 %s 가 나왔습니다."), item_gets[i]->GetName());
  4050. }
  4051. break;
  4052. }
  4053. }
  4054. }
  4055. else
  4056. {
  4057. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("아무것도 얻을 수 없었습니다."));
  4058. return false;
  4059. }
  4060. }
  4061. break;
  4062.  
  4063. case ITEM_GIVE_STAT_RESET_COUNT_VNUM:
  4064. {
  4065. //PointChange(POINT_GOLD, -iCost);
  4066. PointChange(POINT_STAT_RESET_COUNT, 1);
  4067. item->SetCount(item->GetCount()-1);
  4068. }
  4069. break;
  4070.  
  4071. case 50107:
  4072. {
  4073. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4074. {
  4075. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´e·A Aß¿¡´A AI¿eCO ¼o ¾ø´A ¹°C°AO´I´U."));
  4076. return false;
  4077. }
  4078. EffectPacket(SE_CHINA_FIREWORK);
  4079. // 스턴 공격을 올려준다
  4080. AddAffect(AFFECT_CHINA_FIREWORK, POINT_STUN_PCT, 30, AFF_CHINA_FIREWORK, 5*60, 0, true);
  4081. item->SetCount(item->GetCount()-1);
  4082. }
  4083. break;
  4084.  
  4085. case 50108:
  4086. {
  4087. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4088. {
  4089. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  4090. return false;
  4091. }
  4092.  
  4093. EffectPacket(SE_SPIN_TOP);
  4094. // 스턴 공격을 올려준다
  4095. AddAffect(AFFECT_CHINA_FIREWORK, POINT_STUN_PCT, 30, AFF_CHINA_FIREWORK, 5*60, 0, true);
  4096. item->SetCount(item->GetCount()-1);
  4097. }
  4098. break;
  4099.  
  4100. case ITEM_WONSO_BEAN_VNUM:
  4101. PointChange(POINT_HP, GetMaxHP() - GetHP());
  4102. item->SetCount(item->GetCount()-1);
  4103. break;
  4104.  
  4105. case ITEM_WONSO_SUGAR_VNUM:
  4106. PointChange(POINT_SP, GetMaxSP() - GetSP());
  4107. item->SetCount(item->GetCount()-1);
  4108. break;
  4109.  
  4110. case ITEM_WONSO_FRUIT_VNUM:
  4111. PointChange(POINT_STAMINA, GetMaxStamina()-GetStamina());
  4112. item->SetCount(item->GetCount()-1);
  4113. break;
  4114.  
  4115. case ITEM_ELK_VNUM: // 돈꾸러미
  4116. {
  4117. int iGold = item->GetSocket(0);
  4118. ITEM_MANAGER::instance().RemoveItem(item);
  4119. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈 %d 냥을 획득했습니다."), iGold);
  4120. PointChange(POINT_GOLD, iGold);
  4121. }
  4122. break;
  4123.  
  4124. //군주의 증표
  4125. case 70021:
  4126. {
  4127. int HealPrice = quest::CQuestManager::instance().GetEventFlag("MonarchHealGold");
  4128. if (HealPrice == 0)
  4129. HealPrice = 2000000;
  4130.  
  4131. if (CMonarch::instance().HealMyEmpire(this, HealPrice))
  4132. {
  4133. char szNotice[256];
  4134. snprintf(szNotice, sizeof(szNotice), LC_TEXT("군주의 축복으로 이지역 %s 유저는 HP,SP가 모두 채워집니다."), EMPIRE_NAME(GetEmpire()));
  4135. SendNoticeMap(szNotice, GetMapIndex(), false);
  4136.  
  4137. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("군주의 축복을 사용하였습니다."));
  4138. }
  4139. }
  4140. break;
  4141.  
  4142. case 27995:
  4143. {
  4144. }
  4145. break;
  4146.  
  4147. case 71092 : // 변신 해체부 임시
  4148. {
  4149. if (m_pkChrTarget != NULL)
  4150. {
  4151. if (m_pkChrTarget->IsPolymorphed())
  4152. {
  4153. m_pkChrTarget->SetPolymorph(0);
  4154. m_pkChrTarget->RemoveAffect(AFFECT_POLYMORPH);
  4155. }
  4156. }
  4157. else
  4158. {
  4159. if (IsPolymorphed())
  4160. {
  4161. SetPolymorph(0);
  4162. RemoveAffect(AFFECT_POLYMORPH);
  4163. }
  4164. }
  4165. }
  4166. break;
  4167.  
  4168. case 71051 : // 진재가
  4169. {
  4170. // 유럽, 싱가폴, 베트남 진재가 사용금지
  4171. LPITEM item2;
  4172.  
  4173. if (!IsValidItemPosition(DestCell) || !(item2 = GetInventoryItem(wDestCell)))
  4174. return false;
  4175.  
  4176. if (item2->IsBind())
  4177. {
  4178. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item is already binded."));
  4179. return false;
  4180. }
  4181.  
  4182. if (ITEM_COSTUME == item2->GetType()) // @fixme4
  4183. {
  4184. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("KOSTUMLERDE_KULLANILAMAZ"));
  4185. return false;
  4186. }
  4187.  
  4188. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  4189. return false;
  4190.  
  4191. if (item2->GetAttributeSetIndex() == -1)
  4192. {
  4193. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
  4194. return false;
  4195. }
  4196.  
  4197. if (item2->AddRareAttribute() == true)
  4198. {
  4199. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("성공적으로 속성이 추가 되었습니다"));
  4200.  
  4201. int iAddedIdx = item2->GetRareAttrCount() + 4;
  4202. char buf[21];
  4203. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  4204.  
  4205. LogManager::instance().ItemLog(
  4206. GetPlayerID(),
  4207. item2->GetAttributeType(iAddedIdx),
  4208. item2->GetAttributeValue(iAddedIdx),
  4209. item->GetID(),
  4210. "ADD_RARE_ATTR",
  4211. buf,
  4212. GetDesc()->GetHostName(),
  4213. item->GetOriginalVnum());
  4214.  
  4215. item->SetCount(item->GetCount() - 1);
  4216. }
  4217. else
  4218. {
  4219. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 이 아이템으로 속성을 추가할 수 없습니다"));
  4220. }
  4221. }
  4222. break;
  4223.  
  4224. case 71052:
  4225. {
  4226. LPITEM item2;
  4227.  
  4228. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  4229. return false;
  4230.  
  4231. if (ITEM_COSTUME == item2->GetType()) // @fixme4
  4232. {
  4233. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("KOSTUMLERDE_KULLANILAMAZ"));
  4234. return false;
  4235. }
  4236.  
  4237. if (item2->IsExchanging() == true)
  4238. return false;
  4239.  
  4240. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme3
  4241. return false;
  4242.  
  4243. if (item2->IsBind())
  4244. {
  4245. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item is already binded."));
  4246. return false;
  4247. }
  4248.  
  4249. if (item2->GetAttributeSetIndex() == -1)
  4250. {
  4251. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
  4252. return false;
  4253. }
  4254.  
  4255. if (item2->GetAttributeCount() == 5)
  4256. {
  4257. item2->RemoveAttributeAt(4);
  4258. item2->AddAttribute();
  4259. item->SetCount(item->GetCount()-1);
  4260. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_SUCCESS_MARBLE"));
  4261. }
  4262. else if (item2->GetAttributeCount() == 4)
  4263. {
  4264. item2->AddAttribute();
  4265. item->SetCount(item->GetCount()-1);
  4266. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_SUCCESS_MARBLE"));
  4267. }
  4268. else
  4269. {
  4270. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NEW_ATTRIBUTE_MARBLE_ENOUGH_ATTR_COUNT"));
  4271. }
  4272. }
  4273. break;
  4274.  
  4275. case ITEM_AUTO_HP_RECOVERY_S:
  4276. case ITEM_AUTO_HP_RECOVERY_M:
  4277. case ITEM_AUTO_HP_RECOVERY_L:
  4278. case ITEM_AUTO_HP_RECOVERY_X:
  4279. case ITEM_AUTO_SP_RECOVERY_S:
  4280. case ITEM_AUTO_SP_RECOVERY_M:
  4281. case ITEM_AUTO_SP_RECOVERY_L:
  4282. case ITEM_AUTO_SP_RECOVERY_X:
  4283. // 무시무시하지만 이전에 하던 걸 고치기는 무섭고...
  4284. // 그래서 그냥 하드 코딩. 선물 상자용 자동물약 아이템들.
  4285. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
  4286. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
  4287. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
  4288. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
  4289. case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
  4290. case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
  4291. {
  4292. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4293. {
  4294. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  4295. return false;
  4296. }
  4297.  
  4298. EAffectTypes type = AFFECT_NONE;
  4299. bool isSpecialPotion = false;
  4300.  
  4301. switch (item->GetVnum())
  4302. {
  4303. case ITEM_AUTO_HP_RECOVERY_X:
  4304. isSpecialPotion = true;
  4305.  
  4306. case ITEM_AUTO_HP_RECOVERY_S:
  4307. case ITEM_AUTO_HP_RECOVERY_M:
  4308. case ITEM_AUTO_HP_RECOVERY_L:
  4309. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
  4310. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
  4311. case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
  4312. type = AFFECT_AUTO_HP_RECOVERY;
  4313. break;
  4314.  
  4315. case ITEM_AUTO_SP_RECOVERY_X:
  4316. isSpecialPotion = true;
  4317.  
  4318. case ITEM_AUTO_SP_RECOVERY_S:
  4319. case ITEM_AUTO_SP_RECOVERY_M:
  4320. case ITEM_AUTO_SP_RECOVERY_L:
  4321. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
  4322. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
  4323. case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
  4324. type = AFFECT_AUTO_SP_RECOVERY;
  4325. break;
  4326. }
  4327.  
  4328. if (AFFECT_NONE == type)
  4329. break;
  4330.  
  4331. if (item->GetCount() > 1)
  4332. {
  4333. int pos = GetEmptyInventory(item->GetSize());
  4334.  
  4335. if (-1 == pos)
  4336. {
  4337. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지품에 빈 공간이 없습니다."));
  4338. break;
  4339. }
  4340.  
  4341. item->SetCount( item->GetCount() - 1 );
  4342.  
  4343. LPITEM item2 = ITEM_MANAGER::instance().CreateItem( item->GetVnum(), 1 );
  4344. item2->AddToCharacter(this, TItemPos(INVENTORY, pos));
  4345.  
  4346. if (item->GetSocket(1) != 0)
  4347. {
  4348. item2->SetSocket(1, item->GetSocket(1));
  4349. }
  4350.  
  4351. item = item2;
  4352. }
  4353.  
  4354. CAffect* pAffect = FindAffect( type );
  4355.  
  4356. if (NULL == pAffect)
  4357. {
  4358. EPointTypes bonus = POINT_NONE;
  4359.  
  4360. if (true == isSpecialPotion)
  4361. {
  4362. if (type == AFFECT_AUTO_HP_RECOVERY)
  4363. {
  4364. bonus = POINT_MAX_HP_PCT;
  4365. }
  4366. else if (type == AFFECT_AUTO_SP_RECOVERY)
  4367. {
  4368. bonus = POINT_MAX_SP_PCT;
  4369. }
  4370. }
  4371.  
  4372. AddAffect( type, bonus, 4, item->GetID(), INFINITE_AFFECT_DURATION, 0, true, false);
  4373.  
  4374. item->Lock(true);
  4375. item->SetSocket(0, true);
  4376.  
  4377. AutoRecoveryItemProcess( type );
  4378. }
  4379. else
  4380. {
  4381. if (item->GetID() == pAffect->dwFlag)
  4382. {
  4383. RemoveAffect( pAffect );
  4384.  
  4385. item->Lock(false);
  4386. item->SetSocket(0, false);
  4387. }
  4388. else
  4389. {
  4390. LPITEM old = FindItemByID( pAffect->dwFlag );
  4391.  
  4392. if (NULL != old)
  4393. {
  4394. old->Lock(false);
  4395. old->SetSocket(0, false);
  4396. }
  4397.  
  4398. RemoveAffect( pAffect );
  4399.  
  4400. EPointTypes bonus = POINT_NONE;
  4401.  
  4402. if (true == isSpecialPotion)
  4403. {
  4404. if (type == AFFECT_AUTO_HP_RECOVERY)
  4405. {
  4406. bonus = POINT_MAX_HP_PCT;
  4407. }
  4408. else if (type == AFFECT_AUTO_SP_RECOVERY)
  4409. {
  4410. bonus = POINT_MAX_SP_PCT;
  4411. }
  4412. }
  4413.  
  4414. AddAffect( type, bonus, 4, item->GetID(), INFINITE_AFFECT_DURATION, 0, true, false);
  4415.  
  4416. item->Lock(true);
  4417. item->SetSocket(0, true);
  4418.  
  4419. AutoRecoveryItemProcess( type );
  4420. }
  4421. }
  4422. }
  4423. break;
  4424. }
  4425. break;
  4426.  
  4427. case USE_CLEAR:
  4428. {
  4429. RemoveBadAffect();
  4430. item->SetCount(item->GetCount() - 1);
  4431. }
  4432. break;
  4433.  
  4434. case USE_INVISIBILITY:
  4435. {
  4436. if (item->GetVnum() == 70026)
  4437. {
  4438. quest::CQuestManager& q = quest::CQuestManager::instance();
  4439. quest::PC* pPC = q.GetPC(GetPlayerID());
  4440.  
  4441. if (pPC != NULL)
  4442. {
  4443. int last_use_time = pPC->GetFlag("mirror_of_disapper.last_use_time");
  4444.  
  4445. if (get_global_time() - last_use_time < 10*60)
  4446. {
  4447. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아직 사용할 수 없습니다."));
  4448. return false;
  4449. }
  4450.  
  4451. pPC->SetFlag("mirror_of_disapper.last_use_time", get_global_time());
  4452. }
  4453. }
  4454.  
  4455. AddAffect(AFFECT_INVISIBILITY, POINT_NONE, 0, AFF_INVISIBILITY, 300, 0, true);
  4456. item->SetCount(item->GetCount() - 1);
  4457. }
  4458. break;
  4459.  
  4460. case USE_POTION_NODELAY:
  4461. {
  4462. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4463. {
  4464. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
  4465. {
  4466. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  4467. return false;
  4468. }
  4469.  
  4470. switch (item->GetVnum())
  4471. {
  4472. case 70020 :
  4473. case 71018 :
  4474. case 71019 :
  4475. case 71020 :
  4476. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
  4477. {
  4478. if (m_nPotionLimit <= 0)
  4479. {
  4480. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("사용 제한량을 초과하였습니다."));
  4481. return false;
  4482. }
  4483. }
  4484. break;
  4485.  
  4486. default :
  4487. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  4488. return false;
  4489. }
  4490. }
  4491.  
  4492. bool used = false;
  4493.  
  4494. if (item->GetValue(0) != 0) // HP 절대값 회복
  4495. {
  4496. if (GetHP() < GetMaxHP())
  4497. {
  4498. PointChange(POINT_HP, item->GetValue(0) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  4499. EffectPacket(SE_HPUP_RED);
  4500. used = TRUE;
  4501. }
  4502. }
  4503.  
  4504. if (item->GetValue(1) != 0) // SP 절대값 회복
  4505. {
  4506. if (GetSP() < GetMaxSP())
  4507. {
  4508. PointChange(POINT_SP, item->GetValue(1) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  4509. EffectPacket(SE_SPUP_BLUE);
  4510. used = TRUE;
  4511. }
  4512. }
  4513.  
  4514. if (item->GetValue(3) != 0) // HP % 회복
  4515. {
  4516. if (GetHP() < GetMaxHP())
  4517. {
  4518. PointChange(POINT_HP, item->GetValue(3) * GetMaxHP() / 100);
  4519. EffectPacket(SE_HPUP_RED);
  4520. used = TRUE;
  4521. }
  4522. }
  4523.  
  4524. if (item->GetValue(4) != 0) // SP % 회복
  4525. {
  4526. if (GetSP() < GetMaxSP())
  4527. {
  4528. PointChange(POINT_SP, item->GetValue(4) * GetMaxSP() / 100);
  4529. EffectPacket(SE_SPUP_BLUE);
  4530. used = TRUE;
  4531. }
  4532. }
  4533.  
  4534. if (used)
  4535. {
  4536. if (item->GetVnum() == 50085 || item->GetVnum() == 50086)
  4537. {
  4538. if (test_server)
  4539. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("월병 또는 종자 를 사용하였습니다"));
  4540. SetUseSeedOrMoonBottleTime();
  4541. }
  4542. if (GetDungeon())
  4543. GetDungeon()->UsePotion(this);
  4544.  
  4545. if (GetWarMap())
  4546. GetWarMap()->UsePotion(this, item);
  4547.  
  4548. m_nPotionLimit--;
  4549.  
  4550. //RESTRICT_USE_SEED_OR_MOONBOTTLE
  4551. item->SetCount(item->GetCount() - 1);
  4552. //END_RESTRICT_USE_SEED_OR_MOONBOTTLE
  4553. }
  4554. }
  4555. break;
  4556.  
  4557. case USE_POTION:
  4558. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4559. {
  4560. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
  4561. {
  4562. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  4563. return false;
  4564. }
  4565.  
  4566. switch (item->GetVnum())
  4567. {
  4568. case 27001 :
  4569. case 27002 :
  4570. case 27003 :
  4571. case 27004 :
  4572. case 27005 :
  4573. case 27006 :
  4574. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
  4575. {
  4576. if (m_nPotionLimit <= 0)
  4577. {
  4578. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("사용 제한량을 초과하였습니다."));
  4579. return false;
  4580. }
  4581. }
  4582. break;
  4583.  
  4584. default :
  4585. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
  4586. return false;
  4587. }
  4588. }
  4589.  
  4590. if (item->GetValue(1) != 0)
  4591. {
  4592. if (GetPoint(POINT_SP_RECOVERY) + GetSP() >= GetMaxSP())
  4593. {
  4594. return false;
  4595. }
  4596.  
  4597. PointChange(POINT_SP_RECOVERY, item->GetValue(1) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
  4598. StartAffectEvent();
  4599. EffectPacket(SE_SPUP_BLUE);
  4600. }
  4601.  
  4602. if (item->GetValue(0) != 0)
  4603. {
  4604. if (GetPoint(POINT_HP_RECOVERY) + GetHP() >= GetMaxHP())
  4605. {
  4606. return false;
  4607. }
  4608.  
  4609. PointChange(POINT_HP_RECOVERY, item->GetValue(0) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
  4610. StartAffectEvent();
  4611. EffectPacket(SE_HPUP_RED);
  4612. }
  4613.  
  4614. if (GetDungeon())
  4615. GetDungeon()->UsePotion(this);
  4616.  
  4617. if (GetWarMap())
  4618. GetWarMap()->UsePotion(this, item);
  4619.  
  4620. item->SetCount(item->GetCount() - 1);
  4621. m_nPotionLimit--;
  4622. break;
  4623.  
  4624. case USE_POTION_CONTINUE:
  4625. {
  4626. if (item->GetValue(0) != 0)
  4627. {
  4628. AddAffect(AFFECT_HP_RECOVER_CONTINUE, POINT_HP_RECOVER_CONTINUE, item->GetValue(0), 0, item->GetValue(2), 0, true);
  4629. }
  4630. else if (item->GetValue(1) != 0)
  4631. {
  4632. AddAffect(AFFECT_SP_RECOVER_CONTINUE, POINT_SP_RECOVER_CONTINUE, item->GetValue(1), 0, item->GetValue(2), 0, true);
  4633. }
  4634. else
  4635. return false;
  4636. }
  4637.  
  4638. if (GetDungeon())
  4639. GetDungeon()->UsePotion(this);
  4640.  
  4641. if (GetWarMap())
  4642. GetWarMap()->UsePotion(this, item);
  4643.  
  4644. item->SetCount(item->GetCount() - 1);
  4645. break;
  4646.  
  4647. case USE_ABILITY_UP:
  4648. {
  4649. #ifdef ENABLE_YMIR_AFFECT_FIX
  4650. if ((CheckTimeUsed(item) == false))
  4651. {
  4652. return false;
  4653. }
  4654. #endif
  4655. switch (item->GetValue(0))
  4656. {
  4657. case APPLY_MOV_SPEED:
  4658. if (FindAffect(AFFECT_MOV_SPEED)) // @fixme61
  4659. {
  4660. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_ETKI_DEVAM_EDIYOR"));
  4661. return false;
  4662. }
  4663. AddAffect(AFFECT_MOV_SPEED, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true);
  4664. EffectPacket(SE_DXUP_PURPLE); //purple potion
  4665. break;
  4666.  
  4667. case APPLY_ATT_SPEED:
  4668. if (FindAffect(AFFECT_ATT_SPEED)) // @fixme61
  4669. {
  4670. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_ETKI_DEVAM_EDIYOR"));
  4671. return false;
  4672. }
  4673. AddAffect(AFFECT_ATT_SPEED, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true);
  4674. EffectPacket(SE_SPEEDUP_GREEN); //green potion
  4675. break;
  4676.  
  4677. case APPLY_STR:
  4678. AddAffect(AFFECT_STR, POINT_ST, item->GetValue(2), 0, item->GetValue(1), 0, true);
  4679. break;
  4680.  
  4681. case APPLY_DEX:
  4682. AddAffect(AFFECT_DEX, POINT_DX, item->GetValue(2), 0, item->GetValue(1), 0, true);
  4683. break;
  4684.  
  4685. case APPLY_CON:
  4686. AddAffect(AFFECT_CON, POINT_HT, item->GetValue(2), 0, item->GetValue(1), 0, true);
  4687. break;
  4688.  
  4689. case APPLY_INT:
  4690. AddAffect(AFFECT_INT, POINT_IQ, item->GetValue(2), 0, item->GetValue(1), 0, true);
  4691. break;
  4692.  
  4693. case APPLY_CAST_SPEED:
  4694. AddAffect(AFFECT_CAST_SPEED, POINT_CASTING_SPEED, item->GetValue(2), 0, item->GetValue(1), 0, true);
  4695. break;
  4696.  
  4697. case APPLY_ATT_GRADE_BONUS:
  4698. AddAffect(AFFECT_ATT_GRADE, POINT_ATT_GRADE_BONUS,
  4699. item->GetValue(2), 0, item->GetValue(1), 0, true);
  4700. break;
  4701.  
  4702. case APPLY_DEF_GRADE_BONUS:
  4703. AddAffect(AFFECT_DEF_GRADE, POINT_DEF_GRADE_BONUS,
  4704. item->GetValue(2), 0, item->GetValue(1), 0, true);
  4705. break;
  4706. }
  4707. }
  4708.  
  4709. if (GetDungeon())
  4710. GetDungeon()->UsePotion(this);
  4711.  
  4712. if (GetWarMap())
  4713. GetWarMap()->UsePotion(this, item);
  4714.  
  4715. item->SetCount(item->GetCount() - 1);
  4716. break;
  4717.  
  4718. case USE_TALISMAN:
  4719. {
  4720. const int TOWN_PORTAL = 1;
  4721. const int MEMORY_PORTAL = 2;
  4722.  
  4723.  
  4724. // gm_guild_build, oxevent 맵에서 귀환부 귀환기억부 를 사용못하게 막음
  4725. if (GetMapIndex() == 200 || GetMapIndex() == 113)
  4726. {
  4727. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("현재 위치에서 사용할 수 없습니다."));
  4728. return false;
  4729. }
  4730.  
  4731. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4732. {
  4733. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 중에는 이용할 수 없는 물품입니다."));
  4734. return false;
  4735. }
  4736.  
  4737. if (m_pkWarpEvent)
  4738. {
  4739. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이동할 준비가 되어있음으로 귀환부를 사용할수 없습니다"));
  4740. return false;
  4741. }
  4742.  
  4743. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  4744. int consumeLife = CalculateConsume(this);
  4745.  
  4746. if (consumeLife < 0)
  4747. return false;
  4748. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  4749.  
  4750. if (item->GetValue(0) == TOWN_PORTAL) // 귀환부
  4751. {
  4752. if (item->GetSocket(0) == 0)
  4753. {
  4754. if (!GetDungeon())
  4755. if (!GiveRecallItem(item))
  4756. return false;
  4757.  
  4758. PIXEL_POSITION posWarp;
  4759.  
  4760. if (SECTREE_MANAGER::instance().GetRecallPositionByEmpire(GetMapIndex(), GetEmpire(), posWarp))
  4761. {
  4762. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  4763. PointChange(POINT_HP, -consumeLife, false);
  4764. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  4765.  
  4766. WarpSet(posWarp.x, posWarp.y);
  4767. }
  4768. else
  4769. {
  4770. sys_err("CHARACTER::UseItem : cannot find spawn position (name %s, %d x %d)", GetName(), GetX(), GetY());
  4771. }
  4772. }
  4773. else
  4774. {
  4775. if (test_server)
  4776. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("원래 위치로 복귀"));
  4777.  
  4778. ProcessRecallItem(item);
  4779. }
  4780. }
  4781. else if (item->GetValue(0) == MEMORY_PORTAL) // 귀환기억부
  4782. {
  4783. if (item->GetSocket(0) == 0)
  4784. {
  4785. if (GetDungeon())
  4786. {
  4787. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("던전 안에서는 %s%s 사용할 수 없습니다."),
  4788. item->GetName(),
  4789. "");
  4790. return false;
  4791. }
  4792.  
  4793. if (!GiveRecallItem(item))
  4794. return false;
  4795. }
  4796. else
  4797. {
  4798. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  4799. PointChange(POINT_HP, -consumeLife, false);
  4800. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  4801.  
  4802. ProcessRecallItem(item);
  4803. }
  4804. }
  4805. }
  4806. break;
  4807.  
  4808. case USE_TUNING:
  4809. case USE_DETACHMENT:
  4810. {
  4811. LPITEM item2;
  4812.  
  4813. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  4814. return false;
  4815.  
  4816. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  4817. return false;
  4818.  
  4819. #ifdef __SASH_SYSTEM__
  4820. if (item->GetValue(0) == SASH_CLEAN_ATTR_VALUE0)
  4821. {
  4822. if (!CleanSashAttr(item, item2))
  4823. return false;
  4824.  
  4825. return true;
  4826. }
  4827. #endif
  4828. #ifdef __CHANGELOOK_SYSTEM__
  4829. if (item->GetValue(0) == CL_CLEAN_ATTR_VALUE0)
  4830. {
  4831. if (!CleanTransmutation(item, item2))
  4832. return false;
  4833.  
  4834. return true;
  4835. }
  4836. #endif
  4837. if (item2->GetVnum() >= 28330 && item2->GetVnum() <= 28343) // 영석+3
  4838. {
  4839. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("+3 영석은 이 아이템으로 개량할 수 없습니다"));
  4840. return false;
  4841. }
  4842.  
  4843. if (item2->GetVnum() >= 28430 && item2->GetVnum() <= 28443) // 영석+4
  4844. {
  4845. if (item->GetVnum() == 71056) // 청룡의숨결
  4846. {
  4847. RefineItem(item, item2);
  4848. }
  4849. else
  4850. {
  4851. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("영석은 이 아이템으로 개량할 수 없습니다"));
  4852. }
  4853. }
  4854. else
  4855. {
  4856. RefineItem(item, item2);
  4857. }
  4858. }
  4859. break;
  4860.  
  4861. // ACCESSORY_REFINE & ADD/CHANGE_ATTRIBUTES
  4862. case USE_PUT_INTO_BELT_SOCKET:
  4863. case USE_PUT_INTO_RING_SOCKET:
  4864. case USE_PUT_INTO_ACCESSORY_SOCKET:
  4865. case USE_ADD_ACCESSORY_SOCKET:
  4866. case USE_CLEAN_SOCKET:
  4867. case USE_CHANGE_ATTRIBUTE:
  4868. case USE_CHANGE_ATTRIBUTE2 :
  4869. case USE_ADD_ATTRIBUTE:
  4870. case USE_ADD_ATTRIBUTE2:
  4871. {
  4872. LPITEM item2;
  4873. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  4874. return false;
  4875.  
  4876. if (item2->IsEquipped())
  4877. {
  4878. BuffOnAttr_RemoveBuffsFromItem(item2);
  4879. }
  4880.  
  4881. if (item2->IsBind() && item->GetSubType() != USE_PUT_INTO_BELT_SOCKET && item->GetSubType() != USE_PUT_INTO_RING_SOCKET && item->GetSubType() != USE_PUT_INTO_ACCESSORY_SOCKET && item->GetSubType() != USE_ADD_ACCESSORY_SOCKET)
  4882. {
  4883. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't do this because this item is binded."));
  4884. return false;
  4885. }
  4886.  
  4887. if (item2->IsUntilBind() && item->GetSubType() != USE_PUT_INTO_BELT_SOCKET && item->GetSubType() != USE_PUT_INTO_RING_SOCKET && item->GetSubType() != USE_PUT_INTO_ACCESSORY_SOCKET && item->GetSubType() != USE_ADD_ACCESSORY_SOCKET)
  4888. {
  4889. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't do this because this until unbind process."));
  4890. return false;
  4891. }
  4892.  
  4893. // [NOTE] 코스튬 아이템에는 아이템 최초 생성시 랜덤 속성을 부여하되, 재경재가 등등은 막아달라는 요청이 있었음.
  4894. // 원래 ANTI_CHANGE_ATTRIBUTE 같은 아이템 Flag를 추가하여 기획 레벨에서 유연하게 컨트롤 할 수 있도록 할 예정이었으나
  4895. // 그딴거 필요없으니 닥치고 빨리 해달래서 그냥 여기서 막음... -_-
  4896. if (ITEM_COSTUME == item2->GetType())
  4897. {
  4898. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
  4899. return false;
  4900. }
  4901.  
  4902. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  4903. return false;
  4904.  
  4905. switch (item->GetSubType())
  4906. {
  4907. case USE_CLEAN_SOCKET:
  4908. {
  4909. int i;
  4910. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  4911. {
  4912. if (item2->GetSocket(i) == ITEM_BROKEN_METIN_VNUM)
  4913. break;
  4914. }
  4915.  
  4916. if (i == ITEM_SOCKET_MAX_NUM)
  4917. {
  4918. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("청소할 석이 박혀있지 않습니다."));
  4919. return false;
  4920. }
  4921.  
  4922. int j = 0;
  4923.  
  4924. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  4925. {
  4926. if (item2->GetSocket(i) != ITEM_BROKEN_METIN_VNUM && item2->GetSocket(i) != 0)
  4927. item2->SetSocket(j++, item2->GetSocket(i));
  4928. }
  4929.  
  4930. for (; j < ITEM_SOCKET_MAX_NUM; ++j)
  4931. {
  4932. if (item2->GetSocket(j) > 0)
  4933. item2->SetSocket(j, 1);
  4934. }
  4935.  
  4936. {
  4937. char buf[21];
  4938. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  4939. LogManager::instance().ItemLog(this, item, "CLEAN_SOCKET", buf);
  4940. }
  4941.  
  4942. item->SetCount(item->GetCount() - 1);
  4943.  
  4944. }
  4945. break;
  4946.  
  4947. case USE_CHANGE_ATTRIBUTE :
  4948. case USE_CHANGE_ATTRIBUTE2 : // @fixme123
  4949. if (item2->GetAttributeSetIndex() == -1)
  4950. {
  4951. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
  4952. return false;
  4953. }
  4954.  
  4955. if (item2->GetAttributeCount() == 0)
  4956. {
  4957. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("변경할 속성이 없습니다."));
  4958. return false;
  4959. }
  4960.  
  4961. if (GM_PLAYER == GetGMLevel() && false == test_server)
  4962. {
  4963. //
  4964. // Event Flag 를 통해 이전에 아이템 속성 변경을 한 시간으로 부터 충분한 시간이 흘렀는지 검사하고
  4965. // 시간이 충분히 흘렀다면 현재 속성변경에 대한 시간을 설정해 준다.
  4966. //
  4967.  
  4968. DWORD dwChangeItemAttrCycle = quest::CQuestManager::instance().GetEventFlag(msc_szChangeItemAttrCycleFlag);
  4969. if (dwChangeItemAttrCycle < msc_dwDefaultChangeItemAttrCycle)
  4970. dwChangeItemAttrCycle = msc_dwDefaultChangeItemAttrCycle;
  4971. }
  4972.  
  4973. if (item->GetSubType() == USE_CHANGE_ATTRIBUTE2)
  4974. {
  4975. int aiChangeProb[ITEM_ATTRIBUTE_MAX_LEVEL] =
  4976. {
  4977. 0, 0, 30, 40, 3
  4978. };
  4979.  
  4980. item2->ChangeAttribute(aiChangeProb);
  4981. }
  4982. else if (item->GetVnum() == 76014)
  4983. {
  4984. int aiChangeProb[ITEM_ATTRIBUTE_MAX_LEVEL] =
  4985. {
  4986. 0, 10, 50, 39, 1
  4987. };
  4988.  
  4989. item2->ChangeAttribute(aiChangeProb);
  4990. }
  4991.  
  4992. else
  4993. {
  4994. // 연재경 특수처리
  4995. // 절대로 연재가 추가 안될거라 하여 하드 코딩함.
  4996. if (item->GetVnum() == 71151 || item->GetVnum() == 76023)
  4997. {
  4998. if ((item2->GetType() == ITEM_WEAPON)
  4999. || (item2->GetType() == ITEM_ARMOR && item2->GetSubType() == ARMOR_BODY))
  5000. {
  5001. bool bCanUse = true;
  5002. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  5003. {
  5004. if (item2->GetLimitType(i) == LIMIT_LEVEL && item2->GetLimitValue(i) > 40)
  5005. {
  5006. bCanUse = false;
  5007. break;
  5008. }
  5009. }
  5010. if (false == bCanUse)
  5011. {
  5012. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SADECE_40_LEVEL"));
  5013. break;
  5014. }
  5015. }
  5016. else
  5017. {
  5018. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SADECE_40_LEVEL"));
  5019. break;
  5020. }
  5021. }
  5022. item2->ChangeAttribute();
  5023. }
  5024.  
  5025. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경하였습니다."));
  5026. {
  5027. char buf[21];
  5028. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5029. LogManager::instance().ItemLog(this, item, "CHANGE_ATTRIBUTE", buf);
  5030. }
  5031.  
  5032. item->SetCount(item->GetCount() - 1);
  5033. break;
  5034.  
  5035. case USE_ADD_ATTRIBUTE :
  5036. if (ITEM_COSTUME == item2->GetType())
  5037. {
  5038. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼O¼ºA≫ º?°æCO ¼o ¾ø´A ¾ÆAIAUAO´I´U."));
  5039. return false;
  5040. }
  5041.  
  5042. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  5043. return false;
  5044.  
  5045. if (item2->GetAttributeSetIndex() == -1)
  5046. {
  5047. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
  5048. return false;
  5049. }
  5050.  
  5051. if (item2->GetAttributeCount() < 4)
  5052. {
  5053. // 연재가 특수처리
  5054. // 절대로 연재가 추가 안될거라 하여 하드 코딩함.
  5055. if (item->GetVnum() == 71152 || item->GetVnum() == 76024)
  5056. {
  5057. if ((item2->GetType() == ITEM_WEAPON)
  5058. || (item2->GetType() == ITEM_ARMOR && item2->GetSubType() == ARMOR_BODY))
  5059. {
  5060. bool bCanUse = true;
  5061. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  5062. {
  5063. if (item2->GetLimitType(i) == LIMIT_LEVEL && item2->GetLimitValue(i) > 40)
  5064. {
  5065. bCanUse = false;
  5066. break;
  5067. }
  5068. }
  5069. if (false == bCanUse)
  5070. {
  5071. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SADECE_40_LEVEL"));
  5072. break;
  5073. }
  5074. }
  5075. else
  5076. {
  5077. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SADECE_40_LEVEL"));
  5078. break;
  5079. }
  5080. }
  5081. char buf[21];
  5082. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5083.  
  5084. if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
  5085. {
  5086. item2->AddAttribute();
  5087. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 성공하였습니다."));
  5088.  
  5089. int iAddedIdx = item2->GetAttributeCount() - 1;
  5090. LogManager::instance().ItemLog(
  5091. GetPlayerID(),
  5092. item2->GetAttributeType(iAddedIdx),
  5093. item2->GetAttributeValue(iAddedIdx),
  5094. item->GetID(),
  5095. "ADD_ATTRIBUTE_SUCCESS",
  5096. buf,
  5097. GetDesc()->GetHostName(),
  5098. item->GetOriginalVnum());
  5099. }
  5100. else
  5101. {
  5102. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 실패하였습니다."));
  5103. LogManager::instance().ItemLog(this, item, "ADD_ATTRIBUTE_FAIL", buf);
  5104. }
  5105.  
  5106. item->SetCount(item->GetCount() - 1);
  5107. }
  5108. else
  5109. {
  5110. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더이상 이 아이템을 이용하여 속성을 추가할 수 없습니다."));
  5111. }
  5112. break;
  5113.  
  5114. case USE_ADD_ATTRIBUTE2 :
  5115. if (ITEM_COSTUME == item2->GetType())
  5116. {
  5117. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼O¼ºA≫ º?°æCO ¼o ¾ø´A ¾ÆAIAUAO´I´U."));
  5118. return false;
  5119. }
  5120.  
  5121. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  5122. return false;
  5123.  
  5124. if (item2->GetAttributeSetIndex() == -1)
  5125. {
  5126. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성을 변경할 수 없는 아이템입니다."));
  5127. return false;
  5128. }
  5129.  
  5130. // 속성이 이미 4개 추가 되었을 때만 속성을 추가 가능하다.
  5131. if (item2->GetAttributeCount() == 4)
  5132. {
  5133. char buf[21];
  5134. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5135.  
  5136. // 5. efsun duzenlemesi
  5137. if ((number(1, 100) <= aiItemAttributeAddPercent[4]))
  5138. {
  5139. item2->AddAttribute();
  5140. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 성공하였습니다."));
  5141.  
  5142. int iAddedIdx = item2->GetAttributeCount() - 1;
  5143. LogManager::instance().ItemLog(
  5144. GetPlayerID(),
  5145. item2->GetAttributeType(iAddedIdx),
  5146. item2->GetAttributeValue(iAddedIdx),
  5147. item->GetID(),
  5148. "ADD_ATTRIBUTE2_SUCCESS",
  5149. buf,
  5150. GetDesc()->GetHostName(),
  5151. item->GetOriginalVnum());
  5152. }
  5153. else
  5154. {
  5155. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 실패하였습니다."));
  5156. LogManager::instance().ItemLog(this, item, "ADD_ATTRIBUTE2_FAIL", buf);
  5157. }
  5158.  
  5159. item->SetCount(item->GetCount() - 1);
  5160. }
  5161. else if (item2->GetAttributeCount() == 5)
  5162. {
  5163. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 이 아이템을 이용하여 속성을 추가할 수 없습니다."));
  5164. }
  5165. else if (item2->GetAttributeCount() < 4)
  5166. {
  5167. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("먼저 재가비서를 이용하여 속성을 추가시켜 주세요."));
  5168. }
  5169. else
  5170. {
  5171. // wtf ?!
  5172. sys_err("ADD_ATTRIBUTE2 : Item has wrong AttributeCount(%d)", item2->GetAttributeCount());
  5173. }
  5174. break;
  5175.  
  5176. case USE_ADD_ACCESSORY_SOCKET:
  5177. {
  5178. char buf[21];
  5179. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5180.  
  5181. if (item2->IsAccessoryForSocket())
  5182. {
  5183. if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
  5184. {
  5185. if (number(1, 100) <= 80)
  5186. {
  5187. item2->SetAccessorySocketMaxGrade(item2->GetAccessorySocketMaxGrade() + 1);
  5188. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소켓이 성공적으로 추가되었습니다."));
  5189. LogManager::instance().ItemLog(this, item, "ADD_SOCKET_SUCCESS", buf);
  5190. }
  5191. else
  5192. {
  5193. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소켓 추가에 실패하였습니다."));
  5194. LogManager::instance().ItemLog(this, item, "ADD_SOCKET_FAIL", buf);
  5195. }
  5196.  
  5197. item->SetCount(item->GetCount() - 1);
  5198. }
  5199. else
  5200. {
  5201. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 액세서리에는 더이상 소켓을 추가할 공간이 없습니다."));
  5202. }
  5203. }
  5204. else
  5205. {
  5206. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템으로 소켓을 추가할 수 없는 아이템입니다."));
  5207. }
  5208. }
  5209. break;
  5210.  
  5211. case USE_PUT_INTO_BELT_SOCKET:
  5212. case USE_PUT_INTO_ACCESSORY_SOCKET:
  5213. if (item2->IsAccessoryForSocket() && item->CanPutInto(item2))
  5214. {
  5215. char buf[21];
  5216. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5217.  
  5218. if (item2->GetAccessorySocketGrade() < item2->GetAccessorySocketMaxGrade())
  5219. {
  5220. if (number(1, 100) <= aiAccessorySocketPutPct[item2->GetAccessorySocketGrade()])
  5221. {
  5222. item2->SetAccessorySocketGrade(item2->GetAccessorySocketGrade() + 1);
  5223. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("장착에 성공하였습니다."));
  5224. LogManager::instance().ItemLog(this, item, "PUT_SOCKET_SUCCESS", buf);
  5225. }
  5226. else
  5227. {
  5228. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("장착에 실패하였습니다."));
  5229. LogManager::instance().ItemLog(this, item, "PUT_SOCKET_FAIL", buf);
  5230. }
  5231.  
  5232. item->SetCount(item->GetCount() - 1);
  5233. }
  5234. else
  5235. {
  5236. if (item2->GetAccessorySocketMaxGrade() == 0)
  5237. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("먼저 다이아몬드로 악세서리에 소켓을 추가해야합니다."));
  5238. else if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
  5239. {
  5240. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 액세서리에는 더이상 장착할 소켓이 없습니다."));
  5241. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("다이아몬드로 소켓을 추가해야합니다."));
  5242. }
  5243. else
  5244. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 액세서리에는 더이상 보석을 장착할 수 없습니다."));
  5245. }
  5246. }
  5247. else
  5248. {
  5249. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템을 장착할 수 없습니다."));
  5250. }
  5251. break;
  5252. }
  5253. if (item2->IsEquipped())
  5254. {
  5255. BuffOnAttr_AddBuffsFromItem(item2);
  5256. }
  5257. }
  5258. break;
  5259. // END_OF_ACCESSORY_REFINE & END_OF_ADD_ATTRIBUTES & END_OF_CHANGE_ATTRIBUTES
  5260.  
  5261. case USE_BIND:
  5262. {
  5263. LPITEM item2;
  5264. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5265. return false;
  5266.  
  5267. if (item2->IsEquipped())
  5268. {
  5269. BuffOnAttr_RemoveBuffsFromItem(item2);
  5270. }
  5271.  
  5272. if (item2->IsExchanging() || item2->IsEquipped())
  5273. return false;
  5274.  
  5275. if (item2->IsBind())
  5276. {
  5277. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item is already binded."));
  5278. return false;
  5279. }
  5280.  
  5281. if (item2->IsUntilBind())
  5282. {
  5283. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item is until unbind process."));
  5284. return false;
  5285. }
  5286.  
  5287. if (IS_SET(item2->GetAntiFlag(), ITEM_ANTIFLAG_BIND))
  5288. {
  5289. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item can't be binded."));
  5290. return false;
  5291. }
  5292.  
  5293. if (item2->GetType() != ITEM_WEAPON && item2->GetType() != ITEM_ARMOR && item2->GetType() != ITEM_COSTUME)
  5294. {
  5295. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item can't be binded."));
  5296. return false;
  5297. }
  5298.  
  5299. long time_proc = item->GetValue(3);
  5300. item2->Bind(time_proc);
  5301. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have bind succesfully this item."));
  5302. item->SetCount(item->GetCount() - 1);
  5303. }
  5304. break;
  5305.  
  5306. case USE_UNBIND:
  5307. {
  5308. LPITEM item2;
  5309. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5310. return false;
  5311.  
  5312. if (item2->IsEquipped())
  5313. {
  5314. BuffOnAttr_RemoveBuffsFromItem(item2);
  5315. }
  5316.  
  5317. if (item2->IsExchanging() || item2->IsEquipped())
  5318. return false;
  5319.  
  5320. if (item2->IsUntilBind())
  5321. {
  5322. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item is until unbind process."));
  5323. return false;
  5324. }
  5325.  
  5326. if (!item2->IsBind())
  5327. {
  5328. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This item is not binded."));
  5329. return false;
  5330. }
  5331.  
  5332. long time_proc = item->GetValue(3);
  5333. item2->Bind(time(0) + time_proc);
  5334. item2->StartUnBindingExpireEvent();
  5335. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have unbinded succesfully this item, this process require 3 days."));
  5336. item->SetCount(item->GetCount() - 1);
  5337. }
  5338. break;
  5339.  
  5340. case USE_COSTUME_ENCHANT:
  5341. case USE_COSTUME_TRANSFORM:
  5342. {
  5343. LPITEM item2;
  5344. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5345. return false;
  5346.  
  5347. if (item2->IsEquipped())
  5348. {
  5349. BuffOnAttr_RemoveBuffsFromItem(item2);
  5350. }
  5351.  
  5352. if (item2->IsExchanging() || item2->IsEquipped())
  5353. return false;
  5354.  
  5355. if (item2->GetType() != ITEM_COSTUME)
  5356. {
  5357. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("bu_nesneyi_bu_esyada_kullanamazsin"));
  5358. return false;
  5359. }
  5360.  
  5361. if (item2->GetAttributeCount() == 0)
  5362. {
  5363. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kostumda_hic_efsun_yok"));
  5364. return false;
  5365. }
  5366.  
  5367. if (item2->IsBind())
  5368. {
  5369. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kostum_kilitli"));
  5370. return false;
  5371. }
  5372.  
  5373. switch (item->GetSubType())
  5374. {
  5375. case USE_COSTUME_ENCHANT:
  5376. {
  5377. int aiChangeProb[ITEM_ATTRIBUTE_MAX_LEVEL] = {100, 100, 100, 100, 100};
  5378. item2->ChangeAttribute(aiChangeProb);
  5379. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("efsun_basariyla_degistirildi"));
  5380. {
  5381. char buf[21];
  5382. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5383. LogManager::instance().ItemLog(this, item, "USE_COSTUME_ENCHANT", buf);
  5384. }
  5385.  
  5386. item->SetCount(item->GetCount() - 1);
  5387. }
  5388. break;
  5389. case USE_COSTUME_TRANSFORM:
  5390. {
  5391. item2->ClearAttribute();
  5392. int iCostumePercent = number(1, 3);
  5393. for (int i = 0; i < iCostumePercent; ++i)
  5394. {
  5395. item2->AddAttribute();
  5396. }
  5397.  
  5398. int aiChangeProb[ITEM_ATTRIBUTE_MAX_LEVEL] = {100, 100, 100, 100, 100};
  5399. item2->ChangeAttribute(aiChangeProb);
  5400. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("efsun_basariyla_aktarildi"));
  5401. {
  5402. char buf[21];
  5403. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5404. LogManager::instance().ItemLog(this, item, "USE_COSTUME_TRANSFORM", buf);
  5405. }
  5406.  
  5407. item->SetCount(item->GetCount() - 1);
  5408. }
  5409. break;
  5410. }
  5411. }
  5412. break;
  5413.  
  5414. case USE_BAIT:
  5415. {
  5416.  
  5417. if (m_pkFishingEvent)
  5418. {
  5419. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("낚시 중에 미끼를 갈아끼울 수 없습니다."));
  5420. return false;
  5421. }
  5422.  
  5423. LPITEM weapon = GetWear(WEAR_WEAPON);
  5424.  
  5425. if (!weapon || weapon->GetType() != ITEM_ROD)
  5426. return false;
  5427.  
  5428. if (weapon->GetSocket(2))
  5429. {
  5430. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 꽂혀있던 미끼를 빼고 %s를 끼웁니다."), item->GetName());
  5431. }
  5432. else
  5433. {
  5434. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("낚시대에 %s를 미끼로 끼웁니다."), item->GetName());
  5435. }
  5436.  
  5437. weapon->SetSocket(2, item->GetValue(0));
  5438. item->SetCount(item->GetCount() - 1);
  5439. }
  5440. break;
  5441.  
  5442. case USE_MOVE:
  5443. case USE_TREASURE_BOX:
  5444. case USE_MONEYBAG:
  5445. break;
  5446.  
  5447. case USE_AFFECT :
  5448. {
  5449. #ifdef ENABLE_YMIR_AFFECT_FIX
  5450. if ((CheckTimeUsed(item) == false))
  5451. {
  5452. return false;
  5453. }
  5454. #endif
  5455. if (FindAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType))
  5456. {
  5457. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
  5458. }
  5459. else
  5460. {
  5461. // PC_BANG_ITEM_ADD
  5462. if (item->IsPCBangItem() == true)
  5463. {
  5464. // PC방인지 체크해서 처리
  5465. if (CPCBangManager::instance().IsPCBangIP(GetDesc()->GetHostName()) == false)
  5466. {
  5467. // PC방이 아님!
  5468. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 PC방에서만 사용할 수 있습니다."));
  5469. return false;
  5470. }
  5471. }
  5472. // END_PC_BANG_ITEM_ADD
  5473.  
  5474. AddAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType, item->GetValue(2), 0, item->GetValue(3), 0, false);
  5475. item->SetCount(item->GetCount() - 1);
  5476. }
  5477. }
  5478. break;
  5479.  
  5480. case USE_CREATE_STONE:
  5481. AutoGiveItem(number(28000, 28013));
  5482. item->SetCount(item->GetCount() - 1);
  5483. break;
  5484.  
  5485. // 물약 제조 스킬용 레시피 처리
  5486. case USE_RECIPE :
  5487. {
  5488. LPITEM pSource1 = FindSpecifyItem(item->GetValue(1));
  5489. DWORD dwSourceCount1 = item->GetValue(2);
  5490.  
  5491. LPITEM pSource2 = FindSpecifyItem(item->GetValue(3));
  5492. DWORD dwSourceCount2 = item->GetValue(4);
  5493.  
  5494. if (dwSourceCount1 != 0)
  5495. {
  5496. if (pSource1 == NULL)
  5497. {
  5498. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 조합을 위한 재료가 부족합니다."));
  5499. return false;
  5500. }
  5501. }
  5502.  
  5503. if (dwSourceCount2 != 0)
  5504. {
  5505. if (pSource2 == NULL)
  5506. {
  5507. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 조합을 위한 재료가 부족합니다."));
  5508. return false;
  5509. }
  5510. }
  5511.  
  5512. if (pSource1 != NULL)
  5513. {
  5514. if (pSource1->GetCount() < dwSourceCount1)
  5515. {
  5516. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("재료(%s)가 부족합니다."), pSource1->GetName());
  5517. return false;
  5518. }
  5519.  
  5520. pSource1->SetCount(pSource1->GetCount() - dwSourceCount1);
  5521. }
  5522.  
  5523. if (pSource2 != NULL)
  5524. {
  5525. if (pSource2->GetCount() < dwSourceCount2)
  5526. {
  5527. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("재료(%s)가 부족합니다."), pSource2->GetName());
  5528. return false;
  5529. }
  5530.  
  5531. pSource2->SetCount(pSource2->GetCount() - dwSourceCount2);
  5532. }
  5533.  
  5534. LPITEM pBottle = FindSpecifyItem(50901);
  5535.  
  5536. if (!pBottle || pBottle->GetCount() < 1)
  5537. {
  5538. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("빈 병이 모자릅니다."));
  5539. return false;
  5540. }
  5541.  
  5542. pBottle->SetCount(pBottle->GetCount() - 1);
  5543.  
  5544. if (number(1, 100) > item->GetValue(5))
  5545. {
  5546. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제조에 실패했습니다."));
  5547. return false;
  5548. }
  5549.  
  5550. AutoGiveItem(item->GetValue(0));
  5551. }
  5552. break;
  5553. }
  5554. }
  5555. break;
  5556.  
  5557. case ITEM_METIN:
  5558. {
  5559. LPITEM item2;
  5560.  
  5561. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5562. return false;
  5563.  
  5564. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  5565. return false;
  5566.  
  5567. if (item2->GetType() == ITEM_PICK) return false;
  5568. if (item2->GetType() == ITEM_ROD) return false;
  5569.  
  5570. int i;
  5571.  
  5572. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  5573. {
  5574. DWORD dwVnum;
  5575.  
  5576. if ((dwVnum = item2->GetSocket(i)) <= 2)
  5577. continue;
  5578.  
  5579. TItemTable * p = ITEM_MANAGER::instance().GetTable(dwVnum);
  5580.  
  5581. if (!p)
  5582. continue;
  5583.  
  5584. if (item->GetValue(5) == p->alValues[5])
  5585. {
  5586. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("같은 종류의 메틴석은 여러개 부착할 수 없습니다."));
  5587. return false;
  5588. }
  5589. }
  5590.  
  5591. if (item2->GetType() == ITEM_ARMOR)
  5592. {
  5593. if (!IS_SET(item->GetWearFlag(), WEARABLE_BODY) || !IS_SET(item2->GetWearFlag(), WEARABLE_BODY))
  5594. {
  5595. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 메틴석은 장비에 부착할 수 없습니다."));
  5596. return false;
  5597. }
  5598. }
  5599. else if (item2->GetType() == ITEM_WEAPON)
  5600. {
  5601. if (!IS_SET(item->GetWearFlag(), WEARABLE_WEAPON))
  5602. {
  5603. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 메틴석은 무기에 부착할 수 없습니다."));
  5604. return false;
  5605. }
  5606. }
  5607. else
  5608. {
  5609. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("부착할 수 있는 슬롯이 없습니다."));
  5610. return false;
  5611. }
  5612.  
  5613. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  5614. if (item2->GetSocket(i) >= 1 && item2->GetSocket(i) <= 2 && item2->GetSocket(i) >= item->GetValue(2))
  5615. {
  5616. // 석 확률
  5617. if (number(1, 100) <= (TasBasmaOrani))
  5618. {
  5619. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 성공하였습니다."));
  5620. item2->SetSocket(i, item->GetVnum());
  5621. }
  5622. else
  5623. {
  5624. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 실패하였습니다."));
  5625. item2->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
  5626. }
  5627.  
  5628. LogManager::instance().ItemLog(this, item2, "SOCKET", item->GetName());
  5629. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (METIN)");
  5630. break;
  5631. }
  5632.  
  5633. if (i == ITEM_SOCKET_MAX_NUM)
  5634. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("부착할 수 있는 슬롯이 없습니다."));
  5635. }
  5636. break;
  5637.  
  5638. case ITEM_AUTOUSE:
  5639. case ITEM_MATERIAL:
  5640. case ITEM_SPECIAL:
  5641. case ITEM_TOOL:
  5642. case ITEM_LOTTERY:
  5643. break;
  5644.  
  5645. case ITEM_TOTEM:
  5646. {
  5647. if (!item->IsEquipped())
  5648. EquipItem(item);
  5649. }
  5650. break;
  5651.  
  5652. case ITEM_BLEND:
  5653. #ifdef ENABLE_YMIR_AFFECT_FIX
  5654. if ((CheckTimeUsed(item) == false))
  5655. {
  5656. return false;
  5657. }
  5658. #endif
  5659. sys_log(0,"ITEM_BLEND!!");
  5660. if (Blend_Item_find(item->GetVnum()))
  5661. {
  5662. int affect_type = AFFECT_BLEND;
  5663. if (item->GetSocket(0) >= _countof(aApplyInfo))
  5664. {
  5665. sys_err ("INVALID BLEND ITEM(id : %d, vnum : %d). APPLY TYPE IS %d.", item->GetID(), item->GetVnum(), item->GetSocket(0));
  5666. return false;
  5667. }
  5668.  
  5669. int apply_type = aApplyInfo[item->GetSocket(0)].bPointType;
  5670. int apply_value = item->GetSocket(1);
  5671. int apply_duration = item->GetSocket(2);
  5672.  
  5673. if (FindAffect(affect_type, apply_type))
  5674. {
  5675. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
  5676. }
  5677. else
  5678. {
  5679. if (FindAffect(AFFECT_EXP_BONUS_EURO_FREE, POINT_RESIST_MAGIC))
  5680. {
  5681. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
  5682. }
  5683. else
  5684. {
  5685. AddAffect(affect_type, apply_type, apply_value, 0, apply_duration, 0, false);
  5686. item->SetCount(item->GetCount() - 1);
  5687. }
  5688. }
  5689. }
  5690. break;
  5691. case ITEM_EXTRACT:
  5692. {
  5693. LPITEM pDestItem = GetItem(DestCell);
  5694. if (NULL == pDestItem)
  5695. {
  5696. return false;
  5697. }
  5698. switch (item->GetSubType())
  5699. {
  5700. case EXTRACT_DRAGON_SOUL:
  5701. if (pDestItem->IsDragonSoul())
  5702. {
  5703. return DSManager::instance().PullOut(this, NPOS, pDestItem, item);
  5704. }
  5705. return false;
  5706. case EXTRACT_DRAGON_HEART:
  5707. if (item->GetVnum() == 71053)
  5708. {
  5709. if (pDestItem->IsDragonSoul())
  5710. {
  5711. if (DSManager::instance().IsActiveDragonSoul(pDestItem) == true)
  5712. {
  5713. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SIMYA_GIYILIYOR"));
  5714. return false;
  5715. }
  5716.  
  5717. pDestItem->SetForceAttribute(0, 0, 0);
  5718. pDestItem->SetForceAttribute(1, 0, 0);
  5719. pDestItem->SetForceAttribute(2, 0, 0);
  5720. pDestItem->SetForceAttribute(3, 0, 0);
  5721. pDestItem->SetForceAttribute(4, 0, 0);
  5722. pDestItem->SetForceAttribute(5, 0, 0);
  5723. pDestItem->SetForceAttribute(6, 0, 0);
  5724.  
  5725. bool ret = DSManager::instance().PutAttributes(pDestItem);
  5726. if (ret == true)
  5727. {
  5728. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SIMYA_DEGISTIRME_BASARILI!"));
  5729. item->SetCount(item->GetCount()-1);
  5730. }
  5731. else
  5732. {
  5733. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SIMYA_DEGISTIRME_BASARISIZ!"));
  5734. }
  5735. }
  5736. }
  5737. else
  5738. {
  5739. if (pDestItem->IsDragonSoul())
  5740. {
  5741. return DSManager::instance().ExtractDragonHeart(this, pDestItem, item);
  5742. }
  5743. }
  5744. return false;
  5745. default:
  5746. return false;
  5747. }
  5748. }
  5749. break;
  5750.  
  5751. case ITEM_NONE:
  5752. sys_err("Item type NONE %s", item->GetName());
  5753. break;
  5754.  
  5755. default:
  5756. sys_log(0, "UseItemEx: Unknown type %s %d", item->GetName(), item->GetType());
  5757. return false;
  5758. }
  5759.  
  5760. return true;
  5761. }
  5762.  
  5763. int g_nPortalLimitTime = 10;
  5764.  
  5765. bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
  5766. {
  5767. WORD wCell = Cell.cell;
  5768. BYTE window_type = Cell.window_type;
  5769. // WORD wDestCell = DestCell.cell;
  5770. // BYTE bDestInven = DestCell.window_type;
  5771. LPITEM item;
  5772.  
  5773. if (!CanHandleItem())
  5774. return false;
  5775.  
  5776. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  5777. return false;
  5778.  
  5779. sys_log(0, "%s: USE_ITEM %s (inven %d, cell: %d)", GetName(), item->GetName(), window_type, wCell);
  5780.  
  5781. if (item->IsExchanging())
  5782. return false;
  5783.  
  5784. if (!item->CanUsedBy(this))
  5785. {
  5786. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("군직이 맞지않아 이 아이템을 사용할 수 없습니다."));
  5787. return false;
  5788. }
  5789.  
  5790. if (IsStun())
  5791. return false;
  5792.  
  5793. if (false == FN_check_item_sex(this, item))
  5794. {
  5795. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("성별이 맞지않아 이 아이템을 사용할 수 없습니다."));
  5796. return false;
  5797. }
  5798.  
  5799. //PREVENT_TRADE_WINDOW
  5800. if (IS_SUMMON_ITEM(item->GetVnum()))
  5801. {
  5802. if (false == IS_SUMMONABLE_ZONE(GetMapIndex()))
  5803. {
  5804. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("사용할수 없습니다."));
  5805. return false;
  5806. }
  5807.  
  5808. // 경혼반지 사용지 상대방이 SUMMONABLE_ZONE에 있는가는 WarpToPC()에서 체크
  5809.  
  5810. //삼거리 관려 맵에서는 귀환부를 막아버린다.
  5811. if (CThreeWayWar::instance().IsThreeWayWarMapIndex(GetMapIndex()))
  5812. {
  5813. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("삼거리 전투 참가중에는 귀환부,귀환기억부를 사용할수 없습니다."));
  5814. return false;
  5815. }
  5816. int iPulse = thecore_pulse();
  5817.  
  5818. //창고 연후 체크
  5819. if (iPulse - GetSafeboxLoadTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  5820. {
  5821. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("창고를 연후 %d초 이내에는 귀환부,귀환기억부를 사용할 수 없습니다."), g_nPortalLimitTime);
  5822.  
  5823. if (test_server)
  5824. ChatPacket(CHAT_TYPE_INFO, "[TestOnly]Pulse %d LoadTime %d PASS %d", iPulse, GetSafeboxLoadTime(), PASSES_PER_SEC(g_nPortalLimitTime));
  5825. return false;
  5826. }
  5827.  
  5828. //거래관련 창 체크
  5829. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  5830. {
  5831. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("거래창,창고 등을 연 상태에서는 귀환부,귀환기억부 를 사용할수 없습니다."));
  5832. return false;
  5833. }
  5834.  
  5835. //PREVENT_REFINE_HACK
  5836. //개량후 시간체크
  5837. {
  5838. if (iPulse - GetRefineTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  5839. {
  5840. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 개량후 %d초 이내에는 귀환부,귀환기억부를 사용할 수 없습니다."), g_nPortalLimitTime);
  5841. return false;
  5842. }
  5843. }
  5844. //END_PREVENT_REFINE_HACK
  5845.  
  5846.  
  5847. //PREVENT_ITEM_COPY
  5848. {
  5849. if (iPulse - GetMyShopTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  5850. {
  5851. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개인상점 사용후 %d초 이내에는 귀환부,귀환기억부를 사용할 수 없습니다."), g_nPortalLimitTime);
  5852. return false;
  5853. }
  5854.  
  5855. }
  5856. //END_PREVENT_ITEM_COPY
  5857.  
  5858.  
  5859. //귀환부 거리체크
  5860. if (item->GetVnum() != 70302)
  5861. {
  5862. PIXEL_POSITION posWarp;
  5863.  
  5864. int x = 0;
  5865. int y = 0;
  5866.  
  5867. double nDist = 0;
  5868. const double nDistant = 5000.0;
  5869. //귀환기억부
  5870. if (item->GetVnum() == 22010)
  5871. {
  5872. x = item->GetSocket(0) - GetX();
  5873. y = item->GetSocket(1) - GetY();
  5874. }
  5875. //귀환부
  5876. else if (item->GetVnum() == 22000)
  5877. {
  5878. SECTREE_MANAGER::instance().GetRecallPositionByEmpire(GetMapIndex(), GetEmpire(), posWarp);
  5879.  
  5880. if (item->GetSocket(0) == 0)
  5881. {
  5882. x = posWarp.x - GetX();
  5883. y = posWarp.y - GetY();
  5884. }
  5885. else
  5886. {
  5887. x = item->GetSocket(0) - GetX();
  5888. y = item->GetSocket(1) - GetY();
  5889. }
  5890. }
  5891.  
  5892. nDist = sqrt(pow((float)x,2) + pow((float)y,2));
  5893.  
  5894. if (nDistant > nDist)
  5895. {
  5896. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이동 되어질 위치와 너무 가까워 귀환부를 사용할수 없습니다."));
  5897. if (test_server)
  5898. ChatPacket(CHAT_TYPE_INFO, "PossibleDistant %f nNowDist %f", nDistant,nDist);
  5899. return false;
  5900. }
  5901. }
  5902.  
  5903. //PREVENT_PORTAL_AFTER_EXCHANGE
  5904. //교환 후 시간체크
  5905. if (iPulse - GetExchangeTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  5906. {
  5907. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("거래 후 %d초 이내에는 귀환부,귀환기억부등을 사용할 수 없습니다."), g_nPortalLimitTime);
  5908. return false;
  5909. }
  5910. //END_PREVENT_PORTAL_AFTER_EXCHANGE
  5911.  
  5912. }
  5913.  
  5914. //보따리 비단 사용시 거래창 제한 체크
  5915. if ((item->GetVnum() == 50200) || (item->GetVnum() == 71049))
  5916. {
  5917. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  5918. {
  5919. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("거래창,창고 등을 연 상태에서는 보따리,비단보따리를 사용할수 없습니다."));
  5920. return false;
  5921. }
  5922. }
  5923. //END_PREVENT_TRADE_WINDOW
  5924.  
  5925. #ifdef ITEM_BUFF_SYSTEM
  5926. if (item->GetVnum() == MASTER_RESIST_BLESS_ITEM_BUFF_VNUM)
  5927. {
  5928. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  5929. {
  5930. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  5931. return false;
  5932. }
  5933. if (true == IsDead())
  5934. {
  5935. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  5936. return false;
  5937. }
  5938. else
  5939. {
  5940. if (FindAffect(SKILL_RESIST_BUFF))
  5941. {
  5942. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Resistance Buff, [Item Buff]!"));
  5943. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  5944. return false;
  5945. }
  5946. if (IsAffectFlag(AFF_HOSIN))
  5947. {
  5948. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Resistance Buff, [Shaman Buff]!"));
  5949. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  5950. return false;
  5951. }
  5952. {
  5953. item->SetSocket(0, item->GetSocket(0) + 1);
  5954. AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, MASTER_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, MASTER_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  5955. if (item->GetSocket(0) >= MASTER_RESIST_BLESS_USINGS)
  5956. {
  5957. ITEM_MANAGER::instance().RemoveItem(item);
  5958. }
  5959. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Resistance Buff , [Item Buff] for 160 seconds."));
  5960. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff resist rate applied: 24%."));
  5961. }
  5962. }
  5963. }
  5964.  
  5965. if (item->GetVnum() == GRAND_RESIST_BLESS_ITEM_BUFF_VNUM) //
  5966. {
  5967. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  5968. {
  5969. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  5970. return false;
  5971. }
  5972. if (true == IsDead())
  5973. {
  5974. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  5975. return false;
  5976. }
  5977. else
  5978. {
  5979. if (FindAffect(SKILL_RESIST_BUFF))
  5980. {
  5981. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Resistance Buff, [Item Buff]!"));
  5982. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  5983. return false;
  5984. }
  5985. if (IsAffectFlag(AFF_HOSIN))
  5986. {
  5987. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Resistance Buff, [Shaman Buff]!"));
  5988. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  5989. return false;
  5990. }
  5991. {
  5992. item->SetSocket(0, item->GetSocket(0) + 1);
  5993. AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, GRAND_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, GRAND_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  5994. if (item->GetSocket(0) >= GRAND_RESIST_BLESS_USINGS)
  5995. {
  5996. ITEM_MANAGER::instance().RemoveItem(item);
  5997. }
  5998. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Resistance Buff , [Item Buff] for 224 seconds."));
  5999. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff resist rate applied: 29%."));
  6000. }
  6001. }
  6002. }
  6003.  
  6004. if (item->GetVnum() == PERFECT_RESIST_BLESS_ITEM_BUFF_VNUM) //
  6005. {
  6006. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6007. {
  6008. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6009. return false;
  6010. }
  6011. if (true == IsDead())
  6012. {
  6013. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  6014. return false;
  6015. }
  6016. else
  6017. {
  6018. if (FindAffect(SKILL_RESIST_BUFF))
  6019. {
  6020. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Resistance Buff, [Item Buff]!"));
  6021. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6022. return false;
  6023. }
  6024. if (IsAffectFlag(AFF_HOSIN))
  6025. {
  6026. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Resistance Buff, [Shaman Buff]!"));
  6027. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6028. return false;
  6029. }
  6030. {
  6031. item->SetSocket(0, item->GetSocket(0) + 1);
  6032. AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, PERFECT_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, PERFECT_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6033. if (item->GetSocket(0) >= PERFECT_RESIST_BLESS_USINGS)
  6034. {
  6035. ITEM_MANAGER::instance().RemoveItem(item);
  6036. }
  6037. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Resistance Buff, [Item Buff] for 310 seconds."));
  6038. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff resist rate applied: 35%."));
  6039. }
  6040. }
  6041. }
  6042.  
  6043. if (item->GetVnum() == MASTER_CRITICAL_BLESS_ITEM_BUFF_VNUM)
  6044. {
  6045. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6046. {
  6047. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6048. return false;
  6049. }
  6050. if (true == IsDead())
  6051. {
  6052. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  6053. return false;
  6054. }
  6055. else
  6056. {
  6057. if (FindAffect(SKILL_CRITICAL_BUFF))
  6058. {
  6059. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!"));
  6060. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6061. return false;
  6062. }
  6063. if (IsAffectFlag(AFF_GICHEON))
  6064. {
  6065. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!"));
  6066. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6067. return false;
  6068. }
  6069. {
  6070. item->SetSocket(0, item->GetSocket(0) + 1);
  6071. AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, MASTER_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, MASTER_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6072. if (item->GetSocket(0) >= MASTER_CRITICAL_BLESS_USINGS)
  6073. {
  6074. ITEM_MANAGER::instance().RemoveItem(item);
  6075. }
  6076. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 110 seconds."));
  6077. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff critical rate applied: 24%."));
  6078. }
  6079. }
  6080. }
  6081.  
  6082. if (item->GetVnum() == GRAND_CRITICAL_BLESS_ITEM_BUFF_VNUM) //
  6083. {
  6084. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6085. {
  6086. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6087. return false;
  6088. }
  6089. if (true == IsDead())
  6090. {
  6091. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  6092. return false;
  6093. }
  6094. else
  6095. {
  6096. if (FindAffect(SKILL_CRITICAL_BUFF))
  6097. {
  6098. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!"));
  6099. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6100. return false;
  6101. }
  6102. if (IsAffectFlag(AFF_GICHEON))
  6103. {
  6104. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!"));
  6105. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6106. return false;
  6107. }
  6108. {
  6109. item->SetSocket(0, item->GetSocket(0) + 1);
  6110. AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, GRAND_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, GRAND_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6111. if (item->GetSocket(0) >= GRAND_CRITICAL_BLESS_USINGS)
  6112. {
  6113. ITEM_MANAGER::instance().RemoveItem(item);
  6114. }
  6115. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 142 seconds."));
  6116. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff critical rate applied: 29%."));
  6117. }
  6118. }
  6119. }
  6120.  
  6121. if (item->GetVnum() == PERFECT_CRITICAL_BLESS_ITEM_BUFF_VNUM) //
  6122. {
  6123. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6124. {
  6125. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6126. return false;
  6127. }
  6128. if (true == IsDead())
  6129. {
  6130. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff)!"));
  6131. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6132. return false;
  6133. }
  6134. else
  6135. {
  6136. if (FindAffect(SKILL_CRITICAL_BUFF))
  6137. {
  6138. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!"));
  6139. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6140. return false;
  6141. }
  6142. if (IsAffectFlag(AFF_GICHEON))
  6143. {
  6144. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!"));
  6145. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6146. return false;
  6147. }
  6148. {
  6149. item->SetSocket(0, item->GetSocket(0) + 1);
  6150. AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, PERFECT_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, PERFECT_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6151. if (item->GetSocket(0) >= PERFECT_CRITICAL_BLESS_USINGS)
  6152. {
  6153. ITEM_MANAGER::instance().RemoveItem(item);
  6154. }
  6155. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 185 seconds."));
  6156. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff critical rate applied: 35%."));
  6157. }
  6158. }
  6159. }
  6160.  
  6161. if (item->GetVnum() == MASTER_REFLECT_BLESS_ITEM_BUFF_VNUM)
  6162. {
  6163. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6164. {
  6165. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6166. return false;
  6167. }
  6168. if (true == IsDead())
  6169. {
  6170. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  6171. return false;
  6172. }
  6173. else
  6174. {
  6175. if (FindAffect(SKILL_REFLECT_BUFF))
  6176. {
  6177. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Reflection, [Item Buff]!"));
  6178. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6179. return false;
  6180. }
  6181. if (IsAffectFlag(AFF_BOHO))
  6182. {
  6183. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Reflection, [Shaman Buff]!"));
  6184. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6185. return false;
  6186. }
  6187. {
  6188. item->SetSocket(0, item->GetSocket(0) + 1);
  6189. AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, MASTER_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, MASTER_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6190. if (item->GetSocket(0) >= MASTER_REFLECT_BLESS_USINGS)
  6191. {
  6192. ITEM_MANAGER::instance().RemoveItem(item);
  6193. }
  6194. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Reflection, [Item Buff] for 160 seconds."));
  6195. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff reflection rate applied: 21%."));
  6196. }
  6197. }
  6198. }
  6199.  
  6200. if (item->GetVnum() == GRAND_REFLECT_BLESS_ITEM_BUFF_VNUM) //
  6201. {
  6202. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6203. {
  6204. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6205. return false;
  6206. }
  6207. if (true == IsDead())
  6208. {
  6209. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  6210. return false;
  6211. }
  6212. else
  6213. {
  6214. if (FindAffect(SKILL_REFLECT_BUFF))
  6215. {
  6216. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Reflection, [Item Buff]!"));
  6217. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6218. return false;
  6219. }
  6220. if (IsAffectFlag(AFF_BOHO))
  6221. {
  6222. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Reflection, [Shaman Buff]!"));
  6223. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6224. return false;
  6225. }
  6226. {
  6227. item->SetSocket(0, item->GetSocket(0) + 1);
  6228. AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, GRAND_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, GRAND_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6229. if (item->GetSocket(0) >= GRAND_REFLECT_BLESS_USINGS)
  6230. {
  6231. ITEM_MANAGER::instance().RemoveItem(item);
  6232. }
  6233. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Reflection, [Item Buff] for 224 seconds."));
  6234. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff reflection rate applied: 31%."));
  6235. }
  6236. }
  6237. }
  6238.  
  6239. if (item->GetVnum() == PERFECT_REFLECT_BLESS_ITEM_BUFF_VNUM) //
  6240. {
  6241. if (GetOfflineShopOwner() || GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen() || IsAttrTransferOpen())
  6242. {
  6243. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you have exchange,safebox,refine or other windows opened!"));
  6244. return false;
  6245. }
  6246. if (true == IsDead())
  6247. {
  6248. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use buff items while you're dead!"));
  6249. return false;
  6250. }
  6251. else
  6252. {
  6253. if (FindAffect(SKILL_REFLECT_BUFF))
  6254. {
  6255. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Reflection, [Item Buff]!"));
  6256. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6257. return false;
  6258. }
  6259. if (IsAffectFlag(AFF_BOHO))
  6260. {
  6261. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You're already blessed with: Reflection, [Shaman Buff]!"));
  6262. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Wait for your current buff to disappear and try again!"));
  6263. return false;
  6264. }
  6265. {
  6266. item->SetSocket(0, item->GetSocket(0) + 1);
  6267. AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, PERFECT_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, PERFECT_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6268. if (item->GetSocket(0) >= PERFECT_REFLECT_BLESS_USINGS)
  6269. {
  6270. ITEM_MANAGER::instance().RemoveItem(item);
  6271. }
  6272. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You are blessed now with: Reflection, [Item Buff] for 310 seconds."));
  6273. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Buff reflection rate applied: 45%."));
  6274. }
  6275. }
  6276. }
  6277. #endif
  6278.  
  6279. if (IS_SET(item->GetFlag(), ITEM_FLAG_LOG)) // 사용 로그를 남기는 아이템 처리
  6280. {
  6281. DWORD vid = item->GetVID();
  6282. DWORD oldCount = item->GetCount();
  6283. DWORD vnum = item->GetVnum();
  6284.  
  6285. char hint[ITEM_NAME_MAX_LEN + 32 + 1];
  6286. int len = snprintf(hint, sizeof(hint) - 32, "%s", item->GetName());
  6287.  
  6288. if (len < 0 || len >= (int) sizeof(hint) - 32)
  6289. len = (sizeof(hint) - 32) - 1;
  6290.  
  6291. bool ret = UseItemEx(item, DestCell);
  6292.  
  6293. if (NULL == ITEM_MANAGER::instance().FindByVID(vid)) // UseItemEx에서 아이템이 삭제 되었다. 삭제 로그를 남김
  6294. {
  6295. LogManager::instance().ItemLog(this, vid, vnum, "REMOVE", hint);
  6296. }
  6297. else if (oldCount != item->GetCount())
  6298. {
  6299. snprintf(hint + len, sizeof(hint) - len, " %u", oldCount - 1);
  6300. LogManager::instance().ItemLog(this, vid, vnum, "USE_ITEM", hint);
  6301. }
  6302. return (ret);
  6303. }
  6304. else
  6305. return UseItemEx(item, DestCell);
  6306. }
  6307.  
  6308. bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
  6309. {
  6310. LPITEM item = NULL;
  6311.  
  6312. if (!CanHandleItem())
  6313. {
  6314. if (NULL != DragonSoul_RefineWindow_GetOpener())
  6315. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("PENCERE_ACIKK."));
  6316. return false;
  6317. }
  6318.  
  6319. if (IsDead())
  6320. return false;
  6321.  
  6322. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  6323. return false;
  6324.  
  6325. if (item->IsExchanging())
  6326. return false;
  6327.  
  6328. if (true == item->isLocked())
  6329. return false;
  6330.  
  6331. if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
  6332. return false;
  6333.  
  6334. if (item->IsBind() || item->IsUntilBind())
  6335. {
  6336. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ruha_bagli_nesneyi_yere_dusuremezsin"));
  6337. return false;
  6338. }
  6339.  
  6340. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP | ITEM_ANTIFLAG_GIVE))
  6341. {
  6342. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("버릴 수 없는 아이템입니다."));
  6343. return false;
  6344. }
  6345.  
  6346. if (bCount == 0 || bCount > item->GetCount())
  6347. bCount = item->GetCount();
  6348.  
  6349. SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255); // Quickslot 에서 지움
  6350.  
  6351. LPITEM pkItemToDrop;
  6352.  
  6353. if (bCount == item->GetCount())
  6354. {
  6355. item->RemoveFromCharacter();
  6356. pkItemToDrop = item;
  6357. }
  6358. else
  6359. {
  6360. if (bCount == 0)
  6361. {
  6362. if (test_server)
  6363. sys_log(0, "[DROP_ITEM] drop item count == 0");
  6364. return false;
  6365. }
  6366.  
  6367. item->SetCount(item->GetCount() - bCount);
  6368. ITEM_MANAGER::instance().FlushDelayedSave(item);
  6369.  
  6370. pkItemToDrop = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), bCount);
  6371.  
  6372. // copy item socket -- by mhh
  6373. FN_copy_item_socket(pkItemToDrop, item);
  6374.  
  6375. char szBuf[51 + 1];
  6376. snprintf(szBuf, sizeof(szBuf), "%u %u", pkItemToDrop->GetID(), pkItemToDrop->GetCount());
  6377. LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
  6378. }
  6379.  
  6380. PIXEL_POSITION pxPos = GetXYZ();
  6381.  
  6382. if (pkItemToDrop->AddToGround(GetMapIndex(), pxPos))
  6383. {
  6384. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("떨어진 아이템은 3분 후 사라집니다."));
  6385. pkItemToDrop->StartDestroyEvent(5);
  6386.  
  6387. ITEM_MANAGER::instance().FlushDelayedSave(pkItemToDrop);
  6388.  
  6389. char szHint[32 + 1];
  6390. snprintf(szHint, sizeof(szHint), "%s %u %u", pkItemToDrop->GetName(), pkItemToDrop->GetCount(), pkItemToDrop->GetOriginalVnum());
  6391. LogManager::instance().ItemLog(this, pkItemToDrop, "DROP", szHint);
  6392. LastDropTime = thecore_pulse();
  6393. CountDrops++;
  6394. //Motion(MOTION_PICKUP);
  6395. }
  6396.  
  6397. // Clear the variable, it looks the player does not dropped any item in the past second.
  6398. if (thecore_pulse() > LastDropTime + 25)
  6399. CountDrops = 0;
  6400.  
  6401. // It looks the player dropped min. 5 items in the past 1 second
  6402. if (thecore_pulse() < LastDropTime + 25 && CountDrops >= 5)
  6403. {
  6404. // Set it to 0
  6405. CountDrops = 0;
  6406. sys_err("%s[%d] has been disconnected because of drophack using", GetName(), GetPlayerID());
  6407. // Disconnect the player
  6408. // GetDesc()->SetPhase(PHASE_CLOSE);
  6409. return false;
  6410. }
  6411.  
  6412. return true;
  6413. }
  6414.  
  6415. bool CHARACTER::DestroyItem(TItemPos Cell)
  6416. {
  6417. LPITEM item = NULL;
  6418.  
  6419. if (!CanHandleItem())
  6420. {
  6421. if (NULL != DragonSoul_RefineWindow_GetOpener())
  6422. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("PENCERE_ACIKK."));
  6423. return false;
  6424. }
  6425.  
  6426. if (IsDead())
  6427. return false;
  6428.  
  6429. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  6430. return false;
  6431.  
  6432. if (item->IsExchanging())
  6433. return false;
  6434.  
  6435. if (true == item->isLocked())
  6436. return false;
  6437.  
  6438. if (item->IsBind() || item->IsUntilBind())
  6439. {
  6440. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("RUHA_BAGLI_NESNELER_SILINEMEZ"));
  6441. return false;
  6442. }
  6443.  
  6444. if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
  6445. return false;
  6446.  
  6447. if (item->GetCount() <= 0)
  6448. return false;
  6449.  
  6450. #ifdef NEW_PET_SYSTEM
  6451. if (item->GetVnum() == 55701 || item->GetVnum() == 55702 || item->GetVnum() == 55703 || item->GetVnum() == 55704 || item->GetVnum() == 55705 || item->GetVnum() == 55706)
  6452. {
  6453. if (GetNewPetSystem()->IsActivePet())
  6454. return false;
  6455. }
  6456. #endif
  6457.  
  6458. SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255);
  6459. ITEM_MANAGER::instance().RemoveItem(item);
  6460. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s has succesfully deleted"), item->GetName());
  6461. return true;
  6462. }
  6463.  
  6464. bool CHARACTER::SellItem(TItemPos Cell)
  6465. {
  6466. LPITEM item = NULL;
  6467.  
  6468. if (!CanHandleItem())
  6469. {
  6470. if (NULL != DragonSoul_RefineWindow_GetOpener())
  6471. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("PENCERE_ACIKK."));
  6472. return false;
  6473. }
  6474.  
  6475. if (IsDead())
  6476. return false;
  6477.  
  6478. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  6479. return false;
  6480.  
  6481. if (item->IsExchanging())
  6482. return false;
  6483.  
  6484. if (true == item->isLocked())
  6485. return false;
  6486.  
  6487. if (item->IsBind() || item->IsUntilBind())
  6488. {
  6489. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("RUHA_BAGLI_NESNELER_SATILAMAZ"));
  6490. return false;
  6491. }
  6492.  
  6493. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_SELL))
  6494. {
  6495. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("BU_NESNE_SATILAMAZ"));
  6496. return false;
  6497. }
  6498.  
  6499. if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
  6500. return false;
  6501.  
  6502. if (item->GetCount() <= 0)
  6503. return false;
  6504.  
  6505. #ifdef NEW_PET_SYSTEM
  6506. if (item->GetVnum() == 55701 || item->GetVnum() == 55702 || item->GetVnum() == 55703 || item->GetVnum() == 55704 || item->GetVnum() == 55705 || item->GetVnum() == 55706)
  6507. {
  6508. if (GetNewPetSystem()->IsActivePet())
  6509. return false;
  6510. }
  6511. #endif
  6512.  
  6513. DWORD dwPrice = item->GetShopBuyPrice();
  6514. dwPrice *= item->GetCount();
  6515.  
  6516. const int64_t nTotalMoney = static_cast<int64_t>(GetGold()) + static_cast<int64_t>(dwPrice);
  6517. if (GOLD_MAX <= nTotalMoney)
  6518. {
  6519. sys_err("[OVERFLOW_GOLD] id %u name %s gold %u", GetPlayerID(), GetName(), GetGold());
  6520. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("20억냥이 초과하여 물품을 팔수 없습니다."));
  6521. return false;
  6522. }
  6523.  
  6524. DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), dwPrice);
  6525. item->SetCount(item->GetCount() - item->GetCount());
  6526. PointChange(POINT_GOLD, dwPrice, false);
  6527. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s has succesfully sell"), item->GetName());
  6528. return true;
  6529. }
  6530.  
  6531. bool CHARACTER::DropGold(int gold)
  6532. {
  6533. if (gold <= 0 || gold > GetGold())
  6534. return false;
  6535.  
  6536. if (!CanHandleItem())
  6537. return false;
  6538.  
  6539. if (0 != g_GoldDropTimeLimitValue)
  6540. {
  6541. if (get_dword_time() < m_dwLastGoldDropTime+g_GoldDropTimeLimitValue)
  6542. {
  6543. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아직 골드를 버릴 수 없습니다."));
  6544. return false;
  6545. }
  6546. }
  6547.  
  6548. m_dwLastGoldDropTime = get_dword_time();
  6549.  
  6550. LPITEM item = ITEM_MANAGER::instance().CreateItem(1, gold);
  6551.  
  6552. if (item)
  6553. {
  6554. PIXEL_POSITION pos = GetXYZ();
  6555.  
  6556. if (item->AddToGround(GetMapIndex(), pos))
  6557. {
  6558. //Motion(MOTION_PICKUP);
  6559. PointChange(POINT_GOLD, -gold, true);
  6560.  
  6561. if (gold > 1000) // Aμ¿ø AI≫o¸¸ ±a·ICN´U.
  6562. LogManager::instance().CharLog(this, gold, "DROP_GOLD", "");
  6563.  
  6564. item->StartDestroyEvent(5);
  6565. }
  6566.  
  6567. Save();
  6568. return true;
  6569. }
  6570.  
  6571. return false;
  6572. }
  6573.  
  6574. #ifdef ENABLE_CHEQUE_SYSTEM
  6575. bool CHARACTER::DropCheque(int cheque)
  6576. {
  6577. //--By: Edson.Jr
  6578. if (int(GetQuestFlag("BlockItem.Enable")) == 1)
  6579. {
  6580. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("INFO: Proibido remover o Won. Char protegido por senha!"));
  6581. return false;
  6582. }
  6583. //---------------------------------------------------------------------------------
  6584.  
  6585. if (cheque <= 0 || (long long)cheque > GetCheque())
  6586. return false;
  6587.  
  6588. if (!CanHandleItem())
  6589. return false;
  6590.  
  6591. if (0 != g_ChequeDropTimeLimitValue)
  6592. {
  6593. if (get_dword_time() < m_dwLastChequeDropTime+g_ChequeDropTimeLimitValue)
  6594. {
  6595. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("?? ??? ?? ? ????."));
  6596. return false;
  6597. }
  6598. }
  6599.  
  6600. m_dwLastChequeDropTime = get_dword_time();
  6601.  
  6602. LPITEM item = ITEM_MANAGER::instance().CreateItem(80020, cheque);
  6603.  
  6604. if (item)
  6605. {
  6606. PIXEL_POSITION pos = GetXYZ();
  6607.  
  6608. if (item->AddToGround(GetMapIndex(), pos))
  6609. {
  6610. PointChange(POINT_CHEQUE, -cheque, true);
  6611.  
  6612. if (cheque > 1000)
  6613. LogManager::instance().CharLog(this, cheque, "DROP_CHEQUE", "");
  6614.  
  6615. if (false == LC_IsBrazil())
  6616. {
  6617. item->StartDestroyEvent(150);
  6618. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("??? ???? %d? ? ?????."), 150/60);
  6619. }
  6620. else
  6621. {
  6622. item->StartDestroyEvent(60);
  6623. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("??? ???? %d? ? ?????."), 1);
  6624. }
  6625. }
  6626.  
  6627. Save();
  6628. return true;
  6629. }
  6630.  
  6631. return false;
  6632. }
  6633. #endif
  6634.  
  6635. bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
  6636. {
  6637. LPITEM item = NULL;
  6638.  
  6639. if (!IsValidItemPosition(Cell))
  6640. return false;
  6641.  
  6642. if (!(item = GetItem(Cell)))
  6643. return false;
  6644.  
  6645. if (item->IsExchanging())
  6646. return false;
  6647.  
  6648. if (item->GetCount() < count)
  6649. return false;
  6650.  
  6651. if (INVENTORY == Cell.window_type && Cell.cell >= INVENTORY_MAX_NUM && IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
  6652. return false;
  6653.  
  6654. if (true == item->isLocked())
  6655. return false;
  6656.  
  6657. if (!IsValidItemPosition(DestCell))
  6658. {
  6659. return false;
  6660. }
  6661.  
  6662. if (!CanHandleItem())
  6663. {
  6664. if (NULL != DragonSoul_RefineWindow_GetOpener())
  6665. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("PENCERE_ACIKK."));
  6666. return false;
  6667. }
  6668.  
  6669. // 기획자의 요청으로 벨트 인벤토리에는 특정 타입의 아이템만 넣을 수 있다.
  6670. if (DestCell.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(item))
  6671. {
  6672. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 벨트 인벤토리로 옮길 수 없습니다."));
  6673. return false;
  6674. }
  6675.  
  6676. // 이미 착용중인 아이템을 다른 곳으로 옮기는 경우, '장책 해제' 가능한 지 확인하고 옮김
  6677. if (Cell.IsEquipPosition() && !CanUnequipNow(item))
  6678. return false;
  6679.  
  6680. if (DestCell.IsEquipPosition())
  6681. {
  6682. if (GetItem(DestCell)) // 장비일 경우 한 곳만 검사해도 된다.
  6683. {
  6684. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 장비를 착용하고 있습니다."));
  6685.  
  6686. return false;
  6687. }
  6688.  
  6689. EquipItem(item, DestCell.cell - INVENTORY_MAX_NUM);
  6690. }
  6691. else
  6692. {
  6693. if (item->IsDragonSoul())
  6694. {
  6695. if (item->IsEquipped())
  6696. {
  6697. return DSManager::instance().PullOut(this, DestCell, item);
  6698. }
  6699. else
  6700. {
  6701. if (DestCell.window_type != DRAGON_SOUL_INVENTORY)
  6702. {
  6703. return false;
  6704. }
  6705.  
  6706. if (!DSManager::instance().IsValidCellForThisItem(item, DestCell))
  6707. return false;
  6708. }
  6709. }
  6710. // 용혼석이 아닌 아이템은 용혼석 인벤에 들어갈 수 없다.
  6711. else if (DRAGON_SOUL_INVENTORY == DestCell.window_type)
  6712. return false;
  6713.  
  6714. LPITEM item2;
  6715.  
  6716. if ((item2 = GetItem(DestCell)) && item != item2 && item2->IsStackable() &&
  6717. !IS_SET(item2->GetAntiFlag(), ITEM_ANTIFLAG_STACK) &&
  6718. item2->GetVnum() == item->GetVnum()) // 합칠 수 있는 아이템의 경우
  6719. {
  6720. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  6721. if (item2->GetSocket(i) != item->GetSocket(i))
  6722. return false;
  6723.  
  6724. if (count == 0)
  6725. count = item->GetCount();
  6726.  
  6727. sys_log(0, "%s: ITEM_STACK %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
  6728. DestCell.window_type, DestCell.cell, count);
  6729.  
  6730. count = MIN(200 - item2->GetCount(), count);
  6731.  
  6732. item->SetCount(item->GetCount() - count);
  6733. item2->SetCount(item2->GetCount() + count);
  6734. return true;
  6735. }
  6736.  
  6737. if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
  6738. return false;
  6739.  
  6740. if (count == 0 || count >= item->GetCount() || !item->IsStackable() || IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  6741. {
  6742. sys_log(0, "%s: ITEM_MOVE %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
  6743. DestCell.window_type, DestCell.cell, count);
  6744.  
  6745. item->RemoveFromCharacter();
  6746. SetItem(DestCell, item);
  6747.  
  6748. if (INVENTORY == Cell.window_type && INVENTORY == DestCell.window_type)
  6749. SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, DestCell.cell);
  6750. }
  6751. else if (count < item->GetCount())
  6752. {
  6753. sys_log(0, "%s: ITEM_SPLIT %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
  6754. DestCell.window_type, DestCell.cell, count);
  6755.  
  6756. item->SetCount(item->GetCount() - count);
  6757. LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), count);
  6758.  
  6759. // copy socket -- by mhh
  6760. FN_copy_item_socket(item2, item);
  6761.  
  6762. item2->AddToCharacter(this, DestCell);
  6763.  
  6764. char szBuf[51+1];
  6765. snprintf(szBuf, sizeof(szBuf), "%u %u %u %u ", item2->GetID(), item2->GetCount(), item->GetCount(), item->GetCount() + item2->GetCount());
  6766. LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
  6767. }
  6768. }
  6769.  
  6770. return true;
  6771. }
  6772.  
  6773. namespace NPartyPickupDistribute
  6774. {
  6775. struct FFindOwnership
  6776. {
  6777. LPITEM item;
  6778. LPCHARACTER owner;
  6779.  
  6780. FFindOwnership(LPITEM item)
  6781. : item(item), owner(NULL)
  6782. {
  6783. }
  6784.  
  6785. void operator () (LPCHARACTER ch)
  6786. {
  6787. if (item->IsOwnership(ch))
  6788. owner = ch;
  6789. }
  6790. };
  6791.  
  6792. struct FCountNearMember
  6793. {
  6794. int total;
  6795. int x, y;
  6796.  
  6797. FCountNearMember(LPCHARACTER center )
  6798. : total(0), x(center->GetX()), y(center->GetY())
  6799. {
  6800. }
  6801.  
  6802. void operator () (LPCHARACTER ch)
  6803. {
  6804. if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
  6805. total += 1;
  6806. }
  6807. };
  6808.  
  6809. struct FMoneyDistributor
  6810. {
  6811. int total;
  6812. LPCHARACTER c;
  6813. int x, y;
  6814. int iMoney;
  6815.  
  6816. FMoneyDistributor(LPCHARACTER center, int iMoney)
  6817. : total(0), c(center), x(center->GetX()), y(center->GetY()), iMoney(iMoney)
  6818. {
  6819. }
  6820.  
  6821. void operator ()(LPCHARACTER ch)
  6822. {
  6823. if (ch!=c)
  6824. if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
  6825. {
  6826. ch->PointChange(POINT_GOLD, iMoney, true);
  6827.  
  6828. if (iMoney > 1000) // 천원 이상만 기록한다.
  6829. LogManager::instance().CharLog(ch, iMoney, "GET_GOLD", "");
  6830. }
  6831. }
  6832. };
  6833.  
  6834. #ifdef ENABLE_CHEQUE_SYSTEM
  6835. struct FChequeDistributor
  6836. {
  6837. int total;
  6838. LPCHARACTER c;
  6839. int x, y;
  6840. int iCheque;
  6841.  
  6842. FChequeDistributor(LPCHARACTER center, int iCheque)
  6843. : total(0), c(center), x(center->GetX()), y(center->GetY()), iCheque(iCheque)
  6844. {
  6845. }
  6846.  
  6847. void operator ()(LPCHARACTER ch)
  6848. {
  6849. if (ch!=c)
  6850. if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
  6851. {
  6852. ch->PointChange(POINT_CHEQUE, iCheque, true);
  6853.  
  6854. if (iCheque > 1000) // ?? ??? ????.
  6855. LogManager::instance().CharLog(ch, iCheque, "GET_CHEQUE", "");
  6856. }
  6857. }
  6858. };
  6859. #endif
  6860. }
  6861.  
  6862.  
  6863.  
  6864. void CHARACTER::GiveGold(int iAmount)
  6865. {
  6866. if (iAmount <= 0)
  6867. return;
  6868.  
  6869. sys_log(0, "GIVE_GOLD: %s %lld", GetName(), iAmount);
  6870.  
  6871. if (GetParty())
  6872. {
  6873. LPPARTY pParty = GetParty();
  6874.  
  6875. // 파티가 있는 경우 나누어 가진다.
  6876. DWORD dwTotal = iAmount;
  6877. DWORD dwMyAmount = dwTotal;
  6878.  
  6879. NPartyPickupDistribute::FCountNearMember funcCountNearMember(this);
  6880. pParty->ForEachOnlineMember(funcCountNearMember);
  6881.  
  6882. if (funcCountNearMember.total > 1)
  6883. {
  6884. DWORD dwShare = dwTotal / funcCountNearMember.total;
  6885. dwMyAmount -= dwShare * (funcCountNearMember.total - 1);
  6886.  
  6887. NPartyPickupDistribute::FMoneyDistributor funcMoneyDist(this, dwShare);
  6888.  
  6889. pParty->ForEachOnlineMember(funcMoneyDist);
  6890. }
  6891.  
  6892. PointChange(POINT_GOLD, dwMyAmount, true);
  6893.  
  6894. if (dwMyAmount > 1000) // 천원 이상만 기록한다.
  6895. LogManager::instance().CharLog(this, dwMyAmount, "GET_GOLD", "");
  6896. }
  6897. else
  6898. {
  6899. PointChange(POINT_GOLD, iAmount, true);
  6900.  
  6901. // 브라질에 돈이 없어진다는 버그가 있는데,
  6902. // 가능한 시나리오 중에 하나는,
  6903. // 메크로나, 핵을 써서 1000원 이하의 돈을 계속 버려 골드를 0으로 만들고,
  6904. // 돈이 없어졌다고 복구 신청하는 것일 수도 있다.
  6905. // 따라서 그런 경우를 잡기 위해 낮은 수치의 골드에 대해서도 로그를 남김.
  6906. if (LC_IsBrazil() == true)
  6907. {
  6908. if (iAmount >= 213)
  6909. LogManager::instance().CharLog(this, iAmount, "GET_GOLD", "");
  6910. }
  6911. else
  6912. {
  6913. if (iAmount > 1000) // 천원 이상만 기록한다.
  6914. LogManager::instance().CharLog(this, iAmount, "GET_GOLD", "");
  6915. }
  6916. }
  6917. }
  6918.  
  6919. #ifdef ENABLE_CHEQUE_SYSTEM
  6920. void CHARACTER::GiveCheque(int iAmount)
  6921. {
  6922. if (iAmount <= 0)
  6923. return;
  6924.  
  6925. //sys_log(0, "GIVE_GOLD: %s %lld", GetName(), iAmount);
  6926.  
  6927. if (GetParty())
  6928. {
  6929. LPPARTY pParty = GetParty();
  6930.  
  6931. DWORD dwTotal = iAmount;
  6932. DWORD dwMyAmount = dwTotal;
  6933.  
  6934. NPartyPickupDistribute::FCountNearMember funcCountNearMember(this);
  6935. pParty->ForEachOnlineMember(funcCountNearMember);
  6936.  
  6937. if (funcCountNearMember.total > 1)
  6938. {
  6939. DWORD dwShare = dwTotal / funcCountNearMember.total;
  6940. dwMyAmount -= dwShare * (funcCountNearMember.total - 1);
  6941.  
  6942. NPartyPickupDistribute::FChequeDistributor funcChequeDist(this, dwShare);
  6943.  
  6944. pParty->ForEachOnlineMember(funcChequeDist);
  6945. }
  6946.  
  6947. PointChange(POINT_CHEQUE, dwMyAmount, true);
  6948.  
  6949. if (dwMyAmount > 1000)
  6950. LogManager::instance().CharLog(this, dwMyAmount, "GET_CHEQUE", "");
  6951. }
  6952. else
  6953. {
  6954. PointChange(POINT_CHEQUE, iAmount, true);
  6955.  
  6956. if (iAmount > 1000)
  6957. LogManager::instance().CharLog(this, iAmount, "GET_CHEQUE", "");
  6958. }
  6959. }
  6960. #endif
  6961.  
  6962. bool CHARACTER::PickupItem(DWORD dwVID)
  6963. {
  6964. LPITEM item = ITEM_MANAGER::instance().FindByVID(dwVID);
  6965.  
  6966. if (IsObserverMode())
  6967. return false;
  6968.  
  6969. if (!item || !item->GetSectree())
  6970. return false;
  6971.  
  6972. if (item->DistanceValid(this))
  6973. {
  6974. if (item->IsOwnership(this))
  6975. {
  6976. // 만약 주으려 하는 아이템이 엘크라면
  6977. if (item->GetType() == ITEM_ELK)
  6978. {
  6979. GiveGold(item->GetCount());
  6980. item->RemoveFromGround();
  6981.  
  6982. M2_DESTROY_ITEM(item);
  6983.  
  6984. Save();
  6985. }
  6986. #ifdef ENABLE_CHEQUE_SYSTEM
  6987. else if (item->GetType() == ITEM_WON)
  6988. {
  6989. GiveCheque(item->GetCount());
  6990. item->RemoveFromGround();
  6991.  
  6992. M2_DESTROY_ITEM(item);
  6993.  
  6994. Save();
  6995. }
  6996. #endif
  6997. // 평범한 아이템이라면
  6998. else
  6999. {
  7000. if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7001. {
  7002. BYTE bCount = item->GetCount();
  7003.  
  7004. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  7005. {
  7006. LPITEM item2 = GetInventoryItem(i);
  7007.  
  7008. if (!item2)
  7009. continue;
  7010.  
  7011. if (item2->GetVnum() == item->GetVnum())
  7012. {
  7013. int j;
  7014.  
  7015. for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
  7016. if (item2->GetSocket(j) != item->GetSocket(j))
  7017. break;
  7018.  
  7019. if (j != ITEM_SOCKET_MAX_NUM)
  7020. continue;
  7021.  
  7022. BYTE bCount2 = MIN(200 - item2->GetCount(), bCount);
  7023. bCount -= bCount2;
  7024.  
  7025. item2->SetCount(item2->GetCount() + bCount2);
  7026.  
  7027. if (bCount == 0)
  7028. {
  7029. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item2->GetName());
  7030. M2_DESTROY_ITEM(item);
  7031. if (item2->GetType() == ITEM_QUEST)
  7032. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
  7033. return true;
  7034. }
  7035. }
  7036. }
  7037.  
  7038. item->SetCount(bCount);
  7039. }
  7040.  
  7041. int iEmptyCell;
  7042. if (item->IsDragonSoul())
  7043. {
  7044. if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
  7045. {
  7046. sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7047. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지하고 있는 아이템이 너무 많습니다."));
  7048. return false;
  7049. }
  7050. }
  7051. else
  7052. {
  7053. if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
  7054. {
  7055. sys_log(0, "No empty inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7056. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지하고 있는 아이템이 너무 많습니다."));
  7057. return false;
  7058. }
  7059. }
  7060.  
  7061. item->RemoveFromGround();
  7062.  
  7063. if (item->IsDragonSoul())
  7064. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
  7065. else
  7066. item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
  7067.  
  7068. char szHint[32+1];
  7069. snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
  7070. LogManager::instance().ItemLog(this, item, "GET", szHint);
  7071. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
  7072.  
  7073. if (item->GetType() == ITEM_QUEST)
  7074. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
  7075. }
  7076.  
  7077. //Motion(MOTION_PICKUP);
  7078. return true;
  7079. }
  7080. else if (!IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_DROP) && GetParty())
  7081. {
  7082. // 다른 파티원 소유권 아이템을 주으려고 한다면
  7083. NPartyPickupDistribute::FFindOwnership funcFindOwnership(item);
  7084.  
  7085. GetParty()->ForEachOnlineMember(funcFindOwnership);
  7086.  
  7087. LPCHARACTER owner = funcFindOwnership.owner;
  7088.  
  7089. if (!owner)
  7090. return false;
  7091.  
  7092. int iEmptyCell;
  7093.  
  7094. if (item->IsDragonSoul())
  7095. {
  7096. if (!(owner && (iEmptyCell = owner->GetEmptyDragonSoulInventory(item)) != -1))
  7097. {
  7098. owner = this;
  7099.  
  7100. if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
  7101. {
  7102. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지하고 있는 아이템이 너무 많습니다."));
  7103. return false;
  7104. }
  7105. }
  7106. }
  7107. else
  7108. {
  7109. if (!(owner && (iEmptyCell = owner->GetEmptyInventory(item->GetSize())) != -1))
  7110. {
  7111. owner = this;
  7112.  
  7113. if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
  7114. {
  7115. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지하고 있는 아이템이 너무 많습니다."));
  7116. return false;
  7117. }
  7118. }
  7119. }
  7120.  
  7121. item->RemoveFromGround();
  7122.  
  7123. if (item->IsDragonSoul())
  7124. item->AddToCharacter(owner, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
  7125. else
  7126. item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
  7127.  
  7128. char szHint[32+1];
  7129. snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
  7130. LogManager::instance().ItemLog(owner, item, "GET", szHint);
  7131.  
  7132. if (owner == this)
  7133. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
  7134. else
  7135. {
  7136. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s 님으로부터 %s"), GetName(), item->GetName());
  7137. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 전달: %s 님에게 %s"), owner->GetName(), item->GetName());
  7138. }
  7139.  
  7140. if (item->GetType() == ITEM_QUEST)
  7141. quest::CQuestManager::instance().PickupItem (owner->GetPlayerID(), item);
  7142.  
  7143. return true;
  7144. }
  7145. }
  7146.  
  7147. return false;
  7148. }
  7149.  
  7150. bool CHARACTER::SwapItem(BYTE bCell, BYTE bDestCell)
  7151. {
  7152. if (!CanHandleItem())
  7153. return false;
  7154.  
  7155. TItemPos srcCell(INVENTORY, bCell), destCell(INVENTORY, bDestCell);
  7156.  
  7157. // 올바른 Cell 인지 검사
  7158. // 용혼석은 Swap할 수 없으므로, 여기서 걸림.
  7159. //if (bCell >= INVENTORY_MAX_NUM + WEAR_MAX_NUM || bDestCell >= INVENTORY_MAX_NUM + WEAR_MAX_NUM)
  7160. if (srcCell.IsDragonSoulEquipPosition() || destCell.IsDragonSoulEquipPosition())
  7161. return false;
  7162.  
  7163. // 같은 CELL 인지 검사
  7164. if (bCell == bDestCell)
  7165. return false;
  7166.  
  7167. // 둘 다 장비창 위치면 Swap 할 수 없다.
  7168. if (srcCell.IsEquipPosition() && destCell.IsEquipPosition())
  7169. return false;
  7170.  
  7171. LPITEM item1, item2;
  7172.  
  7173. // item2가 장비창에 있는 것이 되도록.
  7174. if (srcCell.IsEquipPosition())
  7175. {
  7176. item1 = GetInventoryItem(bDestCell);
  7177. item2 = GetInventoryItem(bCell);
  7178. }
  7179. else
  7180. {
  7181. item1 = GetInventoryItem(bCell);
  7182. item2 = GetInventoryItem(bDestCell);
  7183. }
  7184.  
  7185. if (!item1 || !item2)
  7186. return false;
  7187.  
  7188. if (item1 == item2)
  7189. {
  7190. sys_log(0, "[WARNING][WARNING][HACK USER!] : %s %d %d", m_stName.c_str(), bCell, bDestCell);
  7191. return false;
  7192. }
  7193.  
  7194. // item2가 bCell위치에 들어갈 수 있는지 확인한다.
  7195. if (!IsEmptyItemGrid(TItemPos (INVENTORY, item1->GetCell()), item2->GetSize(), item1->GetCell()))
  7196. return false;
  7197.  
  7198. // 바꿀 아이템이 장비창에 있으면
  7199. if (TItemPos(EQUIPMENT, item2->GetCell()).IsEquipPosition())
  7200. {
  7201. BYTE bEquipCell = item2->GetCell() - INVENTORY_MAX_NUM;
  7202. BYTE bInvenCell = item1->GetCell();
  7203.  
  7204. // 착용중인 아이템을 벗을 수 있고, 착용 예정 아이템이 착용 가능한 상태여야만 진행
  7205. //if (false == CanUnequipNow(item2) || false == CanEquipNow(item1))
  7206. if (item2->IsDragonSoul()) // @fixme117
  7207. {
  7208. if (false == CanUnequipNow(item2) || false == CanEquipNow(item1))
  7209. return false;
  7210. }
  7211.  
  7212. if (bEquipCell != item1->FindEquipCell(this)) // 같은 위치일때만 허용
  7213. return false;
  7214.  
  7215. item2->RemoveFromCharacter();
  7216.  
  7217. if (item1->EquipTo(this, bEquipCell))
  7218. #ifdef __HIGHLIGHT_SYSTEM__
  7219. item2->AddToCharacter(this, TItemPos(INVENTORY, bInvenCell), false);
  7220. #else
  7221. item2->AddToCharacter(this, TItemPos(INVENTORY, bInvenCell));
  7222. #endif
  7223. else
  7224. sys_err("SwapItem cannot equip %s! item1 %s", item2->GetName(), item1->GetName());
  7225. }
  7226. else
  7227. {
  7228. BYTE bCell1 = item1->GetCell();
  7229. BYTE bCell2 = item2->GetCell();
  7230.  
  7231. item1->RemoveFromCharacter();
  7232. item2->RemoveFromCharacter();
  7233.  
  7234. #ifdef __HIGHLIGHT_SYSTEM__
  7235. item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2), false);
  7236. item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1), false);
  7237. #else
  7238. item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2));
  7239. item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1));
  7240. #endif
  7241. }
  7242.  
  7243. return true;
  7244. }
  7245.  
  7246. bool CHARACTER::UnequipItem(LPITEM item)
  7247. {
  7248. int pos;
  7249.  
  7250. if (false == CanUnequipNow(item))
  7251. return false;
  7252.  
  7253. if (item->IsDragonSoul())
  7254. pos = GetEmptyDragonSoulInventory(item);
  7255. else
  7256. pos = GetEmptyInventory(item->GetSize());
  7257.  
  7258. // HARD CODING
  7259. if (item->GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
  7260. ShowAlignment(true);
  7261.  
  7262. item->RemoveFromCharacter();
  7263.  
  7264. if (item->IsDragonSoul())
  7265. #ifdef __HIGHLIGHT_SYSTEM__
  7266. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, pos), false);
  7267. #else
  7268. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, pos));
  7269. #endif
  7270. else
  7271. #ifdef __HIGHLIGHT_SYSTEM__
  7272. item->AddToCharacter(this, TItemPos(INVENTORY, pos), false);
  7273. #else
  7274. item->AddToCharacter(this, TItemPos(INVENTORY, pos));
  7275. #endif
  7276.  
  7277. CheckMaximumPoints();
  7278.  
  7279. return true;
  7280. }
  7281.  
  7282. //
  7283. // @version 05/07/05 Bang2ni - Skill 사용후 1.5 초 이내에 장비 착용 금지
  7284. //
  7285. bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
  7286. {
  7287. if (item->IsExchanging())
  7288. return false;
  7289.  
  7290. if (false == item->IsEquipable())
  7291. return false;
  7292.  
  7293. if (false == CanEquipNow(item))
  7294. return false;
  7295.  
  7296. int iWearCell = item->FindEquipCell(this, iCandidateCell);
  7297.  
  7298. if ((iWearCell == WEAR_BODY || iWearCell == WEAR_COSTUME_BODY) && IsRiding() && get_global_time() < GetQuestFlag("zirh.engel"))
  7299. {
  7300. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("bu_islemi_bukadar_hizli_yapamazsin"));
  7301. return false;
  7302. }
  7303.  
  7304. if (iWearCell < 0)
  7305. return false;
  7306.  
  7307. // 무언가를 탄 상태에서 턱시도 입기 금지
  7308. if (iWearCell == WEAR_BODY && IsRiding() && (item->GetVnum() >= 11901 && item->GetVnum() <= 11904))
  7309. {
  7310. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("말을 탄 상태에서 예복을 입을 수 없습니다."));
  7311. return false;
  7312. }
  7313.  
  7314. if (iWearCell != WEAR_ARROW && IsPolymorphed())
  7315. {
  7316. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑 중에는 착용중인 장비를 변경할 수 없습니다."));
  7317. return false;
  7318. }
  7319.  
  7320. if (FN_check_item_sex(this, item) == false)
  7321. {
  7322. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("성별이 맞지않아 이 아이템을 사용할 수 없습니다."));
  7323. return false;
  7324. }
  7325.  
  7326. //신규 탈것 사용시 기존 말 사용여부 체크
  7327. if(item->IsRideItem() && IsRiding())
  7328. {
  7329. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 탈것을 이용중입니다."));
  7330. return false;
  7331. }
  7332.  
  7333. // 화살 이외에는 마지막 공격 시간 또는 스킬 사용 1.5 후에 장비 교체가 가능
  7334. DWORD dwCurTime = get_dword_time();
  7335.  
  7336. if (iWearCell != WEAR_ARROW
  7337. && (dwCurTime - GetLastAttackTime() <= 1500 || dwCurTime - m_dwLastSkillTime <= 1500))
  7338. {
  7339. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("가만히 있을 때만 착용할 수 있습니다."));
  7340. return false;
  7341. }
  7342.  
  7343. // 용혼석 특수 처리
  7344. if (item->IsDragonSoul())
  7345. {
  7346. // 같은 타입의 용혼석이 이미 들어가 있다면 착용할 수 없다.
  7347. // 용혼석은 swap을 지원하면 안됨.
  7348. if(GetInventoryItem(INVENTORY_MAX_NUM + iWearCell))
  7349. {
  7350. ChatPacket(CHAT_TYPE_INFO, "이미 같은 종류의 용혼석을 착용하고 있습니다.");
  7351. return false;
  7352. }
  7353.  
  7354. if (!item->EquipTo(this, iWearCell))
  7355. {
  7356. return false;
  7357. }
  7358. }
  7359. // 용혼석이 아님.
  7360. else
  7361. {
  7362. // 착용할 곳에 아이템이 있다면,
  7363. if (GetWear(iWearCell) && !IS_SET(GetWear(iWearCell)->GetFlag(), ITEM_FLAG_IRREMOVABLE))
  7364. {
  7365. // 이 아이템은 한번 박히면 변경 불가. swap 역시 완전 불가
  7366. if (item->GetWearFlag() == WEARABLE_ABILITY)
  7367. return false;
  7368.  
  7369. if (false == SwapItem(item->GetCell(), INVENTORY_MAX_NUM + iWearCell))
  7370. {
  7371. return false;
  7372. }
  7373. }
  7374. else
  7375. {
  7376. BYTE bOldCell = item->GetCell();
  7377.  
  7378. if (item->EquipTo(this, iWearCell))
  7379. {
  7380. SyncQuickslot(QUICKSLOT_TYPE_ITEM, bOldCell, iWearCell);
  7381. }
  7382. }
  7383. }
  7384.  
  7385. if (true == item->IsEquipped())
  7386. {
  7387. // 아이템 최초 사용 이후부터는 사용하지 않아도 시간이 차감되는 방식 처리.
  7388. if (-1 != item->GetProto()->cLimitRealTimeFirstUseIndex)
  7389. {
  7390. // 한 번이라도 사용한 아이템인지 여부는 Socket1을 보고 판단한다. (Socket1에 사용횟수 기록)
  7391. if (0 == item->GetSocket(1))
  7392. {
  7393. // 사용가능시간은 Default 값으로 Limit Value 값을 사용하되, Socket0에 값이 있으면 그 값을 사용하도록 한다. (단위는 초)
  7394. long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[item->GetProto()->cLimitRealTimeFirstUseIndex].lValue;
  7395.  
  7396. if (0 == duration)
  7397. duration = 60 * 60 * 24 * 7;
  7398.  
  7399. item->SetSocket(0, time(0) + duration);
  7400. item->StartRealTimeExpireEvent();
  7401. }
  7402.  
  7403. item->SetSocket(1, item->GetSocket(1) + 1);
  7404. }
  7405.  
  7406. if (item->GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
  7407. ShowAlignment(false);
  7408.  
  7409. const DWORD& dwVnum = item->GetVnum();
  7410.  
  7411. // 라마단 이벤트 초승달의 반지(71135) 착용시 이펙트 발동
  7412. if (true == CItemVnumHelper::IsRamadanMoonRing(dwVnum))
  7413. {
  7414. this->EffectPacket(SE_EQUIP_RAMADAN_RING);
  7415. }
  7416. // 할로윈 사탕(71136) 착용시 이펙트 발동
  7417. else if (true == CItemVnumHelper::IsHalloweenCandy(dwVnum))
  7418. {
  7419. this->EffectPacket(SE_EQUIP_HALLOWEEN_CANDY);
  7420. }
  7421. // 행복의 반지(71143) 착용시 이펙트 발동
  7422. else if (true == CItemVnumHelper::IsHappinessRing(dwVnum))
  7423. {
  7424. this->EffectPacket(SE_EQUIP_HAPPINESS_RING);
  7425. }
  7426. // 사랑의 팬던트(71145) 착용시 이펙트 발동
  7427. else if (true == CItemVnumHelper::IsLovePendant(dwVnum))
  7428. {
  7429. this->EffectPacket(SE_EQUIP_LOVE_PENDANT);
  7430. }
  7431. // ITEM_UNIQUE의 경우, SpecialItemGroup에 정의되어 있고, (item->GetSIGVnum() != NULL)
  7432. //
  7433. else if (ITEM_UNIQUE == item->GetType() && 0 != item->GetSIGVnum())
  7434. {
  7435. const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(item->GetSIGVnum());
  7436. if (NULL != pGroup)
  7437. {
  7438. const CSpecialAttrGroup* pAttrGroup = ITEM_MANAGER::instance().GetSpecialAttrGroup(pGroup->GetAttrVnum(item->GetVnum()));
  7439. if (NULL != pAttrGroup)
  7440. {
  7441. const std::string& std = pAttrGroup->m_stEffectFileName;
  7442. SpecificEffectPacket(std.c_str());
  7443. }
  7444. }
  7445. }
  7446. #ifdef __SASH_SYSTEM__
  7447. else if ((item->GetType() == ITEM_COSTUME) && (item->GetSubType() == COSTUME_SASH))
  7448. this->EffectPacket(SE_EFFECT_SASH_EQUIP);
  7449. #endif
  7450.  
  7451. if (UNIQUE_SPECIAL_RIDE == item->GetSubType() && IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE))
  7452. {
  7453. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  7454. }
  7455.  
  7456. if (COSTUME_MOUNT == item->GetSubType())
  7457. {
  7458. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  7459. }
  7460.  
  7461. if ((iWearCell == WEAR_BODY || iWearCell == WEAR_COSTUME_BODY) && IsRiding())
  7462. {
  7463. SetQuestFlag("zirh.engel", get_global_time() + 2);
  7464. }
  7465. }
  7466.  
  7467. return true;
  7468. }
  7469.  
  7470. void CHARACTER::BuffOnAttr_AddBuffsFromItem(LPITEM pItem)
  7471. {
  7472. for (size_t i = 0; i < sizeof(g_aBuffOnAttrPoints)/sizeof(g_aBuffOnAttrPoints[0]); i++)
  7473. {
  7474. TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(g_aBuffOnAttrPoints[i]);
  7475. if (it != m_map_buff_on_attrs.end())
  7476. {
  7477. it->second->AddBuffFromItem(pItem);
  7478. }
  7479. }
  7480. }
  7481.  
  7482. void CHARACTER::BuffOnAttr_RemoveBuffsFromItem(LPITEM pItem)
  7483. {
  7484. for (size_t i = 0; i < sizeof(g_aBuffOnAttrPoints)/sizeof(g_aBuffOnAttrPoints[0]); i++)
  7485. {
  7486. TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(g_aBuffOnAttrPoints[i]);
  7487. if (it != m_map_buff_on_attrs.end())
  7488. {
  7489. it->second->RemoveBuffFromItem(pItem);
  7490. }
  7491. }
  7492. }
  7493.  
  7494. void CHARACTER::BuffOnAttr_ClearAll()
  7495. {
  7496. for (TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.begin(); it != m_map_buff_on_attrs.end(); it++)
  7497. {
  7498. CBuffOnAttributes* pBuff = it->second;
  7499. if (pBuff)
  7500. {
  7501. pBuff->Initialize();
  7502. }
  7503. }
  7504. }
  7505.  
  7506. void CHARACTER::BuffOnAttr_ValueChange(BYTE bType, BYTE bOldValue, BYTE bNewValue)
  7507. {
  7508. TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(bType);
  7509.  
  7510. if (0 == bNewValue)
  7511. {
  7512. if (m_map_buff_on_attrs.end() == it)
  7513. return;
  7514. else
  7515. it->second->Off();
  7516. }
  7517. else if(0 == bOldValue)
  7518. {
  7519. CBuffOnAttributes* pBuff = NULL;
  7520. if (m_map_buff_on_attrs.end() == it)
  7521. {
  7522. switch (bType)
  7523. {
  7524. case POINT_ENERGY:
  7525. {
  7526. static BYTE abSlot[] = { WEAR_BODY, WEAR_HEAD, WEAR_FOOTS, WEAR_WRIST, WEAR_WEAPON, WEAR_NECK, WEAR_EAR, WEAR_SHIELD };
  7527. static std::vector <BYTE> vec_slots (abSlot, abSlot + _countof(abSlot));
  7528. pBuff = M2_NEW CBuffOnAttributes(this, bType, &vec_slots);
  7529. }
  7530. break;
  7531. case POINT_COSTUME_ATTR_BONUS:
  7532. {
  7533. static BYTE abSlot[] = { WEAR_COSTUME_BODY, WEAR_COSTUME_HAIR,
  7534. #ifdef __WEAPON_COSTUME_SYSTEM__
  7535. WEAR_COSTUME_WEAPON,
  7536. #endif
  7537. WEAR_COSTUME_MOUNT
  7538. };
  7539. static std::vector <BYTE> vec_slots (abSlot, abSlot + _countof(abSlot));
  7540. pBuff = M2_NEW CBuffOnAttributes(this, bType, &vec_slots);
  7541. }
  7542. break;
  7543. default:
  7544. break;
  7545. }
  7546. m_map_buff_on_attrs.insert(TMapBuffOnAttrs::value_type(bType, pBuff));
  7547.  
  7548. }
  7549. else
  7550. pBuff = it->second;
  7551. if (pBuff != NULL)
  7552. pBuff->On(bNewValue);
  7553. }
  7554. else
  7555. {
  7556. assert (m_map_buff_on_attrs.end() != it);
  7557. it->second->ChangeBuffValue(bNewValue);
  7558. }
  7559. }
  7560.  
  7561.  
  7562. LPITEM CHARACTER::FindSpecifyItem(DWORD vnum) const
  7563. {
  7564. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  7565. if (GetInventoryItem(i) && GetInventoryItem(i)->GetVnum() == vnum)
  7566. return GetInventoryItem(i);
  7567.  
  7568. return NULL;
  7569. }
  7570.  
  7571. LPITEM CHARACTER::FindItemByID(DWORD id) const
  7572. {
  7573. for (int i=0 ; i < INVENTORY_MAX_NUM ; ++i)
  7574. {
  7575. if (NULL != GetInventoryItem(i) && GetInventoryItem(i)->GetID() == id)
  7576. return GetInventoryItem(i);
  7577. }
  7578.  
  7579. for (int i=BELT_INVENTORY_SLOT_START; i < BELT_INVENTORY_SLOT_END ; ++i)
  7580. {
  7581. if (NULL != GetInventoryItem(i) && GetInventoryItem(i)->GetID() == id)
  7582. return GetInventoryItem(i);
  7583. }
  7584.  
  7585. return NULL;
  7586. }
  7587.  
  7588. int CHARACTER::CountSpecifyItem(DWORD vnum) const
  7589. {
  7590. int count = 0;
  7591. LPITEM item;
  7592.  
  7593. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  7594. {
  7595. item = GetInventoryItem(i);
  7596. if (NULL != item && item->GetVnum() == vnum)
  7597. {
  7598. // 개인 상점에 등록된 물건이면 넘어간다.
  7599. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  7600. {
  7601. continue;
  7602. }
  7603. else
  7604. {
  7605. count += item->GetCount();
  7606. }
  7607. }
  7608. }
  7609.  
  7610. return count;
  7611. }
  7612.  
  7613. void CHARACTER::RemoveSpecifyItem(DWORD vnum, DWORD count)
  7614. {
  7615. if (0 == count)
  7616. return;
  7617.  
  7618. for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
  7619. {
  7620. if (NULL == GetInventoryItem(i))
  7621. continue;
  7622.  
  7623. if (GetInventoryItem(i)->GetVnum() != vnum)
  7624. continue;
  7625.  
  7626. //개인 상점에 등록된 물건이면 넘어간다. (개인 상점에서 판매될때 이 부분으로 들어올 경우 문제!)
  7627. if(m_pkMyShop)
  7628. {
  7629. bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
  7630. if (isItemSelling)
  7631. continue;
  7632. }
  7633.  
  7634. if (vnum >= 80003 && vnum <= 80007)
  7635. LogManager::instance().GoldBarLog(GetPlayerID(), GetInventoryItem(i)->GetID(), QUEST, "RemoveSpecifyItem");
  7636.  
  7637. if (count >= GetInventoryItem(i)->GetCount())
  7638. {
  7639. count -= GetInventoryItem(i)->GetCount();
  7640. GetInventoryItem(i)->SetCount(0);
  7641.  
  7642. if (0 == count)
  7643. return;
  7644. }
  7645. else
  7646. {
  7647. GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
  7648. return;
  7649. }
  7650. }
  7651.  
  7652. // 예외처리가 약하다.
  7653. if (count)
  7654. sys_log(0, "CHARACTER::RemoveSpecifyItem cannot remove enough item vnum %u, still remain %d", vnum, count);
  7655. }
  7656.  
  7657. int CHARACTER::CountSpecifyTypeItem(BYTE type) const
  7658. {
  7659. int count = 0;
  7660.  
  7661. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  7662. {
  7663. LPITEM pItem = GetInventoryItem(i);
  7664. if (pItem != NULL && pItem->GetType() == type)
  7665. {
  7666. count += pItem->GetCount();
  7667. }
  7668. }
  7669.  
  7670. return count;
  7671. }
  7672.  
  7673. void CHARACTER::RemoveSpecifyTypeItem(BYTE type, DWORD count)
  7674. {
  7675. if (0 == count)
  7676. return;
  7677.  
  7678. for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
  7679. {
  7680. if (NULL == GetInventoryItem(i))
  7681. continue;
  7682.  
  7683. if (GetInventoryItem(i)->GetType() != type)
  7684. continue;
  7685.  
  7686. //개인 상점에 등록된 물건이면 넘어간다. (개인 상점에서 판매될때 이 부분으로 들어올 경우 문제!)
  7687. if(m_pkMyShop)
  7688. {
  7689. bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
  7690. if (isItemSelling)
  7691. continue;
  7692. }
  7693.  
  7694. if (count >= GetInventoryItem(i)->GetCount())
  7695. {
  7696. count -= GetInventoryItem(i)->GetCount();
  7697. GetInventoryItem(i)->SetCount(0);
  7698.  
  7699. if (0 == count)
  7700. return;
  7701. }
  7702. else
  7703. {
  7704. GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
  7705. return;
  7706. }
  7707. }
  7708. }
  7709.  
  7710. void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
  7711. {
  7712. if (NULL == item)
  7713. {
  7714. sys_err ("NULL point.");
  7715. return;
  7716. }
  7717. if (item->GetOwner())
  7718. {
  7719. sys_err ("item %d 's owner exists!",item->GetID());
  7720. return;
  7721. }
  7722.  
  7723. int cell;
  7724. if (item->IsDragonSoul())
  7725. {
  7726. cell = GetEmptyDragonSoulInventory(item);
  7727. }
  7728. else
  7729. {
  7730. cell = GetEmptyInventory (item->GetSize());
  7731. }
  7732.  
  7733. if (cell != -1)
  7734. {
  7735. if (item->IsDragonSoul())
  7736. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
  7737. else
  7738. item->AddToCharacter(this, TItemPos(INVENTORY, cell));
  7739.  
  7740. LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
  7741.  
  7742. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
  7743. {
  7744. TQuickslot * pSlot;
  7745.  
  7746. if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
  7747. {
  7748. TQuickslot slot;
  7749. slot.type = QUICKSLOT_TYPE_ITEM;
  7750. slot.pos = cell;
  7751. SetQuickslot(0, slot);
  7752. }
  7753. }
  7754. }
  7755. else
  7756. {
  7757. item->AddToGround (GetMapIndex(), GetXYZ());
  7758. item->StartDestroyEvent();
  7759.  
  7760. if (longOwnerShip)
  7761. item->SetOwnership (this, 300);
  7762. else
  7763. item->SetOwnership (this, 60);
  7764. LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
  7765. }
  7766. }
  7767.  
  7768. LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, BYTE bCount, int iRarePct, bool bMsg)
  7769. {
  7770. TItemTable * p = ITEM_MANAGER::instance().GetTable(dwItemVnum);
  7771.  
  7772. if (!p)
  7773. return NULL;
  7774.  
  7775. DBManager::instance().SendMoneyLog(MONEY_LOG_DROP, dwItemVnum, bCount);
  7776.  
  7777. if (p->dwFlags & ITEM_FLAG_STACKABLE && p->bType != ITEM_BLEND)
  7778. {
  7779. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  7780. {
  7781. LPITEM item = GetInventoryItem(i);
  7782.  
  7783. if (!item)
  7784. continue;
  7785.  
  7786. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  7787. {
  7788. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  7789. {
  7790. if (bCount < p->alValues[1])
  7791. bCount = p->alValues[1];
  7792. }
  7793.  
  7794. BYTE bCount2 = MIN(200 - item->GetCount(), bCount);
  7795. bCount -= bCount2;
  7796.  
  7797. item->SetCount(item->GetCount() + bCount2);
  7798.  
  7799. if (bCount == 0)
  7800. {
  7801. if (bMsg)
  7802. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
  7803.  
  7804. return item;
  7805. }
  7806. }
  7807. }
  7808. }
  7809.  
  7810. LPITEM item = ITEM_MANAGER::instance().CreateItem(dwItemVnum, bCount, 0, true);
  7811.  
  7812. if (!item)
  7813. {
  7814. sys_err("cannot create item by vnum %u (name: %s)", dwItemVnum, GetName());
  7815. return NULL;
  7816. }
  7817.  
  7818. if (item->GetType() == ITEM_BLEND)
  7819. {
  7820. for (int i=0; i < INVENTORY_MAX_NUM; i++)
  7821. {
  7822. LPITEM inv_item = GetInventoryItem(i);
  7823.  
  7824. if (inv_item == NULL) continue;
  7825.  
  7826. if (inv_item->GetType() == ITEM_BLEND)
  7827. {
  7828. if (inv_item->GetVnum() == item->GetVnum())
  7829. {
  7830. if (inv_item->GetSocket(0) == item->GetSocket(0) &&
  7831. inv_item->GetSocket(1) == item->GetSocket(1) &&
  7832. inv_item->GetSocket(2) == item->GetSocket(2) &&
  7833. inv_item->GetCount() < ITEM_MAX_COUNT)
  7834. {
  7835. inv_item->SetCount(inv_item->GetCount() + item->GetCount());
  7836. return inv_item;
  7837. }
  7838. }
  7839. }
  7840. }
  7841. }
  7842.  
  7843. int iEmptyCell;
  7844. if (item->IsDragonSoul())
  7845. {
  7846. iEmptyCell = GetEmptyDragonSoulInventory(item);
  7847. }
  7848. else
  7849. iEmptyCell = GetEmptyInventory(item->GetSize());
  7850.  
  7851. if (iEmptyCell != -1)
  7852. {
  7853. if (bMsg)
  7854. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
  7855.  
  7856. if (item->IsDragonSoul())
  7857. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
  7858. else
  7859. item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
  7860. LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
  7861.  
  7862. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
  7863. {
  7864. TQuickslot * pSlot;
  7865.  
  7866. if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
  7867. {
  7868. TQuickslot slot;
  7869. slot.type = QUICKSLOT_TYPE_ITEM;
  7870. slot.pos = iEmptyCell;
  7871. SetQuickslot(0, slot);
  7872. }
  7873. }
  7874. }
  7875. else
  7876. {
  7877. item->AddToGround(GetMapIndex(), GetXYZ());
  7878. item->StartDestroyEvent();
  7879. // 안티 드랍 flag가 걸려있는 아이템의 경우,
  7880. // 인벤에 빈 공간이 없어서 어쩔 수 없이 떨어트리게 되면,
  7881. // ownership을 아이템이 사라질 때까지(300초) 유지한다.
  7882. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP))
  7883. item->SetOwnership(this, 300);
  7884. else
  7885. item->SetOwnership(this, 60);
  7886. LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
  7887. }
  7888.  
  7889. sys_log(0,
  7890. "7: %d %d", dwItemVnum, bCount);
  7891. return item;
  7892. }
  7893.  
  7894. bool CHARACTER::GiveItem(LPCHARACTER victim, TItemPos Cell)
  7895. {
  7896. if (!CanHandleItem())
  7897. return false;
  7898.  
  7899. LPITEM item = GetItem(Cell);
  7900.  
  7901. if (item && !item->IsExchanging())
  7902. {
  7903. if (victim->CanReceiveItem(this, item))
  7904. {
  7905. victim->ReceiveItem(this, item);
  7906. return true;
  7907. }
  7908. }
  7909.  
  7910. return false;
  7911. }
  7912.  
  7913. bool CHARACTER::CanReceiveItem(LPCHARACTER from, LPITEM item) const
  7914. {
  7915. if (IsPC())
  7916. return false;
  7917.  
  7918. // TOO_LONG_DISTANCE_EXCHANGE_BUG_FIX
  7919. if (DISTANCE_APPROX(GetX() - from->GetX(), GetY() - from->GetY()) > 2000)
  7920. return false;
  7921. // END_OF_TOO_LONG_DISTANCE_EXCHANGE_BUG_FIX
  7922.  
  7923. switch (GetRaceNum())
  7924. {
  7925. case fishing::CAMPFIRE_MOB:
  7926. if (item->GetType() == ITEM_FISH &&
  7927. (item->GetSubType() == FISH_ALIVE || item->GetSubType() == FISH_DEAD))
  7928. return true;
  7929. break;
  7930.  
  7931. case fishing::FISHER_MOB:
  7932. if (item->GetType() == ITEM_ROD)
  7933. return true;
  7934. break;
  7935.  
  7936. // BUILDING_NPC
  7937. case BLACKSMITH_WEAPON_MOB:
  7938. case DEVILTOWER_BLACKSMITH_WEAPON_MOB:
  7939. if (item->GetType() == ITEM_WEAPON &&
  7940. item->GetRefinedVnum())
  7941. return true;
  7942. else
  7943. return false;
  7944. break;
  7945.  
  7946. case BLACKSMITH_ARMOR_MOB:
  7947. case DEVILTOWER_BLACKSMITH_ARMOR_MOB:
  7948. if (item->GetType() == ITEM_ARMOR &&
  7949. (item->GetSubType() == ARMOR_BODY || item->GetSubType() == ARMOR_SHIELD || item->GetSubType() == ARMOR_HEAD) &&
  7950. item->GetRefinedVnum())
  7951. return true;
  7952. else
  7953. return false;
  7954. break;
  7955.  
  7956. case BLACKSMITH_ACCESSORY_MOB:
  7957. case DEVILTOWER_BLACKSMITH_ACCESSORY_MOB:
  7958. if (item->GetType() == ITEM_ARMOR &&
  7959. !(item->GetSubType() == ARMOR_BODY || item->GetSubType() == ARMOR_SHIELD || item->GetSubType() == ARMOR_HEAD) &&
  7960. item->GetRefinedVnum())
  7961. return true;
  7962. else
  7963. return false;
  7964. break;
  7965. // END_OF_BUILDING_NPC
  7966.  
  7967. case BLACKSMITH_MOB:
  7968. if (item->GetRefinedVnum() && item->GetRefineSet() < 500)
  7969. {
  7970. return true;
  7971. }
  7972. else
  7973. {
  7974. return false;
  7975. }
  7976.  
  7977. case BLACKSMITH2_MOB:
  7978. if (item->GetRefineSet() >= 500)
  7979. {
  7980. return true;
  7981. }
  7982. else
  7983. {
  7984. return false;
  7985. }
  7986.  
  7987. case ALCHEMIST_MOB:
  7988. #ifdef __SOULBINDING_SYSTEM__
  7989. if (item->IsBind() || item->IsUntilBind())
  7990. {
  7991. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("KILIT_SIMYA"));
  7992. return false;
  7993. }
  7994. #endif
  7995. if (item->GetRefinedVnum())
  7996. return true;
  7997. break;
  7998.  
  7999. case 20101:
  8000. case 20102:
  8001. case 20103:
  8002. // 초급 말
  8003. if (item->GetVnum() == ITEM_REVIVE_HORSE_1)
  8004. {
  8005. if (!IsDead())
  8006. {
  8007. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("죽지 않은 말에게 선초를 먹일 수 없습니다."));
  8008. return false;
  8009. }
  8010. return true;
  8011. }
  8012. else if (item->GetVnum() == ITEM_HORSE_FOOD_1)
  8013. {
  8014. if (IsDead())
  8015. {
  8016. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("죽은 말에게 사료를 먹일 수 없습니다."));
  8017. return false;
  8018. }
  8019. return true;
  8020. }
  8021. else if (item->GetVnum() == ITEM_HORSE_FOOD_2 || item->GetVnum() == ITEM_HORSE_FOOD_3)
  8022. {
  8023. return false;
  8024. }
  8025. break;
  8026. case 20104:
  8027. case 20105:
  8028. case 20106:
  8029. // 중급 말
  8030. if (item->GetVnum() == ITEM_REVIVE_HORSE_2)
  8031. {
  8032. if (!IsDead())
  8033. {
  8034. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("죽지 않은 말에게 선초를 먹일 수 없습니다."));
  8035. return false;
  8036. }
  8037. return true;
  8038. }
  8039. else if (item->GetVnum() == ITEM_HORSE_FOOD_2)
  8040. {
  8041. if (IsDead())
  8042. {
  8043. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("죽은 말에게 사료를 먹일 수 없습니다."));
  8044. return false;
  8045. }
  8046. return true;
  8047. }
  8048. else if (item->GetVnum() == ITEM_HORSE_FOOD_1 || item->GetVnum() == ITEM_HORSE_FOOD_3)
  8049. {
  8050. return false;
  8051. }
  8052. break;
  8053. case 20107:
  8054. case 20108:
  8055. case 20109:
  8056. case 20114:
  8057. // 고급 말
  8058. if (item->GetVnum() == ITEM_REVIVE_HORSE_3)
  8059. {
  8060. if (!IsDead())
  8061. {
  8062. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("죽지 않은 말에게 선초를 먹일 수 없습니다."));
  8063. return false;
  8064. }
  8065. return true;
  8066. }
  8067. else if (item->GetVnum() == ITEM_HORSE_FOOD_3)
  8068. {
  8069. if (IsDead())
  8070. {
  8071. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("죽은 말에게 사료를 먹일 수 없습니다."));
  8072. return false;
  8073. }
  8074. return true;
  8075. }
  8076. else if (item->GetVnum() == ITEM_HORSE_FOOD_1 || item->GetVnum() == ITEM_HORSE_FOOD_2)
  8077. {
  8078. return false;
  8079. }
  8080. break;
  8081. }
  8082.  
  8083. //if (IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_GIVE))
  8084. {
  8085. return true;
  8086. }
  8087.  
  8088. return false;
  8089. }
  8090.  
  8091. void CHARACTER::ReceiveItem(LPCHARACTER from, LPITEM item)
  8092. {
  8093. if (IsPC())
  8094. return;
  8095.  
  8096. switch (GetRaceNum())
  8097. {
  8098. case fishing::CAMPFIRE_MOB:
  8099. if (item->GetType() == ITEM_FISH && (item->GetSubType() == FISH_ALIVE || item->GetSubType() == FISH_DEAD))
  8100. fishing::Grill(from, item);
  8101. else
  8102. {
  8103. // TAKE_ITEM_BUG_FIX
  8104. from->SetQuestNPCID(GetVID());
  8105. // END_OF_TAKE_ITEM_BUG_FIX
  8106. quest::CQuestManager::instance().TakeItem(from->GetPlayerID(), GetRaceNum(), item);
  8107. }
  8108. break;
  8109. #ifdef __MELEY_LAIR_DUNGEON__
  8110. case MeleyLair::STATUE_VNUM:
  8111. {
  8112. if (MeleyLair::CMgr::instance().IsMeleyMap(from->GetMapIndex()))
  8113. MeleyLair::CMgr::instance().OnKillStatue(item, from, this, from->GetGuild());
  8114. }
  8115. break;
  8116. #endif
  8117. // DEVILTOWER_NPC
  8118. case DEVILTOWER_BLACKSMITH_WEAPON_MOB:
  8119. case DEVILTOWER_BLACKSMITH_ARMOR_MOB:
  8120. case DEVILTOWER_BLACKSMITH_ACCESSORY_MOB:
  8121. if (item->GetRefinedVnum() != 0 && item->GetRefineSet() != 0 && item->GetRefineSet() < 500)
  8122. {
  8123. from->SetRefineNPC(this);
  8124. from->RefineInformation(item->GetCell(), REFINE_TYPE_MONEY_ONLY);
  8125. }
  8126. else
  8127. {
  8128. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 개량할 수 없습니다."));
  8129. }
  8130. break;
  8131. // END_OF_DEVILTOWER_NPC
  8132.  
  8133. case BLACKSMITH_MOB:
  8134. case BLACKSMITH2_MOB:
  8135. case BLACKSMITH_WEAPON_MOB:
  8136. case BLACKSMITH_ARMOR_MOB:
  8137. case BLACKSMITH_ACCESSORY_MOB:
  8138. if (item->GetRefinedVnum())
  8139. {
  8140. from->SetRefineNPC(this);
  8141. from->RefineInformation(item->GetCell(), REFINE_TYPE_NORMAL);
  8142. }
  8143. else
  8144. {
  8145. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이 아이템은 개량할 수 없습니다."));
  8146. }
  8147. break;
  8148.  
  8149. case 20101:
  8150. case 20102:
  8151. case 20103:
  8152. case 20104:
  8153. case 20105:
  8154. case 20106:
  8155. case 20107:
  8156. case 20108:
  8157. case 20109:
  8158. if (item->GetVnum() == ITEM_REVIVE_HORSE_1 ||
  8159. item->GetVnum() == ITEM_REVIVE_HORSE_2 ||
  8160. item->GetVnum() == ITEM_REVIVE_HORSE_3)
  8161. {
  8162. from->ReviveHorse();
  8163. item->SetCount(item->GetCount()-1);
  8164. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("말에게 선초를 주었습니다."));
  8165. }
  8166. else if (item->GetVnum() == ITEM_HORSE_FOOD_1 ||
  8167. item->GetVnum() == ITEM_HORSE_FOOD_2 ||
  8168. item->GetVnum() == ITEM_HORSE_FOOD_3)
  8169. {
  8170. from->FeedHorse();
  8171. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("말에게 사료를 주었습니다."));
  8172. item->SetCount(item->GetCount()-1);
  8173. EffectPacket(SE_HPUP_RED);
  8174. }
  8175. break;
  8176.  
  8177. default:
  8178. sys_log(0, "TakeItem %s %d %s", from->GetName(), GetRaceNum(), item->GetName());
  8179. from->SetQuestNPCID(GetVID());
  8180. quest::CQuestManager::instance().TakeItem(from->GetPlayerID(), GetRaceNum(), item);
  8181. break;
  8182. }
  8183. }
  8184.  
  8185. bool CHARACTER::IsEquipUniqueItem(DWORD dwItemVnum) const
  8186. {
  8187. {
  8188. LPITEM u = GetWear(WEAR_UNIQUE1);
  8189.  
  8190. if (u && u->GetVnum() == dwItemVnum)
  8191. return true;
  8192. }
  8193.  
  8194. {
  8195. LPITEM u = GetWear(WEAR_UNIQUE2);
  8196.  
  8197. if (u && u->GetVnum() == dwItemVnum)
  8198. return true;
  8199. }
  8200.  
  8201. {
  8202. LPITEM u = GetWear(WEAR_COSTUME_MOUNT);
  8203.  
  8204. if (u && u->GetVnum() == dwItemVnum)
  8205. return true;
  8206. }
  8207.  
  8208. if (dwItemVnum == UNIQUE_ITEM_RING_OF_LANGUAGE)
  8209. return IsEquipUniqueItem(UNIQUE_ITEM_RING_OF_LANGUAGE_SAMPLE);
  8210.  
  8211. return false;
  8212. }
  8213.  
  8214. // CHECK_UNIQUE_GROUP
  8215. bool CHARACTER::IsEquipUniqueGroup(DWORD dwGroupVnum) const
  8216. {
  8217. {
  8218. LPITEM u = GetWear(WEAR_UNIQUE1);
  8219.  
  8220. if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
  8221. return true;
  8222. }
  8223.  
  8224. {
  8225. LPITEM u = GetWear(WEAR_UNIQUE2);
  8226.  
  8227. if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
  8228. return true;
  8229. }
  8230.  
  8231. {
  8232. LPITEM u = GetWear(WEAR_COSTUME_MOUNT);
  8233.  
  8234. if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
  8235. return true;
  8236. }
  8237.  
  8238. return false;
  8239. }
  8240. // END_OF_CHECK_UNIQUE_GROUP
  8241.  
  8242. void CHARACTER::SetRefineMode(int iAdditionalCell)
  8243. {
  8244. m_iRefineAdditionalCell = iAdditionalCell;
  8245. m_bUnderRefine = true;
  8246. }
  8247.  
  8248. void CHARACTER::ClearRefineMode()
  8249. {
  8250. m_bUnderRefine = false;
  8251. SetRefineNPC( NULL );
  8252. }
  8253.  
  8254. bool CHARACTER::GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector<DWORD> &dwItemVnums,
  8255. std::vector<DWORD> &dwItemCounts, std::vector <LPITEM> &item_gets, int &count)
  8256. {
  8257. const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwGroupNum);
  8258.  
  8259. if (!pGroup)
  8260. {
  8261. sys_err("cannot find special item group %d", dwGroupNum);
  8262. return false;
  8263. }
  8264.  
  8265. std::vector <int> idxes;
  8266. int n = pGroup->GetMultiIndex(idxes);
  8267.  
  8268. bool bSuccess;
  8269.  
  8270. for (int i = 0; i < n; i++)
  8271. {
  8272. bSuccess = false;
  8273. int idx = idxes[i];
  8274. DWORD dwVnum = pGroup->GetVnum(idx);
  8275. DWORD dwCount = pGroup->GetCount(idx);
  8276. int iRarePct = pGroup->GetRarePct(idx);
  8277. LPITEM item_get = NULL;
  8278. switch (dwVnum)
  8279. {
  8280. case CSpecialItemGroup::GOLD:
  8281. PointChange(POINT_GOLD, dwCount);
  8282. LogManager::instance().CharLog(this, dwCount, "TREASURE_GOLD", "");
  8283.  
  8284. bSuccess = true;
  8285. break;
  8286. case CSpecialItemGroup::EXP:
  8287. {
  8288. PointChange(POINT_EXP, dwCount);
  8289. LogManager::instance().CharLog(this, dwCount, "TREASURE_EXP", "");
  8290.  
  8291. bSuccess = true;
  8292. }
  8293. break;
  8294.  
  8295. case CSpecialItemGroup::MOB:
  8296. {
  8297. sys_log(0, "CSpecialItemGroup::MOB %d", dwCount);
  8298. int x = GetX() + number(-500, 500);
  8299. int y = GetY() + number(-500, 500);
  8300.  
  8301. LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), x, y, 0, true, -1);
  8302. if (ch)
  8303. ch->SetAggressive();
  8304. bSuccess = true;
  8305. }
  8306. break;
  8307. case CSpecialItemGroup::SLOW:
  8308. {
  8309. sys_log(0, "CSpecialItemGroup::SLOW %d", -(int)dwCount);
  8310. AddAffect(AFFECT_SLOW, POINT_MOV_SPEED, -(int)dwCount, AFF_SLOW, 300, 0, true);
  8311. bSuccess = true;
  8312. }
  8313. break;
  8314. case CSpecialItemGroup::DRAIN_HP:
  8315. {
  8316. int iDropHP = GetMaxHP()*dwCount/100;
  8317. sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
  8318. iDropHP = MIN(iDropHP, GetHP()-1);
  8319. sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
  8320. PointChange(POINT_HP, -iDropHP);
  8321. bSuccess = true;
  8322. }
  8323. break;
  8324. case CSpecialItemGroup::POISON:
  8325. {
  8326. AttackedByPoison(NULL);
  8327. bSuccess = true;
  8328. }
  8329. break;
  8330. case CSpecialItemGroup::BLEED:
  8331. {
  8332. AttackedByBleeding(NULL);
  8333. bSuccess = true;
  8334. }
  8335.  
  8336. case CSpecialItemGroup::MOB_GROUP:
  8337. {
  8338. int sx = GetX() - number(300, 500);
  8339. int sy = GetY() - number(300, 500);
  8340. int ex = GetX() + number(300, 500);
  8341. int ey = GetY() + number(300, 500);
  8342. CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), sx, sy, ex, ey, NULL, true);
  8343.  
  8344. bSuccess = true;
  8345. }
  8346. break;
  8347. default:
  8348. {
  8349. item_get = AutoGiveItem(dwVnum, dwCount, iRarePct);
  8350.  
  8351. if (item_get)
  8352. {
  8353. bSuccess = true;
  8354. }
  8355. }
  8356. break;
  8357. }
  8358.  
  8359. if (bSuccess)
  8360. {
  8361. dwItemVnums.push_back(dwVnum);
  8362. dwItemCounts.push_back(dwCount);
  8363. item_gets.push_back(item_get);
  8364. count++;
  8365.  
  8366. }
  8367. else
  8368. {
  8369. return false;
  8370. }
  8371. }
  8372. return bSuccess;
  8373. }
  8374.  
  8375. // NEW_HAIR_STYLE_ADD
  8376. bool CHARACTER::ItemProcess_Hair(LPITEM item, int iDestCell)
  8377. {
  8378. if (item->CheckItemUseLevel(GetLevel()) == false)
  8379. {
  8380. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아직 이 머리를 사용할 수 없는 레벨입니다."));
  8381. return false;
  8382. }
  8383.  
  8384. DWORD hair = item->GetVnum();
  8385. switch (GetJob())
  8386. {
  8387. case JOB_WARRIOR :
  8388. hair -= 72000;
  8389. break;
  8390.  
  8391. case JOB_ASSASSIN :
  8392. hair -= 71250;
  8393. break;
  8394.  
  8395. case JOB_SURA :
  8396. hair -= 70500;
  8397. break;
  8398.  
  8399. case JOB_SHAMAN :
  8400. hair -= 69750;
  8401. break;
  8402.  
  8403. case JOB_WOLFMAN:
  8404. /* (delete "return false" and add "hair -= vnum" just if you have wolf hair on your server) */
  8405. // hair -= 70750
  8406. return false;
  8407. break;
  8408.  
  8409. default :
  8410. return false;
  8411. break;
  8412. }
  8413.  
  8414. if (hair == GetPart(PART_HAIR))
  8415. {
  8416. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("동일한 머리 스타일로는 교체할 수 없습니다."));
  8417. return true;
  8418. }
  8419.  
  8420. item->SetCount(item->GetCount() - 1);
  8421.  
  8422. SetPart(PART_HAIR, static_cast<WORD>(hair));
  8423. UpdatePacket();
  8424.  
  8425. return true;
  8426. }
  8427.  
  8428. // END_NEW_HAIR_STYLE_ADD
  8429.  
  8430. bool CHARACTER::ItemProcess_Polymorph(LPITEM item)
  8431. {
  8432. if (IsPolymorphed())
  8433. {
  8434. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 둔갑중인 상태입니다."));
  8435. return false;
  8436. }
  8437.  
  8438. if (true == IsRiding())
  8439. {
  8440. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑할 수 없는 상태입니다."));
  8441. return false;
  8442. }
  8443.  
  8444. DWORD dwVnum = item->GetSocket(0);
  8445.  
  8446. if (dwVnum == 0)
  8447. {
  8448. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("잘못된 둔갑 아이템입니다."));
  8449. item->SetCount(item->GetCount()-1);
  8450. return false;
  8451. }
  8452.  
  8453. const CMob* pMob = CMobManager::instance().Get(dwVnum);
  8454.  
  8455. if (pMob == NULL)
  8456. {
  8457. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("잘못된 둔갑 아이템입니다."));
  8458. item->SetCount(item->GetCount()-1);
  8459. return false;
  8460. }
  8461.  
  8462. switch (item->GetVnum())
  8463. {
  8464. case 70104 :
  8465. case 70105 :
  8466. case 70106 :
  8467. case 70107 :
  8468. case 71093 :
  8469. {
  8470. // 둔갑구 처리
  8471. sys_log(0, "USE_POLYMORPH_BALL PID(%d) vnum(%d)", GetPlayerID(), dwVnum);
  8472.  
  8473. // 레벨 제한 체크
  8474. int iPolymorphLevelLimit = MAX(0, 20 - GetLevel() * 3 / 10);
  8475. if (pMob->m_table.bLevel >= GetLevel() + iPolymorphLevelLimit)
  8476. {
  8477. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("나보다 너무 높은 레벨의 몬스터로는 변신 할 수 없습니다."));
  8478. return false;
  8479. }
  8480.  
  8481. int iDuration = GetSkillLevel(POLYMORPH_SKILL_ID) == 0 ? 5 : (5 + (5 + GetSkillLevel(POLYMORPH_SKILL_ID)/40 * 25));
  8482. iDuration *= 60;
  8483.  
  8484. DWORD dwBonus = 0;
  8485.  
  8486. dwBonus = (2 + GetSkillLevel(POLYMORPH_SKILL_ID)/40) * 100;
  8487.  
  8488. AddAffect(AFFECT_POLYMORPH, POINT_POLYMORPH, dwVnum, AFF_POLYMORPH, iDuration, 0, true);
  8489. AddAffect(AFFECT_POLYMORPH, POINT_ATT_BONUS, dwBonus, AFF_POLYMORPH, iDuration, 0, false);
  8490.  
  8491. item->SetCount(item->GetCount()-1);
  8492. }
  8493. break;
  8494.  
  8495. case 50322:
  8496. {
  8497. // 보류
  8498.  
  8499. // 둔갑서 처리
  8500. // 소켓0 소켓1 소켓2
  8501. // 둔갑할 몬스터 번호 수련정도 둔갑서 레벨
  8502. sys_log(0, "USE_POLYMORPH_BOOK: %s(%u) vnum(%u)", GetName(), GetPlayerID(), dwVnum);
  8503.  
  8504. if (CPolymorphUtils::instance().PolymorphCharacter(this, item, pMob) == true)
  8505. {
  8506. CPolymorphUtils::instance().UpdateBookPracticeGrade(this, item);
  8507. }
  8508. else
  8509. {
  8510. }
  8511. }
  8512. break;
  8513.  
  8514. default :
  8515. sys_err("POLYMORPH invalid item passed PID(%d) vnum(%d)", GetPlayerID(), item->GetOriginalVnum());
  8516. return false;
  8517. }
  8518.  
  8519. return true;
  8520. }
  8521.  
  8522. bool CHARACTER::CanDoAttrTransfer() const
  8523. {
  8524. if (m_bIsObserver) return false;
  8525. if (GetShop()) return false;
  8526. if (GetMyShop()) return false;
  8527. if (m_bUnderRefine) return false;
  8528. if (IsWarping()) return false;
  8529. if (GetOfflineShop()) return false;
  8530.  
  8531. return true;
  8532. }
  8533.  
  8534. bool CHARACTER::CanDoCube() const
  8535. {
  8536. if (m_bIsObserver) return false;
  8537. if (GetShop()) return false;
  8538. if (GetMyShop()) return false;
  8539. if (m_bUnderRefine) return false;
  8540. if (IsWarping()) return false;
  8541. if (GetOfflineShop()) return false;
  8542.  
  8543. return true;
  8544. }
  8545.  
  8546. bool CHARACTER::UnEquipSpecialRideUniqueItem()
  8547. {
  8548. LPITEM Unique1 = GetWear(WEAR_UNIQUE1);
  8549. LPITEM Unique2 = GetWear(WEAR_UNIQUE2);
  8550. LPITEM Unique3 = GetWear(WEAR_COSTUME_MOUNT);
  8551.  
  8552. if (NULL != Unique1)
  8553. {
  8554. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique1->GetSpecialGroup())
  8555. {
  8556. return UnequipItem(Unique1);
  8557. }
  8558. }
  8559.  
  8560. if (NULL != Unique2)
  8561. {
  8562. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique2->GetSpecialGroup())
  8563. {
  8564. return UnequipItem(Unique2);
  8565. }
  8566. }
  8567.  
  8568. if (NULL != Unique3)
  8569. {
  8570. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique3->GetSpecialGroup())
  8571. {
  8572. return UnequipItem(Unique3);
  8573. }
  8574. }
  8575.  
  8576. return true;
  8577. }
  8578.  
  8579. void CHARACTER::AutoRecoveryItemProcess(const EAffectTypes type)
  8580. {
  8581. if (true == IsDead() || true == IsStun())
  8582. return;
  8583.  
  8584. if (false == IsPC())
  8585. return;
  8586.  
  8587. if (AFFECT_AUTO_HP_RECOVERY != type && AFFECT_AUTO_SP_RECOVERY != type)
  8588. return;
  8589.  
  8590. if (NULL != FindAffect(AFFECT_STUN))
  8591. return;
  8592.  
  8593. {
  8594. const DWORD stunSkills[] = { SKILL_TANHWAN, SKILL_GEOMPUNG, SKILL_BYEURAK, SKILL_GIGUNG };
  8595.  
  8596. for (size_t i=0 ; i < sizeof(stunSkills)/sizeof(DWORD) ; ++i)
  8597. {
  8598. const CAffect* p = FindAffect(stunSkills[i]);
  8599.  
  8600. if (NULL != p && AFF_STUN == p->dwFlag)
  8601. return;
  8602. }
  8603. }
  8604.  
  8605. const CAffect* pAffect = FindAffect(type);
  8606. const size_t idx_of_amount_of_used = 1;
  8607. const size_t idx_of_amount_of_full = 2;
  8608.  
  8609. if (NULL != pAffect)
  8610. {
  8611. LPITEM pItem = FindItemByID(pAffect->dwFlag);
  8612.  
  8613. if (NULL != pItem && true == pItem->GetSocket(0))
  8614. {
  8615. if (false == CArenaManager::instance().IsArenaMap(GetMapIndex()))
  8616. {
  8617. const long amount_of_used = pItem->GetSocket(idx_of_amount_of_used);
  8618. const long amount_of_full = pItem->GetSocket(idx_of_amount_of_full);
  8619.  
  8620. const int32_t avail = amount_of_full - amount_of_used;
  8621.  
  8622. int32_t amount = 0;
  8623.  
  8624. if (AFFECT_AUTO_HP_RECOVERY == type)
  8625. {
  8626. amount = GetMaxHP() - (GetHP() + GetPoint(POINT_HP_RECOVERY));
  8627. }
  8628. else if (AFFECT_AUTO_SP_RECOVERY == type)
  8629. {
  8630. amount = GetMaxSP() - (GetSP() + GetPoint(POINT_SP_RECOVERY));
  8631. }
  8632.  
  8633. if (amount > 0)
  8634. {
  8635. if (avail > amount)
  8636. {
  8637. const int pct_of_used = amount_of_used * 100 / amount_of_full;
  8638. const int pct_of_will_used = (amount_of_used + amount) * 100 / amount_of_full;
  8639.  
  8640. bool bLog = false;
  8641. // 사용량의 10% 단위로 로그를 남김
  8642. // (사용량의 %에서, 십의 자리가 바뀔 때마다 로그를 남김.)
  8643. if ((pct_of_will_used / 10) - (pct_of_used / 10) >= 1)
  8644. bLog = true;
  8645. pItem->SetSocket(idx_of_amount_of_used, amount_of_used + amount, bLog);
  8646. }
  8647. else
  8648. {
  8649. amount = avail;
  8650.  
  8651. ITEM_MANAGER::instance().RemoveItem( pItem );
  8652. }
  8653.  
  8654. if (AFFECT_AUTO_HP_RECOVERY == type)
  8655. {
  8656. PointChange( POINT_HP_RECOVERY, amount );
  8657. EffectPacket( SE_AUTO_HPUP );
  8658. }
  8659. else if (AFFECT_AUTO_SP_RECOVERY == type)
  8660. {
  8661. PointChange( POINT_SP_RECOVERY, amount );
  8662. EffectPacket( SE_AUTO_SPUP );
  8663. }
  8664. }
  8665. }
  8666. else
  8667. {
  8668. pItem->Lock(false);
  8669. pItem->SetSocket(0, false);
  8670. RemoveAffect( const_cast<CAffect*>(pAffect) );
  8671. }
  8672. }
  8673. else
  8674. {
  8675. RemoveAffect( const_cast<CAffect*>(pAffect) );
  8676. }
  8677. }
  8678. }
  8679.  
  8680. bool CHARACTER::IsValidItemPosition(TItemPos Pos) const
  8681. {
  8682. BYTE window_type = Pos.window_type;
  8683. WORD cell = Pos.cell;
  8684.  
  8685. switch (window_type)
  8686. {
  8687. case RESERVED_WINDOW:
  8688. return false;
  8689.  
  8690. case INVENTORY:
  8691. case EQUIPMENT:
  8692. return cell < (INVENTORY_AND_EQUIP_SLOT_MAX);
  8693.  
  8694. case DRAGON_SOUL_INVENTORY:
  8695. return cell < (DRAGON_SOUL_INVENTORY_MAX_NUM);
  8696.  
  8697. case SAFEBOX:
  8698. if (NULL != m_pkSafebox)
  8699. return m_pkSafebox->IsValidPosition(cell);
  8700. else
  8701. return false;
  8702.  
  8703. case MALL:
  8704. if (NULL != m_pkMall)
  8705. return m_pkMall->IsValidPosition(cell);
  8706. else
  8707. return false;
  8708. default:
  8709. return false;
  8710. }
  8711. }
  8712.  
  8713.  
  8714. // 귀찮아서 만든 매크로.. exp가 true면 msg를 출력하고 return false 하는 매크로 (일반적인 verify 용도랑은 return 때문에 약간 반대라 이름때문에 헷갈릴 수도 있겠다..)
  8715. #define VERIFY_MSG(exp, msg) \
  8716. if (true == (exp)) { \
  8717. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(msg)); \
  8718. return false; \
  8719. }
  8720.  
  8721.  
  8722. /// 현재 캐릭터의 상태를 바탕으로 주어진 item을 착용할 수 있는 지 확인하고, 불가능 하다면 캐릭터에게 이유를 알려주는 함수
  8723. bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell)
  8724. {
  8725. const TItemTable* itemTable = item->GetProto();
  8726. BYTE itemType = item->GetType();
  8727. BYTE itemSubType = item->GetSubType();
  8728.  
  8729. switch (GetJob())
  8730. {
  8731. case JOB_WARRIOR:
  8732. if (item->GetAntiFlag() & ITEM_ANTIFLAG_WARRIOR)
  8733. return false;
  8734. break;
  8735.  
  8736. case JOB_ASSASSIN:
  8737. if (item->GetAntiFlag() & ITEM_ANTIFLAG_ASSASSIN)
  8738. return false;
  8739. break;
  8740.  
  8741. case JOB_SHAMAN:
  8742. if (item->GetAntiFlag() & ITEM_ANTIFLAG_SHAMAN)
  8743. return false;
  8744. break;
  8745.  
  8746. case JOB_SURA:
  8747. if (item->GetAntiFlag() & ITEM_ANTIFLAG_SURA)
  8748. return false;
  8749. break;
  8750.  
  8751. case JOB_WOLFMAN:
  8752. if (item->GetAntiFlag() & ITEM_ANTIFLAG_WOLFMAN)
  8753. return false;
  8754. break;
  8755. }
  8756.  
  8757. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  8758. {
  8759. long limit = itemTable->aLimits[i].lValue;
  8760. switch (itemTable->aLimits[i].bType)
  8761. {
  8762. case LIMIT_LEVEL:
  8763. if (GetLevel() < limit)
  8764. {
  8765. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("레벨이 낮아 착용할 수 없습니다."));
  8766. return false;
  8767. }
  8768. break;
  8769.  
  8770. case LIMIT_STR:
  8771. if (GetPoint(POINT_ST) < limit)
  8772. {
  8773. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("근력이 낮아 착용할 수 없습니다."));
  8774. return false;
  8775. }
  8776. break;
  8777.  
  8778. case LIMIT_INT:
  8779. if (GetPoint(POINT_IQ) < limit)
  8780. {
  8781. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("지능이 낮아 착용할 수 없습니다."));
  8782. return false;
  8783. }
  8784. break;
  8785.  
  8786. case LIMIT_DEX:
  8787. if (GetPoint(POINT_DX) < limit)
  8788. {
  8789. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("민첩이 낮아 착용할 수 없습니다."));
  8790. return false;
  8791. }
  8792. break;
  8793.  
  8794. case LIMIT_CON:
  8795. if (GetPoint(POINT_HT) < limit)
  8796. {
  8797. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("체력이 낮아 착용할 수 없습니다."));
  8798. return false;
  8799. }
  8800. break;
  8801. }
  8802. }
  8803.  
  8804. if (item->GetWearFlag() & WEARABLE_UNIQUE)
  8805. {
  8806. if ((GetWear(WEAR_UNIQUE1) && GetWear(WEAR_UNIQUE1)->IsSameSpecialGroup(item)) ||
  8807. (GetWear(WEAR_UNIQUE2) && GetWear(WEAR_UNIQUE2)->IsSameSpecialGroup(item)) ||
  8808. (GetWear(WEAR_COSTUME_MOUNT) && GetWear(WEAR_COSTUME_MOUNT)->IsSameSpecialGroup(item)))
  8809. {
  8810. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("같은 종류의 유니크 아이템 두 개를 동시에 장착할 수 없습니다."));
  8811. return false;
  8812. }
  8813.  
  8814. if (marriage::CManager::instance().IsMarriageUniqueItem(item->GetVnum()) &&
  8815. !marriage::CManager::instance().IsMarried(GetPlayerID()))
  8816. {
  8817. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("결혼하지 않은 상태에서 예물을 착용할 수 없습니다."));
  8818. return false;
  8819. }
  8820.  
  8821. }
  8822.  
  8823. LPITEM ring1;
  8824. LPITEM ring2;
  8825.  
  8826. if (item->GetType() == ITEM_RING)
  8827. {
  8828. LPITEM ring1 = GetWear(WEAR_RING1);
  8829. LPITEM ring2 = GetWear(WEAR_RING2);
  8830.  
  8831. if (ring1 && (ring1->GetVnum() == item->GetVnum()))
  8832. {
  8833. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("같은 종류의 유니크 아이템 두 개를 동시에 장착할 수 없습니다."));
  8834. return false;
  8835. }
  8836.  
  8837. if (ring2 && (ring2->GetVnum() == item->GetVnum()))
  8838. {
  8839. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("같은 종류의 유니크 아이템 두 개를 동시에 장착할 수 없습니다."));
  8840. return false;
  8841. }
  8842. }
  8843.  
  8844. #ifdef __WEAPON_COSTUME_SYSTEM__
  8845. #ifdef __NEW_ARROW_SYSTEM__
  8846. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW && item->GetSubType() != WEAPON_UNLIMITED_ARROW)
  8847. #else
  8848. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
  8849. #endif
  8850. {
  8851. LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
  8852. if (pkItem)
  8853. {
  8854. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
  8855. return false;
  8856. }
  8857. }
  8858. else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == COSTUME_WEAPON)
  8859. {
  8860. LPITEM pkItem = GetWear(WEAR_WEAPON);
  8861. if (!pkItem)
  8862. {
  8863. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't wear a costume weapon without have a weapon weared."));
  8864. return false;
  8865. }
  8866. else if (item->GetValue(3) != pkItem->GetSubType())
  8867. {
  8868. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't wear a costume weapon who has different type of your weapon."));
  8869. return false;
  8870. }
  8871. else if (pkItem->GetType() == ITEM_ROD || pkItem->GetType() == ITEM_PICK)
  8872. {
  8873. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("kazma_veya_olta_takili"));
  8874. return false;
  8875. }
  8876. }
  8877.  
  8878. if (item->GetType() == ITEM_ROD || item->GetType() == ITEM_PICK)
  8879. {
  8880. LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
  8881. if (pkItem)
  8882. {
  8883. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
  8884. return false;
  8885. }
  8886. }
  8887. #endif
  8888.  
  8889. return true;
  8890. }
  8891.  
  8892. /// 현재 캐릭터의 상태를 바탕으로 착용 중인 item을 벗을 수 있는 지 확인하고, 불가능 하다면 캐릭터에게 이유를 알려주는 함수
  8893. bool CHARACTER::CanUnequipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell)
  8894. {
  8895. if (ITEM_BELT == item->GetType())
  8896. VERIFY_MSG(CBeltInventoryHelper::IsExistItemInBeltInventory(this), "벨트 인벤토리에 아이템이 존재하면 해제할 수 없습니다.");
  8897.  
  8898. // 영원히 해제할 수 없는 아이템
  8899. if (IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
  8900. return false;
  8901.  
  8902. // 아이템 unequip시 인벤토리로 옮길 때 빈 자리가 있는 지 확인
  8903. {
  8904. int pos = -1;
  8905. if (item->IsDragonSoul())
  8906. pos = GetEmptyDragonSoulInventory(item);
  8907. else
  8908. pos = GetEmptyInventory(item->GetSize());
  8909.  
  8910. VERIFY_MSG( -1 == pos, "소지품에 빈 공간이 없습니다." );
  8911. }
  8912.  
  8913. #ifdef __WEAPON_COSTUME_SYSTEM__
  8914. #ifdef __NEW_ARROW_SYSTEM__
  8915. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW && item->GetSubType() != WEAPON_UNLIMITED_ARROW)
  8916. #else
  8917. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
  8918. #endif
  8919. {
  8920. LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
  8921. if (pkItem)
  8922. {
  8923. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
  8924. return false;
  8925. }
  8926. }
  8927. #endif
  8928.  
  8929. return true;
  8930. }
Add Comment
Please, Sign In to add comment