Advertisement
Guest User

Untitled

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