Advertisement
Guest User

Untitled

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