Ionut14

char_item.cpp

Feb 28th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 282.24 KB | None | 0 0
  1. #ifdef ENABLE_BIOLOG_SYSTEM
  2. #include "../../common/service.h"
  3. #endif
  4. #include "stdafx.h"
  5. #include <stack>
  6. #include "utils.h"
  7. #include "config.h"
  8. #include "char.h"
  9. #include "char_manager.h"
  10. #include "item_manager.h"
  11. #include "desc.h"
  12. #include "desc_client.h"
  13. #include "desc_manager.h"
  14. #include "packet.h"
  15. #include "affect.h"
  16. #include "skill.h"
  17. #include "start_position.h"
  18. #include "mob_manager.h"
  19. #include "db.h"
  20. #include "log.h"
  21. #include "vector.h"
  22. #include "buffer_manager.h"
  23. #include "questmanager.h"
  24. #include "fishing.h"
  25. #include "party.h"
  26. #include "dungeon.h"
  27. #include "refine.h"
  28. #include "unique_item.h"
  29. #include "war_map.h"
  30. #include "xmas_event.h"
  31. #include "marriage.h"
  32. #include "monarch.h"
  33. #ifdef NEW_PET_SYSTEM
  34. #include "New_PetSystem.h"
  35. #endif
  36. #include "polymorph.h"
  37. #include "blend_item.h"
  38. #include "castle.h"
  39. #include "BattleArena.h"
  40. #include "arena.h"
  41. #include "dev_log.h"
  42. #include "pcbang.h"
  43. #include "threeway_war.h"
  44. #ifdef __ATTR_SWITCH_SYSTEM__
  45. #include "switchbot.h"
  46. #endif
  47. #include "safebox.h"
  48. #include "shop.h"
  49. #include "../../common/VnumHelper.h"
  50. #include "../../common/service.h"
  51. #include "DragonSoul.h"
  52. #include "biolog.h"
  53. #include "buff_on_attributes.h"
  54. #include "belt_inventory_helper.h"
  55.  
  56. const int ITEM_BROKEN_METIN_VNUM = 28960;
  57.  
  58. // CHANGE_ITEM_ATTRIBUTES
  59. const DWORD CHARACTER::msc_dwDefaultChangeItemAttrCycle = 10;
  60. const char CHARACTER::msc_szLastChangeItemAttrFlag[] = "Item.LastChangeItemAttr";
  61. const char CHARACTER::msc_szChangeItemAttrCycleFlag[] = "change_itemattr_cycle";
  62. // END_OF_CHANGE_ITEM_ATTRIBUTES
  63. const BYTE g_aBuffOnAttrPoints[] = { POINT_ENERGY, POINT_COSTUME_ATTR_BONUS };
  64.  
  65. struct FFindStone
  66. {
  67. std::map<DWORD, LPCHARACTER> m_mapStone;
  68.  
  69. void operator()(LPENTITY pEnt)
  70. {
  71. if (pEnt->IsType(ENTITY_CHARACTER) == true)
  72. {
  73. LPCHARACTER pChar = (LPCHARACTER)pEnt;
  74.  
  75. if (pChar->IsStone() == true)
  76. {
  77. m_mapStone[(DWORD)pChar->GetVID()] = pChar;
  78. }
  79. }
  80. }
  81. };
  82.  
  83. static bool IS_SUMMON_ITEM(int vnum)
  84. {
  85. switch (vnum)
  86. {
  87. case 22000:
  88. case 22010:
  89. case 22011:
  90. case 22020:
  91. case ITEM_MARRIAGE_RING:
  92. return true;
  93. }
  94.  
  95. return false;
  96. }
  97. #ifdef BLOCK_ITEM_IN_MAP
  98. static bool IS_ENABLE_ITEM(int vnum)
  99. {
  100. switch (vnum)
  101. {
  102. case 71015:
  103. case 72049:
  104. case 72050:
  105. case 70005:
  106. case 39002:
  107. return true;
  108. }
  109.  
  110. return false;
  111. }
  112. #endif
  113.  
  114. static bool IS_MONKEY_DUNGEON(int map_index)
  115. {
  116. switch (map_index)
  117. {
  118. case 5:
  119. case 25:
  120. case 45:
  121. case 108:
  122. case 109:
  123. return true;;
  124. }
  125.  
  126. return false;
  127. }
  128.  
  129. bool IS_SUMMONABLE_ZONE(int map_index)
  130. {
  131. if (IS_MONKEY_DUNGEON(map_index))
  132. return false;
  133.  
  134. if (IS_CASTLE_MAP(map_index))
  135. return false;
  136.  
  137. switch (map_index)
  138. {
  139. case 66 :
  140. case 71 :
  141. case 72 :
  142. case 73 :
  143. case 193 :
  144. #if 0
  145. case 184 :
  146. case 185 :
  147. case 186 :
  148. case 187 :
  149. case 188 :
  150. case 189 :
  151. #endif
  152. // case 206 :
  153. case 216 :
  154. case 217 :
  155. case 208 :
  156. return false;
  157. }
  158.  
  159. if (CBattleArena::IsBattleArenaMap(map_index)) return false;
  160.  
  161. if (map_index > 10000) return false;
  162.  
  163. return true;
  164. }
  165.  
  166. #ifdef BLOCK_ITEM_IN_MAP
  167. bool IS_ENABLE_ITEM_ZONE(int map_index)
  168. {
  169. switch (map_index)
  170. {
  171. case 205:
  172. case 206:
  173. return false;
  174. }
  175.  
  176. return true;
  177. }
  178. #endif
  179.  
  180. bool IS_BOTARYABLE_ZONE(int nMapIndex)
  181. {
  182. if (LC_IsYMIR() == false && LC_IsKorea() == false) return true;
  183.  
  184. switch (nMapIndex)
  185. {
  186. case 1 :
  187. case 3 :
  188. case 21 :
  189. case 23 :
  190. case 41 :
  191. case 43 :
  192. return true;
  193. }
  194.  
  195. return false;
  196. }
  197.  
  198. // item socket -- by mhh
  199. static bool FN_check_item_socket(LPITEM item)
  200. {
  201. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  202. {
  203. if (item->GetSocket(i) != item->GetProto()->alSockets[i])
  204. return false;
  205. }
  206. #ifdef ENABLE_SORT_INVENTORY
  207. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_AFFECT)
  208. return true;
  209. #endif
  210. return true;
  211. }
  212.  
  213. // item socket -- by mhh
  214. static void FN_copy_item_socket(LPITEM dest, LPITEM src)
  215. {
  216. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  217. {
  218. dest->SetSocket(i, src->GetSocket(i));
  219. }
  220. }
  221. static bool FN_check_item_sex(LPCHARACTER ch, LPITEM item)
  222. {
  223. //Man
  224. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_MALE))
  225. {
  226. if (SEX_MALE==GET_SEX(ch))
  227. return false;
  228. }
  229. // Girl
  230. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_FEMALE))
  231. {
  232. if (SEX_FEMALE==GET_SEX(ch))
  233. return false;
  234. }
  235.  
  236. return true;
  237. }
  238.  
  239. /////////////////////////////////////////////////////////////////////////////
  240. // ITEM HANDLING
  241. /////////////////////////////////////////////////////////////////////////////
  242. bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver)
  243. {
  244. if (!bSkipObserver)
  245. if (m_bIsObserver)
  246. return false;
  247.  
  248. if (GetMyShop())
  249. return false;
  250.  
  251. if (!bSkipCheckRefine)
  252. if (m_bUnderRefine)
  253. return false;
  254.  
  255. if (IsCubeOpen() || NULL != DragonSoul_RefineWindow_GetOpener())
  256. return false;
  257.  
  258. if (IsWarping())
  259. return false;
  260.  
  261. #ifdef __SASH_SYSTEM__
  262. if ((m_bSashCombination) || (m_bSashAbsorption))
  263. return false;
  264. #endif
  265.  
  266. return true;
  267. }
  268.  
  269. LPITEM CHARACTER::GetInventoryItem(WORD wCell) const
  270. {
  271. return GetItem(TItemPos(INVENTORY, wCell));
  272. }
  273.  
  274. #ifdef ENABLE_SPECIAL_STORAGE
  275. LPITEM CHARACTER::GetUpgradeInventoryItem(WORD wCell) const
  276. {
  277. return GetItem(TItemPos(UPGRADE_INVENTORY, wCell));
  278. }
  279. LPITEM CHARACTER::GetBookInventoryItem(WORD wCell) const
  280. {
  281. return GetItem(TItemPos(BOOK_INVENTORY, wCell));
  282. }
  283. LPITEM CHARACTER::GetStoneInventoryItem(WORD wCell) const
  284. {
  285. return GetItem(TItemPos(STONE_INVENTORY, wCell));
  286. }
  287. LPITEM CHARACTER::GetDndInventoryItem(WORD wCell) const
  288. {
  289. return GetItem(TItemPos(DND_INVENTORY, wCell));
  290. }
  291. LPITEM CHARACTER::GetGearInventoryItem(WORD wCell) const
  292. {
  293. return GetItem(TItemPos(GEAR_INVENTORY, wCell));
  294. }
  295. #endif
  296.  
  297. LPITEM CHARACTER::GetItem(TItemPos Cell) const
  298. {
  299. if (!IsValidItemPosition(Cell))
  300. return NULL;
  301. WORD wCell = Cell.cell;
  302. BYTE window_type = Cell.window_type;
  303. switch (window_type)
  304. {
  305. case INVENTORY:
  306. case EQUIPMENT:
  307. if (wCell >= INVENTORY_AND_EQUIP_SLOT_MAX)
  308. {
  309. sys_err("CHARACTER::GetInventoryItem: invalid item cell %d", wCell);
  310. return NULL;
  311. }
  312. return m_pointsInstant.pItems[wCell];
  313. case DRAGON_SOUL_INVENTORY:
  314. if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  315. {
  316. sys_err("CHARACTER::GetInventoryItem: invalid DS item cell %d", wCell);
  317. return NULL;
  318. }
  319. return m_pointsInstant.pDSItems[wCell];
  320. #ifdef __ATTR_SWITCH_SYSTEM__
  321. case SWITCHBOT:
  322. if (wCell >= SWITCHBOT_SLOT_COUNT)
  323. {
  324. sys_err("CHARACTER::GetInventoryItem: invalid switchbot item cell %d", wCell);
  325. return NULL;
  326. }
  327.  
  328. return m_pointsInstant.pSwitchbotItems[wCell];
  329. #endif
  330. #ifdef ENABLE_SPECIAL_STORAGE
  331. case UPGRADE_INVENTORY:
  332. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  333. {
  334. sys_err("CHARACTER::GetInventoryItem: invalid SSU item cell %d", wCell);
  335. return NULL;
  336. }
  337. return m_pointsInstant.pSSUItems[wCell];
  338. case BOOK_INVENTORY:
  339. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  340. {
  341. sys_err("CHARACTER::GetInventoryItem: invalid SSB item cell %d", wCell);
  342. return NULL;
  343. }
  344. return m_pointsInstant.pSSBItems[wCell];
  345. case STONE_INVENTORY:
  346. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  347. {
  348. sys_err("CHARACTER::GetInventoryItem: invalid SSS item cell %d", wCell);
  349. return NULL;
  350. }
  351. return m_pointsInstant.pSSSItems[wCell];
  352. case DND_INVENTORY:
  353. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  354. {
  355. sys_err("CHARACTER::GetInventoryItem: invalid SSD item cell %d", wCell);
  356. return NULL;
  357. }
  358. return m_pointsInstant.pSSDItems[wCell];
  359. case GEAR_INVENTORY:
  360. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  361. {
  362. sys_err("CHARACTER::GetInventoryItem: invalid SSG item cell %d", wCell);
  363. return NULL;
  364. }
  365. return m_pointsInstant.pSSGItems[wCell];
  366. #endif
  367. default:
  368. return NULL;
  369. }
  370. return NULL;
  371. }
  372.  
  373. #ifdef ENABLE_HIGHLIGHT_NEW_ITEM
  374. void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem, bool bWereMine)
  375. #else
  376. void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
  377. #endif
  378. {
  379. WORD wCell = Cell.cell;
  380. BYTE window_type = Cell.window_type;
  381. if ((unsigned long)((CItem*)pItem) == 0xff || (unsigned long)((CItem*)pItem) == 0xffffffff)
  382. {
  383. sys_err("!!! FATAL ERROR !!! item == 0xff (char: %s cell: %u)", GetName(), wCell);
  384. core_dump();
  385. return;
  386. }
  387.  
  388. if (pItem && pItem->GetOwner())
  389. {
  390. assert(!"GetOwner exist");
  391. return;
  392. }
  393.  
  394. switch(window_type)
  395. {
  396. case INVENTORY:
  397. case EQUIPMENT:
  398. {
  399. if (wCell >= INVENTORY_AND_EQUIP_SLOT_MAX)
  400. {
  401. sys_err("CHARACTER::SetItem: invalid item cell %d", wCell);
  402. return;
  403. }
  404.  
  405. LPITEM pOld = m_pointsInstant.pItems[wCell];
  406.  
  407. if (pOld)
  408. {
  409. if (wCell < INVENTORY_MAX_NUM)
  410. {
  411. for (int i = 0; i < pOld->GetSize(); ++i)
  412. {
  413. int p = wCell + (i * 5);
  414.  
  415. if (p >= INVENTORY_MAX_NUM)
  416. continue;
  417.  
  418. if (m_pointsInstant.pItems[p] && m_pointsInstant.pItems[p] != pOld)
  419. continue;
  420.  
  421. m_pointsInstant.bItemGrid[p] = 0;
  422. }
  423. }
  424. else
  425. m_pointsInstant.bItemGrid[wCell] = 0;
  426. }
  427.  
  428. if (pItem)
  429. {
  430. if (wCell < INVENTORY_MAX_NUM)
  431. {
  432. for (int i = 0; i < pItem->GetSize(); ++i)
  433. {
  434. int p = wCell + (i * 5);
  435.  
  436. if (p >= INVENTORY_MAX_NUM)
  437. continue;
  438.  
  439. m_pointsInstant.bItemGrid[p] = wCell + 1;
  440. }
  441. }
  442. else
  443. m_pointsInstant.bItemGrid[wCell] = wCell + 1;
  444. }
  445.  
  446. m_pointsInstant.pItems[wCell] = pItem;
  447. }
  448. break;
  449. // ¿ëÈ¥¼® Àκ¥Å丮
  450. case DRAGON_SOUL_INVENTORY:
  451. {
  452. LPITEM pOld = m_pointsInstant.pDSItems[wCell];
  453.  
  454. if (pOld)
  455. {
  456. if (wCell < DRAGON_SOUL_INVENTORY_MAX_NUM)
  457. {
  458. for (int i = 0; i < pOld->GetSize(); ++i)
  459. {
  460. int p = wCell + (i * DRAGON_SOUL_BOX_COLUMN_NUM);
  461.  
  462. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  463. continue;
  464.  
  465. if (m_pointsInstant.pDSItems[p] && m_pointsInstant.pDSItems[p] != pOld)
  466. continue;
  467.  
  468. m_pointsInstant.wDSItemGrid[p] = 0;
  469. }
  470. }
  471. else
  472. m_pointsInstant.wDSItemGrid[wCell] = 0;
  473. }
  474.  
  475. if (pItem)
  476. {
  477. if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  478. {
  479. sys_err("CHARACTER::SetItem: invalid DS item cell %d", wCell);
  480. return;
  481. }
  482.  
  483. if (wCell < DRAGON_SOUL_INVENTORY_MAX_NUM)
  484. {
  485. for (int i = 0; i < pItem->GetSize(); ++i)
  486. {
  487. int p = wCell + (i * DRAGON_SOUL_BOX_COLUMN_NUM);
  488.  
  489. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  490. continue;
  491.  
  492. m_pointsInstant.wDSItemGrid[p] = wCell + 1;
  493. }
  494. }
  495. else
  496. m_pointsInstant.wDSItemGrid[wCell] = wCell + 1;
  497. }
  498.  
  499. m_pointsInstant.pDSItems[wCell] = pItem;
  500. }
  501. break;
  502. #ifdef __ATTR_SWITCH_SYSTEM__
  503. case SWITCHBOT:
  504. {
  505. LPITEM pOld = m_pointsInstant.pSwitchbotItems[wCell];
  506. if (pItem && pOld)
  507. return;
  508.  
  509. if (wCell >= SWITCHBOT_SLOT_COUNT)
  510. {
  511. sys_err("CHARACTER::SetItem: invalid switchbot item cell %d", wCell);
  512. return;
  513. }
  514.  
  515. if (pItem)
  516. CSwitchbotManager::Instance().RegisterItem(GetPlayerID(), pItem->GetID(), wCell);
  517. else
  518. CSwitchbotManager::Instance().UnregisterItem(GetPlayerID(), wCell);
  519.  
  520. m_pointsInstant.pSwitchbotItems[wCell] = pItem;
  521. }
  522. break;
  523. #endif
  524. #ifdef ENABLE_SPECIAL_STORAGE
  525. case UPGRADE_INVENTORY:
  526. {
  527. LPITEM pOld = m_pointsInstant.pSSUItems[wCell];
  528.  
  529. if (pOld)
  530. {
  531. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  532. {
  533. for (int i = 0; i < pOld->GetSize(); ++i)
  534. {
  535. int p = wCell + (i * 5);
  536.  
  537. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  538. continue;
  539.  
  540. if (m_pointsInstant.pSSUItems[p] && m_pointsInstant.pSSUItems[p] != pOld)
  541. continue;
  542.  
  543. m_pointsInstant.wSSUItemGrid[p] = 0;
  544. }
  545. }
  546. else
  547. m_pointsInstant.wSSUItemGrid[wCell] = 0;
  548. }
  549.  
  550. if (pItem)
  551. {
  552. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  553. {
  554. sys_err("CHARACTER::SetItem: invalid SSU item cell %d", wCell);
  555. return;
  556. }
  557.  
  558. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  559. {
  560. for (int i = 0; i < pItem->GetSize(); ++i)
  561. {
  562. int p = wCell + (i * 5);
  563.  
  564. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  565. continue;
  566.  
  567. m_pointsInstant.wSSUItemGrid[p] = wCell + 1;
  568. }
  569. }
  570. else
  571. m_pointsInstant.wSSUItemGrid[wCell] = wCell + 1;
  572. }
  573.  
  574. m_pointsInstant.pSSUItems[wCell] = pItem;
  575. }
  576. break;
  577. case BOOK_INVENTORY:
  578. {
  579. LPITEM pOld = m_pointsInstant.pSSBItems[wCell];
  580.  
  581. if (pOld)
  582. {
  583. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  584. {
  585. for (int i = 0; i < pOld->GetSize(); ++i)
  586. {
  587. int p = wCell + (i * 5);
  588.  
  589. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  590. continue;
  591.  
  592. if (m_pointsInstant.pSSBItems[p] && m_pointsInstant.pSSBItems[p] != pOld)
  593. continue;
  594.  
  595. m_pointsInstant.wSSBItemGrid[p] = 0;
  596. }
  597. }
  598. else
  599. m_pointsInstant.wSSBItemGrid[wCell] = 0;
  600. }
  601.  
  602. if (pItem)
  603. {
  604. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  605. {
  606. sys_err("CHARACTER::SetItem: invalid SSB item cell %d", wCell);
  607. return;
  608. }
  609.  
  610. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  611. {
  612. for (int i = 0; i < pItem->GetSize(); ++i)
  613. {
  614. int p = wCell + (i * 5);
  615.  
  616. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  617. continue;
  618.  
  619. m_pointsInstant.wSSBItemGrid[p] = wCell + 1;
  620. }
  621. }
  622. else
  623. m_pointsInstant.wSSBItemGrid[wCell] = wCell + 1;
  624. }
  625.  
  626. m_pointsInstant.pSSBItems[wCell] = pItem;
  627. }
  628. break;
  629. case STONE_INVENTORY:
  630. {
  631. LPITEM pOld = m_pointsInstant.pSSSItems[wCell];
  632.  
  633. if (pOld)
  634. {
  635. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  636. {
  637. for (int i = 0; i < pOld->GetSize(); ++i)
  638. {
  639. int p = wCell + (i * 5);
  640.  
  641. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  642. continue;
  643.  
  644. if (m_pointsInstant.pSSSItems[p] && m_pointsInstant.pSSSItems[p] != pOld)
  645. continue;
  646.  
  647. m_pointsInstant.wSSSItemGrid[p] = 0;
  648. }
  649. }
  650. else
  651. m_pointsInstant.wSSSItemGrid[wCell] = 0;
  652. }
  653.  
  654. if (pItem)
  655. {
  656. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  657. {
  658. sys_err("CHARACTER::SetItem: invalid SSB item cell %d", wCell);
  659. return;
  660. }
  661.  
  662. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  663. {
  664. for (int i = 0; i < pItem->GetSize(); ++i)
  665. {
  666. int p = wCell + (i * 5);
  667.  
  668. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  669. continue;
  670.  
  671. m_pointsInstant.wSSSItemGrid[p] = wCell + 1;
  672. }
  673. }
  674. else
  675. m_pointsInstant.wSSSItemGrid[wCell] = wCell + 1;
  676. }
  677.  
  678. m_pointsInstant.pSSSItems[wCell] = pItem;
  679. }
  680. break;
  681. case DND_INVENTORY:
  682. {
  683. LPITEM pOld = m_pointsInstant.pSSDItems[wCell];
  684.  
  685. if (pOld)
  686. {
  687. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  688. {
  689. for (int i = 0; i < pOld->GetSize(); ++i)
  690. {
  691. int p = wCell + (i * 5);
  692.  
  693. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  694. continue;
  695.  
  696. if (m_pointsInstant.pSSDItems[p] && m_pointsInstant.pSSDItems[p] != pOld)
  697. continue;
  698.  
  699. m_pointsInstant.wSSDItemGrid[p] = 0;
  700. }
  701. }
  702. else
  703. m_pointsInstant.wSSDItemGrid[wCell] = 0;
  704. }
  705.  
  706. if (pItem)
  707. {
  708. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  709. {
  710. sys_err("CHARACTER::SetItem: invalid SSD item cell %d", wCell);
  711. return;
  712. }
  713.  
  714. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  715. {
  716. for (int i = 0; i < pItem->GetSize(); ++i)
  717. {
  718. int p = wCell + (i * 5);
  719.  
  720. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  721. continue;
  722.  
  723. m_pointsInstant.wSSDItemGrid[p] = wCell + 1;
  724. }
  725. }
  726. else
  727. m_pointsInstant.wSSDItemGrid[wCell] = wCell + 1;
  728. }
  729.  
  730. m_pointsInstant.pSSDItems[wCell] = pItem;
  731. }
  732. break;
  733. case GEAR_INVENTORY:
  734. {
  735. LPITEM pOld = m_pointsInstant.pSSGItems[wCell];
  736.  
  737. if (pOld)
  738. {
  739. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  740. {
  741. for (int i = 0; i < pOld->GetSize(); ++i)
  742. {
  743. int p = wCell + (i * 5);
  744.  
  745. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  746. continue;
  747.  
  748. if (m_pointsInstant.pSSGItems[p] && m_pointsInstant.pSSGItems[p] != pOld)
  749. continue;
  750.  
  751. m_pointsInstant.wSSGItemGrid[p] = 0;
  752. }
  753. }
  754. else
  755. m_pointsInstant.wSSGItemGrid[wCell] = 0;
  756. }
  757.  
  758. if (pItem)
  759. {
  760. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  761. {
  762. sys_err("CHARACTER::SetItem: invalid SSG item cell %d", wCell);
  763. return;
  764. }
  765.  
  766. if (wCell < SPECIAL_INVENTORY_MAX_NUM)
  767. {
  768. for (int i = 0; i < pItem->GetSize(); ++i)
  769. {
  770. int p = wCell + (i * 5);
  771.  
  772. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  773. continue;
  774.  
  775. m_pointsInstant.wSSGItemGrid[p] = wCell + 1;
  776. }
  777. }
  778. else
  779. m_pointsInstant.wSSGItemGrid[wCell] = wCell + 1;
  780. }
  781.  
  782. m_pointsInstant.pSSGItems[wCell] = pItem;
  783. }
  784. break;
  785. #endif
  786. default:
  787. sys_err ("Invalid Inventory type %d", window_type);
  788. return;
  789. }
  790.  
  791. if (GetDesc())
  792. {
  793. if (pItem)
  794. {
  795. TPacketGCItemSet pack;
  796. pack.header = HEADER_GC_ITEM_SET;
  797. pack.Cell = Cell;
  798.  
  799. pack.count = pItem->GetCount();
  800. pack.vnum = pItem->GetVnum();
  801. pack.flags = pItem->GetFlag();
  802. pack.anti_flags = pItem->GetAntiFlag();
  803. #ifdef ENABLE_HIGHLIGHT_NEW_ITEM
  804. pack.highlight = !bWereMine || (Cell.window_type == DRAGON_SOUL_INVENTORY);(Cell.window_type == DRAGON_SOUL_INVENTORY);
  805. #else
  806. pack.highlight = (Cell.window_type == DRAGON_SOUL_INVENTORY);
  807. #endif
  808.  
  809. thecore_memcpy(pack.alSockets, pItem->GetSockets(), sizeof(pack.alSockets));
  810. thecore_memcpy(pack.aAttr, pItem->GetAttributes(), sizeof(pack.aAttr));
  811.  
  812. GetDesc()->Packet(&pack, sizeof(TPacketGCItemSet));
  813. }
  814. else
  815. {
  816. TPacketGCItemDelDeprecated pack;
  817. pack.header = HEADER_GC_ITEM_DEL;
  818. pack.Cell = Cell;
  819. pack.count = 0;
  820. pack.vnum = 0;
  821. memset(pack.alSockets, 0, sizeof(pack.alSockets));
  822. memset(pack.aAttr, 0, sizeof(pack.aAttr));
  823.  
  824. GetDesc()->Packet(&pack, sizeof(TPacketGCItemDelDeprecated));
  825. }
  826. }
  827.  
  828. if (pItem)
  829. {
  830. pItem->SetCell(this, wCell);
  831. switch (window_type)
  832. {
  833. case INVENTORY:
  834. case EQUIPMENT:
  835. if ((wCell < INVENTORY_MAX_NUM) || (BELT_INVENTORY_SLOT_START <= wCell && BELT_INVENTORY_SLOT_END > wCell))
  836. pItem->SetWindow(INVENTORY);
  837. else
  838. pItem->SetWindow(EQUIPMENT);
  839. break;
  840. case DRAGON_SOUL_INVENTORY:
  841. pItem->SetWindow(DRAGON_SOUL_INVENTORY);
  842. break;
  843. #ifdef __ATTR_SWITCH_SYSTEM__
  844. case SWITCHBOT:
  845. pItem->SetWindow(SWITCHBOT);
  846. break;
  847. #endif
  848.  
  849. #ifdef ENABLE_SPECIAL_STORAGE
  850. case UPGRADE_INVENTORY:
  851. pItem->SetWindow(UPGRADE_INVENTORY);
  852. break;
  853. case BOOK_INVENTORY:
  854. pItem->SetWindow(BOOK_INVENTORY);
  855. break;
  856. case STONE_INVENTORY:
  857. pItem->SetWindow(STONE_INVENTORY);
  858. break;
  859. case DND_INVENTORY:
  860. pItem->SetWindow(DND_INVENTORY);
  861. break;
  862. case GEAR_INVENTORY:
  863. pItem->SetWindow(GEAR_INVENTORY);
  864. break;
  865. #endif
  866. }
  867. }
  868. }
  869.  
  870. LPITEM CHARACTER::GetWear(BYTE bCell) const
  871. {
  872. // > WEAR_MAX_NUM
  873. if (bCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
  874. {
  875. sys_err("CHARACTER::GetWear: invalid wear cell %d", bCell);
  876. return NULL;
  877. }
  878.  
  879. return m_pointsInstant.pItems[INVENTORY_MAX_NUM + bCell];
  880. }
  881.  
  882. void CHARACTER::SetWear(BYTE bCell, LPITEM item)
  883. {
  884. // > WEAR_MAX_NUM :
  885. if (bCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
  886. {
  887. sys_err("CHARACTER::SetItem: invalid item cell %d", bCell);
  888. return;
  889. }
  890.  
  891. SetItem(TItemPos (INVENTORY, INVENTORY_MAX_NUM + bCell), item);
  892.  
  893. if (!item && bCell == WEAR_WEAPON)
  894. {
  895. if (IsAffectFlag(AFF_GWIGUM))
  896. RemoveAffect(SKILL_GWIGEOM);
  897.  
  898. if (IsAffectFlag(AFF_GEOMGYEONG))
  899. RemoveAffect(SKILL_GEOMKYUNG);
  900. }
  901. }
  902.  
  903. void CHARACTER::ClearItem()
  904. {
  905. int i;
  906. LPITEM item;
  907.  
  908. for (i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
  909. {
  910. if ((item = GetInventoryItem(i)))
  911. {
  912. item->SetSkipSave(true);
  913. ITEM_MANAGER::instance().FlushDelayedSave(item);
  914.  
  915. item->RemoveFromCharacter();
  916. M2_DESTROY_ITEM(item);
  917.  
  918. SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
  919. }
  920. }
  921. for (i = 0; i < DRAGON_SOUL_INVENTORY_MAX_NUM; ++i)
  922. {
  923. if ((item = GetItem(TItemPos(DRAGON_SOUL_INVENTORY, i))))
  924. {
  925. item->SetSkipSave(true);
  926. ITEM_MANAGER::instance().FlushDelayedSave(item);
  927.  
  928. item->RemoveFromCharacter();
  929. M2_DESTROY_ITEM(item);
  930. }
  931. }
  932. #ifdef __ATTR_SWITCH_SYSTEM__
  933. for (i = 0; i < SWITCHBOT_SLOT_COUNT; ++i)
  934. {
  935. if ((item = GetItem(TItemPos(SWITCHBOT, i))))
  936. {
  937. item->SetSkipSave(true);
  938. ITEM_MANAGER::instance().FlushDelayedSave(item);
  939.  
  940. item->RemoveFromCharacter();
  941. M2_DESTROY_ITEM(item);
  942. }
  943. }
  944. #endif
  945. #ifdef ENABLE_SPECIAL_STORAGE
  946. for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  947. {
  948. if ((item = GetItem(TItemPos(UPGRADE_INVENTORY, i))))
  949. {
  950. item->SetSkipSave(true);
  951. ITEM_MANAGER::instance().FlushDelayedSave(item);
  952.  
  953. item->RemoveFromCharacter();
  954. M2_DESTROY_ITEM(item);
  955. }
  956. }
  957. for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  958. {
  959. if ((item = GetItem(TItemPos(BOOK_INVENTORY, i))))
  960. {
  961. item->SetSkipSave(true);
  962. ITEM_MANAGER::instance().FlushDelayedSave(item);
  963.  
  964. item->RemoveFromCharacter();
  965. M2_DESTROY_ITEM(item);
  966. }
  967. }
  968. for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  969. {
  970. if ((item = GetItem(TItemPos(STONE_INVENTORY, i))))
  971. {
  972. item->SetSkipSave(true);
  973. ITEM_MANAGER::instance().FlushDelayedSave(item);
  974.  
  975. item->RemoveFromCharacter();
  976. M2_DESTROY_ITEM(item);
  977. }
  978. }
  979. for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  980. {
  981. if ((item = GetItem(TItemPos(DND_INVENTORY, i))))
  982. {
  983. item->SetSkipSave(true);
  984. ITEM_MANAGER::instance().FlushDelayedSave(item);
  985.  
  986. item->RemoveFromCharacter();
  987. M2_DESTROY_ITEM(item);
  988. }
  989. }
  990. for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  991. {
  992. if ((item = GetItem(TItemPos(GEAR_INVENTORY, i))))
  993. {
  994. item->SetSkipSave(true);
  995. ITEM_MANAGER::instance().FlushDelayedSave(item);
  996.  
  997. item->RemoveFromCharacter();
  998. M2_DESTROY_ITEM(item);
  999. }
  1000. }
  1001. #endif
  1002. }
  1003.  
  1004. bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) const
  1005. {
  1006. switch (Cell.window_type)
  1007. {
  1008. case INVENTORY:
  1009. {
  1010. BYTE bCell = Cell.cell;
  1011.  
  1012. ++iExceptionCell;
  1013.  
  1014. if (Cell.IsBeltInventoryPosition())
  1015. {
  1016. LPITEM beltItem = GetWear(WEAR_BELT);
  1017.  
  1018. if (NULL == beltItem)
  1019. return false;
  1020.  
  1021. if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
  1022. return false;
  1023.  
  1024. if (m_pointsInstant.bItemGrid[bCell])
  1025. {
  1026. if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)
  1027. return true;
  1028.  
  1029. return false;
  1030. }
  1031.  
  1032. if (bSize == 1)
  1033. return true;
  1034.  
  1035. }
  1036. else if (bCell >= INVENTORY_MAX_NUM)
  1037. return false;
  1038.  
  1039. if (m_pointsInstant.bItemGrid[bCell])
  1040. {
  1041. if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)
  1042. {
  1043. if (bSize == 1)
  1044. return true;
  1045.  
  1046. int j = 1;
  1047. BYTE bPage = bCell / (INVENTORY_MAX_NUM / 4);
  1048.  
  1049. do
  1050. {
  1051. BYTE p = bCell + (5 * j);
  1052.  
  1053. if (p >= INVENTORY_MAX_NUM)
  1054. return false;
  1055.  
  1056. if (p / (INVENTORY_MAX_NUM / 4) != bPage)
  1057. return false;
  1058.  
  1059. if (m_pointsInstant.bItemGrid[p])
  1060. if (m_pointsInstant.bItemGrid[p] != iExceptionCell)
  1061. return false;
  1062. }
  1063. while (++j < bSize);
  1064.  
  1065. return true;
  1066. }
  1067. else
  1068. return false;
  1069. }
  1070.  
  1071. if (1 == bSize)
  1072. return true;
  1073. else
  1074. {
  1075. int j = 1;
  1076. BYTE bPage = bCell / (INVENTORY_MAX_NUM / 4);
  1077.  
  1078. do
  1079. {
  1080. BYTE p = bCell + (5 * j);
  1081.  
  1082. if (p >= INVENTORY_MAX_NUM)
  1083. return false;
  1084.  
  1085. if (p / (INVENTORY_MAX_NUM / 4) != bPage)
  1086. return false;
  1087.  
  1088. if (m_pointsInstant.bItemGrid[p])
  1089. if (m_pointsInstant.bItemGrid[p] != iExceptionCell)
  1090. return false;
  1091. }
  1092. while (++j < bSize);
  1093.  
  1094. return true;
  1095. }
  1096. }
  1097. break;
  1098. #ifdef ENABLE_SPECIAL_STORAGE
  1099. case UPGRADE_INVENTORY:
  1100. {
  1101. WORD bCell = Cell.cell;
  1102.  
  1103. iExceptionCell++;
  1104.  
  1105. if (bCell >= SPECIAL_INVENTORY_MAX_NUM)
  1106. return false;
  1107.  
  1108. if (m_pointsInstant.wSSUItemGrid[bCell])
  1109. {
  1110. if (m_pointsInstant.wSSUItemGrid[bCell] == iExceptionCell)
  1111. {
  1112. if (bSize == 1)
  1113. return true;
  1114.  
  1115. int j = 1;
  1116.  
  1117. BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
  1118.  
  1119. do
  1120. {
  1121. BYTE p = bCell + (5 * j);
  1122.  
  1123. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1124. return false;
  1125.  
  1126. if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
  1127. return false;
  1128.  
  1129. if (m_pointsInstant.wSSUItemGrid[p])
  1130. if (m_pointsInstant.wSSUItemGrid[p] != iExceptionCell)
  1131. return false;
  1132. }
  1133. while (++j < bSize);
  1134.  
  1135. return true;
  1136. }
  1137. else
  1138. return false;
  1139. }
  1140.  
  1141. if (1 == bSize)
  1142. return true;
  1143. else
  1144. {
  1145. int j = 1;
  1146.  
  1147. BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
  1148.  
  1149. do
  1150. {
  1151. int p = bCell + (5 * j);
  1152.  
  1153. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1154. return false;
  1155.  
  1156. if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
  1157. return false;
  1158.  
  1159. if (m_pointsInstant.wSSUItemGrid[p])
  1160. if (m_pointsInstant.wSSUItemGrid[p] != iExceptionCell)
  1161. return false;
  1162. }
  1163. while (++j < bSize);
  1164.  
  1165. return true;
  1166. }
  1167. }
  1168. break;
  1169. case BOOK_INVENTORY:
  1170. {
  1171. WORD bCell = Cell.cell;
  1172.  
  1173. iExceptionCell++;
  1174.  
  1175. if (bCell >= SPECIAL_INVENTORY_MAX_NUM)
  1176. return false;
  1177.  
  1178. if (m_pointsInstant.wSSBItemGrid[bCell])
  1179. {
  1180. if (m_pointsInstant.wSSBItemGrid[bCell] == iExceptionCell)
  1181. {
  1182. if (bSize == 1)
  1183. return true;
  1184.  
  1185. int j = 1;
  1186.  
  1187. BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
  1188.  
  1189. do
  1190. {
  1191. int p = bCell + (5 * j);
  1192.  
  1193. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1194. return false;
  1195.  
  1196. if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
  1197. return false;
  1198.  
  1199. if (m_pointsInstant.wSSBItemGrid[p])
  1200. if (m_pointsInstant.wSSBItemGrid[p] != iExceptionCell)
  1201. return false;
  1202. }
  1203. while (++j < bSize);
  1204.  
  1205. return true;
  1206. }
  1207. else
  1208. return false;
  1209. }
  1210.  
  1211. if (1 == bSize)
  1212. return true;
  1213. else
  1214. {
  1215. int j = 1;
  1216.  
  1217. BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
  1218.  
  1219. do
  1220. {
  1221. int p = bCell + (5 * j);
  1222.  
  1223. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1224. return false;
  1225.  
  1226. if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
  1227. return false;
  1228.  
  1229. if (m_pointsInstant.wSSBItemGrid[p])
  1230. if (m_pointsInstant.wSSBItemGrid[p] != iExceptionCell)
  1231. return false;
  1232. }
  1233. while (++j < bSize);
  1234.  
  1235. return true;
  1236. }
  1237. }
  1238. case STONE_INVENTORY:
  1239. {
  1240. WORD bCell = Cell.cell;
  1241.  
  1242. iExceptionCell++;
  1243.  
  1244. if (bCell >= SPECIAL_INVENTORY_MAX_NUM)
  1245. return false;
  1246.  
  1247. if (m_pointsInstant.wSSSItemGrid[bCell])
  1248. {
  1249. if (m_pointsInstant.wSSSItemGrid[bCell] == iExceptionCell)
  1250. {
  1251. if (bSize == 1)
  1252. return true;
  1253.  
  1254. int j = 1;
  1255.  
  1256. BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
  1257.  
  1258. do
  1259. {
  1260. int p = bCell + (5 * j);
  1261.  
  1262. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1263. return false;
  1264.  
  1265. if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
  1266. return false;
  1267.  
  1268. if (m_pointsInstant.wSSSItemGrid[p])
  1269. if (m_pointsInstant.wSSSItemGrid[p] != iExceptionCell)
  1270. return false;
  1271. }
  1272. while (++j < bSize);
  1273.  
  1274. return true;
  1275. }
  1276. else
  1277. return false;
  1278. }
  1279.  
  1280. if (1 == bSize)
  1281. return true;
  1282. else
  1283. {
  1284. int j = 1;
  1285.  
  1286. BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
  1287.  
  1288. do
  1289. {
  1290. int p = bCell + (5 * j);
  1291.  
  1292. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1293. return false;
  1294.  
  1295. if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
  1296. return false;
  1297.  
  1298. if (m_pointsInstant.wSSSItemGrid[p])
  1299. if (m_pointsInstant.wSSSItemGrid[p] != iExceptionCell)
  1300. return false;
  1301. }
  1302. while (++j < bSize);
  1303.  
  1304. return true;
  1305. }
  1306. }
  1307. break;
  1308. case DND_INVENTORY:
  1309. {
  1310. WORD wCell = Cell.cell;
  1311. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  1312. return false;
  1313.  
  1314. iExceptionCell++;
  1315.  
  1316. if (m_pointsInstant.wSSDItemGrid[wCell])
  1317. {
  1318. if (m_pointsInstant.wSSDItemGrid[wCell] == iExceptionCell)
  1319. {
  1320. if (bSize == 1)
  1321. return true;
  1322.  
  1323. int j = 1;
  1324.  
  1325. do
  1326. {
  1327. int p = wCell + (5 * j);
  1328.  
  1329. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1330. return false;
  1331.  
  1332. if (m_pointsInstant.wSSDItemGrid[p])
  1333. if (m_pointsInstant.wSSDItemGrid[p] != iExceptionCell)
  1334. return false;
  1335. }
  1336. while (++j < bSize);
  1337.  
  1338. return true;
  1339. }
  1340. else
  1341. return false;
  1342. }
  1343.  
  1344. if (1 == bSize)
  1345. return true;
  1346. else
  1347. {
  1348. int j = 1;
  1349.  
  1350. do
  1351. {
  1352. int p = wCell + (5 * j);
  1353.  
  1354. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1355. return false;
  1356.  
  1357. if (m_pointsInstant.bItemGrid[p]) // old bItemGrid
  1358. if (m_pointsInstant.wSSDItemGrid[p] != iExceptionCell)
  1359. return false;
  1360. }
  1361. while (++j < bSize);
  1362.  
  1363. return true;
  1364. }
  1365. }
  1366. case GEAR_INVENTORY:
  1367. {
  1368. WORD wCell = Cell.cell;
  1369. if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
  1370. return false;
  1371.  
  1372. iExceptionCell++;
  1373.  
  1374. if (m_pointsInstant.wSSGItemGrid[wCell])
  1375. {
  1376. if (m_pointsInstant.wSSGItemGrid[wCell] == iExceptionCell)
  1377. {
  1378. if (bSize == 1)
  1379. return true;
  1380.  
  1381. int j = 1;
  1382.  
  1383. do
  1384. {
  1385. int p = wCell + (5 * j);
  1386.  
  1387. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1388. return false;
  1389.  
  1390. if (m_pointsInstant.wSSGItemGrid[p])
  1391. if (m_pointsInstant.wSSGItemGrid[p] != iExceptionCell)
  1392. return false;
  1393. }
  1394. while (++j < bSize);
  1395.  
  1396. return true;
  1397. }
  1398. else
  1399. return false;
  1400. }
  1401.  
  1402. if (1 == bSize)
  1403. return true;
  1404. else
  1405. {
  1406. int j = 1;
  1407.  
  1408. do
  1409. {
  1410. int p = wCell + (5 * j);
  1411.  
  1412. if (p >= SPECIAL_INVENTORY_MAX_NUM)
  1413. return false;
  1414.  
  1415. if (m_pointsInstant.bItemGrid[p]) // old bItemGrid
  1416. if (m_pointsInstant.wSSGItemGrid[p] != iExceptionCell)
  1417. return false;
  1418. }
  1419. while (++j < bSize);
  1420.  
  1421. return true;
  1422. }
  1423. }
  1424. #endif
  1425. case DRAGON_SOUL_INVENTORY:
  1426. {
  1427. WORD wCell = Cell.cell;
  1428. if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  1429. return false;
  1430.  
  1431. iExceptionCell++;
  1432.  
  1433. if (m_pointsInstant.wDSItemGrid[wCell])
  1434. {
  1435. if (m_pointsInstant.wDSItemGrid[wCell] == iExceptionCell)
  1436. {
  1437. if (bSize == 1)
  1438. return true;
  1439.  
  1440. int j = 1;
  1441.  
  1442. do
  1443. {
  1444. int p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
  1445.  
  1446. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  1447. return false;
  1448.  
  1449. if (m_pointsInstant.wDSItemGrid[p])
  1450. if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
  1451. return false;
  1452. }
  1453. while (++j < bSize);
  1454.  
  1455. return true;
  1456. }
  1457. else
  1458. return false;
  1459. }
  1460.  
  1461. if (1 == bSize)
  1462. return true;
  1463. else
  1464. {
  1465. int j = 1;
  1466.  
  1467. do
  1468. {
  1469. int p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
  1470.  
  1471. if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  1472. return false;
  1473.  
  1474. if (m_pointsInstant.bItemGrid[p])
  1475. if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
  1476. return false;
  1477. }
  1478. while (++j < bSize);
  1479.  
  1480. return true;
  1481. }
  1482. }
  1483. break;
  1484. #ifdef __ATTR_SWITCH_SYSTEM__
  1485. case SWITCHBOT:
  1486. {
  1487. WORD wCell = Cell.cell;
  1488. if (wCell >= SWITCHBOT_SLOT_COUNT)
  1489. return false;
  1490.  
  1491. if (m_pointsInstant.pSwitchbotItems[wCell])
  1492. return false;
  1493.  
  1494. return true;
  1495. }
  1496. break;
  1497. #endif
  1498. }
  1499. }
  1500.  
  1501. int CHARACTER::GetEmptyInventory(BYTE size) const
  1502. {
  1503. for ( int i = 0; i < INVENTORY_MAX_NUM; ++i)
  1504. if (IsEmptyItemGrid(TItemPos (INVENTORY, i), size))
  1505. return i;
  1506. return -1;
  1507. }
  1508.  
  1509. int CHARACTER::GetEmptyDragonSoulInventory(LPITEM pItem) const
  1510. {
  1511. if (NULL == pItem || !pItem->IsDragonSoul())
  1512. return -1;
  1513. if (!DragonSoul_IsQualified())
  1514. {
  1515. return -1;
  1516. }
  1517. BYTE bSize = pItem->GetSize();
  1518. WORD wBaseCell = DSManager::instance().GetBasePosition(pItem);
  1519.  
  1520. if (WORD_MAX == wBaseCell)
  1521. return -1;
  1522.  
  1523. for (int i = 0; i < DRAGON_SOUL_BOX_SIZE; ++i)
  1524. if (IsEmptyItemGrid(TItemPos(DRAGON_SOUL_INVENTORY, i + wBaseCell), bSize))
  1525. return i + wBaseCell;
  1526.  
  1527. return -1;
  1528. }
  1529.  
  1530. void CHARACTER::CopyDragonSoulItemGrid(std::vector<WORD>& vDragonSoulItemGrid) const
  1531. {
  1532. vDragonSoulItemGrid.resize(DRAGON_SOUL_INVENTORY_MAX_NUM);
  1533.  
  1534. std::copy(m_pointsInstant.wDSItemGrid, m_pointsInstant.wDSItemGrid + DRAGON_SOUL_INVENTORY_MAX_NUM, vDragonSoulItemGrid.begin());
  1535. }
  1536.  
  1537. #ifdef ENABLE_SPECIAL_STORAGE
  1538. int CHARACTER::GetEmptyUpgradeInventory(LPITEM pItem) const
  1539. {
  1540. if (NULL == pItem || !pItem->IsUpgradeItem())
  1541. return -1;
  1542.  
  1543. BYTE bSize = pItem->GetSize();
  1544.  
  1545. for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  1546. if (IsEmptyItemGrid(TItemPos (UPGRADE_INVENTORY, i), bSize))
  1547. return i;
  1548.  
  1549. return -1;
  1550. }
  1551. int CHARACTER::GetEmptyBookInventory(LPITEM pItem) const
  1552. {
  1553. if (NULL == pItem || !pItem->IsBook())
  1554. return -1;
  1555.  
  1556. BYTE bSize = pItem->GetSize();
  1557.  
  1558. for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  1559. if (IsEmptyItemGrid(TItemPos (BOOK_INVENTORY, i), bSize))
  1560. return i;
  1561.  
  1562. return -1;
  1563. }
  1564. int CHARACTER::GetEmptyStoneInventory(LPITEM pItem) const
  1565. {
  1566. if (NULL == pItem || !pItem->IsStone())
  1567. return -1;
  1568.  
  1569. BYTE bSize = pItem->GetSize();
  1570.  
  1571. for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  1572. if (IsEmptyItemGrid(TItemPos (STONE_INVENTORY, i), bSize))
  1573. return i;
  1574.  
  1575. return -1;
  1576. }
  1577. int CHARACTER::GetEmptyDndInventory(LPITEM pItem) const
  1578. {
  1579. if (NULL == pItem || !pItem->IsDnd())
  1580. return -1;
  1581.  
  1582. BYTE bSize = pItem->GetSize();
  1583.  
  1584. for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  1585. if (IsEmptyItemGrid(TItemPos (DND_INVENTORY, i), bSize))
  1586. return i;
  1587.  
  1588. return -1;
  1589. }
  1590. int CHARACTER::GetEmptyGearInventory(LPITEM pItem) const
  1591. {
  1592. if (NULL == pItem || !pItem->IsGear())
  1593. return -1;
  1594.  
  1595. BYTE bSize = pItem->GetSize();
  1596.  
  1597. for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  1598. if (IsEmptyItemGrid(TItemPos (GEAR_INVENTORY, i), bSize))
  1599. return i;
  1600.  
  1601. return -1;
  1602. }
  1603. #endif
  1604.  
  1605. int CHARACTER::CountEmptyInventory() const
  1606. {
  1607. int count = 0;
  1608.  
  1609. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  1610. if (GetInventoryItem(i))
  1611. count += GetInventoryItem(i)->GetSize();
  1612.  
  1613. return (INVENTORY_MAX_NUM - count);
  1614. }
  1615.  
  1616. void TransformRefineItem(LPITEM pkOldItem, LPITEM pkNewItem)
  1617. {
  1618. // ACCESSORY_REFINE
  1619. if (pkOldItem->IsAccessoryForSocket())
  1620. {
  1621. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1622. {
  1623. pkNewItem->SetSocket(i, pkOldItem->GetSocket(i));
  1624. }
  1625. //pkNewItem->StartAccessorySocketExpireEvent();
  1626. }
  1627. // END_OF_ACCESSORY_REFINE
  1628. else
  1629. {
  1630. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1631. {
  1632. if (!pkOldItem->GetSocket(i))
  1633. break;
  1634. else
  1635. pkNewItem->SetSocket(i, 1);
  1636. }
  1637.  
  1638. int slot = 0;
  1639.  
  1640. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1641. {
  1642. long socket = pkOldItem->GetSocket(i);
  1643.  
  1644. if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
  1645. pkNewItem->SetSocket(slot++, socket);
  1646. }
  1647.  
  1648. }
  1649.  
  1650. pkOldItem->CopyAttributeTo(pkNewItem);
  1651. }
  1652.  
  1653. void NotifyRefineSuccess(LPCHARACTER ch, LPITEM item, const char* way)
  1654. {
  1655. if (NULL != ch && item != NULL)
  1656. {
  1657. ch->ChatPacket(CHAT_TYPE_COMMAND, "RefineSuceeded");
  1658.  
  1659. LogManager::instance().RefineLog(ch->GetPlayerID(), item->GetName(), item->GetID(), item->GetRefineLevel(), 1, way);
  1660. }
  1661. }
  1662.  
  1663. void NotifyRefineFail(LPCHARACTER ch, LPITEM item, const char* way, int success = 0)
  1664. {
  1665. if (NULL != ch && NULL != item)
  1666. {
  1667. ch->ChatPacket(CHAT_TYPE_COMMAND, "RefineFailed");
  1668.  
  1669. LogManager::instance().RefineLog(ch->GetPlayerID(), item->GetName(), item->GetID(), item->GetRefineLevel(), success, way);
  1670. }
  1671. }
  1672.  
  1673. void CHARACTER::SetRefineNPC(LPCHARACTER ch)
  1674. {
  1675. if ( ch != NULL )
  1676. {
  1677. m_dwRefineNPCVID = ch->GetVID();
  1678. }
  1679. else
  1680. {
  1681. m_dwRefineNPCVID = 0;
  1682. }
  1683. }
  1684.  
  1685. bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
  1686. {
  1687. if (!CanHandleItem(true))
  1688. {
  1689. ClearRefineMode();
  1690. return false;
  1691. }
  1692.  
  1693. if (quest::CQuestManager::instance().GetEventFlag("update_refine_time") != 0)
  1694. {
  1695. if (get_global_time() < quest::CQuestManager::instance().GetEventFlag("update_refine_time") + (60 * 5))
  1696. {
  1697. sys_log(0, "can't refine %d %s", GetPlayerID(), GetName());
  1698. return false;
  1699. }
  1700. }
  1701.  
  1702. const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
  1703.  
  1704. if (!prt)
  1705. return false;
  1706.  
  1707. DWORD result_vnum = item->GetRefinedVnum();
  1708.  
  1709. // REFINE_COST
  1710. int cost = ComputeRefineFee(prt->cost);
  1711.  
  1712. int RefineChance = GetQuestFlag("main_quest_lv7.refine_chance");
  1713.  
  1714. if (RefineChance > 0)
  1715. {
  1716. if (!item->CheckItemUseLevel(20) || item->GetType() != ITEM_WEAPON)
  1717. {
  1718. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Upgrade gratuit de la nivel 20"));
  1719. return false;
  1720. }
  1721.  
  1722. cost = 0;
  1723. SetQuestFlag("main_quest_lv7.refine_chance", RefineChance - 1);
  1724. }
  1725. // END_OF_REFINE_COST
  1726.  
  1727. if (result_vnum == 0)
  1728. {
  1729. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poate fi inbunatatit."));
  1730. return false;
  1731. }
  1732.  
  1733. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TUNING)
  1734. return false;
  1735.  
  1736. TItemTable * pProto = ITEM_MANAGER::instance().GetTable(item->GetRefinedVnum());
  1737.  
  1738. if (!pProto)
  1739. {
  1740. sys_err("DoRefine NOT GET ITEM PROTO %d", item->GetRefinedVnum());
  1741. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  1742. return false;
  1743. }
  1744.  
  1745. // REFINE_COST
  1746. if (GetGold() < cost)
  1747. {
  1748. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destui bani pentru upgrade."));
  1749. return false;
  1750. }
  1751.  
  1752. if (!bMoneyOnly && !RefineChance)
  1753. {
  1754. for (int i = 0; i < prt->material_count; ++i)
  1755. {
  1756. if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
  1757. {
  1758. if (test_server)
  1759. {
  1760. ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
  1761. }
  1762. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai materialele necesare."));
  1763. return false;
  1764. }
  1765. }
  1766.  
  1767. for (int i = 0; i < prt->material_count; ++i)
  1768. RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
  1769. }
  1770.  
  1771. int prob = number(1, 100);
  1772.  
  1773. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  1774. if (IsRefineThroughGuild())
  1775. {
  1776. prob -= 10;
  1777. }
  1778.  
  1779. int success_prob = prt->prob;
  1780. success_prob += CRefineManager::instance().Result(this);
  1781. #else
  1782. if (IsRefineThroughGuild())
  1783. prob -= 10;
  1784. #endif
  1785.  
  1786. // END_OF_REFINE_COST
  1787.  
  1788. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  1789. if (prob <= success_prob)
  1790. #else
  1791. if (prob <= prt->prob)
  1792. #endif
  1793. {
  1794. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_vnum, 1, 0, false);
  1795.  
  1796. if (pkNewItem)
  1797. {
  1798. ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
  1799. LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
  1800.  
  1801. BYTE bCell = item->GetCell();
  1802.  
  1803. // DETAIL_REFINE_LOG
  1804. NotifyRefineSuccess(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
  1805. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -cost);
  1806. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
  1807. // END_OF_DETAIL_REFINE_LOG
  1808.  
  1809. pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
  1810. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  1811.  
  1812. sys_log(0, "Refine Success %d", cost);
  1813. pkNewItem->AttrLog();
  1814. //PointChange(POINT_GOLD, -cost);
  1815. sys_log(0, "PayPee %d", cost);
  1816. PayRefineFee(cost);
  1817. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  1818. CRefineManager::instance().Reset(this);
  1819. #endif
  1820. sys_log(0, "PayPee End %d", cost);
  1821. }
  1822. else
  1823. {
  1824. // DETAIL_REFINE_LOG
  1825. sys_err("cannot create item %u", result_vnum);
  1826. NotifyRefineFail(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
  1827. // END_OF_DETAIL_REFINE_LOG
  1828. }
  1829. }
  1830. else
  1831. {
  1832. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -cost);
  1833. NotifyRefineFail(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
  1834. item->AttrLog();
  1835. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE FAIL)");
  1836.  
  1837. //PointChange(POINT_GOLD, -cost);
  1838. PayRefineFee(cost);
  1839. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  1840. CRefineManager::instance().Reset(this);
  1841. #endif
  1842. }
  1843.  
  1844. return true;
  1845. }
  1846.  
  1847. enum enum_RefineScrolls
  1848. {
  1849. CHUKBOK_SCROLL = 0,
  1850. HYUNIRON_CHN = 1,
  1851. YONGSIN_SCROLL = 2,
  1852. MUSIN_SCROLL = 3,
  1853. YAGONG_SCROLL = 4,
  1854. MEMO_SCROLL = 5,
  1855. BDRAGON_SCROLL = 6,
  1856. };
  1857.  
  1858. bool CHARACTER::DoRefineWithScroll(LPITEM item)
  1859. {
  1860. if (!CanHandleItem(true))
  1861. {
  1862. ClearRefineMode();
  1863. return false;
  1864. }
  1865.  
  1866. ClearRefineMode();
  1867.  
  1868. if (quest::CQuestManager::instance().GetEventFlag("update_refine_time") != 0)
  1869. {
  1870. if (get_global_time() < quest::CQuestManager::instance().GetEventFlag("update_refine_time") + (60 * 5))
  1871. {
  1872. sys_log(0, "can't refine %d %s", GetPlayerID(), GetName());
  1873. return false;
  1874. }
  1875. }
  1876.  
  1877. const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
  1878.  
  1879. if (!prt)
  1880. return false;
  1881.  
  1882. LPITEM pkItemScroll;
  1883.  
  1884. if (m_iRefineAdditionalCell < 0)
  1885. return false;
  1886.  
  1887. pkItemScroll = GetInventoryItem(m_iRefineAdditionalCell);
  1888.  
  1889. if (!pkItemScroll)
  1890. return false;
  1891.  
  1892. if (!(pkItemScroll->GetType() == ITEM_USE && pkItemScroll->GetSubType() == USE_TUNING))
  1893. return false;
  1894.  
  1895. if (pkItemScroll->GetVnum() == item->GetVnum())
  1896. return false;
  1897.  
  1898. DWORD result_vnum = item->GetRefinedVnum();
  1899. DWORD result_fail_vnum = item->GetRefineFromVnum();
  1900.  
  1901. if (result_vnum == 0)
  1902. {
  1903. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  1904. return false;
  1905. }
  1906.  
  1907. // MUSIN_SCROLL
  1908. if (pkItemScroll->GetValue(0) == MUSIN_SCROLL)
  1909. {
  1910. if (item->GetRefineLevel() >= 4)
  1911. {
  1912. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  1913. return false;
  1914. }
  1915. }
  1916. // END_OF_MUSIC_SCROLL
  1917.  
  1918. else if (pkItemScroll->GetValue(0) == MEMO_SCROLL)
  1919. {
  1920. if (item->GetRefineLevel() != pkItemScroll->GetValue(1))
  1921. {
  1922. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  1923. return false;
  1924. }
  1925. }
  1926. else if (pkItemScroll->GetValue(0) == BDRAGON_SCROLL)
  1927. {
  1928. if (item->GetType() != ITEM_METIN || item->GetRefineLevel() != 4)
  1929. {
  1930. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  1931. return false;
  1932. }
  1933. }
  1934.  
  1935. TItemTable * pProto = ITEM_MANAGER::instance().GetTable(item->GetRefinedVnum());
  1936.  
  1937. if (!pProto)
  1938. {
  1939. sys_err("DoRefineWithScroll NOT GET ITEM PROTO %d", item->GetRefinedVnum());
  1940. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  1941. return false;
  1942. }
  1943.  
  1944. if (GetGold() < prt->cost)
  1945. {
  1946. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destui bani pentru upgrade."));
  1947. return false;
  1948. }
  1949.  
  1950. for (int i = 0; i < prt->material_count; ++i)
  1951. {
  1952. if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
  1953. {
  1954. if (test_server)
  1955. {
  1956. ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
  1957. }
  1958. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai materialele necesare."));
  1959. return false;
  1960. }
  1961. }
  1962.  
  1963. for (int i = 0; i < prt->material_count; ++i)
  1964. RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
  1965.  
  1966. int prob = number(1, 100);
  1967. int success_prob = prt->prob;
  1968. bool bDestroyWhenFail = false;
  1969.  
  1970. const char* szRefineType = "SCROLL";
  1971.  
  1972. if (pkItemScroll->GetValue(0) == HYUNIRON_CHN ||
  1973. pkItemScroll->GetValue(0) == YONGSIN_SCROLL ||
  1974. pkItemScroll->GetValue(0) == YAGONG_SCROLL)
  1975. {
  1976. const char hyuniron_prob[9] = { 100, 75, 65, 55, 45, 40, 35, 25, 20 };
  1977. const char hyuniron_prob_euckr[9] = { 100, 75, 65, 55, 45, 40, 35, 30, 25 };
  1978.  
  1979. const char yagong_prob[9] = { 100, 100, 90, 80, 70, 60, 50, 30, 20 };
  1980. const char yagong_prob_euckr[9] = { 100, 100, 90, 80, 70, 60, 50, 40, 30 };
  1981.  
  1982. if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
  1983. {
  1984. success_prob = hyuniron_prob[MINMAX(0, item->GetRefineLevel(), 8)];
  1985. }
  1986. else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
  1987. {
  1988. success_prob = yagong_prob[MINMAX(0, item->GetRefineLevel(), 8)];
  1989. }
  1990. else if (pkItemScroll->GetValue(0) == HYUNIRON_CHN) {} // @fixme121
  1991. else
  1992. {
  1993. sys_err("REFINE : Unknown refine scroll item. Value0: %d", pkItemScroll->GetValue(0));
  1994. }
  1995.  
  1996. if (test_server)
  1997. {
  1998. ChatPacket(CHAT_TYPE_INFO, "[Only Test] Success_Prob %d, RefineLevel %d ", success_prob, item->GetRefineLevel());
  1999. }
  2000. if (pkItemScroll->GetValue(0) == HYUNIRON_CHN)
  2001. bDestroyWhenFail = true;
  2002.  
  2003. // DETAIL_REFINE_LOG
  2004. if (pkItemScroll->GetValue(0) == HYUNIRON_CHN)
  2005. {
  2006. szRefineType = "HYUNIRON";
  2007. }
  2008. else if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
  2009. {
  2010. szRefineType = "GOD_SCROLL";
  2011. }
  2012. else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
  2013. {
  2014. szRefineType = "YAGONG_SCROLL";
  2015. }
  2016. // END_OF_DETAIL_REFINE_LOG
  2017. }
  2018.  
  2019. // DETAIL_REFINE_LOG
  2020. if (pkItemScroll->GetValue(0) == MUSIN_SCROLL)
  2021. {
  2022. success_prob = 100;
  2023.  
  2024. szRefineType = "MUSIN_SCROLL";
  2025. }
  2026. // END_OF_DETAIL_REFINE_LOG
  2027. else if (pkItemScroll->GetValue(0) == MEMO_SCROLL)
  2028. {
  2029. success_prob = 100;
  2030. szRefineType = "MEMO_SCROLL";
  2031. }
  2032. else if (pkItemScroll->GetValue(0) == BDRAGON_SCROLL)
  2033. {
  2034. success_prob = 80;
  2035. szRefineType = "BDRAGON_SCROLL";
  2036. }
  2037.  
  2038. pkItemScroll->SetCount(pkItemScroll->GetCount() - 1);
  2039. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  2040. success_prob += CRefineManager::instance().Result(this);
  2041. #endif
  2042.  
  2043. if (prob <= success_prob)
  2044. {
  2045. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_vnum, 1, 0, false);
  2046.  
  2047. if (pkNewItem)
  2048. {
  2049. ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
  2050. LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
  2051.  
  2052. BYTE bCell = item->GetCell();
  2053.  
  2054. NotifyRefineSuccess(this, item, szRefineType);
  2055. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -prt->cost);
  2056. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
  2057.  
  2058. pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
  2059. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  2060. pkNewItem->AttrLog();
  2061. //PointChange(POINT_GOLD, -prt->cost);
  2062. PayRefineFee(prt->cost);
  2063. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  2064. CRefineManager::instance().Reset(this);
  2065. #endif
  2066. }
  2067. else
  2068. {
  2069. sys_err("cannot create item %u", result_vnum);
  2070. NotifyRefineFail(this, item, szRefineType);
  2071. }
  2072. }
  2073. else if (!bDestroyWhenFail && result_fail_vnum)
  2074. {
  2075. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_fail_vnum, 1, 0, false);
  2076.  
  2077. if (pkNewItem)
  2078. {
  2079. ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
  2080. LogManager::instance().ItemLog(this, pkNewItem, "REFINE FAIL", pkNewItem->GetName());
  2081.  
  2082. BYTE bCell = item->GetCell();
  2083.  
  2084. DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -prt->cost);
  2085. NotifyRefineFail(this, item, szRefineType, -1);
  2086. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE FAIL)");
  2087.  
  2088. pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
  2089. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  2090.  
  2091. pkNewItem->AttrLog();
  2092.  
  2093. //PointChange(POINT_GOLD, -prt->cost);
  2094. PayRefineFee(prt->cost);
  2095. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  2096. CRefineManager::instance().Reset(this);
  2097. #endif
  2098. }
  2099. else
  2100. {
  2101. sys_err("cannot create item %u", result_fail_vnum);
  2102. NotifyRefineFail(this, item, szRefineType);
  2103. }
  2104. }
  2105. else
  2106. {
  2107. NotifyRefineFail(this, item, szRefineType);
  2108.  
  2109. PayRefineFee(prt->cost);
  2110. #ifdef ENABLE_FEATURES_REFINE_SYSTEM
  2111. CRefineManager::instance().Reset(this);
  2112. #endif
  2113. }
  2114.  
  2115. return true;
  2116. }
  2117.  
  2118. bool CHARACTER::RefineInformation(BYTE bCell, BYTE bType, int iAdditionalCell)
  2119. {
  2120. if (bCell > INVENTORY_MAX_NUM)
  2121. return false;
  2122.  
  2123. LPITEM item = GetInventoryItem(bCell);
  2124.  
  2125. if (!item)
  2126. return false;
  2127.  
  2128. // REFINE_COST
  2129. if (bType == REFINE_TYPE_MONEY_ONLY && !GetQuestFlag("deviltower_zone.can_refine"))
  2130. {
  2131. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Recompensa pentru finalizarea Turnului Demonilor poate fi folosita pana la o singura data."));
  2132. return false;
  2133. }
  2134. // END_OF_REFINE_COST
  2135.  
  2136. TPacketGCRefineInformation p;
  2137.  
  2138. p.header = HEADER_GC_REFINE_INFORMATION;
  2139. p.pos = bCell;
  2140. p.src_vnum = item->GetVnum();
  2141. p.result_vnum = item->GetRefinedVnum();
  2142. p.type = bType;
  2143.  
  2144. if (p.result_vnum == 0)
  2145. {
  2146. sys_err("RefineInformation p.result_vnum == 0");
  2147. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  2148. return false;
  2149. }
  2150.  
  2151. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TUNING)
  2152. {
  2153. if (bType == 0)
  2154. {
  2155. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poate fi inbunatatit."));
  2156. return false;
  2157. }
  2158. else
  2159. {
  2160. LPITEM itemScroll = GetInventoryItem(iAdditionalCell);
  2161. if (!itemScroll || item->GetVnum() == itemScroll->GetVnum())
  2162. {
  2163. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
  2164. return false;
  2165. }
  2166. }
  2167. }
  2168.  
  2169. CRefineManager & rm = CRefineManager::instance();
  2170.  
  2171. const TRefineTable* prt = rm.GetRefineRecipe(item->GetRefineSet());
  2172.  
  2173. if (!prt)
  2174. {
  2175. sys_err("RefineInformation NOT GET REFINE SET %d", item->GetRefineSet());
  2176. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poate fi inbunatatit."));
  2177. return false;
  2178. }
  2179.  
  2180. // REFINE_COST
  2181.  
  2182. //MAIN_QUEST_LV7
  2183. if (GetQuestFlag("main_quest_lv7.refine_chance") > 0)
  2184. {
  2185. if (!item->CheckItemUseLevel(20) || item->GetType() != ITEM_WEAPON)
  2186. {
  2187. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Upgrade gratuit de la nivel 20"));
  2188. return false;
  2189. }
  2190. p.cost = 0;
  2191. }
  2192. else
  2193. p.cost = ComputeRefineFee(prt->cost);
  2194.  
  2195. //END_MAIN_QUEST_LV7
  2196. p.prob = prt->prob;
  2197. if (bType == REFINE_TYPE_MONEY_ONLY)
  2198. {
  2199. p.material_count = 0;
  2200. memset(p.materials, 0, sizeof(p.materials));
  2201. }
  2202. else
  2203. {
  2204. p.material_count = prt->material_count;
  2205. thecore_memcpy(&p.materials, prt->materials, sizeof(prt->materials));
  2206. }
  2207. // END_OF_REFINE_COST
  2208.  
  2209. GetDesc()->Packet(&p, sizeof(TPacketGCRefineInformation));
  2210.  
  2211. SetRefineMode(iAdditionalCell);
  2212. return true;
  2213. }
  2214.  
  2215. bool CHARACTER::RefineItem(LPITEM pkItem, LPITEM pkTarget)
  2216. {
  2217. if (!CanHandleItem())
  2218. return false;
  2219.  
  2220. if (pkItem->GetSubType() == USE_TUNING)
  2221. {
  2222. // MUSIN_SCROLL
  2223. if (pkItem->GetValue(0) == MUSIN_SCROLL)
  2224. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_MUSIN, pkItem->GetCell());
  2225. // END_OF_MUSIN_SCROLL
  2226. else if (pkItem->GetValue(0) == HYUNIRON_CHN)
  2227. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_HYUNIRON, pkItem->GetCell());
  2228. else if (pkItem->GetValue(0) == BDRAGON_SCROLL)
  2229. {
  2230. if (pkTarget->GetRefineSet() != 702) return false;
  2231. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_BDRAGON, pkItem->GetCell());
  2232. }
  2233. else
  2234. {
  2235. if (pkTarget->GetRefineSet() == 501) return false;
  2236. RefineInformation(pkTarget->GetCell(), REFINE_TYPE_SCROLL, pkItem->GetCell());
  2237. }
  2238. }
  2239. else if (pkItem->GetSubType() == USE_DETACHMENT && IS_SET(pkTarget->GetFlag(), ITEM_FLAG_REFINEABLE))
  2240. {
  2241. LogManager::instance().ItemLog(this, pkTarget, "USE_DETACHMENT", pkTarget->GetName());
  2242.  
  2243. bool bHasMetinStone = false;
  2244.  
  2245. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
  2246. {
  2247. long socket = pkTarget->GetSocket(i);
  2248. if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
  2249. {
  2250. bHasMetinStone = true;
  2251. break;
  2252. }
  2253. }
  2254.  
  2255. if (bHasMetinStone)
  2256. {
  2257. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  2258. {
  2259. long socket = pkTarget->GetSocket(i);
  2260. if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
  2261. {
  2262. AutoGiveItem(socket);
  2263.  
  2264. pkTarget->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
  2265. }
  2266. }
  2267. pkItem->SetCount(pkItem->GetCount() - 1);
  2268. return true;
  2269. }
  2270. else
  2271. {
  2272. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu exista nici-o piatra."));
  2273. return false;
  2274. }
  2275. }
  2276.  
  2277. return false;
  2278. }
  2279.  
  2280. EVENTFUNC(kill_campfire_event)
  2281. {
  2282. char_event_info* info = dynamic_cast<char_event_info*>( event->info );
  2283.  
  2284. if ( info == NULL )
  2285. {
  2286. sys_err( "kill_campfire_event> <Factor> Null pointer" );
  2287. return 0;
  2288. }
  2289.  
  2290. LPCHARACTER ch = info->ch;
  2291.  
  2292. if (ch == NULL)
  2293. { // <Factor>
  2294. return 0;
  2295. }
  2296. ch->m_pkMiningEvent = NULL;
  2297. M2_DESTROY_CHARACTER(ch);
  2298. return 0;
  2299. }
  2300.  
  2301. bool CHARACTER::GiveRecallItem(LPITEM item)
  2302. {
  2303. int idx = GetMapIndex();
  2304. int iEmpireByMapIndex = -1;
  2305.  
  2306. if (idx < 20)
  2307. iEmpireByMapIndex = 1;
  2308. else if (idx < 40)
  2309. iEmpireByMapIndex = 2;
  2310. else if (idx < 60)
  2311. iEmpireByMapIndex = 3;
  2312. else if (idx < 10000)
  2313. iEmpireByMapIndex = 0;
  2314.  
  2315. switch (idx)
  2316. {
  2317. case 66:
  2318. case 216:
  2319. iEmpireByMapIndex = -1;
  2320. break;
  2321. }
  2322.  
  2323. if (iEmpireByMapIndex && GetEmpire() != iEmpireByMapIndex)
  2324. {
  2325. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu-mi amintesc aceasta locatie"));
  2326. return false;
  2327. }
  2328.  
  2329. int pos;
  2330.  
  2331. if (item->GetCount() == 1)
  2332. {
  2333. item->SetSocket(0, GetX());
  2334. item->SetSocket(1, GetY());
  2335. }
  2336. else if ((pos = GetEmptyInventory(item->GetSize())) != -1)
  2337. {
  2338. LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), 1);
  2339.  
  2340. if (NULL != item2)
  2341. {
  2342. item2->SetSocket(0, GetX());
  2343. item2->SetSocket(1, GetY());
  2344. item2->AddToCharacter(this, TItemPos(INVENTORY, pos));
  2345.  
  2346. item->SetCount(item->GetCount() - 1);
  2347. }
  2348. }
  2349. else
  2350. {
  2351. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  2352. return false;
  2353. }
  2354.  
  2355. return true;
  2356. }
  2357.  
  2358. void CHARACTER::ProcessRecallItem(LPITEM item)
  2359. {
  2360. int idx;
  2361.  
  2362. if ((idx = SECTREE_MANAGER::instance().GetMapIndex(item->GetSocket(0), item->GetSocket(1))) == 0)
  2363. return;
  2364.  
  2365. int iEmpireByMapIndex = -1;
  2366.  
  2367. if (idx < 20)
  2368. iEmpireByMapIndex = 1;
  2369. else if (idx < 40)
  2370. iEmpireByMapIndex = 2;
  2371. else if (idx < 60)
  2372. iEmpireByMapIndex = 3;
  2373. else if (idx < 10000)
  2374. iEmpireByMapIndex = 0;
  2375.  
  2376. switch (idx)
  2377. {
  2378. case 66:
  2379. case 216:
  2380. iEmpireByMapIndex = -1;
  2381. break;
  2382.  
  2383. case 301:
  2384. case 302:
  2385. case 303:
  2386. case 304:
  2387. if( GetLevel() < 90 )
  2388. {
  2389. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul tau este prea mic."));
  2390. return;
  2391. }
  2392. else
  2393. break;
  2394. }
  2395.  
  2396. if (iEmpireByMapIndex && GetEmpire() != iEmpireByMapIndex)
  2397. {
  2398. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  2399. item->SetSocket(0, 0);
  2400. item->SetSocket(1, 0);
  2401. }
  2402. else
  2403. {
  2404. sys_log(1, "Recall: %s %d %d -> %d %d", GetName(), GetX(), GetY(), item->GetSocket(0), item->GetSocket(1));
  2405. WarpSet(item->GetSocket(0), item->GetSocket(1));
  2406. item->SetCount(item->GetCount() - 1);
  2407. }
  2408. }
  2409.  
  2410. void CHARACTER::__OpenPrivateShop()
  2411. {
  2412. unsigned bodyPart = GetPart(PART_MAIN);
  2413. switch (bodyPart)
  2414. {
  2415. case 0:
  2416. case 1:
  2417. case 2:
  2418. ChatPacket(CHAT_TYPE_COMMAND, "OpenPrivateShop");
  2419. break;
  2420. default:
  2421. ChatPacket(CHAT_TYPE_COMMAND, "OpenPrivateShop");
  2422. break;
  2423. }
  2424. }
  2425.  
  2426. // MYSHOP_PRICE_LIST
  2427. void CHARACTER::SendMyShopPriceListCmd(DWORD dwItemVnum, long long dwItemPrice)
  2428. {
  2429. char szLine[256];
  2430. snprintf(szLine, sizeof(szLine), "MyShopPriceList %u %lld", dwItemVnum, dwItemPrice);
  2431. ChatPacket(CHAT_TYPE_COMMAND, szLine);
  2432. sys_log(0, szLine);
  2433. }
  2434.  
  2435. void CHARACTER::UseSilkBotaryReal(const TPacketMyshopPricelistHeader* p)
  2436. {
  2437. const TItemPriceInfo* pInfo = (const TItemPriceInfo*)(p + 1);
  2438.  
  2439. if (!p->byCount)
  2440.  
  2441. SendMyShopPriceListCmd(1, 0);
  2442. else {
  2443. for (int idx = 0; idx < p->byCount; idx++)
  2444. SendMyShopPriceListCmd(pInfo[ idx ].dwVnum, pInfo[ idx ].dwPrice);
  2445. }
  2446.  
  2447. __OpenPrivateShop();
  2448. }
  2449.  
  2450. void CHARACTER::UseSilkBotary(void)
  2451. {
  2452. if (m_bNoOpenedShop) {
  2453. DWORD dwPlayerID = GetPlayerID();
  2454. db_clientdesc->DBPacket(HEADER_GD_MYSHOP_PRICELIST_REQ, GetDesc()->GetHandle(), &dwPlayerID, sizeof(DWORD));
  2455. m_bNoOpenedShop = false;
  2456. } else {
  2457. __OpenPrivateShop();
  2458. }
  2459. }
  2460. // END_OF_MYSHOP_PRICE_LIST
  2461.  
  2462. int CalculateConsume(LPCHARACTER ch)
  2463. {
  2464. static const int WARP_NEED_LIFE_PERCENT = 30;
  2465. static const int WARP_MIN_LIFE_PERCENT = 10;
  2466. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  2467. int consumeLife = 0;
  2468. {
  2469. // CheckNeedLifeForWarp
  2470. const int curLife = ch->GetHP();
  2471. const int needPercent = WARP_NEED_LIFE_PERCENT;
  2472. const int needLife = ch->GetMaxHP() * needPercent / 100;
  2473. if (curLife < needLife)
  2474. {
  2475. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destula viata pentru a folosi un pergament."));
  2476. return -1;
  2477. }
  2478.  
  2479. consumeLife = needLife;
  2480.  
  2481. const int minPercent = WARP_MIN_LIFE_PERCENT;
  2482. const int minLife = ch->GetMaxHP() * minPercent / 100;
  2483. if (curLife - needLife < minLife)
  2484. consumeLife = curLife - minLife;
  2485.  
  2486. if (consumeLife < 0)
  2487. consumeLife = 0;
  2488. }
  2489. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  2490. return consumeLife;
  2491. }
  2492.  
  2493. int CalculateConsumeSP(LPCHARACTER lpChar)
  2494. {
  2495. static const int NEED_WARP_SP_PERCENT = 30;
  2496.  
  2497. const int curSP = lpChar->GetSP();
  2498. const int needSP = lpChar->GetMaxSP() * NEED_WARP_SP_PERCENT / 100;
  2499.  
  2500. if (curSP < needSP)
  2501. {
  2502. lpChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destule puncte SP."));
  2503. return -1;
  2504. }
  2505.  
  2506. return needSP;
  2507. }
  2508.  
  2509. #ifdef ENABLE_YMIR_AFFECT_FIX
  2510. bool CHARACTER::CheckTimeUsed(LPITEM item)
  2511. {
  2512. switch (item->GetVnum())
  2513. {
  2514. /****************
  2515. * Type = 27 -> ITEM_BLEND (Delete the other case you do not want for check)
  2516. */
  2517. case 50821: case 50822: case 50823: case 50824: case 50825: case 50826:
  2518. case 50813: case 50814: case 50815: case 50816: case 50817: case 50818:
  2519. case 50819: case 50820: case 27866: case 27868: case 27870: case 27873:
  2520. case 39026: case 50093: case 50094: case 50123: case 50801: case 50802:
  2521. case 39010: case 39017: case 39018: case 39019: case 39020: case 39024:
  2522. case 39025: case 39031: case 71014: case 71015: case 71016: case 71017:
  2523. case 71027: case 71028: case 71029: case 71030: case 71034: case 71044:
  2524. case 71045: case 71101: case 71102: case 71153: case 71154: case 71155:
  2525. case 71156: case 72025: case 72026: case 72027: case 72031: case 72032:
  2526. case 72033: case 72034: case 72035: case 72036: case 72037: case 76018:
  2527. case 72038: case 72039: case 72040: case 72041: case 72042: case 72046:
  2528. case 72047: case 72048: case 72312: case 72313: case 72501: case 72502:
  2529.  
  2530. int pGetTime[] = {5}; // Set timer for how you need a long after you login for can use item
  2531.  
  2532. int pGetFlag = GetQuestFlag("item.last_time"); // Get questflag where him set from input_login.cpp (Not change)
  2533.  
  2534. const char* pGetMessage[] = {"|cFFd0ffcc|H|h Nu poti folosii |cFFc9ff00|H|h[%s] |cFFd0ffcc|H|h numai dupa trecerea a|cFFec03e2|H|h[%u] |cFFd0ffcc|H|h de secunde de la loginul initiat!"}; // Get message when you use time so fast
  2535.  
  2536. if (pGetFlag) // Initializate questflag on item
  2537. {
  2538. if (get_global_time() < pGetFlag + pGetTime[0]) // Initializate to get a + second for questflag
  2539. {
  2540. ChatPacket(CHAT_TYPE_INFO, pGetMessage[0], item->GetName(), pGetTime[0]); // Get message
  2541. return false; // Returns false if you use the item quicker than those seconds
  2542. }
  2543. }
  2544. break;
  2545. }
  2546. return true;
  2547. }
  2548. #endif
  2549.  
  2550. #ifdef ENABLE_NEW_AFFECT_POTION
  2551. void CHARACTER::SetAffectPotion(LPITEM item)
  2552. {
  2553. if (!item)
  2554. return;
  2555.  
  2556. int iPotionAffects[] = {AFFECT_POTION_1, AFFECT_POTION_2, AFFECT_POTION_3, AFFECT_POTION_4, AFFECT_POTION_5, AFFECT_POTION_6};
  2557. int iPotionVnums[] = {50821, 50822, 50823, 50824, 50825, 50826};
  2558.  
  2559. for (int i = 0; i < _countof(iPotionVnums); i++)
  2560. {
  2561. if (item->GetVnum() == iPotionVnums[i])
  2562. #ifdef ENABLE_DEWS_PLUS
  2563. AddAffect(iPotionAffects[i], APPLY_NONE, 0, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false, false);
  2564. #else
  2565. AddAffect(iPotionAffects[i], APPLY_NONE, 0, AFF_NONE, item->GetSocket(2), 0, false, false);
  2566. #endif
  2567. }
  2568. }
  2569.  
  2570. void CHARACTER::RemoveAffectPotion(LPITEM item)
  2571. {
  2572. if (!item)
  2573. return;
  2574.  
  2575. int iPotionAffects[] = {AFFECT_POTION_1, AFFECT_POTION_2, AFFECT_POTION_3, AFFECT_POTION_4, AFFECT_POTION_5, AFFECT_POTION_6};
  2576. int iPotionVnums[] = {50821, 50822, 50823, 50824, 50825, 50826};
  2577.  
  2578. for (int i = 0; i < _countof(iPotionVnums); i++)
  2579. {
  2580. if (item->GetVnum() == iPotionVnums[i])
  2581. RemoveAffect(iPotionAffects[i]);
  2582. }
  2583. }
  2584. #endif
  2585.  
  2586.  
  2587. bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
  2588. {
  2589. int iLimitRealtimeStartFirstUseFlagIndex = -1;
  2590. //int iLimitTimerBasedOnWearFlagIndex = -1;
  2591.  
  2592. WORD wDestCell = DestCell.cell;
  2593. BYTE bDestInven = DestCell.window_type;
  2594. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  2595. {
  2596. long limitValue = item->GetProto()->aLimits[i].lValue;
  2597.  
  2598. switch (item->GetProto()->aLimits[i].bType)
  2599. {
  2600. case LIMIT_LEVEL:
  2601. if (GetLevel() < limitValue)
  2602. {
  2603. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul tau este prea mic pentru a purta acest obiect"));
  2604. return false;
  2605. }
  2606. break;
  2607.  
  2608. case LIMIT_REAL_TIME_START_FIRST_USE:
  2609. iLimitRealtimeStartFirstUseFlagIndex = i;
  2610. break;
  2611.  
  2612. case LIMIT_TIMER_BASED_ON_WEAR:
  2613. //iLimitTimerBasedOnWearFlagIndex = i;
  2614. break;
  2615. }
  2616. }
  2617.  
  2618. if (test_server)
  2619. {
  2620. //sys_log(0, "USE_ITEM %s, Inven %d, Cell %d, ItemType %d, SubType %d", item->GetName(), bDestInven, wDestCell, item->GetType(), item->GetSubType());
  2621. }
  2622.  
  2623. if ( CArenaManager::instance().IsLimitedItem( GetMapIndex(), item->GetVnum() ) == true )
  2624. {
  2625. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  2626. return false;
  2627. }
  2628.  
  2629. // @fixme141 BEGIN
  2630. if (TItemPos(item->GetWindow(), item->GetCell()).IsBeltInventoryPosition())
  2631. {
  2632. LPITEM beltItem = GetWear(WEAR_BELT);
  2633.  
  2634. if (NULL == beltItem)
  2635. {
  2636. ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you have no equipped belt.");
  2637. return false;
  2638. }
  2639.  
  2640. if (false == CBeltInventoryHelper::IsAvailableCell(item->GetCell() - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
  2641. {
  2642. ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you don't upgrade your belt.");
  2643. return false;
  2644. }
  2645. }
  2646. // @fixme141 END
  2647.  
  2648. if (item->GetVnum() >= 80003 && item->GetVnum() <= 80008)
  2649. {
  2650. int VnumLingouri[] = {80003, 80004, 80005, 80006, 80007, 80008};
  2651. long SumaLingouri[] = {1000000, 2000000, 5000000, 10000000, 15000000, 20000000};
  2652. long long MaxiLingouri[] = {90000000000LL, 90000000000LL, 90000000000LL, 90000000000LL, 90000000000LL, 90000000000LL};
  2653.  
  2654. for (int i = 0; i < _countof(VnumLingouri); i++)
  2655. {
  2656. if (item->GetVnum() == VnumLingouri[i])
  2657. {
  2658. if (IsOpenSafebox() || GetExchange() || GetMyShop() || IsCubeOpen())
  2659. {
  2660. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti sa utilizezi un lingou cat timp negociezi."));
  2661. return false;
  2662. }
  2663. else
  2664. {
  2665. if (item->GetVnum() == VnumLingouri[i] && GetGold()>= MaxiLingouri[i])
  2666. {
  2667. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
  2668. return false;
  2669. }
  2670. if (item->GetVnum() == VnumLingouri[i+1] && GetGold()>= MaxiLingouri[i+1])
  2671. {
  2672. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
  2673. return false;
  2674. }
  2675. if (item->GetVnum() == VnumLingouri[i+2] && GetGold()>= MaxiLingouri[i+2])
  2676. {
  2677. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
  2678. return false;
  2679. }
  2680. if (item->GetVnum() == VnumLingouri[i+3] && GetGold()>= MaxiLingouri[i+3])
  2681. {
  2682. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
  2683. return false;
  2684. }
  2685. if (item->GetVnum() == VnumLingouri[i+4] && GetGold()>= MaxiLingouri[i+4])
  2686. {
  2687. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
  2688. return false;
  2689. }
  2690. if (item->GetVnum() == VnumLingouri[i+5] && GetGold()>= MaxiLingouri[i+5])
  2691. {
  2692. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
  2693. return false;
  2694. }
  2695. else
  2696. {
  2697. item->SetCount(item->GetCount() - 1);
  2698. PointChange(POINT_GOLD, SumaLingouri[i], true);
  2699. return true;
  2700. }
  2701. }
  2702. }
  2703. }
  2704. return false;
  2705. }
  2706. #ifdef NEW_PET_SYSTEM
  2707. if (item->GetVnum() == 55001)
  2708. {
  2709.  
  2710. LPITEM item2;
  2711.  
  2712. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  2713. return false;
  2714.  
  2715. if (item2->IsExchanging())
  2716. return false;
  2717.  
  2718. if (item2->GetVnum() >= 55718 || item2->GetVnum() < 55701)
  2719. return false;
  2720.  
  2721.  
  2722. char szQuery1[1024];
  2723. snprintf(szQuery1, sizeof(szQuery1), "SELECT duration FROM new_petsystem WHERE id = %lu LIMIT 1", item2->GetID());
  2724. std::unique_ptr<SQLMsg> pmsg2(DBManager::instance().DirectQuery(szQuery1));
  2725. if (pmsg2->Get()->uiNumRows > 0)
  2726. {
  2727. MYSQL_ROW row = mysql_fetch_row(pmsg2->Get()->pSQLResult);
  2728. if (atoi(row[0]) > 0)
  2729. {
  2730. if (GetNewPetSystem()->IsActivePet())
  2731. {
  2732. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to unsummon your pet first."));
  2733. return false;
  2734. }
  2735.  
  2736. DBManager::instance().DirectQuery("UPDATE new_petsystem SET duration =(tduration) WHERE id = %d", item2->GetID());
  2737. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Your Pet's life is now full."));
  2738. }
  2739. else
  2740. {
  2741. DBManager::instance().DirectQuery("UPDATE new_petsystem SET duration =(tduration/2) WHERE id = %d", item2->GetID());
  2742. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Your Pet's life is now restored."));
  2743. }
  2744. item->SetCount(item->GetCount() - 1);
  2745. return true;
  2746. }
  2747. else
  2748. return false;
  2749. }
  2750.  
  2751. if (item->GetVnum() >= 55701 && item->GetVnum() <= 55718)
  2752. {
  2753. LPITEM item2;
  2754.  
  2755. if (item2 = GetItem(DestCell))
  2756. {
  2757. if (item2->GetVnum() == 55002)
  2758. {
  2759. if(item2->GetAttributeValue(0) > 0)
  2760. {
  2761. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cutia are deja un animalut inauntru."));
  2762. }
  2763. else if (item->GetAttributeValue(3) == 0)
  2764. {
  2765. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Scoate animalutul din ou mai intai!"));
  2766. return false;
  2767. }
  2768. else
  2769. {
  2770. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  2771. return false;
  2772.  
  2773. if (item2->IsExchanging())
  2774. return false;
  2775.  
  2776. if (GetNewPetSystem()->IsActivePet())
  2777. {
  2778. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to unsummon your pet first."));
  2779. return false;
  2780. }
  2781.  
  2782. for (int b = 0; b < 3; b++)
  2783. {
  2784. item2->SetForceAttribute(b, 1, item->GetAttributeValue(b));
  2785. }
  2786.  
  2787. item2->SetForceAttribute(3, 1, item->GetAttributeValue(3));
  2788. item2->SetForceAttribute(4, 1, item->GetAttributeValue(4));
  2789. //Pet Yas Bugu Fixi//
  2790. //item2->SetForceAttribute(5, 1, item->GetAttributeValue(5));
  2791. //Pet Yas Bugu Fixi//
  2792. DWORD vnum1 = item->GetVnum()-55700;
  2793. item2->SetSocket(2, vnum1);
  2794. item2->SetSocket(1, item->GetSocket(1));
  2795. //ChatPacket(CHAT_TYPE_INFO, "Pet %d %d %d //// %d %d %d",item->GetAttributeValue(0),item->GetAttributeValue(1),item->GetAttributeValue(2),item2->GetAttributeValue(0),item2->GetAttributeValue(1),item2->GetAttributeValue(2));
  2796. DBManager::instance().DirectQuery("UPDATE new_petsystem SET id =%d WHERE id = %d", item2->GetID(), item->GetID());
  2797. ITEM_MANAGER::instance().RemoveItem(item);
  2798. return true;
  2799. }
  2800. }
  2801. }
  2802. }
  2803.  
  2804. if (item->GetVnum() == 55009)
  2805. {
  2806. int number1461 = number(55010,55027);
  2807. AutoGiveItem(number1461);
  2808. item->SetCount(item->GetCount() - 1);
  2809. }
  2810. if (-1 != iLimitRealtimeStartFirstUseFlagIndex)
  2811. {
  2812. if (0 == item->GetSocket(1))
  2813. {
  2814. long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[iLimitRealtimeStartFirstUseFlagIndex].lValue;
  2815.  
  2816. if (0 == duration)
  2817. duration = 60 * 60 * 24 * 7;
  2818.  
  2819. item->SetSocket(0, time(0) + duration);
  2820. item->StartRealTimeExpireEvent();
  2821. }
  2822.  
  2823. if (false == item->IsEquipped())
  2824. item->SetSocket(1, item->GetSocket(1) + 1);
  2825. }
  2826.  
  2827. if (item->GetVnum() == 55002 && item->GetAttributeValue(0) > 0)
  2828. {
  2829.  
  2830. int pos = GetEmptyInventory(item->GetSize());
  2831. if(pos == -1)
  2832. {
  2833. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destul spatiu in inventar!"));
  2834. return false;
  2835. }
  2836.  
  2837. if (GetLevel() < item->GetSocket(1))
  2838. {
  2839. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul animalutului mai mare decat nivelul tau"));
  2840. return false;
  2841. }
  2842.  
  2843. if (item->IsExchanging())
  2844. return false;
  2845. DWORD vnum2 = 55700+item->GetSocket(2);
  2846. LPITEM item2 = AutoGiveItem(vnum2, 1);
  2847. for (int b = 0; b < 3; b++)
  2848. {
  2849. item2->SetForceAttribute(b, 1, item->GetAttributeValue(b));
  2850. }
  2851. item2->SetForceAttribute(3, 1, item->GetAttributeValue(3));
  2852. item2->SetForceAttribute(4, 1, item->GetAttributeValue(4));
  2853. //Pet Yas Bugu Fixi//
  2854. //item2->SetForceAttribute(5, 1, item->GetAttributeValue(5));
  2855. //Pet Yas Bugu Fixi//
  2856. item2->SetSocket(1,item->GetSocket(1));
  2857. //ChatPacket(CHAT_TYPE_INFO, "Pet1 %d %d %d",item->GetAttributeValue(0),item->GetAttributeValue(1),item->GetAttributeValue(2));
  2858. DBManager::instance().DirectQuery("UPDATE new_petsystem SET id =%d WHERE id = %d", item2->GetID(), item->GetID());
  2859. ITEM_MANAGER::instance().RemoveItem(item);
  2860. return true;
  2861.  
  2862. }
  2863. #endif
  2864.  
  2865. #ifdef __BATTLE_PASS__
  2866. if (!v_counts.empty())
  2867. {
  2868. for (int i=0; i<missions_bp.size(); ++i)
  2869. {
  2870. if (missions_bp[i].type == 1 && item->GetVnum() == missions_bp[i].vnum)
  2871. {
  2872. DoMission(i, 1);
  2873. }
  2874. }
  2875. }
  2876. #endif
  2877.  
  2878. switch (item->GetType())
  2879. {
  2880. case ITEM_HAIR:
  2881. return ItemProcess_Hair(item, wDestCell);
  2882.  
  2883. case ITEM_POLYMORPH:
  2884. return ItemProcess_Polymorph(item);
  2885.  
  2886. case ITEM_QUEST:
  2887. if (GetArena() != NULL || IsObserverMode() == true)
  2888. {
  2889. if (item->GetVnum() == 50051 || item->GetVnum() == 50052 || item->GetVnum() == 50053)
  2890. {
  2891. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  2892. return false;
  2893. }
  2894. }
  2895.  
  2896. if (!IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE | ITEM_FLAG_QUEST_USE_MULTIPLE))
  2897. {
  2898. if (item->GetSIGVnum() == 0)
  2899. {
  2900. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  2901. }
  2902. else
  2903. {
  2904. quest::CQuestManager::instance().SIGUse(GetPlayerID(), item->GetSIGVnum(), item, false);
  2905. }
  2906. }
  2907. break;
  2908.  
  2909. case ITEM_CAMPFIRE:
  2910. {
  2911. float fx, fy;
  2912. GetDeltaByDegree(GetRotation(), 100.0f, &fx, &fy);
  2913.  
  2914. LPSECTREE tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy));
  2915.  
  2916. if (!tree)
  2917. {
  2918. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("No fire."));
  2919. return false;
  2920. }
  2921.  
  2922. if (tree->IsAttr((long)(GetX()+fx), (long)(GetY()+fy), ATTR_WATER))
  2923. {
  2924. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("No fire."));
  2925. return false;
  2926. }
  2927.  
  2928. LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy), 0, false, number(0, 359));
  2929.  
  2930. char_event_info* info = AllocEventInfo<char_event_info>();
  2931.  
  2932. info->ch = campfire;
  2933.  
  2934. campfire->m_pkMiningEvent = event_create(kill_campfire_event, info, PASSES_PER_SEC(40));
  2935.  
  2936. item->SetCount(item->GetCount() - 1);
  2937. }
  2938. break;
  2939.  
  2940. case ITEM_UNIQUE:
  2941. {
  2942. switch (item->GetSubType())
  2943. {
  2944. case USE_ABILITY_UP:
  2945. {
  2946. switch (item->GetValue(0))
  2947. {
  2948. case APPLY_MOV_SPEED:
  2949. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true, true);
  2950. EffectPacket(SE_DXUP_PURPLE); //purple potion
  2951. break;
  2952.  
  2953. case APPLY_ATT_SPEED:
  2954. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true, true);
  2955. EffectPacket(SE_SPEEDUP_GREEN); //green potion
  2956. break;
  2957.  
  2958. case APPLY_STR:
  2959. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ST, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2960. break;
  2961.  
  2962. case APPLY_DEX:
  2963. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_DX, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2964. break;
  2965.  
  2966. case APPLY_CON:
  2967. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_HT, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2968. break;
  2969.  
  2970. case APPLY_INT:
  2971. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_IQ, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2972. break;
  2973.  
  2974. case APPLY_CAST_SPEED:
  2975. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_CASTING_SPEED, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2976. break;
  2977.  
  2978. case APPLY_RESIST_MAGIC:
  2979. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_RESIST_MAGIC, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2980. break;
  2981.  
  2982. case APPLY_ATT_GRADE_BONUS:
  2983. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_GRADE_BONUS,
  2984. item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2985. break;
  2986.  
  2987. case APPLY_DEF_GRADE_BONUS:
  2988. AddAffect(AFFECT_UNIQUE_ABILITY, POINT_DEF_GRADE_BONUS,
  2989. item->GetValue(2), 0, item->GetValue(1), 0, true, true);
  2990. break;
  2991. }
  2992. }
  2993.  
  2994. if (GetDungeon())
  2995. GetDungeon()->UsePotion(this);
  2996.  
  2997. if (GetWarMap())
  2998. GetWarMap()->UsePotion(this, item);
  2999.  
  3000. item->SetCount(item->GetCount() - 1);
  3001. break;
  3002.  
  3003. default:
  3004. {
  3005. if (item->GetSubType() == USE_SPECIAL)
  3006. {
  3007. sys_log(0, "ITEM_UNIQUE: USE_SPECIAL %u", item->GetVnum());
  3008.  
  3009. switch (item->GetVnum())
  3010. {
  3011. case 71049:
  3012. if (LC_IsYMIR() == true || LC_IsKorea() == true)
  3013. {
  3014. if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
  3015. {
  3016. UseSilkBotary();
  3017. }
  3018. else
  3019. {
  3020. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SHOP_OX_ERROR"));
  3021. }
  3022. }
  3023. else
  3024. {
  3025. UseSilkBotary();
  3026. }
  3027. break;
  3028. }
  3029. }
  3030. else
  3031. {
  3032. if (!item->IsEquipped())
  3033. EquipItem(item);
  3034. else
  3035. UnequipItem(item);
  3036. }
  3037. }
  3038. break;
  3039. }
  3040. }
  3041. break;
  3042.  
  3043. case ITEM_COSTUME:
  3044. case ITEM_WEAPON:
  3045. case ITEM_ARMOR:
  3046. case ITEM_ROD:
  3047. case ITEM_RING: // ½Å±Ô ¹ÝÁö ¾ÆÀÌÅÛ
  3048. case ITEM_BELT: // ½Å±Ô º§Æ® ¾ÆÀÌÅÛ
  3049. #ifdef ENABLE_PET_SLOT
  3050. case ITEM_NORMAL_PET:
  3051. #endif
  3052. // MINING
  3053. case ITEM_PICK:
  3054. // END_OF_MINING
  3055. if (!item->IsEquipped())
  3056. EquipItem(item);
  3057. else
  3058. UnequipItem(item);
  3059. break;
  3060.  
  3061. case ITEM_DS:
  3062. {
  3063. if (!item->IsEquipped())
  3064. return false;
  3065. return DSManager::instance().PullOut(this, NPOS, item);
  3066. break;
  3067. }
  3068. case ITEM_SPECIAL_DS:
  3069. if (!item->IsEquipped())
  3070. EquipItem(item);
  3071. else
  3072. UnequipItem(item);
  3073. break;
  3074.  
  3075. case ITEM_FISH:
  3076. {
  3077. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  3078. {
  3079. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  3080. return false;
  3081. }
  3082.  
  3083. if (item->GetSubType() == FISH_ALIVE)
  3084. fishing::UseFish(this, item);
  3085. }
  3086. break;
  3087.  
  3088. case ITEM_TREASURE_BOX:
  3089. {
  3090. return false;
  3091. //ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("¿­¼è·Î Àá°Ü À־ ¿­¸®Áö ¾Ê´Â°Í °°´Ù. ¿­¼è¸¦ ±¸Çغ¸ÀÚ."));
  3092. }
  3093. break;
  3094.  
  3095. case ITEM_TREASURE_KEY:
  3096. {
  3097. LPITEM item2;
  3098.  
  3099. if (!GetItem(DestCell) || !(item2 = GetItem(DestCell)))
  3100. return false;
  3101.  
  3102. if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
  3103. return false;
  3104.  
  3105. if (item2->GetType() != ITEM_TREASURE_BOX)
  3106. {
  3107. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("No_Key."));
  3108. return false;
  3109. }
  3110.  
  3111. if (item->GetValue(0) == item2->GetValue(0))
  3112. {
  3113. DWORD dwBoxVnum = item2->GetVnum();
  3114. std::vector <DWORD> dwVnums;
  3115. std::vector <DWORD> dwCounts;
  3116. std::vector <LPITEM> item_gets(0);
  3117. int count = 0;
  3118.  
  3119. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  3120. {
  3121. ITEM_MANAGER::instance().RemoveItem(item);
  3122. ITEM_MANAGER::instance().RemoveItem(item2);
  3123.  
  3124. for (int i = 0; i < count; i++){
  3125. switch (dwVnums[i])
  3126. {
  3127. case CSpecialItemGroup::GOLD:
  3128. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
  3129. break;
  3130. case CSpecialItemGroup::EXP:
  3131. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ºÎÅÍ ½ÅºñÇÑ ºûÀÌ ³ª¿É´Ï´Ù."));
  3132. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÀÇ °æÇèÄ¡¸¦ ȹµæÇß½À´Ï´Ù."), dwCounts[i]);
  3133. break;
  3134. case CSpecialItemGroup::MOB:
  3135. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
  3136. break;
  3137. case CSpecialItemGroup::SLOW:
  3138. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ³ª¿Â »¡°£ ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ ¿òÁ÷ÀÌ´Â ¼Óµµ°¡ ´À·ÁÁ³½À´Ï´Ù!"));
  3139. break;
  3140. case CSpecialItemGroup::DRAIN_HP:
  3141. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ°¡ °©ÀÚ±â Æø¹ßÇÏ¿´½À´Ï´Ù! »ý¸í·ÂÀÌ °¨¼ÒÇß½À´Ï´Ù."));
  3142. break;
  3143. case CSpecialItemGroup::POISON:
  3144. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ³ª¿Â ³ì»ö ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ µ¶ÀÌ ¿Â¸öÀ¸·Î ÆÛÁý´Ï´Ù!"));
  3145. break;
  3146. case CSpecialItemGroup::MOB_GROUP:
  3147. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
  3148. break;
  3149. default:
  3150. if (item_gets[i])
  3151. {
  3152. if (dwCounts[i] > 1)
  3153. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s - %d x."), item_gets[i]->GetName(), dwCounts[i]);
  3154. else
  3155. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s."), item_gets[i]->GetName());
  3156.  
  3157. }
  3158. }
  3159. }
  3160. }
  3161. else
  3162. {
  3163. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("No_Key."));
  3164. return false;
  3165. }
  3166. }
  3167. else
  3168. {
  3169. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("No_Key."));
  3170. return false;
  3171. }
  3172. }
  3173. break;
  3174.  
  3175. case ITEM_GIFTBOX:
  3176. {
  3177. DWORD dwBoxVnum = item->GetVnum();
  3178. std::vector <DWORD> dwVnums;
  3179. std::vector <DWORD> dwCounts;
  3180. std::vector <LPITEM> item_gets(NULL);
  3181. int count = 0;
  3182.  
  3183. if (dwBoxVnum == 50033 && LC_IsYMIR())
  3184. {
  3185. if (GetLevel() < 15)
  3186. {
  3187. ChatPacket(CHAT_TYPE_INFO, "Nu poate fi utilizat sub nivelul 15.");
  3188. return false;
  3189. }
  3190. }
  3191.  
  3192. if( (dwBoxVnum > 51500 && dwBoxVnum < 52000) || (dwBoxVnum >= 50255 && dwBoxVnum <= 50260) ) // ¿ëÈ¥¿ø¼®µé
  3193. {
  3194. if( !(this->DragonSoul_IsQualified()) )
  3195. {
  3196. ChatPacket(CHAT_TYPE_INFO,LC_TEXT("Finish_Dragon_Soul."));
  3197. return false;
  3198. }
  3199. }
  3200.  
  3201. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  3202. {
  3203. item->SetCount(item->GetCount()-1);
  3204.  
  3205. for (int i = 0; i < count; i++){
  3206. switch (dwVnums[i])
  3207. {
  3208. case CSpecialItemGroup::GOLD:
  3209. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
  3210. break;
  3211. case CSpecialItemGroup::EXP:
  3212. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ºÎÅÍ ½ÅºñÇÑ ºûÀÌ ³ª¿É´Ï´Ù."));
  3213. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÀÇ °æÇèÄ¡¸¦ ȹµæÇß½À´Ï´Ù."), dwCounts[i]);
  3214. break;
  3215. case CSpecialItemGroup::MOB:
  3216. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
  3217. break;
  3218. case CSpecialItemGroup::SLOW:
  3219. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ³ª¿Â »¡°£ ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ ¿òÁ÷ÀÌ´Â ¼Óµµ°¡ ´À·ÁÁ³½À´Ï´Ù!"));
  3220. break;
  3221. case CSpecialItemGroup::DRAIN_HP:
  3222. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ°¡ °©ÀÚ±â Æø¹ßÇÏ¿´½À´Ï´Ù! »ý¸í·ÂÀÌ °¨¼ÒÇß½À´Ï´Ù."));
  3223. break;
  3224. case CSpecialItemGroup::POISON:
  3225. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ³ª¿Â ³ì»ö ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ µ¶ÀÌ ¿Â¸öÀ¸·Î ÆÛÁý´Ï´Ù!"));
  3226. break;
  3227. case CSpecialItemGroup::MOB_GROUP:
  3228. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
  3229. break;
  3230. default:
  3231. if (item_gets[i])
  3232. {
  3233. if (dwCounts[i] > 1)
  3234. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s - %d x."), item_gets[i]->GetName(), dwCounts[i]);
  3235. else
  3236. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s."), item_gets[i]->GetName());
  3237. }
  3238. }
  3239. }
  3240. }
  3241. else
  3242. {
  3243. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Nu am putut obtine nimic."));
  3244. return false;
  3245. }
  3246. }
  3247. break;
  3248.  
  3249.  
  3250. case ITEM_SKILLFORGET:
  3251. {
  3252. if (!item->GetSocket(0))
  3253. {
  3254. item->SetCount(item->GetCount() - 1);
  3255. return false;
  3256. }
  3257.  
  3258. DWORD dwVnum = item->GetSocket(0);
  3259.  
  3260. if (SkillLevelDown(dwVnum))
  3261. {
  3262. item->SetCount(item->GetCount() - 1);
  3263. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ati reusit sa va reduceti nivelul de calificare"));
  3264. }
  3265. else
  3266. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu va puteti reduce nivelul de calificare."));
  3267. }
  3268. break;
  3269.  
  3270. case ITEM_SKILLBOOK:
  3271. {
  3272. if (IsPolymorphed())
  3273. {
  3274. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  3275. return false;
  3276. }
  3277.  
  3278. DWORD dwVnum = 0;
  3279.  
  3280. if (item->GetVnum() == 50300)
  3281. {
  3282. dwVnum = item->GetSocket(0);
  3283. }
  3284. else
  3285. {
  3286. dwVnum = item->GetValue(0);
  3287. }
  3288.  
  3289. if (0 == dwVnum)
  3290. {
  3291. item->SetCount(item->GetCount() - 1);
  3292.  
  3293. return false;
  3294. }
  3295.  
  3296. if (true == LearnSkillByBook(dwVnum))
  3297. {
  3298. #ifdef LEARN_BOOK_FIX
  3299. item->SetCount(item->GetCount() - 1);
  3300. #endif
  3301.  
  3302.  
  3303. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  3304.  
  3305. if (distribution_test_server)
  3306. iReadDelay /= 3;
  3307.  
  3308. if (LC_IsKorea())
  3309. iReadDelay = 86400;
  3310.  
  3311. SetSkillNextReadTime(dwVnum, get_global_time() + iReadDelay);
  3312. }
  3313. }
  3314. break;
  3315.  
  3316. case ITEM_USE:
  3317. {
  3318. switch (item->GetVnum())
  3319. {
  3320. case 40496:
  3321. {
  3322. if (GetLevel() > 4 && GetLevel() < 71)
  3323. {
  3324. {
  3325. if (GetLevel() >= 5 && GetLevel() <=20)
  3326. {
  3327. const static DWORD cufar_armuri[12] = { 11207, 11217, 11227, 11407, 11417, 11427, 11607, 11617, 11627, 11807, 11817, 11827 };
  3328. DWORD dwVnum = cufar_armuri[number(0, 11)];
  3329. AutoGiveItem(dwVnum);
  3330. }
  3331. if (GetLevel() >= 21 && GetLevel() <=45)
  3332. {
  3333. const static DWORD cufar_armuri[12] = { 11237, 11247, 11257, 11437, 11447, 11457, 11637, 11647, 11657, 11837, 11847, 11857 };
  3334. DWORD dwVnum = cufar_armuri[number(0, 11)];
  3335. AutoGiveItem(dwVnum);
  3336. }
  3337. if (GetLevel() >= 46 && GetLevel() <=70)
  3338. {
  3339. const static DWORD cufar_armuri[16] = { 11267, 11277, 11287, 11467, 11477, 11487, 11667, 11677, 11687, 11867, 11877, 11887, 11297, 11497, 11697, 11897 };
  3340. DWORD dwVnum = cufar_armuri[number(0, 15)];
  3341. AutoGiveItem(dwVnum);
  3342. }
  3343. }
  3344. }
  3345. else
  3346. {
  3347. ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-70).");
  3348. return false;
  3349. }
  3350. }
  3351. break;
  3352. case 40495:
  3353. {
  3354. if (GetLevel() > 4 && GetLevel() < 71)
  3355. {
  3356. {
  3357. if (GetLevel() >= 5 && GetLevel() <=20)
  3358. {
  3359. const static DWORD cufar_arme[27] = { 17, 27, 37, 47, 57, 1007, 1107, 1027, 2017, 2027, 2037, 2047, 3007, 3017, 3027, 3037, 3047, 4007, 4017, 5007, 5017, 5027, 7007, 7017, 7027, 7037, 7047 };
  3360. DWORD dwVnum = cufar_arme[number(0, 26)];
  3361. AutoGiveItem(dwVnum);
  3362. }
  3363. if (GetLevel() >= 21 && GetLevel() <=45)
  3364. {
  3365. const static DWORD cufar_arme[26] = { 67, 77, 87, 97, 1037, 1047, 1057, 1067, 2057, 2067, 2077, 2087, 2097, 3057, 3067, 3077, 3087, 3097, 5027, 5037, 5047, 5057, 7057, 7067, 7077, 7087 };
  3366. DWORD dwVnum = cufar_arme[number(0, 25)];
  3367. AutoGiveItem(dwVnum);
  3368. }
  3369. if (GetLevel() >= 46 && GetLevel() <=70)
  3370. {
  3371. const static DWORD cufar_arme[32] = { 117, 127, 137, 1077, 1087, 1097, 2107, 2117, 2127, 3107, 3127, 5067, 5077, 5087, 7097, 7107, 7117, 7127, 145, 3135, 155, 167, 247, 1105, 1117, 2145, 2137, 3147, 5097, 5105, 7137, 7145 };
  3372. DWORD dwVnum = cufar_arme[number(0, 31)];
  3373. AutoGiveItem(dwVnum);
  3374. }
  3375. }
  3376. }
  3377. else
  3378. {
  3379. ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-70).");
  3380. return false;
  3381. }
  3382. }
  3383. break;
  3384. case 50183:
  3385. {
  3386. if (GetLevel() > 4 && GetLevel() < 127)
  3387. {
  3388. {
  3389. if (GetLevel() >= 5 && GetLevel() <=60)
  3390. {
  3391. const static DWORD cufar_carti[10] = { 50300, 50300, 50300, 50300, 50300, 50300, 50300, 50513, 40480, 40480 };
  3392. DWORD dwVnum = cufar_carti[number(0, 9)];
  3393. AutoGiveItem(dwVnum);
  3394. item->SetCount(item->GetCount() - 1);
  3395. }
  3396. if (GetLevel() >= 61 && GetLevel() <=127)
  3397. {
  3398. const static DWORD cufar_carti[9] = { 50300, 50300, 50300, 50300, 50513, 50513, 40480, 40480, 40480 };
  3399. DWORD dwVnum = cufar_carti[number(0, 8)];
  3400. AutoGiveItem(dwVnum);
  3401. item->SetCount(item->GetCount() - 1);
  3402. }
  3403. }
  3404. }
  3405. else
  3406. {
  3407. ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-127).");
  3408. return false;
  3409. }
  3410. }
  3411. break;
  3412. case 50182:
  3413. {
  3414. if (GetLevel() > 4 && GetLevel() < 127)
  3415. {
  3416. {
  3417. if (GetLevel() >= 5 && GetLevel() <=40)
  3418. {
  3419. const static DWORD cufar_pietre[14] = { 28330, 28331, 28332, 28333, 28334, 28335, 28336, 28337, 28338, 28339, 28340, 28341, 28342, 28343 };
  3420. DWORD dwVnum = cufar_pietre[number(0, 13)];
  3421. AutoGiveItem(dwVnum);
  3422. }
  3423. if (GetLevel() >= 41 && GetLevel() <=127)
  3424. {
  3425. const static DWORD cufar_pietre[14] = { 28430, 28431, 28432, 28433, 28434, 28435, 28436, 28437, 28438, 28439, 28440, 28441, 28442, 28443 };
  3426. DWORD dwVnum = cufar_pietre[number(0, 13)];
  3427. AutoGiveItem(dwVnum);
  3428. }
  3429. }
  3430. }
  3431. else
  3432. {
  3433. ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-127).");
  3434. return false;
  3435. }
  3436. }
  3437. break;
  3438. case 70016:
  3439. {
  3440. if (GetLevel() > 30 && GetLevel() < 127)
  3441. {
  3442. {
  3443. if (GetLevel() >= 30 && GetLevel() <=200)
  3444. {
  3445. const static DWORD cufar_carti_pet[3] = { 55003, 55004, 55005 };
  3446. DWORD dwVnum = cufar_carti_pet[number(0, 2)];
  3447. AutoGiveItem(dwVnum);
  3448. item->SetCount(item->GetCount() - 1);
  3449. }
  3450. }
  3451. }
  3452. else
  3453. {
  3454. ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 30-200).");
  3455. return false;
  3456. }
  3457. }
  3458. break;
  3459. }
  3460. if (item->GetVnum() > 50800 && item->GetVnum() <= 50820)
  3461. {
  3462. if (test_server)
  3463. sys_log (0, "ADD addtional effect : vnum(%d) subtype(%d)", item->GetOriginalVnum(), item->GetSubType());
  3464.  
  3465. int affect_type = AFFECT_EXP_BONUS_EURO_FREE;
  3466. int apply_type = aApplyInfo[item->GetValue(0)].bPointType;
  3467. int apply_value = item->GetValue(2);
  3468. int apply_duration = item->GetValue(1);
  3469.  
  3470. switch (item->GetSubType())
  3471. {
  3472. case USE_ABILITY_UP:
  3473. if (FindAffect(affect_type, apply_type))
  3474. {
  3475. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
  3476. return false;
  3477. }
  3478.  
  3479. {
  3480. switch (item->GetValue(0))
  3481. {
  3482. case APPLY_MOV_SPEED:
  3483. AddAffect(affect_type, apply_type, apply_value, AFF_MOV_SPEED_POTION, apply_duration, 0, true, true);
  3484. EffectPacket(SE_DXUP_PURPLE); //purple potion
  3485. break;
  3486.  
  3487. case APPLY_ATT_SPEED:
  3488. AddAffect(affect_type, apply_type, apply_value, AFF_ATT_SPEED_POTION, apply_duration, 0, true, true);
  3489. EffectPacket(SE_SPEEDUP_GREEN); //green potion
  3490. break;
  3491.  
  3492. case APPLY_STR:
  3493. case APPLY_DEX:
  3494. case APPLY_CON:
  3495. case APPLY_INT:
  3496. case APPLY_CAST_SPEED:
  3497. case APPLY_RESIST_MAGIC:
  3498. case APPLY_ATT_GRADE_BONUS:
  3499. case APPLY_DEF_GRADE_BONUS:
  3500. AddAffect(affect_type, apply_type, apply_value, 0, apply_duration, 0, true, true);
  3501. break;
  3502. }
  3503. }
  3504.  
  3505. if (GetDungeon())
  3506. GetDungeon()->UsePotion(this);
  3507.  
  3508. if (GetWarMap())
  3509. GetWarMap()->UsePotion(this, item);
  3510.  
  3511. #ifdef LEARN_BOOK_FIX
  3512. item->SetCount(item->GetCount() - 1);
  3513. #endif
  3514. break;
  3515.  
  3516. #ifdef ENABLE_AFFECT_ITEMS_PLUS
  3517. case USE_AFFECT :
  3518. {
  3519. #ifdef ENABLE_YMIR_AFFECT_FIX
  3520. if ((CheckTimeUsed(item) == false)) { return false; }
  3521. #endif
  3522. int affect_type = item->GetValue(0);
  3523. int apply_type = aApplyInfo[item->GetValue(1)].bPointType;
  3524. int apply_value = item->GetValue(2);
  3525. int affect_state_socket = 0;
  3526.  
  3527. CAffect* pAffect = FindAffect(affect_type, apply_type);
  3528.  
  3529. if (pAffect == NULL)
  3530. {
  3531. AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
  3532. item->SetSocket(affect_state_socket, 1);
  3533. item->Lock(true);
  3534. }
  3535. else
  3536. {
  3537. if (item->GetID() == pAffect->dwFlag)
  3538. {
  3539. RemoveAffect( pAffect );
  3540. item->Lock(false);
  3541. item->SetSocket(affect_state_socket, 0);
  3542. }
  3543. else
  3544. {
  3545. LPITEM old = FindItemByID( pAffect->dwFlag );
  3546. if (NULL != old)
  3547. {
  3548. old->Lock(false);
  3549. old->SetSocket(affect_state_socket, 0);
  3550. }
  3551.  
  3552. RemoveAffect(pAffect);
  3553.  
  3554. AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
  3555. item->SetSocket(affect_state_socket, 1);
  3556. item->Lock(true);
  3557. }
  3558. }
  3559. }
  3560. break;
  3561. #else
  3562. case USE_AFFECT :
  3563. {
  3564. if (FindAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType))
  3565. {
  3566. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
  3567. }
  3568. else
  3569. {
  3570. // PC_BANG_ITEM_ADD
  3571. if (item->IsPCBangItem() == true)
  3572. {
  3573. if (CPCBangManager::instance().IsPCBangIP(GetDesc()->GetHostName()) == false)
  3574. {
  3575. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This book can be found at low levels of metin."));
  3576. return false;
  3577. }
  3578. }
  3579. // END_PC_BANG_ITEM_ADD
  3580.  
  3581. AddAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType, item->GetValue(2), 0, item->GetValue(3), 0, false);
  3582. item->SetCount(item->GetCount() - 1);
  3583.  
  3584. }
  3585. }
  3586. break;
  3587. #endif
  3588.  
  3589. case USE_POTION_NODELAY:
  3590. {
  3591. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  3592. {
  3593. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
  3594. {
  3595. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Can not be used in battle sides"));
  3596. return false;
  3597. }
  3598.  
  3599. switch (item->GetVnum())
  3600. {
  3601. case 70020 :
  3602. case 71018 :
  3603. case 71019 :
  3604. case 71020 :
  3605. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
  3606. {
  3607. if (m_nPotionLimit <= 0)
  3608. {
  3609. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi licori în arena luptelor. "));
  3610. return false;
  3611. }
  3612. }
  3613. break;
  3614.  
  3615. default :
  3616. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  3617. return false;
  3618. break;
  3619. }
  3620. }
  3621.  
  3622. bool used = false;
  3623.  
  3624. if (item->GetValue(0) != 0) // HP
  3625. {
  3626. if (GetHP() < GetMaxHP())
  3627. {
  3628. PointChange(POINT_HP, item->GetValue(0) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  3629. EffectPacket(SE_HPUP_RED);
  3630. used = TRUE;
  3631. }
  3632. }
  3633.  
  3634. if (item->GetValue(1) != 0) // SP
  3635. {
  3636. if (GetSP() < GetMaxSP())
  3637. {
  3638. PointChange(POINT_SP, item->GetValue(1) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  3639. EffectPacket(SE_SPUP_BLUE);
  3640. used = TRUE;
  3641. }
  3642. }
  3643.  
  3644. if (item->GetValue(3) != 0) // HP %
  3645. {
  3646. if (GetHP() < GetMaxHP())
  3647. {
  3648. PointChange(POINT_HP, item->GetValue(3) * GetMaxHP() / 100);
  3649. EffectPacket(SE_HPUP_RED);
  3650. used = TRUE;
  3651. }
  3652. }
  3653.  
  3654. if (item->GetValue(4) != 0) // SP %
  3655. {
  3656. if (GetSP() < GetMaxSP())
  3657. {
  3658. PointChange(POINT_SP, item->GetValue(4) * GetMaxSP() / 100);
  3659. EffectPacket(SE_SPUP_BLUE);
  3660. used = TRUE;
  3661. }
  3662. }
  3663.  
  3664. if (used)
  3665. {
  3666. if (item->GetVnum() == 50085 || item->GetVnum() == 50086)
  3667. {
  3668. if (test_server)
  3669. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("All items were used"));
  3670. SetUseSeedOrMoonBottleTime();
  3671. }
  3672. if (GetDungeon())
  3673. GetDungeon()->UsePotion(this);
  3674.  
  3675. if (GetWarMap())
  3676. GetWarMap()->UsePotion(this, item);
  3677.  
  3678. m_nPotionLimit--;
  3679.  
  3680. //RESTRICT_USE_SEED_OR_MOONBOTTLE
  3681. item->SetCount(item->GetCount() - 1);
  3682. //END_RESTRICT_USE_SEED_OR_MOONBOTTLE
  3683. }
  3684. }
  3685. break;
  3686. }
  3687.  
  3688. return true;
  3689. }
  3690.  
  3691.  
  3692. if (item->GetVnum() >= 27863 && item->GetVnum() <= 27883)
  3693. {
  3694. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  3695. {
  3696. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  3697. return false;
  3698. }
  3699. }
  3700.  
  3701. if (test_server)
  3702. {
  3703. //sys_log (0, "USE_ITEM %s Type %d SubType %d vnum %d", item->GetName(), item->GetType(), item->GetSubType(), item->GetOriginalVnum());
  3704. }
  3705.  
  3706. switch (item->GetSubType())
  3707. {
  3708. case USE_TIME_CHARGE_PER:
  3709. {
  3710. LPITEM pDestItem = GetItem(DestCell);
  3711. if (NULL == pDestItem)
  3712. {
  3713. return false;
  3714. }
  3715. if (pDestItem->IsDragonSoul())
  3716. {
  3717. int ret;
  3718. char buf[128];
  3719. if (item->GetVnum() == DRAGON_HEART_VNUM)
  3720. {
  3721. ret = pDestItem->GiveMoreTime_Per((float)item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
  3722. }
  3723. else
  3724. {
  3725. ret = pDestItem->GiveMoreTime_Per((float)item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  3726. }
  3727. if (ret > 0)
  3728. {
  3729. if (item->GetVnum() == DRAGON_HEART_VNUM)
  3730. {
  3731. 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));
  3732. }
  3733. else
  3734. {
  3735. 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));
  3736. }
  3737.  
  3738. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÃÊ ¸¸Å­ ÃæÀüµÇ¾ú½À´Ï´Ù."), ret);
  3739. item->SetCount(item->GetCount() - 1);
  3740. LogManager::instance().ItemLog(this, item, "DS_CHARGING_SUCCESS", buf);
  3741. return true;
  3742. }
  3743. else
  3744. {
  3745. if (item->GetVnum() == DRAGON_HEART_VNUM)
  3746. {
  3747. 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));
  3748. }
  3749. else
  3750. {
  3751. 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));
  3752. }
  3753.  
  3754. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Alchimie>Puterea Pietrei Dragon este incarcata!"));
  3755. LogManager::instance().ItemLog(this, item, "DS_CHARGING_FAILED", buf);
  3756. return false;
  3757. }
  3758. }
  3759. else
  3760. return false;
  3761. }
  3762. break;
  3763. case USE_TIME_CHARGE_FIX:
  3764. {
  3765. LPITEM pDestItem = GetItem(DestCell);
  3766. if (NULL == pDestItem)
  3767. {
  3768. return false;
  3769. }
  3770. // ¿ì¼± ¿ëÈ¥¼®¿¡ °üÇØ¼­¸¸ Çϵµ·Ï ÇÑ´Ù.
  3771. if (pDestItem->IsDragonSoul())
  3772. {
  3773. int ret = pDestItem->GiveMoreTime_Fix(item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
  3774. char buf[128];
  3775. if (ret)
  3776. {
  3777. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÃÊ ¸¸Å­ ÃæÀüµÇ¾ú½À´Ï´Ù."), ret);
  3778. 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));
  3779. LogManager::instance().ItemLog(this, item, "DS_CHARGING_SUCCESS", buf);
  3780. item->SetCount(item->GetCount() - 1);
  3781. return true;
  3782. }
  3783. else
  3784. {
  3785. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÃæÀüÇÒ ¼ö ¾ø½À´Ï´Ù."));
  3786. 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));
  3787. LogManager::instance().ItemLog(this, item, "DS_CHARGING_FAILED", buf);
  3788. return false;
  3789. }
  3790. }
  3791. else
  3792. return false;
  3793. }
  3794. break;
  3795. case USE_EXTEND_TIME:
  3796. {
  3797. LPITEM item2;
  3798.  
  3799. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  3800. return false;
  3801.  
  3802. if (item2->IsExchanging() || item2->IsEquipped())
  3803. {
  3804. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use this item when you exchange or when your object is equipped."));
  3805. return false;
  3806. }
  3807.  
  3808. if (item2->GetType() != ITEM_COSTUME || (item2->GetSubType() != COSTUME_BODY && item2->GetSubType() != COSTUME_HAIR))
  3809. {
  3810. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use this item for this object."));
  3811. return false;
  3812. }
  3813.  
  3814. item2->SetSocket(0, item2->GetSocket(0) + item->GetValue(0));
  3815. item->SetCount(item->GetCount() - 1);
  3816. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Extended time has been added!"));
  3817. }
  3818. break;
  3819.  
  3820. case USE_SPECIAL:
  3821.  
  3822. switch (item->GetVnum())
  3823. {
  3824. #ifdef ENABLE_ANTI_EXP_SYSTEM
  3825. case ANTIEXP_RING_ID:
  3826. {
  3827. GetBlockExpValue()?SetBlockExpValue(0):SetBlockExpValue(1);
  3828. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("blockexp_set_status%s"), GetBlockExpValue()?LC_TEXT("blockexp_activated_text"):LC_TEXT("blockexp_deactivated_text"));
  3829. UpdatePacket();
  3830. }
  3831. break;
  3832. #ifdef ENABLE_EXP_BOTTLE_FEATURE
  3833. case EXP_BOTTLE_ID:
  3834. {
  3835. if(HasBlockedExp() || GetLevel() >= gPlayerMaxLevel || GetNextExp() > EXP_BOTTLE_STORAGE_LIMIT)
  3836. {
  3837. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("blockexp_can_not_use"));
  3838. return false;
  3839. }
  3840.  
  3841. LPITEM bottle = FindSpecifyItem(EXP_BOTTLE_ID);
  3842. if(!bottle)
  3843. return false;
  3844.  
  3845. if(bottle->GetSocket(1) > 0)
  3846. {
  3847. int exp = GetExp();
  3848. int next_step = GetNextExp();
  3849. int toadd = next_step - exp;
  3850. int realtoadd = 0;
  3851.  
  3852. if(bottle->GetSocket(1) < toadd)
  3853. realtoadd = bottle->GetSocket(1);
  3854. else
  3855. realtoadd = toadd;
  3856.  
  3857. PointChange(POINT_EXP, realtoadd, true);
  3858. bottle->SetSocket(1, bottle->GetSocket(1)-realtoadd);
  3859. }
  3860. }
  3861. break;
  3862. #endif
  3863. #endif
  3864. //Å©¸®½º¸¶½º ¶õÁÖ
  3865. case ITEM_NOG_POCKET:
  3866. {
  3867. /*
  3868. ¶õÁÖ´É·ÂÄ¡ : item_proto value ÀǹÌ
  3869. À̵¿¼Óµµ value 1
  3870. °ø°Ý·Â value 2
  3871. °æÇèÄ¡ value 3
  3872. Áö¼Ó½Ã°£ value 0 (´ÜÀ§ ÃÊ)
  3873.  
  3874. */
  3875. if (FindAffect(AFFECT_NOG_ABILITY))
  3876. {
  3877. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
  3878. return false;
  3879. }
  3880. long time = item->GetValue(0);
  3881. long moveSpeedPer = item->GetValue(1);
  3882. long attPer = item->GetValue(2);
  3883. long expPer = item->GetValue(3);
  3884. AddAffect(AFFECT_NOG_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true);
  3885. EffectPacket(SE_DXUP_PURPLE);
  3886. AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
  3887. AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true);
  3888. item->SetCount(item->GetCount() - 1);
  3889. }
  3890. break;
  3891.  
  3892. //¶ó¸¶´Ü¿ë »çÅÁ
  3893. case ITEM_RAMADAN_CANDY:
  3894. {
  3895. /*
  3896. »çÅÁ´É·ÂÄ¡ : item_proto value ÀǹÌ
  3897. À̵¿¼Óµµ value 1
  3898. °ø°Ý·Â value 2
  3899. °æÇèÄ¡ value 3
  3900. Áö¼Ó½Ã°£ value 0 (´ÜÀ§ ÃÊ)
  3901.  
  3902. */
  3903. long time = item->GetValue(0);
  3904. long moveSpeedPer = item->GetValue(1);
  3905. long attPer = item->GetValue(2);
  3906. long expPer = item->GetValue(3);
  3907. AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true);
  3908. AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
  3909. AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true);
  3910. item->SetCount(item->GetCount() - 1);
  3911. }
  3912. break;
  3913. case ITEM_MARRIAGE_RING:
  3914. {
  3915. marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID());
  3916. if (pMarriage)
  3917. {
  3918. if (pMarriage->ch1 != NULL)
  3919. {
  3920. if (CArenaManager::instance().IsArenaMap(pMarriage->ch1->GetMapIndex()) == true)
  3921. {
  3922. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  3923. break;
  3924. }
  3925. }
  3926.  
  3927. if (pMarriage->ch2 != NULL)
  3928. {
  3929. if (CArenaManager::instance().IsArenaMap(pMarriage->ch2->GetMapIndex()) == true)
  3930. {
  3931. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  3932. break;
  3933. }
  3934. }
  3935.  
  3936. int consumeSP = CalculateConsumeSP(this);
  3937.  
  3938. if (consumeSP < 0)
  3939. return false;
  3940.  
  3941. PointChange(POINT_SP, -consumeSP, false);
  3942.  
  3943. WarpToPID(pMarriage->GetOther(GetPlayerID()));
  3944. }
  3945. else
  3946. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti casatori decat daca ai inelul de logodna"));
  3947. }
  3948. break;
  3949.  
  3950.  
  3951. case UNIQUE_ITEM_CAPE_OF_COURAGE:
  3952.  
  3953. case REWARD_BOX_UNIQUE_ITEM_CAPE_OF_COURAGE:
  3954. AggregateMonster();
  3955. item->SetCount(item->GetCount()-0);
  3956. break;
  3957.  
  3958. case UNIQUE_ITEM_WHITE_FLAG:
  3959. ForgetMyAttacker();
  3960. item->SetCount(item->GetCount()-1);
  3961. break;
  3962.  
  3963. case UNIQUE_ITEM_TREASURE_BOX:
  3964. break;
  3965.  
  3966. case 30094:
  3967. case 30095:
  3968. case 30096:
  3969. // º¹ÁÖ¸Ó´Ï
  3970. {
  3971. const int MAX_BAG_INFO = 26;
  3972. static struct LuckyBagInfo
  3973. {
  3974. DWORD count;
  3975. int prob;
  3976. DWORD vnum;
  3977. } b1[MAX_BAG_INFO] =
  3978. {
  3979. { 1000, 302, 1 },
  3980. { 10, 150, 27002 },
  3981. { 10, 75, 27003 },
  3982. { 10, 100, 27005 },
  3983. { 10, 50, 27006 },
  3984. { 10, 80, 27001 },
  3985. { 10, 50, 27002 },
  3986. { 10, 80, 27004 },
  3987. { 10, 50, 27005 },
  3988. { 1, 10, 50300 },
  3989. { 1, 6, 92 },
  3990. { 1, 2, 132 },
  3991. { 1, 6, 1052 },
  3992. { 1, 2, 1092 },
  3993. { 1, 6, 2082 },
  3994. { 1, 2, 2122 },
  3995. { 1, 6, 3082 },
  3996. { 1, 2, 3122 },
  3997. { 1, 6, 5052 },
  3998. { 1, 2, 5082 },
  3999. { 1, 6, 7082 },
  4000. { 1, 2, 7122 },
  4001. { 1, 1, 11282 },
  4002. { 1, 1, 11482 },
  4003. { 1, 1, 11682 },
  4004. { 1, 1, 11882 },
  4005. };
  4006.  
  4007. struct LuckyBagInfo b2[MAX_BAG_INFO] =
  4008. {
  4009. { 1000, 302, 1 },
  4010. { 10, 150, 27002 },
  4011. { 10, 75, 27002 },
  4012. { 10, 100, 27005 },
  4013. { 10, 50, 27005 },
  4014. { 10, 80, 27001 },
  4015. { 10, 50, 27002 },
  4016. { 10, 80, 27004 },
  4017. { 10, 50, 27005 },
  4018. { 1, 10, 50300 },
  4019. { 1, 6, 92 },
  4020. { 1, 2, 132 },
  4021. { 1, 6, 1052 },
  4022. { 1, 2, 1092 },
  4023. { 1, 6, 2082 },
  4024. { 1, 2, 2122 },
  4025. { 1, 6, 3082 },
  4026. { 1, 2, 3122 },
  4027. { 1, 6, 5052 },
  4028. { 1, 2, 5082 },
  4029. { 1, 6, 7082 },
  4030. { 1, 2, 7122 },
  4031. { 1, 1, 11282 },
  4032. { 1, 1, 11482 },
  4033. { 1, 1, 11682 },
  4034. { 1, 1, 11882 },
  4035. };
  4036.  
  4037. LuckyBagInfo * bi = NULL;
  4038. if (LC_IsHongKong())
  4039. bi = b2;
  4040. else
  4041. bi = b1;
  4042.  
  4043. int pct = number(1, 1000);
  4044.  
  4045. int i;
  4046. for (i=0;i<MAX_BAG_INFO;i++)
  4047. {
  4048. if (pct <= bi[i].prob)
  4049. break;
  4050. pct -= bi[i].prob;
  4051. }
  4052. if (i>=MAX_BAG_INFO)
  4053. return false;
  4054.  
  4055. if (bi[i].vnum == 50300)
  4056. {
  4057. // ½ºÅ³¼ö·Ã¼­´Â Ư¼öÇÏ°Ô ÁØ´Ù.
  4058. GiveRandomSkillBook();
  4059. }
  4060. else if (bi[i].vnum == 1)
  4061. {
  4062. PointChange(POINT_GOLD, 1000, true);
  4063. }
  4064. else
  4065. {
  4066. AutoGiveItem(bi[i].vnum, bi[i].count);
  4067. }
  4068. item->SetCount(item->GetCount() - 1);
  4069. }
  4070. break;
  4071.  
  4072. case 50004:
  4073. {
  4074. if (item->GetSocket(0))
  4075. {
  4076. item->SetSocket(0, item->GetSocket(0) + 1);
  4077. }
  4078. else
  4079. {
  4080. int iMapIndex = GetMapIndex();
  4081.  
  4082. PIXEL_POSITION pos;
  4083.  
  4084. if (SECTREE_MANAGER::instance().GetRandomLocation(iMapIndex, pos, 700))
  4085. {
  4086. item->SetSocket(0, 1);
  4087. item->SetSocket(1, pos.x);
  4088. item->SetSocket(2, pos.y);
  4089. }
  4090. else
  4091. {
  4092. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This improvement does not work with current events"));
  4093. return false;
  4094. }
  4095. }
  4096.  
  4097. int dist = 0;
  4098. float distance = (DISTANCE_SQRT(GetX()-item->GetSocket(1), GetY()-item->GetSocket(2)));
  4099.  
  4100. if (distance < 1000.0f)
  4101. {
  4102. // ¹ß°ß!
  4103. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The fish disappeared."));
  4104.  
  4105. struct TEventStoneInfo
  4106. {
  4107. DWORD dwVnum;
  4108. int count;
  4109. int prob;
  4110. };
  4111. const int EVENT_STONE_MAX_INFO = 15;
  4112. TEventStoneInfo info_10[EVENT_STONE_MAX_INFO] =
  4113. {
  4114. { 27001, 10, 8 },
  4115. { 27004, 10, 6 },
  4116. { 27002, 10, 12 },
  4117. { 27005, 10, 12 },
  4118. { 27100, 1, 9 },
  4119. { 27103, 1, 9 },
  4120. { 27101, 1, 10 },
  4121. { 27104, 1, 10 },
  4122. { 27999, 1, 12 },
  4123.  
  4124. { 25040, 1, 4 },
  4125.  
  4126. { 27410, 1, 0 },
  4127. { 27600, 1, 0 },
  4128. { 25100, 1, 0 },
  4129.  
  4130. { 50001, 1, 0 },
  4131. { 50003, 1, 1 },
  4132. };
  4133. TEventStoneInfo info_7[EVENT_STONE_MAX_INFO] =
  4134. {
  4135. { 27001, 10, 1 },
  4136. { 27004, 10, 1 },
  4137. { 27004, 10, 9 },
  4138. { 27005, 10, 9 },
  4139. { 27100, 1, 5 },
  4140. { 27103, 1, 5 },
  4141. { 27101, 1, 10 },
  4142. { 27104, 1, 10 },
  4143. { 27999, 1, 14 },
  4144.  
  4145. { 25040, 1, 5 },
  4146.  
  4147. { 27410, 1, 5 },
  4148. { 27600, 1, 5 },
  4149. { 25100, 1, 5 },
  4150.  
  4151. { 50001, 1, 0 },
  4152. { 50003, 1, 5 },
  4153.  
  4154. };
  4155. TEventStoneInfo info_4[EVENT_STONE_MAX_INFO] =
  4156. {
  4157. { 27001, 10, 0 },
  4158. { 27004, 10, 0 },
  4159. { 27002, 10, 0 },
  4160. { 27005, 10, 0 },
  4161. { 27100, 1, 0 },
  4162. { 27103, 1, 0 },
  4163. { 27101, 1, 0 },
  4164. { 27104, 1, 0 },
  4165. { 27999, 1, 25 },
  4166.  
  4167. { 25040, 1, 0 },
  4168.  
  4169. { 27410, 1, 0 },
  4170. { 27600, 1, 0 },
  4171. { 25100, 1, 15 },
  4172.  
  4173. { 50001, 1, 10 },
  4174. { 50003, 1, 50 },
  4175.  
  4176. };
  4177.  
  4178. {
  4179. TEventStoneInfo* info;
  4180. if (item->GetSocket(0) <= 4)
  4181. info = info_4;
  4182. else if (item->GetSocket(0) <= 7)
  4183. info = info_7;
  4184. else
  4185. info = info_10;
  4186.  
  4187. int prob = number(1, 100);
  4188.  
  4189. for (int i = 0; i < EVENT_STONE_MAX_INFO; ++i)
  4190. {
  4191. if (!info[i].prob)
  4192. continue;
  4193.  
  4194. if (prob <= info[i].prob)
  4195. {
  4196. if (info[i].dwVnum == 50001)
  4197. {
  4198. DWORD * pdw = M2_NEW DWORD[2];
  4199.  
  4200. pdw[0] = info[i].dwVnum;
  4201. pdw[1] = info[i].count;
  4202.  
  4203. DBManager::instance().ReturnQuery(QID_LOTTO, GetPlayerID(), pdw,
  4204. "INSERT INTO lotto_list VALUES(0, 'server%s', %u, NOW())",
  4205. get_table_postfix(), GetPlayerID());
  4206. }
  4207. else
  4208. AutoGiveItem(info[i].dwVnum, info[i].count);
  4209.  
  4210. break;
  4211. }
  4212. prob -= info[i].prob;
  4213. }
  4214. }
  4215.  
  4216. char chatbuf[CHAT_MAX_LEN + 1];
  4217. int len = snprintf(chatbuf, sizeof(chatbuf), "StoneDetect %u 0 0", (DWORD)GetVID());
  4218.  
  4219. if (len < 0 || len >= (int) sizeof(chatbuf))
  4220. len = sizeof(chatbuf) - 1;
  4221.  
  4222. ++len;
  4223.  
  4224. TPacketGCChat pack_chat;
  4225. pack_chat.header = HEADER_GC_CHAT;
  4226. pack_chat.size = sizeof(TPacketGCChat) + len;
  4227. pack_chat.type = CHAT_TYPE_COMMAND;
  4228. pack_chat.id = 0;
  4229. pack_chat.bEmpire = GetDesc()->GetEmpire();
  4230. //pack_chat.id = vid;
  4231.  
  4232. TEMP_BUFFER buf;
  4233. buf.write(&pack_chat, sizeof(TPacketGCChat));
  4234. buf.write(chatbuf, len);
  4235.  
  4236. PacketAround(buf.read_peek(), buf.size());
  4237.  
  4238. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (DETECT_EVENT_STONE) 1");
  4239. return true;
  4240. }
  4241. else if (distance < 20000)
  4242. dist = 1;
  4243. else if (distance < 70000)
  4244. dist = 2;
  4245. else
  4246. dist = 3;
  4247.  
  4248. // ¸¹ÀÌ »ç¿ëÇßÀ¸¸é »ç¶óÁø´Ù.
  4249. const int STONE_DETECT_MAX_TRY = 10;
  4250. if (item->GetSocket(0) >= STONE_DETECT_MAX_TRY)
  4251. {
  4252. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The object disappears."));
  4253. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (DETECT_EVENT_STONE) 0");
  4254. AutoGiveItem(27002);
  4255. return true;
  4256. }
  4257.  
  4258. if (dist)
  4259. {
  4260. char chatbuf[CHAT_MAX_LEN + 1];
  4261. int len = snprintf(chatbuf, sizeof(chatbuf),
  4262. "StoneDetect %u %d %d",
  4263. (DWORD)GetVID(), dist, (int)GetDegreeFromPositionXY(GetX(), item->GetSocket(2), item->GetSocket(1), GetY()));
  4264.  
  4265. if (len < 0 || len >= (int) sizeof(chatbuf))
  4266. len = sizeof(chatbuf) - 1;
  4267.  
  4268. ++len;
  4269.  
  4270. TPacketGCChat pack_chat;
  4271. pack_chat.header = HEADER_GC_CHAT;
  4272. pack_chat.size = sizeof(TPacketGCChat) + len;
  4273. pack_chat.type = CHAT_TYPE_COMMAND;
  4274. pack_chat.id = 0;
  4275. pack_chat.bEmpire = GetDesc()->GetEmpire();
  4276. //pack_chat.id = vid;
  4277.  
  4278. TEMP_BUFFER buf;
  4279. buf.write(&pack_chat, sizeof(TPacketGCChat));
  4280. buf.write(chatbuf, len);
  4281.  
  4282. PacketAround(buf.read_peek(), buf.size());
  4283. }
  4284.  
  4285. }
  4286. break;
  4287.  
  4288. case 27987: // Á¶°³
  4289. // 50 µ¹Á¶°¢ 47990
  4290. // 30 ²Î
  4291. // 10 ¹éÁøÁÖ 47992
  4292. // 7 ûÁøÁÖ 47993
  4293. // 3 ÇÇÁøÁÖ 47994
  4294. {
  4295. item->SetCount(item->GetCount() - 1);
  4296.  
  4297. int r = number(1, 100);
  4298.  
  4299. if (r <= 50)
  4300. {
  4301. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai deschis o scoica."));
  4302. AutoGiveItem(27990);
  4303. }
  4304. else
  4305. {
  4306. const int prob_table_euckr[] =
  4307. {
  4308. 80, 90, 97
  4309. };
  4310.  
  4311. const int prob_table_gb2312[] =
  4312. {
  4313. 95, 97, 99
  4314. };
  4315.  
  4316. const int * prob_table = !g_iUseLocale ? prob_table_euckr : prob_table_gb2312;
  4317.  
  4318. if (r <= prob_table[0])
  4319. {
  4320. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai deschis o scoica goala."));
  4321. }
  4322. else if (r <= prob_table[1])
  4323. {
  4324. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Se pare ca ai gasit o scoica Alba"));
  4325. AutoGiveItem(27992);
  4326. }
  4327. else if (r <= prob_table[2])
  4328. {
  4329. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Se pare ca ai gasit o scoica Albastra"));
  4330. AutoGiveItem(27993);
  4331. }
  4332. else
  4333. {
  4334. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Se pare ca ai gasit o scoica Rosie"));
  4335. AutoGiveItem(27994);
  4336. }
  4337. }
  4338. }
  4339. break;
  4340.  
  4341. case 71013: // ÃàÁ¦¿ëÆøÁ×
  4342. CreateFly(number(FLY_FIREWORK1, FLY_FIREWORK6), this);
  4343. item->SetCount(item->GetCount() - 1);
  4344. break;
  4345.  
  4346. case 50100: // ÆøÁ×
  4347. case 50101:
  4348. case 50102:
  4349. case 50103:
  4350. case 50104:
  4351. case 50105:
  4352. case 50106:
  4353. CreateFly(item->GetVnum() - 50100 + FLY_FIREWORK1, this);
  4354. item->SetCount(item->GetCount() - 1);
  4355. break;
  4356.  
  4357. case 50200: // º¸µû¸®
  4358. if (LC_IsYMIR() == true || LC_IsKorea() == true)
  4359. {
  4360. if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
  4361. {
  4362. __OpenPrivateShop();
  4363. }
  4364. else
  4365. {
  4366. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide magazin in acest loc"));
  4367. }
  4368. }
  4369. else
  4370. {
  4371. __OpenPrivateShop();
  4372. }
  4373. break;
  4374.  
  4375. case fishing::FISH_MIND_PILL_VNUM:
  4376. AddAffect(AFFECT_FISH_MIND_PILL, POINT_NONE, 0, AFF_FISH_MIND, 20*60, 0, true);
  4377. item->SetCount(item->GetCount() - 1);
  4378. break;
  4379.  
  4380. case 50301: // Åë¼Ö·Â ¼ö·Ã¼­
  4381. case 50302:
  4382. case 50303:
  4383. {
  4384. if (IsPolymorphed() == true)
  4385. {
  4386. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4387. return false;
  4388. }
  4389.  
  4390. int lv = GetSkillLevel(SKILL_LEADERSHIP);
  4391.  
  4392. if (lv < item->GetValue(0))
  4393. {
  4394. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Competenta este prea mica pentru a fi ridicata cu o carte."));
  4395. return false;
  4396. }
  4397.  
  4398. if (lv >= item->GetValue(1))
  4399. {
  4400. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu mai poti urca aceasta competenta."));
  4401. return false;
  4402. }
  4403.  
  4404. if (LearnSkillByBook(SKILL_LEADERSHIP))
  4405. {
  4406. item->SetCount(item->GetCount() - 1);
  4407.  
  4408. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4409. if (distribution_test_server) iReadDelay /= 3;
  4410.  
  4411. SetSkillNextReadTime(SKILL_LEADERSHIP, get_global_time() + iReadDelay);
  4412. }
  4413. }
  4414. break;
  4415.  
  4416. case 50304: // ¿¬°è±â ¼ö·Ã¼­
  4417. case 50305:
  4418. case 50306:
  4419. {
  4420. if (IsPolymorphed())
  4421. {
  4422. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4423. return false;
  4424.  
  4425. }
  4426. if (GetSkillLevel(SKILL_COMBO) == 0 && GetLevel() < 30)
  4427. {
  4428. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti invata aceasta carte pana la nivel 30."));
  4429. return false;
  4430. }
  4431.  
  4432. if (GetSkillLevel(SKILL_COMBO) == 1 && GetLevel() < 50)
  4433. {
  4434. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti invata aceasta carte pana la nivel 50."));
  4435. return false;
  4436. }
  4437.  
  4438. if (GetSkillLevel(SKILL_COMBO) >= 2)
  4439. {
  4440. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu pot folosi aceasta carte."));
  4441. return false;
  4442. }
  4443.  
  4444. int iPct = item->GetValue(0);
  4445.  
  4446. if (LearnSkillByBook(SKILL_COMBO, iPct))
  4447. {
  4448. item->SetCount(item->GetCount() - 1);
  4449.  
  4450. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4451. if (distribution_test_server) iReadDelay /= 3;
  4452.  
  4453. SetSkillNextReadTime(SKILL_COMBO, get_global_time() + iReadDelay);
  4454. }
  4455. }
  4456. break;
  4457. case 50311: // ¾ð¾î ¼ö·Ã¼­
  4458. case 50312:
  4459. case 50313:
  4460. {
  4461. if (IsPolymorphed())
  4462. {
  4463. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4464. return false;
  4465.  
  4466. }
  4467. DWORD dwSkillVnum = item->GetValue(0);
  4468. int iPct = MINMAX(0, item->GetValue(1), 100);
  4469. if (GetSkillLevel(dwSkillVnum)>=20 || dwSkillVnum-SKILL_LANGUAGE1+1 == GetEmpire())
  4470. {
  4471. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti citi aceasta carte."));
  4472. return false;
  4473. }
  4474.  
  4475. if (LearnSkillByBook(dwSkillVnum, iPct))
  4476. {
  4477. item->SetCount(item->GetCount() - 1);
  4478.  
  4479. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4480. if (distribution_test_server) iReadDelay /= 3;
  4481.  
  4482. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  4483. }
  4484. }
  4485. break;
  4486.  
  4487. case 50061 : // ÀϺ» ¸» ¼Òȯ ½ºÅ³ ¼ö·Ã¼­
  4488. {
  4489. if (IsPolymorphed())
  4490. {
  4491. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4492. return false;
  4493.  
  4494. }
  4495. DWORD dwSkillVnum = item->GetValue(0);
  4496. int iPct = MINMAX(0, item->GetValue(1), 100);
  4497.  
  4498. if (GetSkillLevel(dwSkillVnum) >= 10)
  4499. {
  4500. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
  4501. return false;
  4502. }
  4503.  
  4504. if (LearnSkillByBook(dwSkillVnum, iPct))
  4505. {
  4506. item->SetCount(item->GetCount() - 1);
  4507.  
  4508. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4509. if (distribution_test_server) iReadDelay /= 3;
  4510.  
  4511. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  4512. }
  4513. }
  4514. break;
  4515.  
  4516. case 50314: case 50315: case 50316:
  4517. case 50323: case 50324:
  4518. case 50325: case 50326:
  4519. {
  4520. if (IsPolymorphed() == true)
  4521. {
  4522. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4523. return false;
  4524. }
  4525.  
  4526. int iSkillLevelLowLimit = item->GetValue(0);
  4527. int iSkillLevelHighLimit = item->GetValue(1);
  4528. int iPct = MINMAX(0, item->GetValue(2), 100);
  4529. int iLevelLimit = item->GetValue(3);
  4530. DWORD dwSkillVnum = 0;
  4531.  
  4532. switch (item->GetVnum())
  4533. {
  4534. case 50314: case 50315: case 50316:
  4535. dwSkillVnum = SKILL_POLYMORPH;
  4536. break;
  4537.  
  4538. case 50323: case 50324:
  4539. dwSkillVnum = SKILL_ADD_HP;
  4540. break;
  4541.  
  4542. case 50325: case 50326:
  4543. dwSkillVnum = SKILL_RESIST_PENETRATE;
  4544. break;
  4545.  
  4546. default:
  4547. return false;
  4548. }
  4549.  
  4550. if (0 == dwSkillVnum)
  4551. return false;
  4552.  
  4553. if (GetLevel() < iLevelLimit)
  4554. {
  4555. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You must have the consent of the user."));
  4556. return false;
  4557. }
  4558.  
  4559. if (GetSkillLevel(dwSkillVnum) >= 40)
  4560. {
  4561. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
  4562. return false;
  4563. }
  4564.  
  4565. if (GetSkillLevel(dwSkillVnum) < iSkillLevelLowLimit)
  4566. {
  4567. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Competenta este prea mica pentru a fi ridicata cu o carte."));
  4568. return false;
  4569. }
  4570.  
  4571. if (GetSkillLevel(dwSkillVnum) >= iSkillLevelHighLimit)
  4572. {
  4573. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
  4574. return false;
  4575. }
  4576.  
  4577. if (LearnSkillByBook(dwSkillVnum, iPct))
  4578. {
  4579. item->SetCount(item->GetCount() - 1);
  4580.  
  4581. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4582. if (distribution_test_server) iReadDelay /= 3;
  4583.  
  4584. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  4585. }
  4586. }
  4587. break;
  4588.  
  4589. case 50902:
  4590. case 50903:
  4591. case 50904:
  4592. {
  4593. if (IsPolymorphed())
  4594. {
  4595. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4596. return false;
  4597.  
  4598. }
  4599. DWORD dwSkillVnum = SKILL_CREATE;
  4600. int iPct = MINMAX(0, item->GetValue(1), 100);
  4601.  
  4602. if (GetSkillLevel(dwSkillVnum)>=40)
  4603. {
  4604. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
  4605. return false;
  4606. }
  4607.  
  4608. if (LearnSkillByBook(dwSkillVnum, iPct))
  4609. {
  4610. item->SetCount(item->GetCount() - 1);
  4611.  
  4612. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4613. if (distribution_test_server) iReadDelay /= 3;
  4614.  
  4615. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  4616.  
  4617. if (test_server)
  4618. {
  4619. ChatPacket(CHAT_TYPE_INFO, "[TEST_SERVER] Success to learn skill ");
  4620. }
  4621. }
  4622. else
  4623. {
  4624. if (test_server)
  4625. {
  4626. ChatPacket(CHAT_TYPE_INFO, "[TEST_SERVER] Failed to learn skill ");
  4627. }
  4628. }
  4629. }
  4630. break;
  4631.  
  4632. // MINING
  4633. case ITEM_MINING_SKILL_TRAIN_BOOK:
  4634. {
  4635. if (IsPolymorphed())
  4636. {
  4637. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4638. return false;
  4639.  
  4640. }
  4641. DWORD dwSkillVnum = SKILL_MINING;
  4642. int iPct = MINMAX(0, item->GetValue(1), 100);
  4643.  
  4644. if (GetSkillLevel(dwSkillVnum)>=40)
  4645. {
  4646. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
  4647. return false;
  4648. }
  4649.  
  4650. if (LearnSkillByBook(dwSkillVnum, iPct))
  4651. {
  4652. item->SetCount(item->GetCount() - 1);
  4653.  
  4654. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4655. if (distribution_test_server) iReadDelay /= 3;
  4656.  
  4657. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  4658. }
  4659. }
  4660. break;
  4661. // END_OF_MINING
  4662.  
  4663. case ITEM_HORSE_SKILL_TRAIN_BOOK:
  4664. {
  4665. if (IsPolymorphed())
  4666. {
  4667. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
  4668. return false;
  4669.  
  4670. }
  4671. DWORD dwSkillVnum = SKILL_HORSE;
  4672. int iPct = MINMAX(0, item->GetValue(1), 100);
  4673.  
  4674. if (GetLevel() < 50)
  4675. {
  4676. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You will be able to improve your horsemanship."));
  4677. return false;
  4678. }
  4679.  
  4680. if (!test_server && get_global_time() < GetSkillNextReadTime(dwSkillVnum))
  4681. {
  4682. if (FindAffect(AFFECT_SKILL_NO_BOOK_DELAY))
  4683. {
  4684. RemoveAffect(AFFECT_SKILL_NO_BOOK_DELAY);
  4685. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Spiritul meu este pur ! Se pare ca am scapat de blestem."));
  4686. }
  4687. else
  4688. {
  4689. SkillLearnWaitMoreTimeMessage(GetSkillNextReadTime(dwSkillVnum) - get_global_time());
  4690. return false;
  4691. }
  4692. }
  4693.  
  4694. if (GetPoint(POINT_HORSE_SKILL) >= 20 ||
  4695. GetSkillLevel(SKILL_HORSE_WILDATTACK) + GetSkillLevel(SKILL_HORSE_CHARGE) + GetSkillLevel(SKILL_HORSE_ESCAPE) >= 60 ||
  4696. GetSkillLevel(SKILL_HORSE_WILDATTACK_RANGE) + GetSkillLevel(SKILL_HORSE_CHARGE) + GetSkillLevel(SKILL_HORSE_ESCAPE) >= 60)
  4697. {
  4698. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citi aceasta carte."));
  4699. return false;
  4700. }
  4701.  
  4702. if (number(1, 100) <= iPct)
  4703. {
  4704. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You understood the Reitanleitung..."));
  4705. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You will receive a Reitpunkt."));
  4706. PointChange(POINT_HORSE_SKILL, 1);
  4707.  
  4708. int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
  4709. if (distribution_test_server) iReadDelay /= 3;
  4710.  
  4711. if (!test_server)
  4712. SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
  4713. }
  4714. else
  4715. {
  4716. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti intelege aceasta carte."));
  4717. }
  4718.  
  4719. item->SetCount(item->GetCount() - 1);
  4720. }
  4721. break;
  4722.  
  4723. case 70102:
  4724. case 70103:
  4725. {
  4726. if (GetAlignment() >= 0)
  4727. return false;
  4728.  
  4729. int delta = MIN(-GetAlignment(), item->GetValue(0));
  4730.  
  4731. sys_log(0, "%s ALIGNMENT ITEM %d", GetName(), delta);
  4732.  
  4733. UpdateAlignment(delta);
  4734. item->SetCount(item->GetCount() - 1);
  4735.  
  4736. if (delta / 10 > 0)
  4737. {
  4738. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Mintea ta a fost eliberata de spiritul rau."));
  4739. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Gradul tau a urcat cu %d puncte."), delta/10);
  4740. }
  4741. }
  4742. break;
  4743.  
  4744. case 71107: // õµµº¹¼þ¾Æ
  4745. {
  4746. int val = item->GetValue(0);
  4747. int interval = item->GetValue(1);
  4748. quest::PC* pPC = quest::CQuestManager::instance().GetPC(GetPlayerID());
  4749. int last_use_time = pPC->GetFlag("mythical_peach.last_use_time");
  4750.  
  4751. if (get_global_time() - last_use_time < interval * 60 * 60)
  4752. {
  4753. if (test_server == false)
  4754. {
  4755. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa mai astepti."));
  4756. return false;
  4757. }
  4758. else
  4759. {
  4760. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Timpul de testare a trecut."));
  4761. }
  4762. }
  4763.  
  4764. if (GetAlignment() == 200000)
  4765. {
  4766. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Fructul Vietii] Gradul tau este maxim."));
  4767. return false;
  4768. }
  4769.  
  4770. if (200000 - GetAlignment() < val * 10)
  4771. {
  4772. val = (200000 - GetAlignment()) / 10;
  4773. }
  4774.  
  4775. int old_alignment = GetAlignment() / 10;
  4776.  
  4777. UpdateAlignment(val*10);
  4778.  
  4779. item->SetCount(item->GetCount()-1);
  4780. pPC->SetFlag("mythical_peach.last_use_time", get_global_time());
  4781.  
  4782. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Mintea ta a fost eliberata de spiritul rau."));
  4783. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Balanta dintre Rau si Bine are un procentaj de %d."), val);
  4784.  
  4785. char buf[256 + 1];
  4786. snprintf(buf, sizeof(buf), "%d %d", old_alignment, GetAlignment() / 10);
  4787. LogManager::instance().CharLog(this, val, "MYTHICAL_PEACH", buf);
  4788. }
  4789. break;
  4790.  
  4791.  
  4792. case ITEM_NEW_YEAR_GREETING_VNUM:
  4793. {
  4794. DWORD dwBoxVnum = ITEM_NEW_YEAR_GREETING_VNUM;
  4795. std::vector <DWORD> dwVnums;
  4796. std::vector <DWORD> dwCounts;
  4797. std::vector <LPITEM> item_gets;
  4798. int count = 0;
  4799.  
  4800. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  4801. {
  4802. for (int i = 0; i < count; i++)
  4803. {
  4804. if (dwVnums[i] == CSpecialItemGroup::GOLD)
  4805. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
  4806. }
  4807.  
  4808. item->SetCount(item->GetCount() - 1);
  4809. }
  4810. }
  4811. break;
  4812.  
  4813. case ITEM_VALENTINE_ROSE:
  4814. case ITEM_VALENTINE_CHOCOLATE:
  4815. {
  4816. DWORD dwBoxVnum = item->GetVnum();
  4817. std::vector <DWORD> dwVnums;
  4818. std::vector <DWORD> dwCounts;
  4819. std::vector <LPITEM> item_gets(0);
  4820. int count = 0;
  4821.  
  4822.  
  4823. if (item->GetVnum() == ITEM_VALENTINE_ROSE && SEX_MALE==GET_SEX(this) ||
  4824. item->GetVnum() == ITEM_VALENTINE_CHOCOLATE && SEX_FEMALE==GET_SEX(this))
  4825. {
  4826. // ¼ºº°ÀÌ ¸ÂÁö¾Ê¾Æ ¾µ ¼ö ¾ø´Ù.
  4827. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have the wrong gender, you can not open the item."));
  4828. return false;
  4829. }
  4830.  
  4831.  
  4832. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  4833. item->SetCount(item->GetCount()-1);
  4834. }
  4835. break;
  4836.  
  4837. case ITEM_WHITEDAY_CANDY:
  4838. case ITEM_WHITEDAY_ROSE:
  4839. {
  4840. DWORD dwBoxVnum = item->GetVnum();
  4841. std::vector <DWORD> dwVnums;
  4842. std::vector <DWORD> dwCounts;
  4843. std::vector <LPITEM> item_gets(NULL);
  4844. int count = 0;
  4845.  
  4846.  
  4847. if (item->GetVnum() == ITEM_WHITEDAY_CANDY && SEX_MALE==GET_SEX(this) ||
  4848. item->GetVnum() == ITEM_WHITEDAY_ROSE && SEX_FEMALE==GET_SEX(this))
  4849. {
  4850. // 성별이 맞지않아 쓸 수 없다.
  4851. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest articol nu poate fi deschis deoarece sexul este incorect."));
  4852. return false;
  4853. }
  4854.  
  4855.  
  4856. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  4857. item->SetCount(item->GetCount()-1);
  4858. }
  4859. break;
  4860.  
  4861. case 50011: // ¿ù±¤º¸ÇÕ
  4862. {
  4863. DWORD dwBoxVnum = 50011;
  4864. std::vector <DWORD> dwVnums;
  4865. std::vector <DWORD> dwCounts;
  4866. std::vector <LPITEM> item_gets(0);
  4867. int count = 0;
  4868.  
  4869. if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
  4870. {
  4871. for (int i = 0; i < count; i++)
  4872. {
  4873. char buf[50 + 1];
  4874. snprintf(buf, sizeof(buf), "%u %u", dwVnums[i], dwCounts[i]);
  4875. LogManager::instance().ItemLog(this, item, "MOONLIGHT_GET", buf);
  4876.  
  4877. //item->SetCount(item->GetCount() - 1);
  4878. item->SetCount(item->GetCount() - 1);
  4879.  
  4880. switch (dwVnums[i])
  4881. {
  4882. case CSpecialItemGroup::GOLD:
  4883. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
  4884. break;
  4885.  
  4886. case CSpecialItemGroup::EXP:
  4887. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ºÎÅÍ ½ÅºñÇÑ ºûÀÌ ³ª¿É´Ï´Ù."));
  4888. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÀÇ °æÇèÄ¡¸¦ ȹµæÇß½À´Ï´Ù."), dwCounts[i]);
  4889. break;
  4890.  
  4891. case CSpecialItemGroup::MOB:
  4892. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
  4893. break;
  4894.  
  4895. case CSpecialItemGroup::SLOW:
  4896. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ³ª¿Â »¡°£ ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ ¿òÁ÷ÀÌ´Â ¼Óµµ°¡ ´À·ÁÁ³½À´Ï´Ù!"));
  4897. break;
  4898.  
  4899. case CSpecialItemGroup::DRAIN_HP:
  4900. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ°¡ °©ÀÚ±â Æø¹ßÇÏ¿´½À´Ï´Ù! »ý¸í·ÂÀÌ °¨¼ÒÇß½À´Ï´Ù."));
  4901. break;
  4902.  
  4903. case CSpecialItemGroup::POISON:
  4904. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ³ª¿Â ³ì»ö ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ µ¶ÀÌ ¿Â¸öÀ¸·Î ÆÛÁý´Ï´Ù!"));
  4905. break;
  4906.  
  4907. case CSpecialItemGroup::MOB_GROUP:
  4908. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼­ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
  4909. break;
  4910.  
  4911. default:
  4912. if (item_gets[i])
  4913. {
  4914. if (dwCounts[i] > 1)
  4915. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s - %d x."), item_gets[i]->GetName(), dwCounts[i]);
  4916. else
  4917. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s."), item_gets[i]->GetName());
  4918. }
  4919. break;
  4920. }
  4921. }
  4922. }
  4923. else
  4924. {
  4925. ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Nu ai primit nimic deoarece cufarul pare sa fie gol."));
  4926. return false;
  4927. }
  4928. }
  4929. break;
  4930.  
  4931. case ITEM_GIVE_STAT_RESET_COUNT_VNUM:
  4932. {
  4933. //PointChange(POINT_GOLD, -iCost);
  4934. PointChange(POINT_STAT_RESET_COUNT, 1);
  4935. item->SetCount(item->GetCount()-1);
  4936. }
  4937. break;
  4938.  
  4939. case 50107:
  4940. {
  4941. EffectPacket(SE_CHINA_FIREWORK);
  4942. // ½ºÅÏ °ø°ÝÀ» ¿Ã·ÁÁØ´Ù
  4943. AddAffect(AFFECT_CHINA_FIREWORK, POINT_STUN_PCT, 30, AFF_CHINA_FIREWORK, 5*60, 0, true);
  4944. item->SetCount(item->GetCount()-1);
  4945. }
  4946. break;
  4947.  
  4948. case 50108:
  4949. {
  4950. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  4951. {
  4952. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  4953. return false;
  4954. }
  4955.  
  4956. EffectPacket(SE_SPIN_TOP);
  4957. // ½ºÅÏ °ø°ÝÀ» ¿Ã·ÁÁØ´Ù
  4958. AddAffect(AFFECT_CHINA_FIREWORK, POINT_STUN_PCT, 30, AFF_CHINA_FIREWORK, 5*60, 0, true);
  4959. item->SetCount(item->GetCount()-1);
  4960. }
  4961. break;
  4962.  
  4963. case ITEM_WONSO_BEAN_VNUM:
  4964. PointChange(POINT_HP, GetMaxHP() - GetHP());
  4965. item->SetCount(item->GetCount()-1);
  4966. break;
  4967.  
  4968. case ITEM_WONSO_SUGAR_VNUM:
  4969. PointChange(POINT_SP, GetMaxSP() - GetSP());
  4970. item->SetCount(item->GetCount()-1);
  4971. break;
  4972.  
  4973. case ITEM_WONSO_FRUIT_VNUM:
  4974. PointChange(POINT_STAMINA, GetMaxStamina()-GetStamina());
  4975. item->SetCount(item->GetCount()-1);
  4976. break;
  4977.  
  4978. case ITEM_ELK_VNUM:
  4979. {
  4980. int iGold = item->GetSocket(0);
  4981. item->SetCount(item->GetCount() - 1);
  4982. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), iGold);
  4983. PointChange(POINT_GOLD, iGold);
  4984. }
  4985. break;
  4986. #ifdef __BATTLE_PASS__
  4987. case ITEM_BATTLE_PASS:
  4988. {
  4989. if (!v_counts.empty())
  4990. {
  4991. ChatPacket(CHAT_TYPE_INFO, "You have already one active!");
  4992. return false;
  4993. }
  4994.  
  4995. FILE *fileID;
  4996. char file_name[256+1];
  4997.  
  4998. snprintf(file_name, sizeof(file_name), "%s/battlepass_players/%s.txt", LocaleService_GetBasePath().c_str(),GetName());
  4999. fileID = fopen(file_name, "w");
  5000.  
  5001. if (NULL == fileID)
  5002. return false;
  5003.  
  5004. for (int i=0; i<missions_bp.size(); ++i)
  5005. {
  5006. fprintf(fileID,"MISSION %d %d\n", 0, 0);
  5007. }
  5008.  
  5009. fclose(fileID);
  5010.  
  5011. Load_BattlePass();
  5012. ChatPacket(CHAT_TYPE_INFO, "You activate battle pass for this month!");
  5013. item->SetCount(item->GetCount() - 1);
  5014. }
  5015. break;
  5016. #endif
  5017. case 70021:
  5018. {
  5019. int HealPrice = quest::CQuestManager::instance().GetEventFlag("MonarchHealGold");
  5020. if (HealPrice == 0)
  5021. HealPrice = 2000000;
  5022.  
  5023. if (CMonarch::instance().HealMyEmpire(this, HealPrice))
  5024. {
  5025. char szNotice[256];
  5026. snprintf(szNotice, sizeof(szNotice), LC_TEXT("The monarch spoke his blessing to %s and fills all the HP and SP."), EMPIRE_NAME(GetEmpire()));
  5027. SendNoticeMap(szNotice, GetMapIndex(), false);
  5028.  
  5029. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Blessing of the RE used."));
  5030. }
  5031. }
  5032. break;
  5033.  
  5034. case 71092 :
  5035. {
  5036. if (m_pkChrTarget != NULL)
  5037. {
  5038. if (m_pkChrTarget->IsPolymorphed())
  5039. {
  5040. m_pkChrTarget->SetPolymorph(0);
  5041. m_pkChrTarget->RemoveAffect(AFFECT_POLYMORPH);
  5042. }
  5043. }
  5044. else
  5045. {
  5046. if (IsPolymorphed())
  5047. {
  5048. SetPolymorph(0);
  5049. RemoveAffect(AFFECT_POLYMORPH);
  5050. }
  5051. }
  5052. }
  5053. break;
  5054.  
  5055. case 71051 :
  5056. {
  5057.  
  5058. LPITEM item2;
  5059.  
  5060. if (!IsValidItemPosition(DestCell) || !(item2 = GetInventoryItem(wDestCell)))
  5061. return false;
  5062.  
  5063. if (item2->IsExchanging() == true)
  5064. return false;
  5065. #ifdef BONUS_ON_EQUIPED_FIX
  5066. if (item2->IsEquipped())
  5067. {
  5068. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti adauga bonusuri obiectelor echipate!"));
  5069. return false;
  5070. }
  5071. #endif
  5072. //blocare bonus pe costume 6/7 dnd START
  5073. #ifdef DISABLE_BONUS_67_COSTUME
  5074. if (item2->GetType() == ITEM_COSTUME)
  5075. {
  5076. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti atribuii bonusuri unui costum!"));
  5077. return false;
  5078. }
  5079. #endif //blocare bonus pe costume 6/7 dnd END
  5080.  
  5081. //blocare bonus ob speciale 6/7 dnd END
  5082. if (item2->GetType() == ITEM_RING)
  5083. {
  5084. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti atribuii bonusuri unui obiect special!"));
  5085. return false;
  5086. }
  5087.  
  5088. if (item2->GetAttributeSetIndex() == -1)
  5089. {
  5090. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti adauga mai multe bonusuri speciale!"));
  5091. return false;
  5092. }
  5093.  
  5094. if (item2->AddRareAttribute() == true)
  5095. {
  5096. //ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Ai adaugat bonusul cu succes!"));
  5097.  
  5098. int iAddedIdx = item2->GetRareAttrCount() + 4;
  5099. char buf[21];
  5100. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5101.  
  5102. LogManager::instance().ItemLog(
  5103. GetPlayerID(),
  5104. item2->GetAttributeType(iAddedIdx),
  5105. item2->GetAttributeValue(iAddedIdx),
  5106. item->GetID(),
  5107. "ADD_RARE_ATTR",
  5108. buf,
  5109. GetDesc()->GetHostName(),
  5110. item->GetOriginalVnum());
  5111.  
  5112. item->SetCount(item->GetCount() - 1);
  5113. }
  5114. else
  5115. {
  5116. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti adauga mai multe bonusuri speciale!"));
  5117. }
  5118. }
  5119. break;
  5120.  
  5121. case 71052 :
  5122. {
  5123.  
  5124. LPITEM item2;
  5125.  
  5126. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5127. return false;
  5128.  
  5129. if (item2->IsExchanging() == true)
  5130. return false;
  5131.  
  5132. #ifdef DISABLE_BONUS_67_COSTUME
  5133. if (item2->GetType() == ITEM_COSTUME)
  5134. {
  5135. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cant change 6/7 bonuses on costumes"));
  5136. return false;
  5137. }
  5138. #endif
  5139. if (item2->GetType() == ITEM_RING)
  5140. {
  5141. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cant change 6/7 bonuses on special items"));
  5142. return false;
  5143. }
  5144.  
  5145. if (item2->GetAttributeSetIndex() == -1)
  5146. {
  5147. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga un bonus acestui item."));
  5148. return false;
  5149. }
  5150. #ifdef BONUS_ON_EQUIPED_FIX
  5151. if (item2->IsEquipped())
  5152. {
  5153. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti schimba bonusurile obiectelor echipate!"));
  5154. return false;
  5155. }
  5156. #endif
  5157.  
  5158. if (item2->ChangeRareAttribute() == true)
  5159. {
  5160. char buf[21];
  5161. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5162. LogManager::instance().ItemLog(this, item, "CHANGE_RARE_ATTR", buf);
  5163.  
  5164. item->SetCount(item->GetCount() - 1);
  5165. }
  5166. else
  5167. {
  5168. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai schimbat bonusul cu succes."));
  5169. }
  5170. }
  5171. break;
  5172. case ITEM_AUTO_HP_RECOVERY_S:
  5173. case ITEM_AUTO_HP_RECOVERY_M:
  5174. case ITEM_AUTO_HP_RECOVERY_L:
  5175. case ITEM_AUTO_HP_RECOVERY_X:
  5176. case ITEM_AUTO_SP_RECOVERY_S:
  5177. case ITEM_AUTO_SP_RECOVERY_M:
  5178. case ITEM_AUTO_SP_RECOVERY_L:
  5179. case ITEM_AUTO_SP_RECOVERY_X:
  5180. // ¹«½Ã¹«½ÃÇÏÁö¸¸ ÀÌÀü¿¡ ÇÏ´ø °É °íÄ¡±â´Â ¹«¼·°í...
  5181. // ±×·¡¼­ ±×³É Çϵå ÄÚµù. ¼±¹° »óÀÚ¿ë ÀÚµ¿¹°¾à ¾ÆÀÌÅÛµé.
  5182. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
  5183. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
  5184. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
  5185. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
  5186. case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
  5187. case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
  5188. if (FindAffect(AFFECT_ITEM_BLOCK))
  5189. {
  5190. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Sistem> Trebuie sa astepti 5 secunde pentru a putea face asta!"));
  5191. return false;
  5192. }
  5193. {
  5194. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  5195. {
  5196. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  5197. return false;
  5198. }
  5199.  
  5200. EAffectTypes type = AFFECT_NONE;
  5201. bool isSpecialPotion = false;
  5202.  
  5203. switch (item->GetVnum())
  5204. {
  5205. case ITEM_AUTO_HP_RECOVERY_X:
  5206. isSpecialPotion = true;
  5207.  
  5208. case ITEM_AUTO_HP_RECOVERY_S:
  5209. case ITEM_AUTO_HP_RECOVERY_M:
  5210. case ITEM_AUTO_HP_RECOVERY_L:
  5211. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
  5212. case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
  5213. case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
  5214. type = AFFECT_AUTO_HP_RECOVERY;
  5215. break;
  5216.  
  5217. case ITEM_AUTO_SP_RECOVERY_X:
  5218. isSpecialPotion = true;
  5219.  
  5220. case ITEM_AUTO_SP_RECOVERY_S:
  5221. case ITEM_AUTO_SP_RECOVERY_M:
  5222. case ITEM_AUTO_SP_RECOVERY_L:
  5223. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
  5224. case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
  5225. case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
  5226. type = AFFECT_AUTO_SP_RECOVERY;
  5227. break;
  5228. }
  5229.  
  5230. if (AFFECT_NONE == type)
  5231. break;
  5232.  
  5233. if (item->GetCount() > 1)
  5234. {
  5235. int pos = GetEmptyInventory(item->GetSize());
  5236.  
  5237. if (-1 == pos)
  5238. {
  5239. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Item divided."));
  5240. break;
  5241. }
  5242.  
  5243. item->SetCount( item->GetCount() - 1 );
  5244.  
  5245. LPITEM item2 = ITEM_MANAGER::instance().CreateItem( item->GetVnum(), 1 );
  5246. item2->AddToCharacter(this, TItemPos(INVENTORY, pos));
  5247.  
  5248. if (item->GetSocket(1) != 0)
  5249. {
  5250. item2->SetSocket(1, item->GetSocket(1));
  5251. }
  5252.  
  5253. item = item2;
  5254. }
  5255.  
  5256. CAffect* pAffect = FindAffect( type );
  5257.  
  5258. if (NULL == pAffect)
  5259. {
  5260. EPointTypes bonus = POINT_NONE;
  5261.  
  5262. if (true == isSpecialPotion)
  5263. {
  5264. if (type == AFFECT_AUTO_HP_RECOVERY)
  5265. {
  5266. bonus = POINT_MAX_HP_PCT;
  5267. }
  5268. else if (type == AFFECT_AUTO_SP_RECOVERY)
  5269. {
  5270. bonus = POINT_MAX_SP_PCT;
  5271. }
  5272. }
  5273.  
  5274. AddAffect( type, bonus, 4, item->GetID(), INFINITE_AFFECT_DURATION, 0, true, false);
  5275.  
  5276. item->Lock(true);
  5277. item->SetSocket(0, true);
  5278.  
  5279. AutoRecoveryItemProcess( type );
  5280. AddAffect(AFFECT_ITEM_BLOCK, POINT_NONE, 0, 0, 5, 0, true, false);
  5281. }
  5282. else
  5283. {
  5284. if (item->GetID() == pAffect->dwFlag)
  5285. {
  5286. RemoveAffect( pAffect );
  5287.  
  5288. item->Lock(false);
  5289. item->SetSocket(0, false);
  5290. }
  5291. else
  5292. {
  5293. LPITEM old = FindItemByID( pAffect->dwFlag );
  5294.  
  5295. if (NULL != old)
  5296. {
  5297. old->Lock(false);
  5298. old->SetSocket(0, false);
  5299. }
  5300.  
  5301. RemoveAffect( pAffect );
  5302.  
  5303. EPointTypes bonus = POINT_NONE;
  5304.  
  5305. if (true == isSpecialPotion)
  5306. {
  5307. if (type == AFFECT_AUTO_HP_RECOVERY)
  5308. {
  5309. bonus = POINT_MAX_HP_PCT;
  5310. }
  5311. else if (type == AFFECT_AUTO_SP_RECOVERY)
  5312. {
  5313. bonus = POINT_MAX_SP_PCT;
  5314. }
  5315. }
  5316.  
  5317. AddAffect( type, bonus, 4, item->GetID(), INFINITE_AFFECT_DURATION, 0, true, false);
  5318.  
  5319. item->Lock(true);
  5320. item->SetSocket(0, true);
  5321.  
  5322. AutoRecoveryItemProcess( type );
  5323. }
  5324. }
  5325. }
  5326. break;
  5327. }
  5328. break;
  5329.  
  5330. case USE_CLEAR:
  5331. {
  5332. RemoveBadAffect();
  5333. item->SetCount(item->GetCount() - 1);
  5334. }
  5335. break;
  5336.  
  5337. case USE_POTION_NODELAY:
  5338. {
  5339. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  5340. {
  5341. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
  5342. {
  5343. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  5344. return false;
  5345. }
  5346.  
  5347. switch (item->GetVnum())
  5348. {
  5349. case 70020 :
  5350. case 71018 :
  5351. case 71019 :
  5352. case 71020 :
  5353. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
  5354. {
  5355. if (m_nPotionLimit <= 0)
  5356. {
  5357. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi licori în arena luptelor. "));
  5358. return false;
  5359. }
  5360. }
  5361. break;
  5362.  
  5363. default :
  5364. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  5365. return false;
  5366. }
  5367. }
  5368.  
  5369. bool used = false;
  5370.  
  5371. if (item->GetValue(0) != 0) // HP
  5372. {
  5373. if (GetHP() < GetMaxHP())
  5374. {
  5375. PointChange(POINT_HP, item->GetValue(0) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  5376. EffectPacket(SE_HPUP_RED);
  5377. used = TRUE;
  5378. }
  5379. }
  5380.  
  5381. if (item->GetValue(1) != 0) // SP
  5382. {
  5383. if (GetSP() < GetMaxSP())
  5384. {
  5385. PointChange(POINT_SP, item->GetValue(1) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
  5386. EffectPacket(SE_SPUP_BLUE);
  5387. used = TRUE;
  5388. }
  5389. }
  5390.  
  5391. if (item->GetValue(3) != 0) // HP %
  5392. {
  5393. if (GetHP() < GetMaxHP())
  5394. {
  5395. PointChange(POINT_HP, item->GetValue(3) * GetMaxHP() / 100);
  5396. EffectPacket(SE_HPUP_RED);
  5397. used = TRUE;
  5398. }
  5399. }
  5400.  
  5401. if (item->GetValue(4) != 0) // SP %
  5402. {
  5403. if (GetSP() < GetMaxSP())
  5404. {
  5405. PointChange(POINT_SP, item->GetValue(4) * GetMaxSP() / 100);
  5406. EffectPacket(SE_SPUP_BLUE);
  5407. used = TRUE;
  5408. }
  5409. }
  5410.  
  5411. if (used)
  5412. {
  5413. if (item->GetVnum() == 50085 || item->GetVnum() == 50086)
  5414. {
  5415. if (test_server)
  5416. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("All items were used"));
  5417. SetUseSeedOrMoonBottleTime();
  5418. }
  5419. if (GetDungeon())
  5420. GetDungeon()->UsePotion(this);
  5421.  
  5422. if (GetWarMap())
  5423. GetWarMap()->UsePotion(this, item);
  5424.  
  5425. m_nPotionLimit--;
  5426.  
  5427. //RESTRICT_USE_SEED_OR_MOONBOTTLE
  5428. item->SetCount(item->GetCount() - 1);
  5429. //END_RESTRICT_USE_SEED_OR_MOONBOTTLE
  5430. }
  5431. }
  5432. break;
  5433.  
  5434. case USE_POTION:
  5435. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  5436. {
  5437. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
  5438. {
  5439. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  5440. return false;
  5441. }
  5442.  
  5443. switch (item->GetVnum())
  5444. {
  5445. case 27001 :
  5446. case 27002 :
  5447. case 27003 :
  5448. case 27004 :
  5449. case 27005 :
  5450. case 27006 :
  5451. case 40489 :
  5452. case 40490 :
  5453. case 40491 :
  5454. case 40492 :
  5455. if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
  5456. {
  5457. if (m_nPotionLimit <= 0)
  5458. {
  5459. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi licori în arena luptelor. "));
  5460. return false;
  5461. }
  5462. }
  5463. break;
  5464.  
  5465. default :
  5466. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  5467. return false;
  5468. }
  5469. }
  5470.  
  5471. if (item->GetValue(1) != 0)
  5472. {
  5473. if (GetPoint(POINT_SP_RECOVERY) + GetSP() >= GetMaxSP())
  5474. {
  5475. return false;
  5476. }
  5477.  
  5478. PointChange(POINT_SP_RECOVERY, item->GetValue(1) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
  5479. StartAffectEvent();
  5480. EffectPacket(SE_SPUP_BLUE);
  5481. }
  5482.  
  5483. if (item->GetValue(0) != 0)
  5484. {
  5485. if (GetPoint(POINT_HP_RECOVERY) + GetHP() >= GetMaxHP())
  5486. {
  5487. return false;
  5488. }
  5489.  
  5490. PointChange(POINT_HP_RECOVERY, item->GetValue(0) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
  5491. StartAffectEvent();
  5492. EffectPacket(SE_HPUP_RED);
  5493. }
  5494.  
  5495. if (GetDungeon())
  5496. GetDungeon()->UsePotion(this);
  5497.  
  5498. if (GetWarMap())
  5499. GetWarMap()->UsePotion(this, item);
  5500.  
  5501. item->SetCount(item->GetCount() - 1);
  5502. m_nPotionLimit--;
  5503. break;
  5504.  
  5505. case USE_POTION_CONTINUE:
  5506. {
  5507. if (item->GetValue(0) != 0)
  5508. {
  5509. AddAffect(AFFECT_HP_RECOVER_CONTINUE, POINT_HP_RECOVER_CONTINUE, item->GetValue(0), 0, item->GetValue(2), 0, true);
  5510. }
  5511. else if (item->GetValue(1) != 0)
  5512. {
  5513. AddAffect(AFFECT_SP_RECOVER_CONTINUE, POINT_SP_RECOVER_CONTINUE, item->GetValue(1), 0, item->GetValue(2), 0, true);
  5514. }
  5515. else
  5516. return false;
  5517. }
  5518.  
  5519. if (GetDungeon())
  5520. GetDungeon()->UsePotion(this);
  5521.  
  5522. if (GetWarMap())
  5523. GetWarMap()->UsePotion(this, item);
  5524.  
  5525. item->SetCount(item->GetCount() - 1);
  5526. break;
  5527.  
  5528. case USE_ABILITY_UP:
  5529. #ifdef ENABLE_YMIR_AFFECT_FIX
  5530. if ((CheckTimeUsed(item) == false)) { return false; }
  5531. #endif
  5532. {
  5533. switch (item->GetValue(0))
  5534. {
  5535. #ifdef ENABLE_DnD_AFFECT_FIX
  5536. case APPLY_MOV_SPEED:
  5537. if (FindAffect(AFFECT_MOV_SPEED))
  5538. {
  5539. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<System> Folosesti deja un efect de viteza!"));
  5540. return false;
  5541. }
  5542. AddAffect(AFFECT_MOV_SPEED, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true);
  5543. EffectPacket(SE_DXUP_PURPLE); //purple potion
  5544. break;
  5545. #endif
  5546. #ifdef ENABLE_DnD_AFFECT_FIX
  5547. case APPLY_ATT_SPEED:
  5548. if (FindAffect(AFFECT_ATT_SPEED))
  5549. {
  5550. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<System> Folosesti deja un efect de viteza!"));
  5551. return false;
  5552. }
  5553. AddAffect(AFFECT_ATT_SPEED, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true);
  5554. EffectPacket(SE_SPEEDUP_GREEN); //green potion
  5555. break;
  5556. #endif
  5557. case APPLY_STR:
  5558. AddAffect(AFFECT_STR, POINT_ST, item->GetValue(2), 0, item->GetValue(1), 0, true);
  5559. break;
  5560.  
  5561. case APPLY_DEX:
  5562. AddAffect(AFFECT_DEX, POINT_DX, item->GetValue(2), 0, item->GetValue(1), 0, true);
  5563. break;
  5564.  
  5565. case APPLY_CON:
  5566. AddAffect(AFFECT_CON, POINT_HT, item->GetValue(2), 0, item->GetValue(1), 0, true);
  5567. break;
  5568.  
  5569. case APPLY_INT:
  5570. AddAffect(AFFECT_INT, POINT_IQ, item->GetValue(2), 0, item->GetValue(1), 0, true);
  5571. break;
  5572.  
  5573. case APPLY_CAST_SPEED:
  5574. AddAffect(AFFECT_CAST_SPEED, POINT_CASTING_SPEED, item->GetValue(2), 0, item->GetValue(1), 0, true);
  5575. break;
  5576.  
  5577. case APPLY_ATT_GRADE_BONUS:
  5578. AddAffect(AFFECT_ATT_GRADE, POINT_ATT_GRADE_BONUS,
  5579. item->GetValue(2), 0, item->GetValue(1), 0, true);
  5580. break;
  5581.  
  5582. case APPLY_DEF_GRADE_BONUS:
  5583. AddAffect(AFFECT_DEF_GRADE, POINT_DEF_GRADE_BONUS,
  5584. item->GetValue(2), 0, item->GetValue(1), 0, true);
  5585. break;
  5586. }
  5587. }
  5588.  
  5589. if (GetDungeon())
  5590. GetDungeon()->UsePotion(this);
  5591.  
  5592. if (GetWarMap())
  5593. GetWarMap()->UsePotion(this, item);
  5594.  
  5595. item->SetCount(item->GetCount() - 1);
  5596. break;
  5597.  
  5598. case USE_TALISMAN:
  5599. {
  5600. const int TOWN_PORTAL = 1;
  5601. const int MEMORY_PORTAL = 2;
  5602.  
  5603.  
  5604. // gm_guild_build, oxevent ¸Ê¿¡¼­ ±ÍȯºÎ ±Íȯ±â¾ïºÎ ¸¦ »ç¿ë¸øÇÏ°Ô ¸·À½
  5605. if (GetMapIndex() == 200 || GetMapIndex() == 113)
  5606. {
  5607. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Disponibila in prezent."));
  5608. return false;
  5609. }
  5610.  
  5611. if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
  5612. {
  5613. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
  5614. return false;
  5615. }
  5616.  
  5617. if (m_pkWarpEvent)
  5618. {
  5619. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Te rog incearca mai tarziu"));
  5620. return false;
  5621. }
  5622.  
  5623. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  5624. int consumeLife = CalculateConsume(this);
  5625.  
  5626. if (consumeLife < 0)
  5627. return false;
  5628. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  5629.  
  5630. if (item->GetValue(0) == TOWN_PORTAL)
  5631. {
  5632. if (item->GetSocket(0) == 0)
  5633. {
  5634. if (!GetDungeon())
  5635. if (!GiveRecallItem(item))
  5636. return false;
  5637.  
  5638. PIXEL_POSITION posWarp;
  5639.  
  5640. if (SECTREE_MANAGER::instance().GetRecallPositionByEmpire(GetMapIndex(), GetEmpire(), posWarp))
  5641. {
  5642. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  5643. PointChange(POINT_HP, -consumeLife, false);
  5644. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  5645.  
  5646. WarpSet(posWarp.x, posWarp.y);
  5647. }
  5648. else
  5649. {
  5650. sys_err("CHARACTER::UseItem : cannot find spawn position (name %s, %d x %d)", GetName(), GetX(), GetY());
  5651. }
  5652. }
  5653. else
  5654. {
  5655. if (test_server)
  5656. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You will be teleported to the last position"));
  5657.  
  5658. ProcessRecallItem(item);
  5659. }
  5660. }
  5661. else if (item->GetValue(0) == MEMORY_PORTAL)
  5662. {
  5663. if (item->GetSocket(0) == 0)
  5664. {
  5665. if (GetDungeon())
  5666. {
  5667. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi %s%s"),
  5668. item->GetName(),
  5669. g_iUseLocale ? "" : (under_han(item->GetName()) ? LC_TEXT("de") : LC_TEXT("la")));
  5670. return false;
  5671. }
  5672.  
  5673. if (!GiveRecallItem(item))
  5674. return false;
  5675. }
  5676. else
  5677. {
  5678. // CONSUME_LIFE_WHEN_USE_WARP_ITEM
  5679. PointChange(POINT_HP, -consumeLife, false);
  5680. // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
  5681.  
  5682. ProcessRecallItem(item);
  5683. }
  5684. }
  5685. }
  5686. break;
  5687.  
  5688. case USE_TUNING:
  5689. case USE_DETACHMENT:
  5690. {
  5691. LPITEM item2;
  5692.  
  5693. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5694. return false;
  5695.  
  5696. if (item2->IsExchanging())
  5697. return false;
  5698.  
  5699. if (item2->IsEquipped())
  5700. return false;
  5701.  
  5702. #ifdef __SASH_SYSTEM__
  5703. if (item->GetValue(0) == SASH_CLEAN_ATTR_VALUE0)
  5704. {
  5705. if (!CleanSashAttr(item, item2))
  5706. return false;
  5707.  
  5708. return true;
  5709. }
  5710. #endif
  5711.  
  5712. if (item2->GetVnum() >= 28330 && item2->GetVnum() <= 28343) //+3
  5713. {
  5714. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("+3 ¿µ¼®Àº ÀÌ ¾ÆÀÌÅÛÀ¸·Î °³·®ÇÒ ¼ö ¾ø½À´Ï´Ù"));
  5715. return false;
  5716. }
  5717. #ifdef STONE_ON_EQUIPED_FIX
  5718. if (item2->IsEquipped())
  5719. return false;
  5720. #endif
  5721.  
  5722. if (item2->GetVnum() >= 28430 && item2->GetVnum() <= 28443) // +4
  5723. {
  5724. if (item->GetVnum() == 71056)
  5725. {
  5726. RefineItem(item, item2);
  5727. }
  5728. #ifdef STONE_ON_EQUIPED_FIX
  5729. if (item2->IsEquipped())
  5730. return false;
  5731. #endif
  5732. else
  5733. {
  5734. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Pietrele spirituale nu pot fi actualizate cu acest obiect."));
  5735. }
  5736. }
  5737. else
  5738. {
  5739. RefineItem(item, item2);
  5740. }
  5741. }
  5742. break;
  5743.  
  5744. // ACCESSORY_REFINE & ADD/CHANGE_ATTRIBUTES
  5745. case USE_PUT_INTO_BELT_SOCKET:
  5746. case USE_PUT_INTO_RING_SOCKET:
  5747. case USE_PUT_INTO_ACCESSORY_SOCKET:
  5748. case USE_ADD_ACCESSORY_SOCKET:
  5749. case USE_CLEAN_SOCKET:
  5750. case USE_CHANGE_ATTRIBUTE:
  5751. case USE_CHANGE_ATTRIBUTE2 :
  5752. case USE_ADD_ATTRIBUTE:
  5753. case USE_ADD_ATTRIBUTE2:
  5754. {
  5755. LPITEM item2;
  5756. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  5757. return false;
  5758.  
  5759. if (item2->IsEquipped())
  5760. {
  5761. BuffOnAttr_RemoveBuffsFromItem(item2);
  5762. }
  5763.  
  5764. if (ITEM_COSTUME == item2->GetType())
  5765. {
  5766. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
  5767. return false;
  5768. }
  5769.  
  5770. if (ITEM_RING == item2->GetType())
  5771. {
  5772. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
  5773. return false;
  5774. }
  5775.  
  5776. if (item2->IsExchanging())
  5777. return false;
  5778.  
  5779. switch (item->GetSubType())
  5780. {
  5781. case USE_CLEAN_SOCKET:
  5782. {
  5783. int i;
  5784. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  5785. {
  5786. if (item2->GetSocket(i) == ITEM_BROKEN_METIN_VNUM)
  5787. break;
  5788. }
  5789.  
  5790. if (i == ITEM_SOCKET_MAX_NUM)
  5791. {
  5792. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Spatiul nu este gasit."));
  5793. return false;
  5794. }
  5795.  
  5796. int j = 0;
  5797.  
  5798. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  5799. {
  5800. if (item2->GetSocket(i) != ITEM_BROKEN_METIN_VNUM && item2->GetSocket(i) != 0)
  5801. item2->SetSocket(j++, item2->GetSocket(i));
  5802. }
  5803.  
  5804. for (; j < ITEM_SOCKET_MAX_NUM; ++j)
  5805. {
  5806. if (item2->GetSocket(j) > 0)
  5807. item2->SetSocket(j, 1);
  5808. }
  5809.  
  5810. {
  5811. char buf[21];
  5812. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5813. LogManager::instance().ItemLog(this, item, "CLEAN_SOCKET", buf);
  5814. }
  5815.  
  5816. item->SetCount(item->GetCount() - 1);
  5817.  
  5818. }
  5819. break;
  5820.  
  5821. case USE_CHANGE_ATTRIBUTE :
  5822. if (item2->GetAttributeSetIndex() == -1)
  5823. {
  5824. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
  5825. return false;
  5826. }
  5827.  
  5828. if (item2->IsEquipped()){
  5829. ChatPacket(CHAT_TYPE_INFO, "[SYSTEM] Nu poti schimba bonusurile obiectelor echipate!");
  5830. return false;
  5831. }
  5832.  
  5833. if (item2->GetAttributeCount() == 0)
  5834. {
  5835. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu exista proprietati de modificat."));
  5836. return false;
  5837. }
  5838.  
  5839. if (GM_PLAYER == GetGMLevel() && false == test_server)
  5840. {
  5841.  
  5842. DWORD dwChangeItemAttrCycle = quest::CQuestManager::instance().GetEventFlag(msc_szChangeItemAttrCycleFlag);
  5843. if (dwChangeItemAttrCycle < msc_dwDefaultChangeItemAttrCycle)
  5844. dwChangeItemAttrCycle = msc_dwDefaultChangeItemAttrCycle;
  5845.  
  5846. quest::PC* pPC = quest::CQuestManager::instance().GetPC(GetPlayerID());
  5847.  
  5848. if (pPC)
  5849. {
  5850. DWORD dwNowMin = get_global_time() / 60;
  5851.  
  5852.  
  5853. pPC->SetFlag(msc_szLastChangeItemAttrFlag, dwNowMin);
  5854. }
  5855. }
  5856.  
  5857. if (item->GetSubType() == USE_CHANGE_ATTRIBUTE2)
  5858. {
  5859. int aiChangeProb[ITEM_ATTRIBUTE_MAX_LEVEL] =
  5860. {
  5861. 0, 0, 30, 40, 3
  5862. };
  5863.  
  5864. item2->ChangeAttribute(aiChangeProb);
  5865. }
  5866.  
  5867. else
  5868. {
  5869. if (item->GetVnum() == 71151 || item->GetVnum() == 76023)
  5870. {
  5871. if ((item2->GetType() == ITEM_WEAPON)
  5872. || (item2->GetType() == ITEM_ARMOR && item2->GetSubType() == ARMOR_BODY))
  5873. {
  5874. bool bCanUse = true;
  5875. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  5876. {
  5877. if (item2->GetLimitType(i) == LIMIT_LEVEL && item2->GetLimitValue(i) > 40)
  5878. {
  5879. bCanUse = false;
  5880. break;
  5881. }
  5882. }
  5883. if (false == bCanUse)
  5884. {
  5885. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest item poate fi folosit doar pentru armele si armurile pana in level 40."));
  5886. break;
  5887. }
  5888. }
  5889. else
  5890. {
  5891. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Disponibil doar pe arme si armuri."));
  5892. break;
  5893. }
  5894. }
  5895. item2->ChangeAttribute();
  5896. }
  5897.  
  5898. //ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonus schimbat..."));
  5899. {
  5900. char buf[21];
  5901. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5902. LogManager::instance().ItemLog(this, item, "CHANGE_ATTRIBUTE", buf);
  5903. }
  5904.  
  5905. item->SetCount(item->GetCount() - 1);
  5906. break;
  5907.  
  5908. case USE_ADD_ATTRIBUTE :
  5909. if (item2->GetAttributeSetIndex() == -1)
  5910. {
  5911. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
  5912. return false;
  5913. }
  5914.  
  5915. #ifdef BONUS_ON_EQUIPED_FIX
  5916. if (item2->IsEquipped())
  5917. {
  5918. ChatPacket(CHAT_TYPE_INFO, "You can`t change attributes when item is equipped!");
  5919. return false;
  5920. }
  5921. #endif
  5922.  
  5923. if (item2->GetAttributeCount() < 4)
  5924. {
  5925.  
  5926. if (item->GetVnum() == 71152 || item->GetVnum() == 76024)
  5927. {
  5928. if ((item2->GetType() == ITEM_WEAPON)
  5929. || (item2->GetType() == ITEM_ARMOR && item2->GetSubType() == ARMOR_BODY))
  5930. {
  5931. bool bCanUse = true;
  5932. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  5933. {
  5934. if (item2->GetLimitType(i) == LIMIT_LEVEL && item2->GetLimitValue(i) > 40)
  5935. {
  5936. bCanUse = false;
  5937. break;
  5938. }
  5939. }
  5940. if (false == bCanUse)
  5941. {
  5942. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest item poate fi folosit doar pentru armele si armurile pana in level 40."));
  5943. break;
  5944. }
  5945. }
  5946. else
  5947. {
  5948. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Disponibil doar pe arme si armuri."));
  5949. break;
  5950. }
  5951. }
  5952. char buf[21];
  5953. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  5954.  
  5955. if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
  5956. {
  5957. item2->AddAttribute();
  5958. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a fost adaugat cu succes."));
  5959.  
  5960. int iAddedIdx = item2->GetAttributeCount() - 1;
  5961. LogManager::instance().ItemLog(
  5962. GetPlayerID(),
  5963. item2->GetAttributeType(iAddedIdx),
  5964. item2->GetAttributeValue(iAddedIdx),
  5965. item->GetID(),
  5966. "ADD_ATTRIBUTE_SUCCESS",
  5967. buf,
  5968. GetDesc()->GetHostName(),
  5969. item->GetOriginalVnum());
  5970. }
  5971. else
  5972. {
  5973. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a esuat la adaugare."));
  5974. LogManager::instance().ItemLog(this, item, "ADD_ATTRIBUTE_FAIL", buf);
  5975. }
  5976.  
  5977. item->SetCount(item->GetCount() - 1);
  5978. }
  5979. else
  5980. {
  5981. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga bonus."));
  5982. }
  5983. break;
  5984.  
  5985. case USE_ADD_ATTRIBUTE2 :
  5986.  
  5987. if (item2->GetAttributeSetIndex() == -1)
  5988. {
  5989. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
  5990. return false;
  5991. }
  5992.  
  5993. if (item2->GetType() == ARMOR_PENDANT)
  5994. {
  5995. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
  5996. return false;
  5997. }
  5998.  
  5999. if (item2->GetAttributeCount() == 4)
  6000. {
  6001. char buf[21];
  6002. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  6003.  
  6004. if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
  6005. {
  6006. item2->AddAttribute();
  6007. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a esuat la adaugare."));
  6008.  
  6009. int iAddedIdx = item2->GetAttributeCount() - 1;
  6010. LogManager::instance().ItemLog(
  6011. GetPlayerID(),
  6012. item2->GetAttributeType(iAddedIdx),
  6013. item2->GetAttributeValue(iAddedIdx),
  6014. item->GetID(),
  6015. "ADD_ATTRIBUTE2_SUCCESS",
  6016. buf,
  6017. GetDesc()->GetHostName(),
  6018. item->GetOriginalVnum());
  6019. }
  6020. else
  6021. {
  6022. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a esuat la adaugare."));
  6023. LogManager::instance().ItemLog(this, item, "ADD_ATTRIBUTE2_FAIL", buf);
  6024. }
  6025.  
  6026. item->SetCount(item->GetCount() - 1);
  6027. }
  6028. else if (item2->GetAttributeCount() == 5)
  6029. {
  6030. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga alte bonusuri."));
  6031. }
  6032. else if (item2->GetAttributeCount() < 4)
  6033. {
  6034. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi asa ceva."));
  6035. }
  6036. else
  6037. {
  6038. // wtf ?!
  6039. sys_err("ADD_ATTRIBUTE2 : Item has wrong AttributeCount(%d)", item2->GetAttributeCount());
  6040. }
  6041. break;
  6042.  
  6043. case USE_ADD_ACCESSORY_SOCKET:
  6044. {
  6045. char buf[21];
  6046. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  6047.  
  6048. if (item2->IsAccessoryForSocket())
  6049. {
  6050. if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
  6051. {
  6052. if (number(1, 100) <= 50)
  6053. {
  6054. item2->SetAccessorySocketMaxGrade(item2->GetAccessorySocketMaxGrade() + 1);
  6055. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugarea diamantului a reusit."));
  6056. LogManager::instance().ItemLog(this, item, "ADD_SOCKET_SUCCESS", buf);
  6057. }
  6058. else
  6059. {
  6060. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugarea diamantului a esuat."));
  6061. LogManager::instance().ItemLog(this, item, "ADD_SOCKET_FAIL", buf);
  6062. }
  6063.  
  6064. item->SetCount(item->GetCount() - 1);
  6065. }
  6066. else
  6067. {
  6068. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu mai exista sloturi disponibile pe acest item."));
  6069. }
  6070. }
  6071. else
  6072. {
  6073. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citi aceasta carte !."));
  6074. }
  6075. }
  6076. break;
  6077.  
  6078. case USE_PUT_INTO_BELT_SOCKET:
  6079. case USE_PUT_INTO_ACCESSORY_SOCKET:
  6080. if (item2->IsAccessoryForSocket() && item->CanPutInto(item2))
  6081. {
  6082. char buf[21];
  6083. snprintf(buf, sizeof(buf), "%u", item2->GetID());
  6084.  
  6085. if (item2->GetAccessorySocketGrade() < item2->GetAccessorySocketMaxGrade())
  6086. {
  6087. if (number(1, 100) <= aiAccessorySocketPutPct[item2->GetAccessorySocketGrade()])
  6088. {
  6089. item2->SetAccessorySocketGrade(item2->GetAccessorySocketGrade() + 1);
  6090. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugare reusita."));
  6091. LogManager::instance().ItemLog(this, item, "PUT_SOCKET_SUCCESS", buf);
  6092. }
  6093. else
  6094. {
  6095. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugare esuata."));
  6096. LogManager::instance().ItemLog(this, item, "PUT_SOCKET_FAIL", buf);
  6097. }
  6098.  
  6099. item->SetCount(item->GetCount() - 1);
  6100. }
  6101. else
  6102. {
  6103. if (item2->GetAccessorySocketMaxGrade() == 0)
  6104. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai adaugat un diamant."));
  6105. else if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
  6106. {
  6107. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("In this object there are no other slots for stones."));
  6108. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai adaugat diamantul cu succes."));
  6109. }
  6110. else
  6111. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Exorcism role Enabled"));
  6112. }
  6113. }
  6114. else
  6115. {
  6116. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asa ceva."));
  6117. }
  6118. break;
  6119. }
  6120. if (item2->IsEquipped())
  6121. {
  6122. BuffOnAttr_AddBuffsFromItem(item2);
  6123. }
  6124. }
  6125. break;
  6126. // END_OF_ACCESSORY_REFINE & END_OF_ADD_ATTRIBUTES & END_OF_CHANGE_ATTRIBUTES
  6127.  
  6128. case USE_BAIT:
  6129. {
  6130.  
  6131. if (m_pkFishingEvent)
  6132. {
  6133. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not change bait!"));
  6134. return false;
  6135. }
  6136.  
  6137. LPITEM weapon = GetWear(WEAR_WEAPON);
  6138.  
  6139. if (!weapon || weapon->GetType() != ITEM_ROD)
  6140. return false;
  6141.  
  6142. if (weapon->GetSocket(2))
  6143. {
  6144. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai schimbat momeala."), item->GetName());
  6145. }
  6146. else
  6147. {
  6148. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Folosesti ca momeala: %s"), item->GetName());
  6149. }
  6150.  
  6151. weapon->SetSocket(2, item->GetValue(0));
  6152. item->SetCount(item->GetCount() - 1);
  6153. }
  6154. break;
  6155.  
  6156. case USE_MOVE:
  6157. case USE_TREASURE_BOX:
  6158. case USE_MONEYBAG:
  6159. break;
  6160.  
  6161. #ifdef ENABLE_AFFECT_ITEMS_PLUS
  6162. case USE_AFFECT :
  6163. {
  6164. int affect_type = item->GetValue(0);
  6165. int apply_type = aApplyInfo[item->GetValue(1)].bPointType;
  6166. int apply_value = item->GetValue(2);
  6167. int affect_state_socket = 0;
  6168.  
  6169. CAffect* pAffect = FindAffect(affect_type, apply_type);
  6170.  
  6171. if (pAffect == NULL)
  6172. {
  6173. AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
  6174. item->SetSocket(affect_state_socket, 1);
  6175. item->Lock(true);
  6176. }
  6177. else
  6178. {
  6179. if (item->GetID() == pAffect->dwFlag)
  6180. {
  6181. RemoveAffect( pAffect );
  6182. item->Lock(false);
  6183. item->SetSocket(affect_state_socket, 0);
  6184. }
  6185. else
  6186. {
  6187. LPITEM old = FindItemByID( pAffect->dwFlag );
  6188. if (NULL != old)
  6189. {
  6190. old->Lock(false);
  6191. old->SetSocket(affect_state_socket, 0);
  6192. }
  6193.  
  6194. RemoveAffect(pAffect);
  6195.  
  6196. AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
  6197. item->SetSocket(affect_state_socket, 1);
  6198. item->Lock(true);
  6199. }
  6200. }
  6201. }
  6202. break;
  6203. #else
  6204. case USE_AFFECT :
  6205. {
  6206. if (FindAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType))
  6207. {
  6208. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
  6209. }
  6210. else
  6211. {
  6212. // PC_BANG_ITEM_ADD
  6213. if (item->IsPCBangItem() == true)
  6214. {
  6215. // PC¹æÀÎÁö Ã¼Å©ÇØ¼­ ó¸®
  6216. if (CPCBangManager::instance().IsPCBangIP(GetDesc()->GetHostName()) == false)
  6217. {
  6218. // PC¹æÀÌ ¾Æ´Ô!
  6219. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This book can be found at low levels of metin."));
  6220. return false;
  6221. }
  6222. }
  6223. // END_PC_BANG_ITEM_ADD
  6224.  
  6225. AddAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType, item->GetValue(2), 0, item->GetValue(3), 0, false);
  6226. item->SetCount(item->GetCount() - 1);
  6227.  
  6228. }
  6229. }
  6230. break;
  6231. #endif
  6232.  
  6233. case USE_CREATE_STONE:
  6234. AutoGiveItem(number(28000, 28013));
  6235. item->SetCount(item->GetCount() - 1);
  6236. break;
  6237. }
  6238. }
  6239. break;
  6240.  
  6241. case ITEM_METIN:
  6242. {
  6243. LPITEM item2;
  6244.  
  6245. if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
  6246. return false;
  6247.  
  6248. if (item2->IsExchanging())
  6249. return false;
  6250.  
  6251. if (item2->GetType() == ITEM_PICK) return false;
  6252. if (item2->GetType() == ITEM_ROD) return false;
  6253.  
  6254. int i;
  6255.  
  6256. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  6257. {
  6258. DWORD dwVnum;
  6259.  
  6260. if ((dwVnum = item2->GetSocket(i)) <= 2)
  6261. continue;
  6262.  
  6263. TItemTable * p = ITEM_MANAGER::instance().GetTable(dwVnum);
  6264.  
  6265. if (!p)
  6266. continue;
  6267.  
  6268. if (item->GetValue(5) == p->alValues[5])
  6269. {
  6270. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga mai multe pietre de aceelasi fel."));
  6271. return false;
  6272. }
  6273. }
  6274.  
  6275. if (item2->GetType() == ITEM_ARMOR)
  6276. {
  6277. if (!IS_SET(item->GetWearFlag(), WEARABLE_BODY) || !IS_SET(item2->GetWearFlag(), WEARABLE_BODY))
  6278. {
  6279. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Exista deja pietre."));
  6280. return false;
  6281. }
  6282. }
  6283. else if (item2->GetType() == ITEM_WEAPON)
  6284. {
  6285. if (!IS_SET(item->GetWearFlag(), WEARABLE_WEAPON))
  6286. {
  6287. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Only you can put 2 stones in war."));
  6288. return false;
  6289. }
  6290. }
  6291. else
  6292. {
  6293. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu se poate adauga pe acest slot."));
  6294. return false;
  6295. }
  6296.  
  6297. for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  6298. if (item2->GetSocket(i) >= 1 && item2->GetSocket(i) <= 2 && item2->GetSocket(i) >= item->GetValue(2))
  6299. {
  6300. if (number(1, 100) <= 30)
  6301. {
  6302. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Piatra a fost adaugata cu succes!"));
  6303. item2->SetSocket(i, item->GetVnum());
  6304. }
  6305. else
  6306. {
  6307. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Piatra nu a fost adaugata."));
  6308. item2->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
  6309. }
  6310.  
  6311. LogManager::instance().ItemLog(this, item2, "SOCKET", item->GetName());
  6312. item->SetCount(item->GetCount() - 1);
  6313. break;
  6314. }
  6315.  
  6316. if (i == ITEM_SOCKET_MAX_NUM)
  6317. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu se poate adauga pe acest slot."));
  6318. }
  6319. break;
  6320.  
  6321. case ITEM_AUTOUSE:
  6322. case ITEM_MATERIAL:
  6323. case ITEM_SPECIAL:
  6324. case ITEM_TOOL:
  6325. case ITEM_LOTTERY:
  6326. break;
  6327.  
  6328. case ITEM_TOTEM:
  6329. {
  6330. if (!item->IsEquipped())
  6331. EquipItem(item);
  6332. }
  6333. break;
  6334.  
  6335. #ifdef ENABLE_DEWS_PLUS
  6336. case ITEM_BLEND:
  6337. #ifdef ENABLE_YMIR_AFFECT_FIX
  6338. if ((CheckTimeUsed(item) == false)) { return false; }
  6339. #endif
  6340. sys_log(0,"ITEM_BLEND!!");
  6341. if (Blend_Item_find(item->GetVnum()))
  6342. {
  6343. int affect_type = AFFECT_BLEND;
  6344. if (item->GetSocket(0) >= (int)_countof(aApplyInfo))
  6345. {
  6346. sys_err ("INVALID BLEND ITEM(id : %d, vnum : %d). APPLY TYPE IS %d.", item->GetID(), item->GetVnum(), item->GetSocket(0));
  6347. return false;
  6348. }
  6349. int apply_type = aApplyInfo[item->GetSocket(0)].bPointType;
  6350. int apply_value = item->GetSocket(1);
  6351.  
  6352. CAffect* pAffect = FindAffect(affect_type, apply_type);
  6353. item->SetSocket(2, 0);
  6354. if (pAffect == NULL)
  6355. {
  6356. AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
  6357. item->SetSocket(2, 1);
  6358. item->Lock(true);
  6359. #ifdef ENABLE_NEW_AFFECT_POTION
  6360. SetAffectPotion(item);
  6361. #endif
  6362. }
  6363. else
  6364. {
  6365. if (item->GetID() == pAffect->dwFlag)
  6366. {
  6367. RemoveAffect( pAffect );
  6368. item->Lock(false);
  6369. item->SetSocket(2, 0);
  6370. #ifdef ENABLE_NEW_AFFECT_POTION
  6371. RemoveAffectPotion(item);
  6372. #endif
  6373. }
  6374. else
  6375. {
  6376. LPITEM old = FindItemByID( pAffect->dwFlag );
  6377. if (NULL != old)
  6378. {
  6379. old->Lock(false);
  6380. old->SetSocket(2, 0);
  6381. }
  6382.  
  6383. RemoveAffect(pAffect);
  6384. #ifdef ENABLE_NEW_AFFECT_POTION
  6385. RemoveAffectPotion(item);
  6386. #endif
  6387.  
  6388. AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
  6389. item->SetSocket(2, 1);
  6390. item->Lock(true);
  6391. #ifdef ENABLE_NEW_AFFECT_POTION
  6392. SetAffectPotion(item);
  6393. #endif
  6394. }
  6395. }
  6396. }
  6397. break;
  6398. #else
  6399. case ITEM_BLEND:
  6400. sys_log(0,"ITEM_BLEND!!");
  6401. if (Blend_Item_find(item->GetVnum()))
  6402. {
  6403. int affect_type = AFFECT_BLEND;
  6404. int apply_type = aApplyInfo[item->GetSocket(0)].bPointType;
  6405. int apply_value = item->GetSocket(1);
  6406. int apply_duration = item->GetSocket(2);
  6407.  
  6408. if (FindAffect(affect_type, apply_type))
  6409. {
  6410. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Folosesti efectul!"));
  6411. }
  6412. else
  6413. {
  6414. if (FindAffect(AFFECT_EXP_BONUS_EURO_FREE, POINT_RESIST_MAGIC))
  6415. {
  6416. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Folosesti efectul!"));
  6417. }
  6418. else
  6419. {
  6420. AddAffect(affect_type, apply_type, apply_value, 0, apply_duration, 0, false);
  6421. #ifdef ENABLE_NEW_AFFECT_POTION
  6422. SetAffectPotion(item);
  6423. #endif
  6424. item->SetCount(item->GetCount() - 1);
  6425. }
  6426. }
  6427. }
  6428. break;
  6429. #endif
  6430. case ITEM_EXTRACT:
  6431. {
  6432. LPITEM pDestItem = GetItem(DestCell);
  6433. if (NULL == pDestItem)
  6434. {
  6435. return false;
  6436. }
  6437. switch (item->GetSubType())
  6438. {
  6439. case EXTRACT_DRAGON_SOUL:
  6440. if (pDestItem->IsDragonSoul())
  6441. {
  6442. return DSManager::instance().PullOut(this, NPOS, pDestItem, item);
  6443. }
  6444. return false;
  6445. case EXTRACT_DRAGON_HEART:
  6446. if (pDestItem->IsDragonSoul())
  6447. {
  6448. return DSManager::instance().ExtractDragonHeart(this, pDestItem, item);
  6449. }
  6450. return false;
  6451. default:
  6452. return false;
  6453. }
  6454. }
  6455. break;
  6456.  
  6457. case ITEM_NONE:
  6458. sys_err("Item type NONE %s", item->GetName());
  6459. break;
  6460.  
  6461. default:
  6462. sys_log(0, "UseItemEx: Unknown type %s %d", item->GetName(), item->GetType());
  6463. return false;
  6464. }
  6465.  
  6466. return true;
  6467. }
  6468.  
  6469. int g_nPortalLimitTime = 10;
  6470.  
  6471. bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
  6472. {
  6473. WORD wCell = Cell.cell;
  6474. BYTE window_type = Cell.window_type;
  6475. WORD wDestCell = DestCell.cell;
  6476. BYTE bDestInven = DestCell.window_type;
  6477. LPITEM item;
  6478.  
  6479. if (!CanHandleItem())
  6480. return false;
  6481.  
  6482. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  6483. return false;
  6484.  
  6485. if (item->GetVnum() == 50570) // change with your item vnum
  6486. {
  6487. BiologManager::instance().RestartTime(this);
  6488. item->SetCount(item->GetCount() - 1);
  6489. }
  6490.  
  6491. sys_log(0, "%s: USE_ITEM %s (inven %d, cell: %d)", GetName(), item->GetName(), window_type, wCell);
  6492.  
  6493. #ifdef __BIOLOG_TIME__
  6494. if (item->GetVnum() == 30219)
  6495. {
  6496. BiologManager::instance().RestartTime(this);
  6497. item->SetCount(item->GetCount() - 1);
  6498. }
  6499. #endif
  6500.  
  6501. if (item->IsExchanging())
  6502. return false;
  6503.  
  6504. #ifdef __ATTR_SWITCH_SYSTEM__
  6505. if (Cell.IsSwitchbotPosition())
  6506. {
  6507. CSwitchbot* pkSwitchbot = CSwitchbotManager::Instance().FindSwitchbot(GetPlayerID());
  6508. if (pkSwitchbot && pkSwitchbot->IsActive(Cell.cell))
  6509. return false;
  6510.  
  6511. int iEmptyCell = GetEmptyInventory(item->GetSize());
  6512.  
  6513. if (iEmptyCell == -1)
  6514. {
  6515. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cannot remove item from switchbot. Inventory is full."));
  6516. return false;
  6517. }
  6518.  
  6519. MoveItem(Cell, TItemPos(INVENTORY, iEmptyCell), item->GetCount());
  6520. return true;
  6521. }
  6522. #endif
  6523.  
  6524. if (!item->CanUsedBy(this))
  6525. {
  6526. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti purta asa ceva!"));
  6527. return false;
  6528. }
  6529.  
  6530. if (IsStun())
  6531. return false;
  6532.  
  6533. if (false == FN_check_item_sex(this, item))
  6534. {
  6535. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de sexul dumneavoastra."));
  6536. return false;
  6537. }
  6538. #ifdef BLOCK_ITEM_IN_MAP
  6539. if (IS_ENABLE_ITEM(item->GetVnum()))
  6540. {
  6541. if (false == IS_ENABLE_ITEM_ZONE(GetMapIndex()))
  6542. {
  6543. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti folosii obiectul in aceasta mapa"));
  6544. return false;
  6545. }
  6546. }
  6547. #endif
  6548. //PREVENT_TRADE_WINDOW
  6549. if (IS_SUMMON_ITEM(item->GetVnum()))
  6550. {
  6551. if (false == IS_SUMMONABLE_ZONE(GetMapIndex()))
  6552. {
  6553. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu se poate folosi un pergament in acest loc."));
  6554. return false;
  6555. }
  6556.  
  6557. if (CThreeWayWar::instance().IsThreeWayWarMapIndex(GetMapIndex()))
  6558. {
  6559. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu uita, in batalii nu poti folosii potiuni speciale."));
  6560. return false;
  6561. }
  6562. int iPulse = thecore_pulse();
  6563.  
  6564. if (iPulse - GetSafeboxLoadTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  6565. {
  6566. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti folosi aceasta aptitudine incã ."), g_nPortalLimitTime);
  6567.  
  6568. if (test_server)
  6569. ChatPacket(CHAT_TYPE_INFO, "[TestOnly]Pulse %d LoadTime %d PASS %d", iPulse, GetSafeboxLoadTime(), PASSES_PER_SEC(g_nPortalLimitTime));
  6570. return false;
  6571. }
  6572.  
  6573. //PREVENT_REFINE_HACK
  6574. {
  6575. if (iPulse - GetRefineTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  6576. {
  6577. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa astepti %d"), g_nPortalLimitTime);
  6578. return false;
  6579. }
  6580. }
  6581. //END_PREVENT_REFINE_HACK
  6582.  
  6583.  
  6584. //PREVENT_ITEM_COPY
  6585. {
  6586. if (iPulse - GetMyShopTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  6587. {
  6588. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa astepti %d secunde"), g_nPortalLimitTime);
  6589. return false;
  6590. }
  6591.  
  6592. }
  6593. //END_PREVENT_ITEM_COPY
  6594.  
  6595. if (item->GetVnum() != 70302)
  6596. {
  6597. PIXEL_POSITION posWarp;
  6598.  
  6599. int x = 0;
  6600. int y = 0;
  6601.  
  6602. double nDist = 0;
  6603. const double nDistant = 5000.0;
  6604.  
  6605. if (item->GetVnum() == 22010)
  6606. {
  6607. x = item->GetSocket(0) - GetX();
  6608. y = item->GetSocket(1) - GetY();
  6609. }
  6610.  
  6611. else if (item->GetVnum() == 22000)
  6612. {
  6613. SECTREE_MANAGER::instance().GetRecallPositionByEmpire(GetMapIndex(), GetEmpire(), posWarp);
  6614.  
  6615. if (item->GetSocket(0) == 0)
  6616. {
  6617. x = posWarp.x - GetX();
  6618. y = posWarp.y - GetY();
  6619. }
  6620. else
  6621. {
  6622. x = item->GetSocket(0) - GetX();
  6623. y = item->GetSocket(1) - GetY();
  6624. }
  6625. }
  6626.  
  6627. nDist = sqrt(pow((float)x,2) + pow((float)y,2));
  6628.  
  6629. if (nDistant > nDist)
  6630. {
  6631. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti teleporta in acest loc."));
  6632. if (test_server)
  6633. ChatPacket(CHAT_TYPE_INFO, "PossibleDistant %f nNowDist %f", nDistant,nDist);
  6634. return false;
  6635. }
  6636. }
  6637.  
  6638. //PREVENT_PORTAL_AFTER_EXCHANGE
  6639. if (iPulse - GetExchangeTime() < PASSES_PER_SEC(g_nPortalLimitTime))
  6640. {
  6641. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa astepti %d secunde"), g_nPortalLimitTime);
  6642. return false;
  6643. }
  6644. //END_PREVENT_PORTAL_AFTER_EXCHANGE
  6645.  
  6646. }
  6647.  
  6648. if (item->GetVnum() == 50200 | item->GetVnum() == 71049)
  6649. {
  6650. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6651. {
  6652. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide magain in timp ce ai alte ferestre deschise sau esti transformat."));
  6653. return false;
  6654. }
  6655. }
  6656. #ifdef ITEM_BUFF_SYSTEM
  6657. if (item->GetVnum() == MASTER_RESIST_BLESS_ITEM_BUFF_VNUM)
  6658. {
  6659. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6660. {
  6661. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6662. return false;
  6663. }
  6664. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6665. {
  6666. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6667. return false;
  6668. }
  6669. if (true == IsDead())
  6670. {
  6671. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6672. return false;
  6673. }
  6674. else
  6675. {
  6676. if (FindAffect(SKILL_RESIST_BUFF))
  6677. {
  6678. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Item Buff]!");
  6679. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6680. return false;
  6681. }
  6682. if (IsAffectFlag(AFF_HOSIN))
  6683. {
  6684. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Shaman Buff]!");
  6685. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6686. return false;
  6687. }
  6688. {
  6689. item->SetSocket(0, item->GetSocket(0) + 1);
  6690. AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, MASTER_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, MASTER_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6691. if (item->GetSocket(0) >= MASTER_RESIST_BLESS_USINGS)
  6692. {
  6693. ITEM_MANAGER::instance().RemoveItem(item);
  6694. }
  6695. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Resistance Buff , [Item Buff] for 160 seconds.");
  6696. ChatPacket(CHAT_TYPE_INFO, "Buff resist rate applied: 24%.");
  6697. }
  6698. }
  6699. }
  6700.  
  6701. if (item->GetVnum() == GRAND_RESIST_BLESS_ITEM_BUFF_VNUM) //
  6702. {
  6703. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6704. {
  6705. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6706. return false;
  6707. }
  6708. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6709. {
  6710. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6711. return false;
  6712. }
  6713. if (true == IsDead())
  6714. {
  6715. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6716. return false;
  6717. }
  6718. else
  6719. {
  6720. if (FindAffect(SKILL_RESIST_BUFF))
  6721. {
  6722. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Item Buff]!");
  6723. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6724. return false;
  6725. }
  6726. if (IsAffectFlag(AFF_HOSIN))
  6727. {
  6728. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Shaman Buff]!");
  6729. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6730. return false;
  6731. }
  6732. {
  6733. item->SetSocket(0, item->GetSocket(0) + 1);
  6734. AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, GRAND_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, GRAND_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6735. if (item->GetSocket(0) >= GRAND_RESIST_BLESS_USINGS)
  6736. {
  6737. ITEM_MANAGER::instance().RemoveItem(item);
  6738. }
  6739. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Resistance Buff , [Item Buff] for 224 seconds.");
  6740. ChatPacket(CHAT_TYPE_INFO, "Buff resist rate applied: 29%.");
  6741. }
  6742. }
  6743. }
  6744.  
  6745. if (item->GetVnum() == PERFECT_RESIST_BLESS_ITEM_BUFF_VNUM) //
  6746. {
  6747. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6748. {
  6749. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6750. return false;
  6751. }
  6752. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6753. {
  6754. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6755. return false;
  6756. }
  6757. if (true == IsDead())
  6758. {
  6759. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6760. return false;
  6761. }
  6762. else
  6763. {
  6764. if (FindAffect(SKILL_RESIST_BUFF))
  6765. {
  6766. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Item Buff]!");
  6767. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6768. return false;
  6769. }
  6770. if (IsAffectFlag(AFF_HOSIN))
  6771. {
  6772. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Shaman Buff]!");
  6773. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6774. return false;
  6775. }
  6776. {
  6777. item->SetSocket(0, item->GetSocket(0) + 1);
  6778. AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, PERFECT_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, PERFECT_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6779. if (item->GetSocket(0) >= PERFECT_RESIST_BLESS_USINGS)
  6780. {
  6781. ITEM_MANAGER::instance().RemoveItem(item);
  6782. }
  6783. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Resistance Buff, [Item Buff] for 310 seconds.");
  6784. ChatPacket(CHAT_TYPE_INFO, "Buff resist rate applied: 35%.");
  6785. }
  6786. }
  6787. }
  6788.  
  6789. if (item->GetVnum() == MASTER_CRITICAL_BLESS_ITEM_BUFF_VNUM)
  6790. {
  6791. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6792. {
  6793. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6794. return false;
  6795. }
  6796. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6797. {
  6798. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6799. return false;
  6800. }
  6801. if (true == IsDead())
  6802. {
  6803. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6804. return false;
  6805. }
  6806. else
  6807. {
  6808. if (FindAffect(SKILL_CRITICAL_BUFF))
  6809. {
  6810. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!");
  6811. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6812. return false;
  6813. }
  6814. if (IsAffectFlag(AFF_GICHEON))
  6815. {
  6816. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!");
  6817. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6818. return false;
  6819. }
  6820. {
  6821. item->SetSocket(0, item->GetSocket(0) + 1);
  6822. AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, MASTER_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, MASTER_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6823. if (item->GetSocket(0) >= MASTER_CRITICAL_BLESS_USINGS)
  6824. {
  6825. ITEM_MANAGER::instance().RemoveItem(item);
  6826. }
  6827. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 110 seconds.");
  6828. ChatPacket(CHAT_TYPE_INFO, "Buff critical rate applied: 24%.");
  6829. }
  6830. }
  6831. }
  6832.  
  6833. if (item->GetVnum() == GRAND_CRITICAL_BLESS_ITEM_BUFF_VNUM) //
  6834. {
  6835. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6836. {
  6837. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6838. return false;
  6839. }
  6840. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6841. {
  6842. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6843. return false;
  6844. }
  6845. if (true == IsDead())
  6846. {
  6847. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6848. return false;
  6849. }
  6850. else
  6851. {
  6852. if (FindAffect(SKILL_CRITICAL_BUFF))
  6853. {
  6854. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!");
  6855. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6856. return false;
  6857. }
  6858. if (IsAffectFlag(AFF_GICHEON))
  6859. {
  6860. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!");
  6861. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6862. return false;
  6863. }
  6864. {
  6865. item->SetSocket(0, item->GetSocket(0) + 1);
  6866. AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, GRAND_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, GRAND_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6867. if (item->GetSocket(0) >= GRAND_CRITICAL_BLESS_USINGS)
  6868. {
  6869. ITEM_MANAGER::instance().RemoveItem(item);
  6870. }
  6871. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 142 seconds.");
  6872. ChatPacket(CHAT_TYPE_INFO, "Buff critical rate applied: 29%.");
  6873. }
  6874. }
  6875. }
  6876.  
  6877. if (item->GetVnum() == PERFECT_CRITICAL_BLESS_ITEM_BUFF_VNUM) //
  6878. {
  6879. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6880. {
  6881. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6882. return false;
  6883. }
  6884. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6885. {
  6886. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6887. return false;
  6888. }
  6889. if (true == IsDead())
  6890. {
  6891. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff)!");
  6892. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6893. return false;
  6894. }
  6895. else
  6896. {
  6897. if (FindAffect(SKILL_CRITICAL_BUFF))
  6898. {
  6899. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!");
  6900. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6901. return false;
  6902. }
  6903. if (IsAffectFlag(AFF_GICHEON))
  6904. {
  6905. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!");
  6906. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6907. return false;
  6908. }
  6909. {
  6910. item->SetSocket(0, item->GetSocket(0) + 1);
  6911. AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, PERFECT_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, PERFECT_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6912. if (item->GetSocket(0) >= PERFECT_CRITICAL_BLESS_USINGS)
  6913. {
  6914. ITEM_MANAGER::instance().RemoveItem(item);
  6915. }
  6916. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 185 seconds.");
  6917. ChatPacket(CHAT_TYPE_INFO, "Buff critical rate applied: 35%.");
  6918. }
  6919. }
  6920. }
  6921.  
  6922. if (item->GetVnum() == MASTER_REFLECT_BLESS_ITEM_BUFF_VNUM)
  6923. {
  6924. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6925. {
  6926. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6927. return false;
  6928. }
  6929. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6930. {
  6931. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6932. return false;
  6933. }
  6934. if (true == IsDead())
  6935. {
  6936. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6937. return false;
  6938. }
  6939. else
  6940. {
  6941. if (FindAffect(SKILL_REFLECT_BUFF))
  6942. {
  6943. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Item Buff]!");
  6944. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6945. return false;
  6946. }
  6947. if (IsAffectFlag(AFF_BOHO))
  6948. {
  6949. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Shaman Buff]!");
  6950. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6951. return false;
  6952. }
  6953. {
  6954. item->SetSocket(0, item->GetSocket(0) + 1);
  6955. AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, MASTER_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, MASTER_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  6956. if (item->GetSocket(0) >= MASTER_REFLECT_BLESS_USINGS)
  6957. {
  6958. ITEM_MANAGER::instance().RemoveItem(item);
  6959. }
  6960. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Reflection, [Item Buff] for 160 seconds.");
  6961. ChatPacket(CHAT_TYPE_INFO, "Buff reflection rate applied: 21%.");
  6962. }
  6963. }
  6964. }
  6965.  
  6966. if (item->GetVnum() == GRAND_REFLECT_BLESS_ITEM_BUFF_VNUM) //
  6967. {
  6968. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  6969. {
  6970. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  6971. return false;
  6972. }
  6973. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  6974. {
  6975. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  6976. return false;
  6977. }
  6978. if (true == IsDead())
  6979. {
  6980. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  6981. return false;
  6982. }
  6983. else
  6984. {
  6985. if (FindAffect(SKILL_REFLECT_BUFF))
  6986. {
  6987. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Item Buff]!");
  6988. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6989. return false;
  6990. }
  6991. if (IsAffectFlag(AFF_BOHO))
  6992. {
  6993. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Shaman Buff]!");
  6994. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  6995. return false;
  6996. }
  6997. {
  6998. item->SetSocket(0, item->GetSocket(0) + 1);
  6999. AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, GRAND_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, GRAND_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  7000. if (item->GetSocket(0) >= GRAND_REFLECT_BLESS_USINGS)
  7001. {
  7002. ITEM_MANAGER::instance().RemoveItem(item);
  7003. }
  7004. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Reflection, [Item Buff] for 224 seconds.");
  7005. ChatPacket(CHAT_TYPE_INFO, "Buff reflection rate applied: 31%.");
  7006. }
  7007. }
  7008. }
  7009.  
  7010. if (item->GetVnum() == PERFECT_REFLECT_BLESS_ITEM_BUFF_VNUM) //
  7011. {
  7012. if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
  7013. {
  7014. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
  7015. return false;
  7016. }
  7017. if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
  7018. {
  7019. ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
  7020. return false;
  7021. }
  7022. if (true == IsDead())
  7023. {
  7024. ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
  7025. return false;
  7026. }
  7027. else
  7028. {
  7029. if (FindAffect(SKILL_REFLECT_BUFF))
  7030. {
  7031. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Item Buff]!");
  7032. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  7033. return false;
  7034. }
  7035. if (IsAffectFlag(AFF_BOHO))
  7036. {
  7037. ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Shaman Buff]!");
  7038. ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
  7039. return false;
  7040. }
  7041. {
  7042. item->SetSocket(0, item->GetSocket(0) + 1);
  7043. AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, PERFECT_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, PERFECT_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
  7044. if (item->GetSocket(0) >= PERFECT_REFLECT_BLESS_USINGS)
  7045. {
  7046. ITEM_MANAGER::instance().RemoveItem(item);
  7047. }
  7048. ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Reflection, [Item Buff] for 310 seconds.");
  7049. ChatPacket(CHAT_TYPE_INFO, "Buff reflection rate applied: 45%.");
  7050. }
  7051. }
  7052. }
  7053. #endif
  7054. //END_PREVENT_TRADE_WINDOW
  7055.  
  7056. if (IS_SET(item->GetFlag(), ITEM_FLAG_LOG))
  7057. {
  7058. DWORD vid = item->GetVID();
  7059. DWORD oldCount = item->GetCount();
  7060. DWORD vnum = item->GetVnum();
  7061.  
  7062. char hint[ITEM_NAME_MAX_LEN + 32 + 1];
  7063. int len = snprintf(hint, sizeof(hint) - 32, "%s", item->GetName());
  7064.  
  7065. if (len < 0 || len >= (int) sizeof(hint) - 32)
  7066. len = (sizeof(hint) - 32) - 1;
  7067.  
  7068. bool ret = UseItemEx(item, DestCell);
  7069.  
  7070. if (NULL == ITEM_MANAGER::instance().FindByVID(vid))
  7071. {
  7072. LogManager::instance().ItemLog(this, vid, vnum, "REMOVE", hint);
  7073. }
  7074. else if (oldCount != item->GetCount())
  7075. {
  7076. snprintf(hint + len, sizeof(hint) - len, " %u", oldCount - 1);
  7077. LogManager::instance().ItemLog(this, vid, vnum, "USE_ITEM", hint);
  7078. }
  7079. return (ret);
  7080. }
  7081. else
  7082. return UseItemEx(item, DestCell);
  7083. }
  7084.  
  7085. bool CHARACTER::DropItem(TItemPos Cell, WORD bCount)
  7086. {
  7087. LPITEM item = NULL;
  7088.  
  7089. if (!CanHandleItem())
  7090. {
  7091. if (NULL != DragonSoul_RefineWindow_GetOpener())
  7092. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Alchimie>Obiectul nu poate fi mutat atat timp cat fereastra rafinament este deschisa."));
  7093. return false;
  7094. }
  7095.  
  7096. if (IsDead())
  7097. return false;
  7098.  
  7099. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  7100. return false;
  7101.  
  7102. if (item->IsExchanging())
  7103. return false;
  7104.  
  7105. if (true == item->isLocked())
  7106. return false;
  7107.  
  7108. if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
  7109. return false;
  7110.  
  7111. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP | ITEM_ANTIFLAG_GIVE))
  7112. {
  7113. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti arunca acest item."));
  7114. return false;
  7115. }
  7116.  
  7117. if (bCount == 0 || bCount > item->GetCount())
  7118. bCount = item->GetCount();
  7119.  
  7120. SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255);
  7121.  
  7122. LPITEM pkItemToDrop;
  7123.  
  7124. if (bCount == item->GetCount())
  7125. {
  7126. item->RemoveFromCharacter();
  7127. pkItemToDrop = item;
  7128. }
  7129. else
  7130. {
  7131. if (bCount == 0)
  7132. {
  7133. if (test_server)
  7134. sys_log(0, "[DROP_ITEM] drop item count == 0");
  7135. return false;
  7136. }
  7137.  
  7138. item->SetCount(item->GetCount() - bCount);
  7139. ITEM_MANAGER::instance().FlushDelayedSave(item);
  7140.  
  7141. pkItemToDrop = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), bCount);
  7142.  
  7143. // copy item socket -- by mhh
  7144. FN_copy_item_socket(pkItemToDrop, item);
  7145.  
  7146. char szBuf[51 + 1];
  7147. snprintf(szBuf, sizeof(szBuf), "%u %u", pkItemToDrop->GetID(), pkItemToDrop->GetCount());
  7148. LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
  7149. }
  7150.  
  7151. PIXEL_POSITION pxPos = GetXYZ();
  7152.  
  7153. if (pkItemToDrop->AddToGround(GetMapIndex(), pxPos))
  7154. {
  7155. if (LC_IsYMIR())
  7156. item->AttrLog();
  7157.  
  7158. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul aruncat va disparea in 5 secunde."));
  7159. pkItemToDrop->StartDestroyEvent(6);
  7160.  
  7161. ITEM_MANAGER::instance().FlushDelayedSave(pkItemToDrop);
  7162.  
  7163. char szHint[32 + 1];
  7164. snprintf(szHint, sizeof(szHint), "%s %u %u", pkItemToDrop->GetName(), pkItemToDrop->GetCount(), pkItemToDrop->GetOriginalVnum());
  7165. LogManager::instance().ItemLog(this, pkItemToDrop, "DROP", szHint);
  7166. //Motion(MOTION_PICKUP);
  7167. }
  7168.  
  7169. return true;
  7170. }
  7171.  
  7172. bool CHARACTER::DestroyItem(TItemPos Cell, DWORD dwCount)
  7173. {
  7174.  
  7175. LPITEM item = NULL;
  7176. if (!CanHandleItem())
  7177. {
  7178. if (NULL != DragonSoul_RefineWindow_GetOpener())
  7179. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¡Æ*E*A¡ËA¡í ¢¯¡þ ¡íoAA¢¯¢®¨ù*¢¥A ¨ú¨¡AIAUA¡í ¢¯A¡¾©¡ ¨ùo ¨ú©ª¨öA¢¥I¢¥U."));
  7180. return false;
  7181. }
  7182. if (IsDead())
  7183. return false;
  7184.  
  7185. if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
  7186. return false;
  7187.  
  7188. if (item->IsExchanging())
  7189. return false;
  7190. if (true == item->isLocked())
  7191. return false;
  7192. if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
  7193. return false;
  7194. if (item->GetCount() <= 0)
  7195. return false;
  7196.  
  7197.  
  7198. //if (item->GetVnum() == 91010 || item->GetVnum() == 91011 || item->GetVnum() == 55703 || item->GetVnum() == 55704)
  7199. //{
  7200. // ChatPacket(CHAT_TYPE_INFO,("Nu poti sterge acest obiect."));
  7201. // return false;
  7202. //}
  7203. //DnD obiect util care nu poate fii sters (functional)
  7204. #ifdef NEW_PET_SYSTEM
  7205. if (GetNewPetSystem()->IsActivePet())
  7206. {
  7207. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Mai intai trimite pet-ul"));
  7208. return false;
  7209. }
  7210. #endif
  7211. SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255);
  7212. ITEM_MANAGER::instance().RemoveItem(item);
  7213.  
  7214. #ifdef ENABLE_SPECIAL_STORAGE
  7215. if (Cell.IsSpecialInventory())
  7216. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai distrus |cFFff0000|H|h[%s]|H|h|r din depozitul special !"), item->GetName());
  7217. else
  7218. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai distrus:[%s] !"), item->GetName());
  7219. #else
  7220. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai distrus:[%s] !"), item->GetName());
  7221. #endif
  7222.  
  7223. #ifdef __BATTLE_PASS__
  7224. if (!v_counts.empty())
  7225. {
  7226. for (int i=0; i<missions_bp.size(); ++i)
  7227. {
  7228. if (missions_bp[i].type == 4)
  7229. {
  7230. DoMission(i, item->GetCount());
  7231. }
  7232. }
  7233. }
  7234. #endif
  7235.  
  7236. return true;
  7237. }
  7238.  
  7239. #ifdef DISABLE_GOLD_DROP
  7240. bool CHARACTER::DropGold(int gold)
  7241. {
  7242. return false;
  7243. }
  7244. #endif
  7245.  
  7246. bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, WORD count)
  7247. {
  7248. LPITEM item = NULL;
  7249.  
  7250. if (!IsValidItemPosition(Cell))
  7251. return false;
  7252.  
  7253. if (!(item = GetItem(Cell)))
  7254. return false;
  7255.  
  7256. if (item->IsExchanging())
  7257. return false;
  7258.  
  7259. if (item->GetCount() < count)
  7260. return false;
  7261.  
  7262. if (INVENTORY == Cell.window_type && Cell.cell >= INVENTORY_MAX_NUM && IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
  7263. return false;
  7264.  
  7265. if (true == item->isLocked())
  7266. return false;
  7267.  
  7268. if (!IsValidItemPosition(DestCell))
  7269. {
  7270. return false;
  7271. }
  7272.  
  7273. if (!CanHandleItem())
  7274. {
  7275. if (NULL != DragonSoul_RefineWindow_GetOpener())
  7276. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Belt>Acest articol nu poate fi mutat aici"));
  7277. return false;
  7278. }
  7279.  
  7280. if (DestCell.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(item))
  7281. {
  7282. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Belt>Acest articol nu poate fi mutat aici."));
  7283. return false;
  7284. }
  7285. #ifdef ENABLE_SPECIAL_STORAGE
  7286. if (!item->IsUpgradeItem() && UPGRADE_INVENTORY == DestCell.window_type)
  7287. {
  7288. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
  7289. return false;
  7290. }
  7291. if (!item->IsBook() && BOOK_INVENTORY == DestCell.window_type)
  7292. {
  7293. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
  7294. return false;
  7295. }
  7296. if (!item->IsStone() && STONE_INVENTORY == DestCell.window_type)
  7297. {
  7298. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
  7299. return false;
  7300. }
  7301. if (!item->IsDnd() && DND_INVENTORY == DestCell.window_type)
  7302. {
  7303. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
  7304. return false;
  7305. }
  7306. if (!item->IsGear() && GEAR_INVENTORY == DestCell.window_type)
  7307. {
  7308. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
  7309. return false;
  7310. }
  7311. #endif
  7312.  
  7313. #ifdef __ATTR_SWITCH_SYSTEM__
  7314. if (Cell.IsSwitchbotPosition() && CSwitchbotManager::Instance().IsActive(GetPlayerID(), Cell.cell))
  7315. {
  7316. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot move active items here."));
  7317. return false;
  7318. }
  7319.  
  7320. if (DestCell.IsSwitchbotPosition() && !SwitchbotHelper::IsValidItem(item))
  7321. {
  7322. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot move this item here."));
  7323. return false;
  7324. }
  7325.  
  7326. if ((DestCell.IsSwitchbotPosition() && item->IsEquipped()) || (Cell.IsSwitchbotPosition() && DestCell.IsEquipPosition()))
  7327. {
  7328. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot move equiped items here."));
  7329. return false;
  7330. }
  7331. #endif
  7332. if (Cell.IsEquipPosition())
  7333. {
  7334. if (!CanUnequipNow(item))
  7335. return false;
  7336.  
  7337. #ifdef ENABLE_WEAPON_COSTUME_SYSTEM
  7338. int iWearCell = item->FindEquipCell(this);
  7339. if (iWearCell == WEAR_WEAPON)
  7340. {
  7341. LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
  7342. if (costumeWeapon && !UnequipItem(costumeWeapon))
  7343. {
  7344. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
  7345. return false;
  7346. }
  7347.  
  7348. if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
  7349. return UnequipItem(item);
  7350. }
  7351. #endif
  7352. }
  7353.  
  7354. if (DestCell.IsEquipPosition())
  7355. {
  7356. if (GetItem(DestCell))
  7357. {
  7358. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Alchimie>Ai adaugat Piatra Dragon cu succes!"));
  7359.  
  7360. return false;
  7361. }
  7362.  
  7363. EquipItem(item, DestCell.cell - INVENTORY_MAX_NUM);
  7364. }
  7365. else
  7366. {
  7367. if (item->IsDragonSoul())
  7368. {
  7369. if (item->IsEquipped())
  7370. {
  7371. return DSManager::instance().PullOut(this, DestCell, item);
  7372. }
  7373. else
  7374. {
  7375. if (DestCell.window_type != DRAGON_SOUL_INVENTORY)
  7376. {
  7377. return false;
  7378. }
  7379.  
  7380. if (!DSManager::instance().IsValidCellForThisItem(item, DestCell))
  7381. return false;
  7382. }
  7383. }
  7384. else if (DRAGON_SOUL_INVENTORY == DestCell.window_type)
  7385. return false;
  7386.  
  7387. #ifdef ENABLE_SPECIAL_STORAGE
  7388. if (!item->IsUpgradeItem() && UPGRADE_INVENTORY == DestCell.window_type)
  7389. return false;
  7390.  
  7391. if (!item->IsBook() && BOOK_INVENTORY == DestCell.window_type)
  7392. return false;
  7393.  
  7394. if (!item->IsStone() && STONE_INVENTORY == DestCell.window_type)
  7395. return false;
  7396.  
  7397. if (!item->IsDnd() && DND_INVENTORY == DestCell.window_type)
  7398. return false;
  7399.  
  7400. if (!item->IsGear() && GEAR_INVENTORY == DestCell.window_type)
  7401. return false;
  7402. #endif
  7403. LPITEM item2;
  7404.  
  7405. if ((item2 = GetItem(DestCell)) && item != item2 && item2->IsStackable() &&
  7406. !IS_SET(item2->GetAntiFlag(), ITEM_ANTIFLAG_STACK) &&
  7407. item2->GetVnum() == item->GetVnum())
  7408. {
  7409. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  7410. if (item2->GetSocket(i) != item->GetSocket(i))
  7411. return false;
  7412.  
  7413. if (count == 0)
  7414. count = item->GetCount();
  7415.  
  7416. //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,
  7417. //DestCell.window_type, DestCell.cell, count);
  7418.  
  7419. count = MIN(ITEM_MAX_COUNT - item2->GetCount(), count);
  7420.  
  7421. item->SetCount(item->GetCount() - count);
  7422. item2->SetCount(item2->GetCount() + count);
  7423. return true;
  7424. }
  7425.  
  7426. if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
  7427. return false;
  7428.  
  7429. if (count == 0 || count >= item->GetCount() || !item->IsStackable() || IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7430. {
  7431. //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,
  7432. //DestCell.window_type, DestCell.cell, count);
  7433.  
  7434. item->RemoveFromCharacter();
  7435. #ifdef ENABLE_HIGHLIGHT_NEW_ITEM
  7436. SetItem(DestCell, item, true);
  7437. #else
  7438. SetItem(DestCell, item);
  7439. #endif
  7440. #ifdef ENABLE_PET_SLOT
  7441. if(ITEM_NORMAL_PET == item->GetType())
  7442. {
  7443. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  7444. }
  7445. #endif
  7446. if (INVENTORY == Cell.window_type && INVENTORY == DestCell.window_type)
  7447. SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, DestCell.cell);
  7448. }
  7449. else if (count < item->GetCount())
  7450. {
  7451. 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,
  7452. DestCell.window_type, DestCell.cell, count);
  7453.  
  7454. item->SetCount(item->GetCount() - count);
  7455. LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), count);
  7456.  
  7457. FN_copy_item_socket(item2, item);
  7458.  
  7459. item2->AddToCharacter(this, DestCell);
  7460.  
  7461. char szBuf[51+1];
  7462. snprintf(szBuf, sizeof(szBuf), "%u %u %u %u ", item2->GetID(), item2->GetCount(), item->GetCount(), item->GetCount() + item2->GetCount());
  7463. LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
  7464. }
  7465. }
  7466.  
  7467. return true;
  7468. }
  7469.  
  7470. namespace NPartyPickupDistribute
  7471. {
  7472. struct FFindOwnership
  7473. {
  7474. LPITEM item;
  7475. LPCHARACTER owner;
  7476.  
  7477. FFindOwnership(LPITEM item)
  7478. : item(item), owner(NULL)
  7479. {
  7480. }
  7481.  
  7482. void operator () (LPCHARACTER ch)
  7483. {
  7484. if (item->IsOwnership(ch))
  7485. owner = ch;
  7486. }
  7487. };
  7488.  
  7489. struct FCountNearMember
  7490. {
  7491. int total;
  7492. int x, y;
  7493.  
  7494. FCountNearMember(LPCHARACTER center )
  7495. : total(0), x(center->GetX()), y(center->GetY())
  7496. {
  7497. }
  7498.  
  7499. void operator () (LPCHARACTER ch)
  7500. {
  7501. if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
  7502. total += 1;
  7503. }
  7504. };
  7505.  
  7506. struct FMoneyDistributor
  7507. {
  7508. int total;
  7509. LPCHARACTER c;
  7510. int x, y;
  7511. int iMoney;
  7512.  
  7513. FMoneyDistributor(LPCHARACTER center, int iMoney)
  7514. : total(0), c(center), x(center->GetX()), y(center->GetY()), iMoney(iMoney)
  7515. {
  7516. }
  7517.  
  7518. void operator ()(LPCHARACTER ch)
  7519. {
  7520. if (ch!=c)
  7521. if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
  7522. {
  7523. ch->PointChange(POINT_GOLD, iMoney, true);
  7524.  
  7525. if (iMoney > 1000)
  7526. LogManager::instance().CharLog(ch, iMoney, "GET_GOLD", "");
  7527. }
  7528. }
  7529. };
  7530. }
  7531.  
  7532. void CHARACTER::GiveGold(long long iAmount)
  7533. {
  7534. if (iAmount <= 0)
  7535. return;
  7536.  
  7537. sys_log(0, "GIVE_GOLD: %s %lld", GetName(), iAmount);
  7538.  
  7539. if (GetParty())
  7540. {
  7541. LPPARTY pParty = GetParty();
  7542.  
  7543. long long dwTotal = iAmount;
  7544. long long dwMyAmount = dwTotal;
  7545.  
  7546. NPartyPickupDistribute::FCountNearMember funcCountNearMember(this);
  7547. pParty->ForEachOnlineMember(funcCountNearMember);
  7548.  
  7549. if (funcCountNearMember.total > 1)
  7550. {
  7551. DWORD dwShare = dwTotal / funcCountNearMember.total;
  7552. dwMyAmount -= dwShare * (funcCountNearMember.total - 1);
  7553.  
  7554. NPartyPickupDistribute::FMoneyDistributor funcMoneyDist(this, dwShare);
  7555.  
  7556. pParty->ForEachOnlineMember(funcMoneyDist);
  7557. }
  7558.  
  7559. PointChange(POINT_GOLD, dwMyAmount, true);
  7560.  
  7561. if (dwMyAmount > 1000)
  7562. LogManager::instance().CharLog(this, dwMyAmount, "GET_GOLD", "");
  7563. }
  7564. else
  7565. {
  7566. PointChange(POINT_GOLD, iAmount, true);
  7567.  
  7568. if (LC_IsBrazil() == true)
  7569. {
  7570. if (iAmount >= 213)
  7571. LogManager::instance().CharLog(this, iAmount, "GET_GOLD", "");
  7572. }
  7573. else
  7574. {
  7575. if (iAmount > 1000)
  7576. LogManager::instance().CharLog(this, iAmount, "GET_GOLD", "");
  7577. }
  7578. }
  7579. }
  7580.  
  7581. bool CHARACTER::PickupItem(DWORD dwVID)
  7582. {
  7583. LPITEM item = ITEM_MANAGER::instance().FindByVID(dwVID);
  7584.  
  7585. if (IsObserverMode())
  7586. return false;
  7587.  
  7588. if (!item || !item->GetSectree())
  7589. return false;
  7590.  
  7591. if (item->DistanceValid(this))
  7592. {
  7593. // @fixme150 BEGIN
  7594. if (item->GetType() == ITEM_QUEST)
  7595. {
  7596. if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
  7597. {
  7598. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot pickup this item if you're using quests"));
  7599. return false;
  7600. }
  7601. }
  7602. // @fixme150 END
  7603. if (item->IsOwnership(this))
  7604. {
  7605. if (item->GetType() == ITEM_ELK)
  7606. {
  7607. GiveGold(item->GetCount());
  7608. item->RemoveFromGround();
  7609.  
  7610. M2_DESTROY_ITEM(item);
  7611.  
  7612. Save();
  7613. }
  7614. else
  7615. {
  7616. if ((item->IsBook() || item->IsUpgradeItem() || item->IsStone() || item->IsDnd() || item->IsGear()) && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7617. {
  7618. #ifdef ENABLE_SPECIAL_STORAGE
  7619. if (item->IsUpgradeItem())
  7620. {
  7621. WORD bCount = item->GetCount();
  7622.  
  7623. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  7624. {
  7625. LPITEM item2 = GetUpgradeInventoryItem(i);
  7626.  
  7627. if (!item2)
  7628. continue;
  7629.  
  7630. if (item2->GetVnum() == item->GetVnum())
  7631. {
  7632. int j;
  7633.  
  7634. for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
  7635. if (item2->GetSocket(j) != item->GetSocket(j))
  7636. break;
  7637.  
  7638. if (j != ITEM_SOCKET_MAX_NUM)
  7639. continue;
  7640.  
  7641. WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
  7642. bCount -= bCount2;
  7643.  
  7644. item2->SetCount(item2->GetCount() + bCount2);
  7645. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item2->GetName());
  7646.  
  7647. if (bCount == 0)
  7648. {
  7649. M2_DESTROY_ITEM(item);
  7650. if (item2->GetType() == ITEM_QUEST)
  7651. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
  7652. return true;
  7653. }
  7654. }
  7655. }
  7656.  
  7657. item->SetCount(bCount);
  7658. }
  7659. else if (item->IsBook() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7660. {
  7661. WORD bCount = item->GetCount();
  7662.  
  7663. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  7664. {
  7665. LPITEM item2 = GetBookInventoryItem(i);
  7666.  
  7667. if (!item2)
  7668. continue;
  7669.  
  7670. if (item2->GetVnum() == item->GetVnum())
  7671. {
  7672. int j;
  7673.  
  7674. for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
  7675. if (item2->GetSocket(j) != item->GetSocket(j))
  7676. break;
  7677.  
  7678. if (j != ITEM_SOCKET_MAX_NUM)
  7679. continue;
  7680.  
  7681. WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
  7682. bCount -= bCount2;
  7683.  
  7684. item2->SetCount(item2->GetCount() + bCount2);
  7685.  
  7686. if (bCount == 0)
  7687. {
  7688. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item2->GetName());
  7689. M2_DESTROY_ITEM(item);
  7690. if (item2->GetType() == ITEM_SKILLBOOK)
  7691. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
  7692. return true;
  7693. }
  7694. }
  7695. }
  7696.  
  7697. item->SetCount(bCount);
  7698. }
  7699. else if (item->IsStone() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7700. {
  7701. WORD bCount = item->GetCount();
  7702.  
  7703. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  7704. {
  7705. LPITEM item2 = GetStoneInventoryItem(i);
  7706.  
  7707. if (!item2)
  7708. continue;
  7709.  
  7710. if (item2->GetVnum() == item->GetVnum())
  7711. {
  7712. int j;
  7713.  
  7714. for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
  7715. if (item2->GetSocket(j) != item->GetSocket(j))
  7716. break;
  7717.  
  7718. if (j != ITEM_SOCKET_MAX_NUM)
  7719. continue;
  7720.  
  7721. WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
  7722. bCount -= bCount2;
  7723.  
  7724. item2->SetCount(item2->GetCount() + bCount2);
  7725.  
  7726. if (bCount == 0)
  7727. {
  7728. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item2->GetName());
  7729. M2_DESTROY_ITEM(item);
  7730. if (item2->GetType() == ITEM_METIN)
  7731. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
  7732. return true;
  7733. }
  7734. }
  7735. }
  7736.  
  7737. item->SetCount(bCount);
  7738. }
  7739. else if (item->IsDnd() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7740.  
  7741. {
  7742. WORD bCount = item->GetCount();
  7743.  
  7744. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  7745. {
  7746. LPITEM item2 = GetDndInventoryItem(i);
  7747.  
  7748. if (!item2)
  7749. continue;
  7750.  
  7751. if (item2->GetVnum() == item->GetVnum())
  7752. {
  7753.  
  7754. WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
  7755. bCount -= bCount2;
  7756.  
  7757. item2->SetCount(item2->GetCount() + bCount2);
  7758.  
  7759. if (bCount == 0)
  7760. {
  7761. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item2->GetName());
  7762. M2_DESTROY_ITEM(item);
  7763. return true;
  7764. }
  7765. }
  7766. }
  7767.  
  7768. item->SetCount(bCount);
  7769. }
  7770. else if (item->IsGear() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
  7771. {
  7772. WORD bCount = item->GetCount();
  7773.  
  7774. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  7775. {
  7776. LPITEM item2 = GetGearInventoryItem(i);
  7777.  
  7778. if (!item2)
  7779. continue;
  7780.  
  7781. if (item2->GetVnum() == item->GetVnum())
  7782. {
  7783.  
  7784. WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
  7785. bCount -= bCount2;
  7786.  
  7787. item2->SetCount(item2->GetCount() + bCount2);
  7788.  
  7789. if (bCount == 0)
  7790. {
  7791. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special "), item2->GetName());
  7792.  
  7793. M2_DESTROY_ITEM(item);
  7794. return true;
  7795. }
  7796. }
  7797. }
  7798.  
  7799. item->SetCount(bCount);
  7800. }
  7801. #endif
  7802. else
  7803. {
  7804. WORD bCount = item->GetCount();
  7805.  
  7806. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  7807. {
  7808. LPITEM item2 = GetInventoryItem(i);
  7809.  
  7810. if (!item2)
  7811. continue;
  7812.  
  7813. if (item2->GetVnum() == item->GetVnum())
  7814. {
  7815. int j;
  7816.  
  7817. for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
  7818. if (item2->GetSocket(j) != item->GetSocket(j))
  7819. break;
  7820.  
  7821. if (j != ITEM_SOCKET_MAX_NUM)
  7822. continue;
  7823.  
  7824. WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
  7825. bCount -= bCount2;
  7826.  
  7827. item2->SetCount(item2->GetCount() + bCount2);
  7828.  
  7829. if (bCount == 0)
  7830. {
  7831. ChatPacket(CHAT_TYPE_INFO,("Ai primit %s"), item2->GetName()); //Nu
  7832. M2_DESTROY_ITEM(item);
  7833. if (item2->GetType() == ITEM_QUEST)
  7834. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
  7835. return true;
  7836. }
  7837. }
  7838. }
  7839. item->SetCount(bCount);
  7840. #ifdef ENABLE_SPECIAL_STORAGE
  7841. }
  7842. #endif
  7843. }
  7844.  
  7845. int iEmptyCell;
  7846. if (item->IsDragonSoul())
  7847. {
  7848. if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
  7849. {
  7850. sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7851. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  7852. return false;
  7853. }
  7854. }
  7855. #ifdef ENABLE_SPECIAL_STORAGE
  7856. else if (item->IsUpgradeItem())
  7857. {
  7858. if ((iEmptyCell = GetEmptyUpgradeInventory(item)) == -1)
  7859. {
  7860. sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7861. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  7862. return false;
  7863. }
  7864. }
  7865. else if (item->IsBook())
  7866. {
  7867. if ((iEmptyCell = GetEmptyBookInventory(item)) == -1)
  7868. {
  7869. sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7870. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  7871. return false;
  7872. }
  7873. }
  7874. else if (item->IsStone())
  7875. {
  7876. if ((iEmptyCell = GetEmptyStoneInventory(item)) == -1)
  7877. {
  7878. sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7879. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  7880. return false;
  7881. }
  7882. }
  7883. else if (item->IsDnd())
  7884. {
  7885. if ((iEmptyCell = GetEmptyDndInventory(item)) == -1)
  7886. {
  7887. sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7888. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  7889. return false;
  7890. }
  7891. }
  7892. else if (item->IsGear())
  7893. {
  7894. if ((iEmptyCell = GetEmptyGearInventory(item)) == -1)
  7895. {
  7896. sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7897. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
  7898. return false;
  7899. }
  7900. }
  7901. #endif
  7902. else
  7903. {
  7904. if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
  7905. {
  7906. sys_log(0, "No empty inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
  7907. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  7908. return false;
  7909. }
  7910. }
  7911.  
  7912. item->RemoveFromGround();
  7913.  
  7914. if (item->IsDragonSoul())
  7915. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
  7916. #ifdef ENABLE_SPECIAL_STORAGE
  7917. else if (item->IsUpgradeItem())
  7918. {
  7919. item->AddToCharacter(this, TItemPos(UPGRADE_INVENTORY, iEmptyCell));
  7920. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  7921. }
  7922. else if (item->IsBook())
  7923. {
  7924. item->AddToCharacter(this, TItemPos(BOOK_INVENTORY, iEmptyCell));
  7925. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
  7926. }
  7927. else if (item->IsStone())
  7928. {
  7929. item->AddToCharacter(this, TItemPos(STONE_INVENTORY, iEmptyCell));
  7930. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
  7931. }
  7932. else if (item->IsDnd())
  7933. {
  7934. item->AddToCharacter(this, TItemPos(DND_INVENTORY, iEmptyCell));
  7935. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cufarul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  7936. }
  7937. else if (item->IsGear())
  7938. {
  7939. item->AddToCharacter(this, TItemPos(GEAR_INVENTORY, iEmptyCell));
  7940. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special! "), item->GetName());
  7941. }
  7942. #endif
  7943. else
  7944. {
  7945. item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
  7946. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s"), item->GetName()); //EDIT DND
  7947. }
  7948. char szHint[32+1];
  7949. snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
  7950. LogManager::instance().ItemLog(this, item, "GET", szHint);
  7951.  
  7952. if (item->GetType() == ITEM_QUEST)
  7953. quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
  7954. }
  7955.  
  7956. //Motion(MOTION_PICKUP);
  7957. return true;
  7958. }
  7959. else if (!IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_DROP) && GetParty())
  7960. {
  7961. NPartyPickupDistribute::FFindOwnership funcFindOwnership(item);
  7962.  
  7963. GetParty()->ForEachOnlineMember(funcFindOwnership);
  7964.  
  7965. LPCHARACTER owner = funcFindOwnership.owner;
  7966. // @fixme115
  7967. if (!owner)
  7968. return false;
  7969.  
  7970. int iEmptyCell;
  7971.  
  7972. if (item->IsDragonSoul())
  7973. {
  7974. if (!(owner && (iEmptyCell = owner->GetEmptyDragonSoulInventory(item)) != -1))
  7975. {
  7976. owner = this;
  7977.  
  7978. if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
  7979. {
  7980. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  7981. return false;
  7982. }
  7983. }
  7984. }
  7985. #ifdef ENABLE_SPECIAL_STORAGE
  7986. else if (item->IsUpgradeItem())
  7987. {
  7988. if (!(owner && (iEmptyCell = owner->GetEmptyUpgradeInventory(item)) != -1))
  7989. {
  7990. owner = this;
  7991.  
  7992. if ((iEmptyCell = GetEmptyUpgradeInventory(item)) == -1)
  7993. {
  7994. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  7995. return false;
  7996. }
  7997. }
  7998. }
  7999. else if (item->IsBook())
  8000. {
  8001. if (!(owner && (iEmptyCell = owner->GetEmptyBookInventory(item)) != -1))
  8002. {
  8003. owner = this;
  8004.  
  8005. if ((iEmptyCell = GetEmptyBookInventory(item)) == -1)
  8006. {
  8007. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  8008. return false;
  8009. }
  8010. }
  8011. }
  8012. else if (item->IsStone())
  8013. {
  8014. if (!(owner && (iEmptyCell = owner->GetEmptyStoneInventory(item)) != -1))
  8015. {
  8016. owner = this;
  8017.  
  8018. if ((iEmptyCell = GetEmptyStoneInventory(item)) == -1)
  8019. {
  8020. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  8021. return false;
  8022. }
  8023. }
  8024. }
  8025. else if (item->IsDnd())
  8026. {
  8027. if (!(owner && (iEmptyCell = owner->GetEmptyDndInventory(item)) != -1))
  8028. {
  8029. owner = this;
  8030.  
  8031. if ((iEmptyCell = GetEmptyDndInventory(item)) == -1)
  8032. {
  8033. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  8034. return false;
  8035. }
  8036. }
  8037. }
  8038. else if (item->IsGear())
  8039. {
  8040. if (!(owner && (iEmptyCell = owner->GetEmptyGearInventory(item)) != -1))
  8041. {
  8042. owner = this;
  8043.  
  8044. if ((iEmptyCell = GetEmptyGearInventory(item)) == -1)
  8045. {
  8046. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  8047. return false;
  8048. }
  8049. }
  8050. }
  8051. #endif
  8052. else
  8053. {
  8054. if (!(owner && (iEmptyCell = owner->GetEmptyInventory(item->GetSize())) != -1))
  8055. {
  8056. owner = this;
  8057.  
  8058. if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
  8059. {
  8060. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
  8061. return false;
  8062. }
  8063. }
  8064. }
  8065.  
  8066. item->RemoveFromGround();
  8067.  
  8068. if (item->IsDragonSoul())
  8069. item->AddToCharacter(owner, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
  8070. #ifdef ENABLE_SPECIAL_STORAGE
  8071. else if (item->IsUpgradeItem())
  8072. item->AddToCharacter(owner, TItemPos(UPGRADE_INVENTORY, iEmptyCell));
  8073. else if (item->IsBook())
  8074. item->AddToCharacter(owner, TItemPos(BOOK_INVENTORY, iEmptyCell));
  8075. else if (item->IsStone())
  8076. item->AddToCharacter(owner, TItemPos(STONE_INVENTORY, iEmptyCell));
  8077. else if (item->IsDnd())
  8078. item->AddToCharacter(owner, TItemPos(DND_INVENTORY, iEmptyCell));
  8079. else if (item->IsGear())
  8080. item->AddToCharacter(owner, TItemPos(GEAR_INVENTORY, iEmptyCell));
  8081. #endif
  8082. else
  8083. item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
  8084.  
  8085. char szHint[32+1];
  8086. snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
  8087. LogManager::instance().ItemLog(owner, item, "GET", szHint);
  8088.  
  8089. if (owner == this)
  8090. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit %s"), item->GetName()); // Nu
  8091. else
  8092. {
  8093. owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s de la %s"), GetName(), item->GetName());
  8094. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai dat %s lui %s"), owner->GetName(), item->GetName());
  8095. }
  8096.  
  8097. if (item->GetType() == ITEM_QUEST)
  8098. quest::CQuestManager::instance().PickupItem (owner->GetPlayerID(), item);
  8099.  
  8100. return true;
  8101. }
  8102. }
  8103.  
  8104. return false;
  8105. }
  8106.  
  8107. bool CHARACTER::SwapItem(BYTE bCell, BYTE bDestCell)
  8108. {
  8109. if (!CanHandleItem())
  8110. return false;
  8111.  
  8112. TItemPos srcCell(INVENTORY, bCell), destCell(INVENTORY, bDestCell);
  8113. if (srcCell.IsDragonSoulEquipPosition() || destCell.IsDragonSoulEquipPosition())
  8114. return false;
  8115.  
  8116. if (bCell == bDestCell)
  8117. return false;
  8118.  
  8119. if (srcCell.IsEquipPosition() && destCell.IsEquipPosition())
  8120. return false;
  8121.  
  8122. LPITEM item1, item2;
  8123.  
  8124. if (srcCell.IsEquipPosition())
  8125. {
  8126. item1 = GetInventoryItem(bDestCell);
  8127. item2 = GetInventoryItem(bCell);
  8128. }
  8129. else
  8130. {
  8131. item1 = GetInventoryItem(bCell);
  8132. item2 = GetInventoryItem(bDestCell);
  8133. }
  8134.  
  8135. if (!item1 || !item2)
  8136. return false;
  8137.  
  8138. if (item1 == item2)
  8139. {
  8140. sys_log(0, "[WARNING][WARNING][HACK USER!] : %s %d %d", m_stName.c_str(), bCell, bDestCell);
  8141. return false;
  8142. }
  8143.  
  8144. if (!IsEmptyItemGrid(TItemPos (INVENTORY, item1->GetCell()), item2->GetSize(), item1->GetCell()))
  8145. return false;
  8146.  
  8147. if (TItemPos(EQUIPMENT, item2->GetCell()).IsEquipPosition())
  8148. {
  8149. BYTE bEquipCell = item2->GetCell() - INVENTORY_MAX_NUM;
  8150. BYTE bInvenCell = item1->GetCell();
  8151.  
  8152. #ifdef CHANGE_EQ_FULL_INV_FIX
  8153. if (false == CanEquipNow(item1))
  8154. return false;
  8155. if (item2->IsDragonSoul() && false == CanUnequipNow(item2))
  8156. return false;
  8157. #endif
  8158.  
  8159. if (item2->IsDragonSoul() || item2->GetType() == ITEM_BELT) // @fixme117
  8160. {
  8161. if (false == CanUnequipNow(item2) || false == CanEquipNow(item1))
  8162. return false;
  8163. }
  8164.  
  8165. if (GetWear(WEAR_COSTUME_WEAPON) && item1->GetType() == ITEM_ROD || GetWear(WEAR_COSTUME_WEAPON) && item1->GetType() == ITEM_PICK) // // block fish rod and pick
  8166. {
  8167. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("costume_weapon_on_rod"));
  8168. return false;
  8169. }
  8170.  
  8171. if (bEquipCell != item1->FindEquipCell(this))
  8172. return false;
  8173.  
  8174. #ifdef ENABLE_PET_SLOT
  8175. if(ITEM_NORMAL_PET == item2->GetType())
  8176. {
  8177. quest::CQuestManager::instance().UseItem(GetPlayerID(), item2, false);
  8178. }
  8179. #endif
  8180.  
  8181. item2->RemoveFromCharacter();
  8182.  
  8183. if (item1->EquipTo(this, bEquipCell))
  8184. item2->AddToCharacter(this, TItemPos(INVENTORY, bInvenCell));
  8185. else
  8186. sys_err("SwapItem cannot equip %s! item1 %s", item2->GetName(), item1->GetName());
  8187. }
  8188. else
  8189. {
  8190. BYTE bCell1 = item1->GetCell();
  8191. BYTE bCell2 = item2->GetCell();
  8192.  
  8193. item1->RemoveFromCharacter();
  8194. item2->RemoveFromCharacter();
  8195.  
  8196. item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2));
  8197. item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1));
  8198. }
  8199.  
  8200. return true;
  8201. }
  8202.  
  8203. bool CHARACTER::UnequipItem(LPITEM item)
  8204. {
  8205. #ifdef ENABLE_WEAPON_COSTUME_SYSTEM
  8206. int iWearCell = item->FindEquipCell(this);
  8207. if (iWearCell == WEAR_WEAPON)
  8208. {
  8209. LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
  8210. if (costumeWeapon && !UnequipItem(costumeWeapon))
  8211. {
  8212. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
  8213. return false;
  8214. }
  8215. }
  8216. #endif
  8217.  
  8218. if (false == CanUnequipNow(item))
  8219. return false;
  8220.  
  8221. int pos;
  8222. if (item->IsDragonSoul())
  8223. pos = GetEmptyDragonSoulInventory(item);
  8224. #ifdef ENABLE_SPECIAL_STORAGE
  8225. else if (item->IsBook())
  8226. pos = GetEmptyBookInventory(item);
  8227. else if (item->IsUpgradeItem())
  8228. pos = GetEmptyUpgradeInventory(item);
  8229. else if (item->IsStone())
  8230. pos = GetEmptyStoneInventory(item);
  8231. else if (item->IsDnd())
  8232. pos = GetEmptyDndInventory(item);
  8233. else if (item->IsGear())
  8234. pos = GetEmptyGearInventory(item);
  8235. #endif
  8236. else
  8237. pos = GetEmptyInventory(item->GetSize());
  8238.  
  8239. // HARD CODING
  8240. if (item->GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
  8241. ShowAlignment(true);
  8242.  
  8243. #ifdef ENABLE_PET_SLOT
  8244. if(ITEM_NORMAL_PET == item->GetType())
  8245. {
  8246. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  8247. }
  8248. #endif
  8249.  
  8250. item->RemoveFromCharacter();
  8251. if (item->IsDragonSoul())
  8252. {
  8253. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, pos));
  8254. }
  8255. else
  8256. item->AddToCharacter(this, TItemPos(INVENTORY, pos));
  8257.  
  8258. CheckMaximumPoints();
  8259.  
  8260. return true;
  8261. }
  8262.  
  8263. bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
  8264. {
  8265. #ifdef BELT_INVENTORY_FIX
  8266. LPITEM belt1,belt2;
  8267. #endif
  8268. if (item->IsExchanging())
  8269. return false;
  8270.  
  8271. if (false == item->IsEquipable())
  8272. return false;
  8273.  
  8274. if (false == CanEquipNow(item))
  8275. return false;
  8276.  
  8277. int iWearCell = item->FindEquipCell(this, iCandidateCell);
  8278. TItemPos srcCell(INVENTORY, item->GetCell()), destCell(INVENTORY, INVENTORY_MAX_NUM + iWearCell);
  8279. if (iWearCell < 0)
  8280. return false;
  8281.  
  8282. if (iWearCell != WEAR_ARROW && IsPolymorphed())
  8283. {
  8284. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu iti poti schimba itemele cat timp esti transformat."));
  8285. return false;
  8286. }
  8287. //fix dnd costum nunta end
  8288. if (GetWear(WEAR_COSTUME_BODY) && item->GetVnum() >= 11901 && item->GetVnum() <= 11904)
  8289. {
  8290. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti purta un costum atat timp cat ai echipat un obiect de nunta."));
  8291. return false;
  8292. }
  8293.  
  8294. if (FN_check_item_sex(this, item) == false)
  8295. {
  8296. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest articol nu poate fi deschis deoarece sexul este incorect"));
  8297. return false;
  8298. }
  8299.  
  8300. if(item->IsRideItem() && IsRiding())
  8301. {
  8302. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Poti sa te dai jos de pe acest mount apasand ctrl + g !."));
  8303. return false;
  8304. }
  8305.  
  8306. DWORD dwCurTime = get_dword_time();
  8307.  
  8308. if (iWearCell != WEAR_ARROW
  8309. && (dwCurTime - GetLastAttackTime() <= 1500 || dwCurTime - m_dwLastSkillTime <= 1500))
  8310. {
  8311. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
  8312. return false;
  8313. }
  8314. #ifdef ENABLE_WEAPON_COSTUME_SYSTEM
  8315. if (iWearCell == WEAR_WEAPON)
  8316. {
  8317. if (item->GetType() == ITEM_WEAPON)
  8318. {
  8319. LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
  8320. if (costumeWeapon && costumeWeapon->GetValue(3) != item->GetSubType() && !UnequipItem(costumeWeapon))
  8321. {
  8322. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
  8323. return false;
  8324. }
  8325. }
  8326. else //fishrod/pickaxe
  8327. {
  8328. LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
  8329. if (costumeWeapon && !UnequipItem(costumeWeapon))
  8330. {
  8331. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
  8332. return false;
  8333. }
  8334. }
  8335. }
  8336. else if (iWearCell == WEAR_COSTUME_WEAPON)
  8337. {
  8338. if (item->GetType() == ITEM_COSTUME && item->GetSubType() == COSTUME_WEAPON)
  8339. {
  8340. LPITEM pkWeapon = GetWear(WEAR_WEAPON);
  8341. if (!pkWeapon || pkWeapon->GetType() != ITEM_WEAPON || item->GetValue(3) != pkWeapon->GetSubType())
  8342. {
  8343. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot equip the costume weapon. Wrong equipped weapon."));
  8344. return false;
  8345. }
  8346. }
  8347. }
  8348. #endif
  8349.  
  8350. if (item->IsDragonSoul())
  8351. {
  8352. if(GetInventoryItem(INVENTORY_MAX_NUM + iWearCell))
  8353. {
  8354. ChatPacket(CHAT_TYPE_INFO, "ÀÌ¹Ì °°Àº Á¾·ùÀÇ ¿ëÈ¥¼®À» Âø¿ëÇϰí ÀÖ½À´Ï´Ù.");
  8355. return false;
  8356. }
  8357.  
  8358. if (!item->EquipTo(this, iWearCell))
  8359. {
  8360. return false;
  8361. }
  8362. }
  8363. else
  8364. {
  8365. if (GetWear(iWearCell) && !IS_SET(GetWear(iWearCell)->GetFlag(), ITEM_FLAG_IRREMOVABLE))
  8366. {
  8367. if (item->GetWearFlag() == WEARABLE_ABILITY)
  8368. return false;
  8369.  
  8370. #ifdef BELT_INVENTORY_FIX
  8371. if (srcCell.IsEquipPosition())
  8372. {
  8373. belt1 = GetInventoryItem(INVENTORY_MAX_NUM + iWearCell);
  8374. belt2 = GetInventoryItem(item->GetCell());
  8375. }
  8376. else
  8377. {
  8378. belt1 = GetInventoryItem(item->GetCell());
  8379. belt2 = GetInventoryItem(INVENTORY_MAX_NUM + iWearCell);
  8380. }
  8381.  
  8382. if ((ITEM_BELT == belt2->GetType()) && (CBeltInventoryHelper::IsExistItemInBeltInventory(this) == true))
  8383. {
  8384. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta!"));
  8385. return false;
  8386. }
  8387. #endif
  8388.  
  8389. if (false == SwapItem(item->GetCell(), INVENTORY_MAX_NUM + iWearCell))
  8390. {
  8391. return false;
  8392. }
  8393. }
  8394. else
  8395. {
  8396. BYTE bOldCell = item->GetCell();
  8397.  
  8398. if (item->EquipTo(this, iWearCell))
  8399. {
  8400. SyncQuickslot(QUICKSLOT_TYPE_ITEM, bOldCell, iWearCell);
  8401. }
  8402. }
  8403. }
  8404.  
  8405. if (true == item->IsEquipped())
  8406. {
  8407. if (-1 != item->GetProto()->cLimitRealTimeFirstUseIndex)
  8408. {
  8409. if (0 == item->GetSocket(1))
  8410. {
  8411. long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[item->GetProto()->cLimitRealTimeFirstUseIndex].lValue;
  8412.  
  8413. if (0 == duration)
  8414. duration = 60 * 60 * 24 * 7;
  8415.  
  8416. item->SetSocket(0, time(0) + duration);
  8417. item->StartRealTimeExpireEvent();
  8418. }
  8419.  
  8420. item->SetSocket(1, item->GetSocket(1) + 1);
  8421. }
  8422.  
  8423. if (item->GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
  8424. ShowAlignment(false);
  8425.  
  8426. const DWORD& dwVnum = item->GetVnum();
  8427.  
  8428. if (true == CItemVnumHelper::IsRamadanMoonRing(dwVnum))
  8429. {
  8430. this->EffectPacket(SE_EQUIP_RAMADAN_RING);
  8431. }
  8432. else if (true == CItemVnumHelper::IsHalloweenCandy(dwVnum))
  8433. {
  8434. this->EffectPacket(SE_EQUIP_HALLOWEEN_CANDY);
  8435. }
  8436. else if (true == CItemVnumHelper::IsHappinessRing(dwVnum))
  8437. {
  8438. this->EffectPacket(SE_EQUIP_HAPPINESS_RING);
  8439. }
  8440. //(71145)
  8441. else if (true == CItemVnumHelper::IsLovePendant(dwVnum))
  8442. {
  8443. this->EffectPacket(SE_EQUIP_LOVE_PENDANT);
  8444. }
  8445. // ITEM_UNIQUEÀÇ °æ¿ì, SpecialItemGroup¿¡ Á¤ÀǵǾî ÀÖ°í, (item->GetSIGVnum() != NULL)
  8446. //
  8447. else if (true == CItemVnumHelper::IsEGY1(dwVnum))
  8448. {
  8449. this->EffectPacket(SE_EQUIP_EGY1);
  8450. }
  8451. else if (true == CItemVnumHelper::IsEGY2(dwVnum))
  8452. {
  8453. this->EffectPacket(SE_EQUIP_EGY2);
  8454. }
  8455. else if (true == CItemVnumHelper::IsSEA1(dwVnum))
  8456. {
  8457. this->EffectPacket(SE_EQUIP_SEA1);
  8458. }
  8459. else if (true == CItemVnumHelper::IsSEA2(dwVnum))
  8460. {
  8461. this->EffectPacket(SE_EQUIP_SEA2);
  8462. }
  8463. else if (true == CItemVnumHelper::IsDEM1(dwVnum))
  8464. {
  8465. this->EffectPacket(SE_EQUIP_DEM1);
  8466. }
  8467. else if (true == CItemVnumHelper::IsDEM2(dwVnum))
  8468. {
  8469. this->EffectPacket(SE_EQUIP_DEM2);
  8470. }
  8471. else if (true == CItemVnumHelper::IsATK1(dwVnum))
  8472. {
  8473. this->EffectPacket(SE_EQUIP_ATK1);
  8474. }
  8475. else if (true == CItemVnumHelper::IsAPR2(dwVnum))
  8476. {
  8477. this->EffectPacket(SE_EQUIP_APR2);
  8478. }
  8479.  
  8480. else if (ITEM_UNIQUE == item->GetType() && 0 != item->GetSIGVnum())
  8481. {
  8482. const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(item->GetSIGVnum());
  8483. if (NULL != pGroup)
  8484. {
  8485. const CSpecialAttrGroup* pAttrGroup = ITEM_MANAGER::instance().GetSpecialAttrGroup(pGroup->GetAttrVnum(item->GetVnum()));
  8486. if (NULL != pAttrGroup)
  8487. {
  8488. const std::string& std = pAttrGroup->m_stEffectFileName;
  8489. SpecificEffectPacket(std.c_str());
  8490. }
  8491. }
  8492. }
  8493. #ifdef __SASH_SYSTEM__
  8494. else if ((item->GetType() == ITEM_COSTUME) && (item->GetSubType() == COSTUME_SASH))
  8495. this->EffectPacket(SE_EFFECT_SASH_EQUIP);
  8496. #endif
  8497.  
  8498. if (
  8499. (ITEM_UNIQUE == item->GetType() && UNIQUE_SPECIAL_RIDE == item->GetSubType() && IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE))
  8500. || (ITEM_UNIQUE == item->GetType() && UNIQUE_SPECIAL_MOUNT_RIDE == item->GetSubType() && IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE)))
  8501. {
  8502. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  8503. }
  8504. if (COSTUME_MOUNT == item->GetSubType())
  8505. {
  8506. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  8507. }
  8508. #ifdef ENABLE_PET_SLOT
  8509. else if(ITEM_NORMAL_PET == item->GetType())
  8510. {
  8511. quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
  8512. }
  8513. #endif
  8514. }
  8515.  
  8516. return true;
  8517. }
  8518.  
  8519. void CHARACTER::BuffOnAttr_AddBuffsFromItem(LPITEM pItem)
  8520. {
  8521. for (size_t i = 0; i < sizeof(g_aBuffOnAttrPoints)/sizeof(g_aBuffOnAttrPoints[0]); i++)
  8522. {
  8523. TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(g_aBuffOnAttrPoints[i]);
  8524. if (it != m_map_buff_on_attrs.end())
  8525. {
  8526. it->second->AddBuffFromItem(pItem);
  8527. }
  8528. }
  8529. }
  8530.  
  8531. void CHARACTER::BuffOnAttr_RemoveBuffsFromItem(LPITEM pItem)
  8532. {
  8533. for (size_t i = 0; i < sizeof(g_aBuffOnAttrPoints)/sizeof(g_aBuffOnAttrPoints[0]); i++)
  8534. {
  8535. TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(g_aBuffOnAttrPoints[i]);
  8536. if (it != m_map_buff_on_attrs.end())
  8537. {
  8538. it->second->RemoveBuffFromItem(pItem);
  8539. }
  8540. }
  8541. }
  8542.  
  8543. void CHARACTER::BuffOnAttr_ClearAll()
  8544. {
  8545. for (TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.begin(); it != m_map_buff_on_attrs.end(); it++)
  8546. {
  8547. CBuffOnAttributes* pBuff = it->second;
  8548. if (pBuff)
  8549. {
  8550. pBuff->Initialize();
  8551. }
  8552. }
  8553. }
  8554.  
  8555. void CHARACTER::BuffOnAttr_ValueChange(BYTE bType, BYTE bOldValue, BYTE bNewValue)
  8556. {
  8557. TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(bType);
  8558.  
  8559. if (0 == bNewValue)
  8560. {
  8561. if (m_map_buff_on_attrs.end() == it)
  8562. return;
  8563. else
  8564. it->second->Off();
  8565. }
  8566. else if(0 == bOldValue)
  8567. {
  8568. CBuffOnAttributes* pBuff = NULL;
  8569. if (m_map_buff_on_attrs.end() == it)
  8570. {
  8571. switch (bType)
  8572. {
  8573. case POINT_ENERGY:
  8574. {
  8575. static BYTE abSlot[] = { WEAR_BODY, WEAR_HEAD, WEAR_FOOTS, WEAR_WRIST, WEAR_WEAPON, WEAR_NECK, WEAR_EAR, WEAR_SHIELD };
  8576. static std::vector <BYTE> vec_slots (abSlot, abSlot + _countof(abSlot));
  8577. pBuff = M2_NEW CBuffOnAttributes(this, bType, &vec_slots);
  8578. }
  8579. break;
  8580. case POINT_COSTUME_ATTR_BONUS:
  8581. {
  8582. static BYTE abSlot[] = {
  8583. WEAR_COSTUME_BODY,
  8584. WEAR_COSTUME_HAIR,
  8585. WEAR_COSTUME_MOUNT,
  8586. #ifdef __WEAPON_COSTUME_SYSTEM__
  8587. WEAR_COSTUME_WEAPON,
  8588. #endif
  8589. };
  8590. static std::vector <BYTE> vec_slots (abSlot, abSlot + _countof(abSlot));
  8591. pBuff = M2_NEW CBuffOnAttributes(this, bType, &vec_slots);
  8592. }
  8593. break;
  8594. default:
  8595. break;
  8596. }
  8597. m_map_buff_on_attrs.insert(TMapBuffOnAttrs::value_type(bType, pBuff));
  8598.  
  8599. }
  8600. else
  8601. pBuff = it->second;
  8602. if (pBuff != NULL)
  8603. pBuff->On(bNewValue);
  8604. }
  8605. else
  8606. {
  8607. assert (m_map_buff_on_attrs.end() != it);
  8608. it->second->ChangeBuffValue(bNewValue);
  8609. }
  8610. }
  8611.  
  8612. LPITEM CHARACTER::FindSpecifyItem(DWORD vnum) const
  8613. {
  8614. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  8615. if (GetInventoryItem(i) && GetInventoryItem(i)->GetVnum() == vnum)
  8616. return GetInventoryItem(i);
  8617.  
  8618. return NULL;
  8619. }
  8620.  
  8621. LPITEM CHARACTER::FindItemByID(DWORD id) const
  8622. {
  8623. for (int i = 0 ; i < INVENTORY_MAX_NUM ; ++i)
  8624. {
  8625. if (NULL != GetInventoryItem(i) && GetInventoryItem(i)->GetID() == id)
  8626. return GetInventoryItem(i);
  8627. }
  8628.  
  8629. for (int i=BELT_INVENTORY_SLOT_START; i < BELT_INVENTORY_SLOT_END ; ++i)
  8630. {
  8631. if (NULL != GetInventoryItem(i) && GetInventoryItem(i)->GetID() == id)
  8632. return GetInventoryItem(i);
  8633. }
  8634.  
  8635. return NULL;
  8636. }
  8637.  
  8638. int CHARACTER::CountSpecifyItem(DWORD vnum) const
  8639. {
  8640. int count = 0;
  8641. LPITEM item;
  8642.  
  8643. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  8644. {
  8645. item = GetInventoryItem(i);
  8646. if (NULL != item && item->GetVnum() == vnum)
  8647. {
  8648. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  8649. {
  8650. continue;
  8651. }
  8652. else
  8653. {
  8654. count += item->GetCount();
  8655. }
  8656. }
  8657. }
  8658. #ifdef ENABLE_SPECIAL_STORAGE
  8659. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8660. {
  8661. item = GetUpgradeInventoryItem(i);
  8662. if (NULL != item && item->GetVnum() == vnum)
  8663. {
  8664. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  8665. continue;
  8666. else
  8667. count += item->GetCount();
  8668. }
  8669. }
  8670. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8671. {
  8672. item = GetBookInventoryItem(i);
  8673. if (NULL != item && item->GetVnum() == vnum)
  8674. {
  8675. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  8676. continue;
  8677. else
  8678. count += item->GetCount();
  8679. }
  8680. }
  8681. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8682. {
  8683. item = GetStoneInventoryItem(i);
  8684. if (NULL != item && item->GetVnum() == vnum)
  8685. {
  8686. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  8687. continue;
  8688. else
  8689. count += item->GetCount();
  8690. }
  8691. }
  8692. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8693. {
  8694. item = GetDndInventoryItem(i);
  8695. if (NULL != item && item->GetVnum() == vnum)
  8696. {
  8697. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  8698. continue;
  8699. else
  8700. count += item->GetCount();
  8701. }
  8702. }
  8703. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8704. {
  8705. item = GetGearInventoryItem(i);
  8706. if (NULL != item && item->GetVnum() == vnum)
  8707. {
  8708. if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
  8709. continue;
  8710. else
  8711. count += item->GetCount();
  8712. }
  8713. }
  8714. #endif
  8715. return count;
  8716. }
  8717.  
  8718. void CHARACTER::RemoveSpecifyItem(DWORD vnum, DWORD count)
  8719. {
  8720. if (0 == count)
  8721. return;
  8722.  
  8723. for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
  8724. {
  8725. if (NULL == GetInventoryItem(i))
  8726. continue;
  8727.  
  8728. if (GetInventoryItem(i)->GetVnum() != vnum)
  8729. continue;
  8730.  
  8731. if(m_pkMyShop)
  8732. {
  8733. bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
  8734. if (isItemSelling)
  8735. continue;
  8736. }
  8737.  
  8738. if (vnum >= 80003 && vnum <= 80007)
  8739. LogManager::instance().GoldBarLog(GetPlayerID(), GetInventoryItem(i)->GetID(), QUEST, "RemoveSpecifyItem");
  8740.  
  8741. if (count >= GetInventoryItem(i)->GetCount())
  8742. {
  8743. count -= GetInventoryItem(i)->GetCount();
  8744. GetInventoryItem(i)->SetCount(0);
  8745.  
  8746. if (0 == count)
  8747. return;
  8748. }
  8749. else
  8750. {
  8751. GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
  8752. return;
  8753. }
  8754. }
  8755. #ifdef ENABLE_SPECIAL_STORAGE
  8756. for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8757. {
  8758. if (NULL == GetUpgradeInventoryItem(i))
  8759. continue;
  8760.  
  8761. if (GetUpgradeInventoryItem(i)->GetVnum() != vnum)
  8762. continue;
  8763.  
  8764. if(m_pkMyShop)
  8765. {
  8766. bool isItemSelling = m_pkMyShop->IsSellingItem(GetUpgradeInventoryItem(i)->GetID());
  8767. if (isItemSelling)
  8768. continue;
  8769. }
  8770.  
  8771. if (count >= GetUpgradeInventoryItem(i)->GetCount())
  8772. {
  8773. count -= GetUpgradeInventoryItem(i)->GetCount();
  8774. GetUpgradeInventoryItem(i)->SetCount(0);
  8775.  
  8776. if (0 == count)
  8777. return;
  8778. }
  8779. else
  8780. {
  8781. GetUpgradeInventoryItem(i)->SetCount(GetUpgradeInventoryItem(i)->GetCount() - count);
  8782. return;
  8783. }
  8784. }
  8785. for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8786. {
  8787. if (NULL == GetBookInventoryItem(i))
  8788. continue;
  8789.  
  8790. if (GetBookInventoryItem(i)->GetVnum() != vnum)
  8791. continue;
  8792.  
  8793. if(m_pkMyShop)
  8794. {
  8795. bool isItemSelling = m_pkMyShop->IsSellingItem(GetBookInventoryItem(i)->GetID());
  8796. if (isItemSelling)
  8797. continue;
  8798. }
  8799.  
  8800. if (count >= GetBookInventoryItem(i)->GetCount())
  8801. {
  8802. count -= GetBookInventoryItem(i)->GetCount();
  8803. GetBookInventoryItem(i)->SetCount(0);
  8804.  
  8805. if (0 == count)
  8806. return;
  8807. }
  8808. else
  8809. {
  8810. GetBookInventoryItem(i)->SetCount(GetBookInventoryItem(i)->GetCount() - count);
  8811. return;
  8812. }
  8813. }
  8814. for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8815. {
  8816. if (NULL == GetStoneInventoryItem(i))
  8817. continue;
  8818.  
  8819. if (GetStoneInventoryItem(i)->GetVnum() != vnum)
  8820. continue;
  8821.  
  8822. if(m_pkMyShop)
  8823. {
  8824. bool isItemSelling = m_pkMyShop->IsSellingItem(GetStoneInventoryItem(i)->GetID());
  8825. if (isItemSelling)
  8826. continue;
  8827. }
  8828.  
  8829. if (count >= GetStoneInventoryItem(i)->GetCount())
  8830. {
  8831. count -= GetStoneInventoryItem(i)->GetCount();
  8832. GetStoneInventoryItem(i)->SetCount(0);
  8833.  
  8834. if (0 == count)
  8835. return;
  8836. }
  8837. else
  8838. {
  8839. GetStoneInventoryItem(i)->SetCount(GetStoneInventoryItem(i)->GetCount() - count);
  8840. return;
  8841. }
  8842. }
  8843. for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8844. {
  8845. if (NULL == GetDndInventoryItem(i))
  8846. continue;
  8847.  
  8848. if (GetDndInventoryItem(i)->GetVnum() != vnum)
  8849. continue;
  8850.  
  8851. if(m_pkMyShop)
  8852. {
  8853. bool isItemSelling = m_pkMyShop->IsSellingItem(GetDndInventoryItem(i)->GetID());
  8854. if (isItemSelling)
  8855. continue;
  8856. }
  8857.  
  8858. if (count >= GetDndInventoryItem(i)->GetCount())
  8859. {
  8860. count -= GetDndInventoryItem(i)->GetCount();
  8861. GetDndInventoryItem(i)->SetCount(0);
  8862.  
  8863. if (0 == count)
  8864. return;
  8865. }
  8866. else
  8867. {
  8868. GetDndInventoryItem(i)->SetCount(GetDndInventoryItem(i)->GetCount() - count);
  8869. return;
  8870. }
  8871. }
  8872. for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  8873. {
  8874. if (NULL == GetGearInventoryItem(i))
  8875. continue;
  8876.  
  8877. if (GetGearInventoryItem(i)->GetVnum() != vnum)
  8878. continue;
  8879.  
  8880. if(m_pkMyShop)
  8881. {
  8882. bool isItemSelling = m_pkMyShop->IsSellingItem(GetGearInventoryItem(i)->GetID());
  8883. if (isItemSelling)
  8884. continue;
  8885. }
  8886.  
  8887. if (count >= GetGearInventoryItem(i)->GetCount())
  8888. {
  8889. count -= GetGearInventoryItem(i)->GetCount();
  8890. GetGearInventoryItem(i)->SetCount(0);
  8891.  
  8892. if (0 == count)
  8893. return;
  8894. }
  8895. else
  8896. {
  8897. GetGearInventoryItem(i)->SetCount(GetGearInventoryItem(i)->GetCount() - count);
  8898. return;
  8899. }
  8900. }
  8901. #endif
  8902. // ¿¹¿Ü󸮰¡ ¾àÇÏ´Ù.
  8903. if (count)
  8904. sys_log(0, "CHARACTER::RemoveSpecifyItem cannot remove enough item vnum %u, still remain %d", vnum, count);
  8905. }
  8906.  
  8907. int CHARACTER::CountSpecifyTypeItem(BYTE type) const
  8908. {
  8909. int count = 0;
  8910. for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
  8911. {
  8912. LPITEM pItem = GetInventoryItem(i);
  8913. if (pItem != NULL && pItem->GetType() == type)
  8914. {
  8915. count += pItem->GetCount();
  8916. }
  8917. }
  8918.  
  8919. return count;
  8920. }
  8921.  
  8922. void CHARACTER::RemoveSpecifyTypeItem(BYTE type, DWORD count)
  8923. {
  8924. if (0 == count)
  8925. return;
  8926.  
  8927. for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
  8928. {
  8929. if (NULL == GetInventoryItem(i))
  8930. continue;
  8931.  
  8932. if (GetInventoryItem(i)->GetType() != type)
  8933. continue;
  8934.  
  8935. if(m_pkMyShop)
  8936. {
  8937. bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
  8938. if (isItemSelling)
  8939. continue;
  8940. }
  8941.  
  8942. if (count >= GetInventoryItem(i)->GetCount())
  8943. {
  8944. count -= GetInventoryItem(i)->GetCount();
  8945. GetInventoryItem(i)->SetCount(0);
  8946.  
  8947. if (0 == count)
  8948. return;
  8949. }
  8950. else
  8951. {
  8952. GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
  8953. return;
  8954. }
  8955. }
  8956. }
  8957.  
  8958. #ifdef ENABLE_SORT_INVENTORY
  8959. void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip, bool bWereMine)
  8960. #else
  8961. void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
  8962. #endif
  8963. {
  8964. if (NULL == item)
  8965. {
  8966. sys_err ("NULL point.");
  8967. return;
  8968. }
  8969. if (item->GetOwner())
  8970. {
  8971. sys_err ("item %d 's owner exists!",item->GetID());
  8972. return;
  8973. }
  8974.  
  8975. int cell;
  8976. if (item->IsDragonSoul())
  8977. {
  8978. cell = GetEmptyDragonSoulInventory(item);
  8979. }
  8980. #ifdef ENABLE_SPECIAL_STORAGE
  8981. else if (item->IsUpgradeItem())
  8982. {
  8983. cell = GetEmptyUpgradeInventory(item);
  8984. }
  8985. else if (item->IsBook())
  8986. {
  8987. cell = GetEmptyBookInventory(item);
  8988. }
  8989. else if (item->IsStone())
  8990. {
  8991. cell = GetEmptyStoneInventory(item);
  8992. }
  8993. else if (item->IsDnd())
  8994. {
  8995. cell = GetEmptyDndInventory(item);
  8996. }
  8997. else if (item->IsGear())
  8998. {
  8999. cell = GetEmptyGearInventory(item);
  9000. }
  9001. #endif
  9002. else
  9003. {
  9004. cell = GetEmptyInventory (item->GetSize());
  9005. }
  9006.  
  9007. if (cell != -1)
  9008. {
  9009. if (item->IsDragonSoul())
  9010. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
  9011. #ifdef ENABLE_SPECIAL_STORAGE
  9012. else if (item->IsUpgradeItem())
  9013. item->AddToCharacter(this, TItemPos(UPGRADE_INVENTORY, cell));
  9014. else if (item->IsBook())
  9015. item->AddToCharacter(this, TItemPos(BOOK_INVENTORY, cell));
  9016. else if (item->IsStone())
  9017. item->AddToCharacter(this, TItemPos(STONE_INVENTORY, cell));
  9018. else if (item->IsDnd())
  9019. item->AddToCharacter(this, TItemPos(DND_INVENTORY, cell));
  9020. else if (item->IsGear())
  9021. item->AddToCharacter(this, TItemPos(GEAR_INVENTORY, cell));
  9022. #endif
  9023. else
  9024. //item->AddToCharacter(this, TItemPos(INVENTORY, cell));
  9025. #ifdef ENABLE_SORT_INVENTORY
  9026. item->AddToCharacter(this, TItemPos(INVENTORY, cell), bWereMine);
  9027. #else
  9028. item->AddToCharacter(this, TItemPos(INVENTORY, cell));
  9029. #endif
  9030. LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
  9031.  
  9032. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
  9033. {
  9034. TQuickslot * pSlot;
  9035.  
  9036. if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
  9037. {
  9038. TQuickslot slot;
  9039. slot.type = QUICKSLOT_TYPE_ITEM;
  9040. slot.pos = cell;
  9041. SetQuickslot(0, slot);
  9042. }
  9043. }
  9044. }
  9045. else
  9046. {
  9047. item->AddToGround (GetMapIndex(), GetXYZ());
  9048. item->StartDestroyEvent();
  9049.  
  9050. if (longOwnerShip)
  9051. item->SetOwnership (this, 10); //DnD works -spam 30s
  9052. else
  9053. item->SetOwnership (this, 6); //DnD works -spam 25s
  9054. LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
  9055. }
  9056. }
  9057.  
  9058. #ifdef ENABLE_SORT_INVENTORY
  9059. LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, WORD bCount, int iRarePct, bool bMsg, bool bWereMine)
  9060. #else
  9061. LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, WORD bCount, int iRarePct, bool bMsg)
  9062. #endif
  9063. {
  9064. TItemTable * p = ITEM_MANAGER::instance().GetTable(dwItemVnum);
  9065.  
  9066. if (!p)
  9067. return NULL;
  9068.  
  9069. DBManager::instance().SendMoneyLog(MONEY_LOG_DROP, dwItemVnum, bCount);
  9070.  
  9071. if (p->dwFlags & ITEM_FLAG_STACKABLE && p->bType != ITEM_BLEND)
  9072. {
  9073. #ifdef ENABLE_SPECIAL_STORAGE
  9074. if (p->bType == ITEM_MATERIAL && p->bSubType == MATERIAL_LEATHER) //upgrade item
  9075. {
  9076. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  9077. {
  9078. LPITEM item = GetUpgradeInventoryItem(i);
  9079.  
  9080. if (!item)
  9081. continue;
  9082.  
  9083. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  9084. {
  9085. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  9086. {
  9087. if (bCount < p->alValues[1])
  9088. bCount = p->alValues[1];
  9089. }
  9090.  
  9091. WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
  9092. bCount -= bCount2;
  9093.  
  9094. item->SetCount(item->GetCount() + bCount2);
  9095.  
  9096. if (bCount == 0)
  9097. {
  9098. if (bMsg)
  9099. ChatPacket(CHAT_TYPE_INFO, ("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  9100.  
  9101. return item;
  9102. }
  9103. }
  9104. }
  9105. }
  9106. else if (dwItemVnum == 50300) //book item
  9107. {
  9108. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  9109. {
  9110. LPITEM item = GetBookInventoryItem(i);
  9111.  
  9112. if (!item)
  9113. continue;
  9114.  
  9115. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  9116. {
  9117. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  9118. {
  9119. if (bCount < p->alValues[1])
  9120. bCount = p->alValues[1];
  9121. }
  9122.  
  9123. WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
  9124. bCount -= bCount2;
  9125.  
  9126. item->SetCount(item->GetCount() + bCount2);
  9127.  
  9128. if (bCount == 0)
  9129. {
  9130. if (bMsg)
  9131. ChatPacket(CHAT_TYPE_INFO, ("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  9132.  
  9133. return item;
  9134. }
  9135. }
  9136. }
  9137. }
  9138. else if (p->bType == ITEM_METIN && p->bSubType == METIN_NORMAL) //stone item
  9139. {
  9140. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  9141. {
  9142. LPITEM item = GetStoneInventoryItem(i);
  9143.  
  9144. if (!item)
  9145. continue;
  9146.  
  9147. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  9148. {
  9149. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  9150. {
  9151. if (bCount < p->alValues[1])
  9152. bCount = p->alValues[1];
  9153. }
  9154.  
  9155. WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
  9156. bCount -= bCount2;
  9157.  
  9158. item->SetCount(item->GetCount() + bCount2);
  9159.  
  9160. if (bCount == 0)
  9161. {
  9162. if (bMsg)
  9163. ChatPacket(CHAT_TYPE_INFO, ("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
  9164.  
  9165. return item;
  9166. }
  9167. }
  9168. }
  9169. }
  9170. else if ((p->bType == ITEM_USE && p->bSubType == USE_ABILITY_UP) || (p->bType == ITEM_USE && p->bSubType == USE_AFFECT) || (p->bType == ITEM_BLEND))//Special items
  9171. {
  9172. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  9173. {
  9174. LPITEM item = GetDndInventoryItem(i);
  9175.  
  9176. if (!item)
  9177. continue;
  9178.  
  9179. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  9180. {
  9181. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  9182. {
  9183. if (bCount < p->alValues[1])
  9184. bCount = p->alValues[1];
  9185. }
  9186.  
  9187. WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
  9188. bCount -= bCount2;
  9189.  
  9190. item->SetCount(item->GetCount() + bCount2);
  9191.  
  9192. if (bCount == 0)
  9193. {
  9194. if (bMsg)
  9195. ChatPacket(CHAT_TYPE_INFO, ("Cufarul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  9196.  
  9197. return item;
  9198. }
  9199. }
  9200. }
  9201. }
  9202. else if ((p->bType == ITEM_RESOURCE && p->bSubType == RESOURCE_FISHBONE) || (p->bType == ITEM_USE && p->bSubType == USE_BAIT) || (p->bType == ITEM_FISH && p->bSubType == FISH_ALIVE) || (p->bType == ITEM_FISH && p->bSubType == FISH_DEAD) || (p->bType == ITEM_CAMPFIRE) || (p->bType == ITEM_SPECIAL && p->bSubType == SPECIAL_MAP) || (p->bType == ITEM_USE && p->bSubType == USE_PUT_INTO_ACCESSORY_SOCKET) || (p->bType == ITEM_RESOURCE && p->bSubType == RESOURCE_WATERSTONEPIECE) || (p->bType == ITEM_USE && p->bSubType == USE_ADD_ACCESSORY_SOCKET))//Special items
  9203. {
  9204. for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
  9205. {
  9206. LPITEM item = GetGearInventoryItem(i);
  9207.  
  9208. if (!item)
  9209. continue;
  9210.  
  9211. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  9212. {
  9213. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  9214. {
  9215. if (bCount < p->alValues[1])
  9216. bCount = p->alValues[1];
  9217. }
  9218.  
  9219. WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
  9220. bCount -= bCount2;
  9221.  
  9222. item->SetCount(item->GetCount() + bCount2);
  9223.  
  9224. if (bCount == 0)
  9225. {
  9226. if (bMsg)
  9227. ChatPacket(CHAT_TYPE_INFO, (" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special! "), item->GetName());
  9228.  
  9229. return item;
  9230. }
  9231. }
  9232. }
  9233. }
  9234. else
  9235. {
  9236. #endif
  9237. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  9238. {
  9239. LPITEM item = GetInventoryItem(i);
  9240.  
  9241. if (!item)
  9242. continue;
  9243.  
  9244. #ifdef ENABLE_SORT_INVENTORY
  9245. if (item->GetOriginalVnum() == dwItemVnum && FN_check_item_socket(item))
  9246. #else
  9247. if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
  9248. #endif
  9249. {
  9250. if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
  9251. {
  9252. if (bCount < p->alValues[1])
  9253. bCount = p->alValues[1];
  9254. }
  9255.  
  9256. WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
  9257. bCount -= bCount2;
  9258.  
  9259. item->SetCount(item->GetCount() + bCount2);
  9260.  
  9261. if (bCount == 0)
  9262. {
  9263. if (bMsg)
  9264. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit - %s"), item->GetName()); // Nu
  9265.  
  9266. return item;
  9267. }
  9268. }
  9269. }
  9270. }
  9271. #ifdef ENABLE_SPECIAL_STORAGE
  9272. }
  9273. #endif
  9274. LPITEM item = ITEM_MANAGER::instance().CreateItem(dwItemVnum, bCount, 0, true);
  9275.  
  9276. if (!item)
  9277. {
  9278. sys_err("cannot create item by vnum %u (name: %s)", dwItemVnum, GetName());
  9279. return NULL;
  9280. }
  9281.  
  9282. if (item->GetType() == ITEM_BLEND)
  9283. {
  9284. for (int i=0; i < INVENTORY_MAX_NUM; i++)
  9285. {
  9286. LPITEM inv_item = GetInventoryItem(i);
  9287.  
  9288. if (inv_item == NULL) continue;
  9289.  
  9290. if (inv_item->GetType() == ITEM_BLEND)
  9291. {
  9292. if (inv_item->GetVnum() == item->GetVnum())
  9293. {
  9294. if (inv_item->GetSocket(0) == item->GetSocket(0) &&
  9295. inv_item->GetSocket(1) == item->GetSocket(1) &&
  9296. inv_item->GetSocket(2) == item->GetSocket(2) &&
  9297. inv_item->GetCount() < ITEM_MAX_COUNT)
  9298. {
  9299. inv_item->SetCount(inv_item->GetCount() + item->GetCount());
  9300. // Memory Leak Fix
  9301. M2_DESTROY_ITEM(item);
  9302. return inv_item;
  9303. }
  9304. }
  9305. }
  9306. }
  9307. }
  9308.  
  9309. int iEmptyCell;
  9310. if (item->IsDragonSoul())
  9311. {
  9312. iEmptyCell = GetEmptyDragonSoulInventory(item);
  9313. }
  9314. #ifdef ENABLE_SPECIAL_STORAGE
  9315. else if(item->IsUpgradeItem())
  9316. {
  9317. iEmptyCell = GetEmptyUpgradeInventory(item);
  9318. }
  9319. else if(item->IsBook())
  9320. {
  9321. iEmptyCell = GetEmptyBookInventory(item);
  9322. }
  9323. else if(item->IsStone())
  9324. {
  9325. iEmptyCell = GetEmptyStoneInventory(item);
  9326. }
  9327. else if(item->IsDnd())
  9328. {
  9329. iEmptyCell = GetEmptyDndInventory(item);
  9330. }
  9331. else if(item->IsGear())
  9332. {
  9333. iEmptyCell = GetEmptyGearInventory(item);
  9334. }
  9335. #endif
  9336. else
  9337. iEmptyCell = GetEmptyInventory(item->GetSize());
  9338.  
  9339. if (iEmptyCell != -1)
  9340. {
  9341.  
  9342. if (item->IsDragonSoul())
  9343. item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
  9344. #ifdef ENABLE_SPECIAL_STORAGE
  9345. else if (item->IsUpgradeItem())
  9346. {
  9347. item->AddToCharacter(this, TItemPos(UPGRADE_INVENTORY, iEmptyCell));
  9348. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  9349. }
  9350. else if (item->IsBook())
  9351. {
  9352. item->AddToCharacter(this, TItemPos(BOOK_INVENTORY, iEmptyCell));
  9353. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
  9354. }
  9355. else if (item->IsStone())
  9356. {
  9357. item->AddToCharacter(this, TItemPos(STONE_INVENTORY, iEmptyCell));
  9358. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
  9359. }
  9360. else if (item->IsDnd())
  9361. {
  9362. item->AddToCharacter(this, TItemPos(DND_INVENTORY, iEmptyCell));
  9363. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cufarul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
  9364. }
  9365. else if (item->IsGear())
  9366. {
  9367. item->AddToCharacter(this, TItemPos(GEAR_INVENTORY, iEmptyCell));
  9368. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special! "), item->GetName());
  9369. }
  9370. #endif
  9371. else
  9372.  
  9373. #ifdef ENABLE_SORT_INVENTORY
  9374. item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell), bWereMine);
  9375. #else
  9376. item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
  9377. #endif
  9378. LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
  9379.  
  9380.  
  9381. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
  9382. {
  9383. TQuickslot * pSlot;
  9384.  
  9385. if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
  9386. {
  9387. TQuickslot slot;
  9388. slot.type = QUICKSLOT_TYPE_ITEM;
  9389. slot.pos = iEmptyCell;
  9390. SetQuickslot(0, slot);
  9391. }
  9392. }
  9393. }
  9394. else
  9395. {
  9396. item->AddToGround(GetMapIndex(), GetXYZ());
  9397. item->StartDestroyEvent();
  9398. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP))
  9399. item->SetOwnership(this, 6); //DnD work drop spam 30
  9400. else
  9401. item->SetOwnership(this, 8); //DnD work drop spam 35
  9402. LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
  9403. }
  9404.  
  9405. sys_log(0,
  9406. "7: %d %d", dwItemVnum, bCount);
  9407. return item;
  9408. }
  9409.  
  9410. bool CHARACTER::GiveItem(LPCHARACTER victim, TItemPos Cell)
  9411. {
  9412. if (!CanHandleItem())
  9413. return false;
  9414.  
  9415. LPITEM item = GetItem(Cell);
  9416.  
  9417. if (item && !item->IsExchanging())
  9418. {
  9419. if (victim->CanReceiveItem(this, item))
  9420. {
  9421. victim->ReceiveItem(this, item);
  9422. return true;
  9423. }
  9424. }
  9425.  
  9426. return false;
  9427. }
  9428.  
  9429. bool CHARACTER::CanReceiveItem(LPCHARACTER from, LPITEM item) const
  9430. {
  9431. if (IsPC())
  9432. return false;
  9433.  
  9434. // TOO_LONG_DISTANCE_EXCHANGE_BUG_FIX
  9435. if (DISTANCE_APPROX(GetX() - from->GetX(), GetY() - from->GetY()) > 2000)
  9436. return false;
  9437. // END_OF_TOO_LONG_DISTANCE_EXCHANGE_BUG_FIX
  9438.  
  9439. switch (GetRaceNum())
  9440. {
  9441. case fishing::CAMPFIRE_MOB:
  9442. if (item->GetType() == ITEM_FISH &&
  9443. (item->GetSubType() == FISH_ALIVE || item->GetSubType() == FISH_DEAD))
  9444. return true;
  9445. break;
  9446.  
  9447. case fishing::FISHER_MOB:
  9448. if (item->GetType() == ITEM_ROD)
  9449. return true;
  9450. break;
  9451.  
  9452. // BUILDING_NPC
  9453. case BLACKSMITH_WEAPON_MOB:
  9454. case DEVILTOWER_BLACKSMITH_WEAPON_MOB:
  9455. if (item->GetType() == ITEM_WEAPON &&
  9456. item->GetRefinedVnum())
  9457. return true;
  9458. else
  9459. return false;
  9460. break;
  9461.  
  9462. case BLACKSMITH_ARMOR_MOB:
  9463. case DEVILTOWER_BLACKSMITH_ARMOR_MOB:
  9464. if (item->GetType() == ITEM_ARMOR &&
  9465. (item->GetSubType() == ARMOR_BODY || item->GetSubType() == ARMOR_SHIELD || item->GetSubType() == ARMOR_HEAD) &&
  9466. item->GetRefinedVnum())
  9467. return true;
  9468. else
  9469. return false;
  9470. break;
  9471.  
  9472. case BLACKSMITH_ACCESSORY_MOB:
  9473. case DEVILTOWER_BLACKSMITH_ACCESSORY_MOB:
  9474. if (item->GetType() == ITEM_ARMOR &&
  9475. !(item->GetSubType() == ARMOR_BODY || item->GetSubType() == ARMOR_SHIELD || item->GetSubType() == ARMOR_HEAD) &&
  9476. item->GetRefinedVnum())
  9477. return true;
  9478. else
  9479. return false;
  9480. break;
  9481. // END_OF_BUILDING_NPC
  9482.  
  9483. case BLACKSMITH_MOB:
  9484. if (item->GetRefinedVnum() && item->GetRefineSet() < 500)
  9485. {
  9486. return true;
  9487. }
  9488. else
  9489. {
  9490. return false;
  9491. }
  9492.  
  9493. case BLACKSMITH2_MOB:
  9494. if (item->GetRefineSet() >= 500)
  9495. {
  9496. return true;
  9497. }
  9498. else
  9499. {
  9500. return false;
  9501. }
  9502.  
  9503. case ALCHEMIST_MOB:
  9504. if (item->GetRefinedVnum())
  9505. return true;
  9506. break;
  9507.  
  9508. case 20101:
  9509. case 20102:
  9510. case 20103:
  9511. // ÃÊ±Þ ¸»
  9512. if (item->GetVnum() == ITEM_REVIVE_HORSE_1)
  9513. {
  9514. if (!IsDead())
  9515. {
  9516. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
  9517. return false;
  9518. }
  9519. return true;
  9520. }
  9521. else if (item->GetVnum() == ITEM_HORSE_FOOD_1)
  9522. {
  9523. if (IsDead())
  9524. {
  9525. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
  9526. return false;
  9527. }
  9528. return true;
  9529. }
  9530. else if (item->GetVnum() == ITEM_HORSE_FOOD_2 || item->GetVnum() == ITEM_HORSE_FOOD_3)
  9531. {
  9532. return false;
  9533. }
  9534. break;
  9535. case 20104:
  9536. case 20105:
  9537. case 20106:
  9538. // Áß±Þ ¸»
  9539. if (item->GetVnum() == ITEM_REVIVE_HORSE_2)
  9540. {
  9541. if (!IsDead())
  9542. {
  9543. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
  9544. return false;
  9545. }
  9546. return true;
  9547. }
  9548. else if (item->GetVnum() == ITEM_HORSE_FOOD_2)
  9549. {
  9550. if (IsDead())
  9551. {
  9552. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
  9553. return false;
  9554. }
  9555. return true;
  9556. }
  9557. else if (item->GetVnum() == ITEM_HORSE_FOOD_1 || item->GetVnum() == ITEM_HORSE_FOOD_3)
  9558. {
  9559. return false;
  9560. }
  9561. break;
  9562. case 20107:
  9563. case 20108:
  9564. case 20109:
  9565. // °í±Þ ¸»
  9566. if (item->GetVnum() == ITEM_REVIVE_HORSE_3)
  9567. {
  9568. if (!IsDead())
  9569. {
  9570. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
  9571. return false;
  9572. }
  9573. return true;
  9574. }
  9575. else if (item->GetVnum() == ITEM_HORSE_FOOD_3)
  9576. {
  9577. if (IsDead())
  9578. {
  9579. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
  9580. return false;
  9581. }
  9582. return true;
  9583. }
  9584. else if (item->GetVnum() == ITEM_HORSE_FOOD_1 || item->GetVnum() == ITEM_HORSE_FOOD_2)
  9585. {
  9586. return false;
  9587. }
  9588. break;
  9589. }
  9590.  
  9591. //if (IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_GIVE))
  9592. {
  9593. return true;
  9594. }
  9595.  
  9596. return false;
  9597. }
  9598.  
  9599. void CHARACTER::ReceiveItem(LPCHARACTER from, LPITEM item)
  9600. {
  9601. if (IsPC())
  9602. return;
  9603.  
  9604. switch (GetRaceNum())
  9605. {
  9606. case fishing::CAMPFIRE_MOB:
  9607. if (item->GetType() == ITEM_FISH && (item->GetSubType() == FISH_ALIVE || item->GetSubType() == FISH_DEAD))
  9608. fishing::Grill(from, item);
  9609. else
  9610. {
  9611. // TAKE_ITEM_BUG_FIX
  9612. from->SetQuestNPCID(GetVID());
  9613. // END_OF_TAKE_ITEM_BUG_FIX
  9614. quest::CQuestManager::instance().TakeItem(from->GetPlayerID(), GetRaceNum(), item);
  9615. }
  9616. break;
  9617.  
  9618. // DEVILTOWER_NPC
  9619. case DEVILTOWER_BLACKSMITH_WEAPON_MOB:
  9620. case DEVILTOWER_BLACKSMITH_ARMOR_MOB:
  9621. case DEVILTOWER_BLACKSMITH_ACCESSORY_MOB:
  9622. if (item->GetRefinedVnum() != 0 && item->GetRefineSet() != 0 && item->GetRefineSet() < 500)
  9623. {
  9624. from->SetRefineNPC(this);
  9625. from->RefineInformation(item->GetCell(), REFINE_TYPE_MONEY_ONLY);
  9626. }
  9627. else
  9628. {
  9629. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti urca nivelul itemului actual."));
  9630. }
  9631. break;
  9632. // END_OF_DEVILTOWER_NPC
  9633.  
  9634. case BLACKSMITH_MOB:
  9635. case BLACKSMITH2_MOB:
  9636. case BLACKSMITH_WEAPON_MOB:
  9637. case BLACKSMITH_ARMOR_MOB:
  9638. case BLACKSMITH_ACCESSORY_MOB:
  9639. if (item->GetRefinedVnum())
  9640. {
  9641. from->SetRefineNPC(this);
  9642. from->RefineInformation(item->GetCell(), REFINE_TYPE_NORMAL);
  9643. }
  9644. else
  9645. {
  9646. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
  9647. }
  9648. break;
  9649.  
  9650. case 20101:
  9651. case 20102:
  9652. case 20103:
  9653. case 20104:
  9654. case 20105:
  9655. case 20106:
  9656. case 20107:
  9657. case 20108:
  9658. case 20109:
  9659. if (item->GetVnum() == ITEM_REVIVE_HORSE_1 ||
  9660. item->GetVnum() == ITEM_REVIVE_HORSE_2 ||
  9661. item->GetVnum() == ITEM_REVIVE_HORSE_3)
  9662. {
  9663. from->ReviveHorse();
  9664. item->SetCount(item->GetCount()-1);
  9665. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Calul tau este intr-o conditie perfecta !"));
  9666. }
  9667. else if (item->GetVnum() == ITEM_HORSE_FOOD_1 ||
  9668. item->GetVnum() == ITEM_HORSE_FOOD_2 ||
  9669. item->GetVnum() == ITEM_HORSE_FOOD_3)
  9670. {
  9671. from->FeedHorse();
  9672. from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Calul tau trebuie hranit."));
  9673. item->SetCount(item->GetCount()-1);
  9674. EffectPacket(SE_HPUP_RED);
  9675. }
  9676. break;
  9677.  
  9678. default:
  9679. sys_log(0, "TakeItem %s %d %s", from->GetName(), GetRaceNum(), item->GetName());
  9680. from->SetQuestNPCID(GetVID());
  9681. quest::CQuestManager::instance().TakeItem(from->GetPlayerID(), GetRaceNum(), item);
  9682. break;
  9683. }
  9684. }
  9685.  
  9686. bool CHARACTER::IsEquipUniqueItem(DWORD dwItemVnum) const
  9687. {
  9688. {
  9689. LPITEM u = GetWear(WEAR_UNIQUE1);
  9690.  
  9691. if (u && u->GetVnum() == dwItemVnum)
  9692. return true;
  9693. }
  9694.  
  9695. {
  9696. LPITEM u = GetWear(WEAR_UNIQUE2);
  9697.  
  9698. if (u && u->GetVnum() == dwItemVnum)
  9699. return true;
  9700. }
  9701.  
  9702. {
  9703. LPITEM u = GetWear(WEAR_COSTUME_MOUNT);
  9704.  
  9705. if (u && u->GetVnum() == dwItemVnum)
  9706. return true;
  9707. }
  9708.  
  9709. if (dwItemVnum == UNIQUE_ITEM_RING_OF_LANGUAGE)
  9710. return IsEquipUniqueItem(UNIQUE_ITEM_RING_OF_LANGUAGE_SAMPLE);
  9711.  
  9712. return false;
  9713. }
  9714.  
  9715. // CHECK_UNIQUE_GROUP
  9716. bool CHARACTER::IsEquipUniqueGroup(DWORD dwGroupVnum) const
  9717. {
  9718. {
  9719. LPITEM u = GetWear(WEAR_UNIQUE1);
  9720.  
  9721. if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
  9722. return true;
  9723. }
  9724.  
  9725. {
  9726. LPITEM u = GetWear(WEAR_UNIQUE2);
  9727.  
  9728. if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
  9729. return true;
  9730. }
  9731.  
  9732. {
  9733. LPITEM u = GetWear(WEAR_COSTUME_MOUNT);
  9734.  
  9735. if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
  9736. return true;
  9737. }
  9738.  
  9739. return false;
  9740. }
  9741. // END_OF_CHECK_UNIQUE_GROUP
  9742.  
  9743. void CHARACTER::SetRefineMode(int iAdditionalCell)
  9744. {
  9745. m_iRefineAdditionalCell = iAdditionalCell;
  9746. m_bUnderRefine = true;
  9747. }
  9748.  
  9749. void CHARACTER::ClearRefineMode()
  9750. {
  9751. m_bUnderRefine = false;
  9752. SetRefineNPC( NULL );
  9753. }
  9754.  
  9755. bool CHARACTER::GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector<DWORD> &dwItemVnums,
  9756. std::vector<DWORD> &dwItemCounts, std::vector <LPITEM> &item_gets, int &count)
  9757. {
  9758. const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwGroupNum);
  9759.  
  9760. if (!pGroup)
  9761. {
  9762. sys_err("cannot find special item group %d", dwGroupNum);
  9763. return false;
  9764. }
  9765.  
  9766. std::vector <int> idxes;
  9767. int n = pGroup->GetMultiIndex(idxes);
  9768.  
  9769. bool bSuccess;
  9770.  
  9771. for (int i = 0; i < n; i++)
  9772. {
  9773. bSuccess = false;
  9774. int idx = idxes[i];
  9775. DWORD dwVnum = pGroup->GetVnum(idx);
  9776. DWORD dwCount = pGroup->GetCount(idx);
  9777. int iRarePct = pGroup->GetRarePct(idx);
  9778. LPITEM item_get = NULL;
  9779. switch (dwVnum)
  9780. {
  9781. case CSpecialItemGroup::GOLD:
  9782. PointChange(POINT_GOLD, dwCount);
  9783. LogManager::instance().CharLog(this, dwCount, "TREASURE_GOLD", "");
  9784.  
  9785. bSuccess = true;
  9786. break;
  9787. case CSpecialItemGroup::EXP:
  9788. {
  9789. PointChange(POINT_EXP, dwCount);
  9790. LogManager::instance().CharLog(this, dwCount, "TREASURE_EXP", "");
  9791.  
  9792. bSuccess = true;
  9793. }
  9794. break;
  9795.  
  9796. case CSpecialItemGroup::MOB:
  9797. {
  9798. sys_log(0, "CSpecialItemGroup::MOB %d", dwCount);
  9799. int x = GetX() + number(-500, 500);
  9800. int y = GetY() + number(-500, 500);
  9801.  
  9802. LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), x, y, 0, true, -1);
  9803. if (ch)
  9804. ch->SetAggressive();
  9805. bSuccess = true;
  9806. }
  9807. break;
  9808. case CSpecialItemGroup::SLOW:
  9809. {
  9810. sys_log(0, "CSpecialItemGroup::SLOW %d", -(int)dwCount);
  9811. AddAffect(AFFECT_SLOW, POINT_MOV_SPEED, -(int)dwCount, AFF_SLOW, 300, 0, true);
  9812. bSuccess = true;
  9813. }
  9814. break;
  9815. case CSpecialItemGroup::DRAIN_HP:
  9816. {
  9817. int iDropHP = GetMaxHP()*dwCount/100;
  9818. sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
  9819. iDropHP = MIN(iDropHP, GetHP()-1);
  9820. sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
  9821. PointChange(POINT_HP, -iDropHP);
  9822. bSuccess = true;
  9823. }
  9824. break;
  9825. case CSpecialItemGroup::POISON:
  9826. {
  9827. AttackedByPoison(NULL);
  9828. bSuccess = true;
  9829. }
  9830. break;
  9831.  
  9832. case CSpecialItemGroup::MOB_GROUP:
  9833. {
  9834. int sx = GetX() - number(300, 500);
  9835. int sy = GetY() - number(300, 500);
  9836. int ex = GetX() + number(300, 500);
  9837. int ey = GetY() + number(300, 500);
  9838. CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), sx, sy, ex, ey, NULL, true);
  9839.  
  9840. bSuccess = true;
  9841. }
  9842. break;
  9843. default:
  9844. {
  9845. item_get = AutoGiveItem(dwVnum, dwCount, iRarePct);
  9846.  
  9847. if (item_get)
  9848. {
  9849. bSuccess = true;
  9850. }
  9851. }
  9852. break;
  9853. }
  9854.  
  9855. if (bSuccess)
  9856. {
  9857. dwItemVnums.push_back(dwVnum);
  9858. dwItemCounts.push_back(dwCount);
  9859. item_gets.push_back(item_get);
  9860. count++;
  9861.  
  9862. }
  9863. else
  9864. {
  9865. return false;
  9866. }
  9867. }
  9868. return bSuccess;
  9869. }
  9870.  
  9871. // NEW_HAIR_STYLE_ADD
  9872. bool CHARACTER::ItemProcess_Hair(LPITEM item, int iDestCell)
  9873. {
  9874. if (item->CheckItemUseLevel(GetLevel()) == false)
  9875. {
  9876.  
  9877. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
  9878. return false;
  9879. }
  9880.  
  9881. DWORD hair = item->GetVnum();
  9882.  
  9883. switch (GetJob())
  9884. {
  9885. case JOB_WARRIOR :
  9886. hair -= 72000; // 73001 - 72000 = 1001 ºÎÅÍ Çì¾î ¹øÈ£ ½ÃÀÛ
  9887. break;
  9888.  
  9889. case JOB_ASSASSIN :
  9890. hair -= 71250;
  9891. break;
  9892.  
  9893. case JOB_SURA :
  9894. hair -= 70500;
  9895. break;
  9896.  
  9897. case JOB_SHAMAN :
  9898. hair -= 69750;
  9899. break;
  9900.  
  9901. default :
  9902. return false;
  9903. break;
  9904. }
  9905.  
  9906. if (hair == GetPart(PART_HAIR))
  9907. {
  9908. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
  9909. return true;
  9910. }
  9911.  
  9912. item->SetCount(item->GetCount() - 1);
  9913.  
  9914. SetPart(PART_HAIR, hair);
  9915. UpdatePacket();
  9916.  
  9917. return true;
  9918. }
  9919. // END_NEW_HAIR_STYLE_ADD
  9920.  
  9921. bool CHARACTER::ItemProcess_Polymorph(LPITEM item)
  9922. {
  9923. if (IsPolymorphed())
  9924. {
  9925. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Esti deja transformat."));
  9926. return false;
  9927. }
  9928.  
  9929. if (true == IsRiding())
  9930. {
  9931. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti transforma calare."));
  9932. return false;
  9933. }
  9934.  
  9935. DWORD dwVnum = item->GetSocket(0);
  9936.  
  9937. if (dwVnum == 0)
  9938. {
  9939. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citii aceasta carte."));
  9940. item->SetCount(item->GetCount()-1);
  9941. return false;
  9942. }
  9943.  
  9944. const CMob* pMob = CMobManager::instance().Get(dwVnum);
  9945.  
  9946. if (pMob == NULL)
  9947. {
  9948. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citii aceasta carte."));
  9949. item->SetCount(item->GetCount()-1);
  9950. return false;
  9951. }
  9952.  
  9953. switch (item->GetVnum())
  9954. {
  9955. case 70104 :
  9956. case 70105 :
  9957. case 70106 :
  9958. case 70107 :
  9959. case 71093 :
  9960. {
  9961. sys_log(0, "USE_POLYMORPH_BALL PID(%d) vnum(%d)", GetPlayerID(), dwVnum);
  9962.  
  9963. int iPolymorphLevelLimit = MAX(0, 20 - GetLevel() * 3 / 10);
  9964. if (pMob->m_table.bLevel >= GetLevel() + iPolymorphLevelLimit)
  9965. {
  9966. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti transforma."));
  9967. return false;
  9968. }
  9969.  
  9970. int iDuration = GetSkillLevel(POLYMORPH_SKILL_ID) == 0 ? 5 : (5 + (5 + GetSkillLevel(POLYMORPH_SKILL_ID)/40 * 25));
  9971. iDuration *= 60;
  9972.  
  9973. DWORD dwBonus = 0;
  9974.  
  9975. if (true == LC_IsYMIR() || true == LC_IsKorea())
  9976. {
  9977. dwBonus = GetSkillLevel(POLYMORPH_SKILL_ID) + 60;
  9978. }
  9979. else
  9980. {
  9981. dwBonus = (2 + GetSkillLevel(POLYMORPH_SKILL_ID)/40) * 100;
  9982. }
  9983.  
  9984. AddAffect(AFFECT_POLYMORPH, POINT_POLYMORPH, dwVnum, AFF_POLYMORPH, iDuration, 0, true);
  9985. AddAffect(AFFECT_POLYMORPH, POINT_ATT_BONUS, dwBonus, AFF_POLYMORPH, iDuration, 0, false);
  9986.  
  9987. item->SetCount(item->GetCount()-1);
  9988. }
  9989. break;
  9990.  
  9991. case 50322:
  9992. {
  9993. sys_log(0, "USE_POLYMORPH_BOOK: %s(%u) vnum(%u)", GetName(), GetPlayerID(), dwVnum);
  9994.  
  9995. if (CPolymorphUtils::instance().PolymorphCharacter(this, item, pMob) == true)
  9996. {
  9997. CPolymorphUtils::instance().UpdateBookPracticeGrade(this, item);
  9998. }
  9999. else
  10000. {
  10001. }
  10002. }
  10003. break;
  10004.  
  10005. default :
  10006. sys_err("POLYMORPH invalid item passed PID(%d) vnum(%d)", GetPlayerID(), item->GetOriginalVnum());
  10007. return false;
  10008. }
  10009.  
  10010. return true;
  10011. }
  10012.  
  10013. bool CHARACTER::CanDoCube() const
  10014. {
  10015. if (m_bIsObserver) return false;
  10016. if (GetShop()) return false;
  10017. if (GetMyShop()) return false;
  10018. if (m_bUnderRefine) return false;
  10019. if (IsWarping()) return false;
  10020.  
  10021. return true;
  10022. }
  10023.  
  10024. bool CHARACTER::UnEquipSpecialRideUniqueItem()
  10025. {
  10026. LPITEM Unique1 = GetWear(WEAR_UNIQUE1);
  10027. LPITEM Unique2 = GetWear(WEAR_UNIQUE2);
  10028. LPITEM Unique3 = GetWear(WEAR_COSTUME_MOUNT);
  10029.  
  10030. if (NULL != Unique1)
  10031. {
  10032. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique1->GetSpecialGroup())
  10033. {
  10034. return UnequipItem(Unique1);
  10035. }
  10036. }
  10037.  
  10038. if (NULL != Unique2)
  10039. {
  10040. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique2->GetSpecialGroup())
  10041. {
  10042. return UnequipItem(Unique2);
  10043. }
  10044. }
  10045.  
  10046. if (NULL != Unique3)
  10047. {
  10048. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique3->GetSpecialGroup())
  10049. {
  10050. return UnequipItem(Unique3);
  10051. }
  10052. }
  10053.  
  10054. return true;
  10055. }
  10056.  
  10057. void CHARACTER::AutoRecoveryItemProcess(const EAffectTypes type)
  10058. {
  10059. if (true == IsDead() || true == IsStun())
  10060. return;
  10061.  
  10062. if (false == IsPC())
  10063. return;
  10064.  
  10065. if (AFFECT_AUTO_HP_RECOVERY != type && AFFECT_AUTO_SP_RECOVERY != type)
  10066. return;
  10067.  
  10068. if (NULL != FindAffect(AFFECT_STUN))
  10069. return;
  10070.  
  10071. {
  10072. const DWORD stunSkills[] = { SKILL_TANHWAN, SKILL_GEOMPUNG, SKILL_BYEURAK, SKILL_GIGUNG };
  10073.  
  10074. for (size_t i=0 ; i < sizeof(stunSkills)/sizeof(DWORD) ; ++i)
  10075. {
  10076. const CAffect* p = FindAffect(stunSkills[i]);
  10077.  
  10078. if (NULL != p && AFF_STUN == p->dwFlag)
  10079. return;
  10080. }
  10081. }
  10082.  
  10083. const CAffect* pAffect = FindAffect(type);
  10084. const size_t idx_of_amount_of_used = 1;
  10085. const size_t idx_of_amount_of_full = 2;
  10086.  
  10087. if (NULL != pAffect)
  10088. {
  10089. LPITEM pItem = FindItemByID(pAffect->dwFlag);
  10090.  
  10091. if (NULL != pItem && true == pItem->GetSocket(0))
  10092. {
  10093. if (false == CArenaManager::instance().IsArenaMap(GetMapIndex()))
  10094. {
  10095. const long amount_of_used = pItem->GetSocket(idx_of_amount_of_used);
  10096. const long amount_of_full = pItem->GetSocket(idx_of_amount_of_full);
  10097.  
  10098. const int32_t avail = amount_of_full - amount_of_used;
  10099.  
  10100. int32_t amount = 0;
  10101.  
  10102. if (AFFECT_AUTO_HP_RECOVERY == type)
  10103. {
  10104. amount = GetMaxHP() - (GetHP() + GetPoint(POINT_HP_RECOVERY));
  10105. }
  10106. else if (AFFECT_AUTO_SP_RECOVERY == type)
  10107. {
  10108. amount = GetMaxSP() - (GetSP() + GetPoint(POINT_SP_RECOVERY));
  10109. }
  10110.  
  10111. if (amount > 0)
  10112. {
  10113. if (avail > amount)
  10114. {
  10115. const int pct_of_used = amount_of_used * 100 / amount_of_full;
  10116. const int pct_of_will_used = (amount_of_used + amount) * 100 / amount_of_full;
  10117.  
  10118. bool bLog = false;
  10119.  
  10120. if ((pct_of_will_used / 10) - (pct_of_used / 10) >= 1)
  10121. bLog = true;
  10122. pItem->SetSocket(idx_of_amount_of_used, amount_of_used + amount, bLog);
  10123. }
  10124. else
  10125. {
  10126. amount = avail;
  10127.  
  10128. ITEM_MANAGER::instance().RemoveItem( pItem );
  10129. }
  10130.  
  10131. if (AFFECT_AUTO_HP_RECOVERY == type)
  10132. {
  10133. PointChange( POINT_HP_RECOVERY, amount );
  10134. EffectPacket( SE_AUTO_HPUP );
  10135. }
  10136. else if (AFFECT_AUTO_SP_RECOVERY == type)
  10137. {
  10138. PointChange( POINT_SP_RECOVERY, amount );
  10139. EffectPacket( SE_AUTO_SPUP );
  10140. }
  10141. }
  10142. }
  10143. else
  10144. {
  10145. pItem->Lock(false);
  10146. pItem->SetSocket(0, false);
  10147. RemoveAffect( const_cast<CAffect*>(pAffect) );
  10148. }
  10149. }
  10150. else
  10151. {
  10152. RemoveAffect( const_cast<CAffect*>(pAffect) );
  10153. }
  10154. }
  10155. }
  10156.  
  10157. bool CHARACTER::IsValidItemPosition(TItemPos Pos) const
  10158. {
  10159. BYTE window_type = Pos.window_type;
  10160. WORD cell = Pos.cell;
  10161.  
  10162. switch (window_type)
  10163. {
  10164. case RESERVED_WINDOW:
  10165. return false;
  10166.  
  10167. case INVENTORY:
  10168. case EQUIPMENT:
  10169. return cell < (INVENTORY_AND_EQUIP_SLOT_MAX);
  10170.  
  10171. case DRAGON_SOUL_INVENTORY:
  10172. return cell < (DRAGON_SOUL_INVENTORY_MAX_NUM);
  10173. #ifdef ENABLE_SPECIAL_STORAGE
  10174. case UPGRADE_INVENTORY:
  10175. case BOOK_INVENTORY:
  10176. case STONE_INVENTORY:
  10177. case DND_INVENTORY:
  10178. case GEAR_INVENTORY:
  10179. return cell < (SPECIAL_INVENTORY_MAX_NUM);
  10180. #endif
  10181. case SAFEBOX:
  10182. if (NULL != m_pkSafebox)
  10183. return m_pkSafebox->IsValidPosition(cell);
  10184. else
  10185. return false;
  10186.  
  10187. case MALL:
  10188. if (NULL != m_pkMall)
  10189. return m_pkMall->IsValidPosition(cell);
  10190. else
  10191. return false;
  10192.  
  10193. #ifdef __ATTR_SWITCH_SYSTEM__
  10194. case SWITCHBOT:
  10195. return cell < SWITCHBOT_SLOT_COUNT;
  10196. #endif
  10197.  
  10198. default:
  10199. return false;
  10200. }
  10201. }
  10202.  
  10203.  
  10204. #define VERIFY_MSG(exp, msg) \
  10205. if (true == (exp)) { \
  10206. ChatPacket(CHAT_TYPE_INFO, LC_TEXT(msg)); \
  10207. return false; \
  10208. }
  10209.  
  10210.  
  10211. bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell) /*const*/
  10212. {
  10213. const TItemTable* itemTable = item->GetProto();
  10214. BYTE itemType = item->GetType();
  10215. BYTE itemSubType = item->GetSubType();
  10216. #ifdef __WEAPON_COSTUME_SYSTEM__
  10217.  
  10218. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
  10219. {
  10220. LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
  10221. if (pkItem)
  10222. {
  10223. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
  10224. return false;
  10225. }
  10226. }
  10227.  
  10228. else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == COSTUME_WEAPON)
  10229. {
  10230. LPITEM pkItem = GetWear(WEAR_WEAPON);
  10231. if (!pkItem)
  10232. {
  10233. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't wear a costume weapon without have a weapon weared."));
  10234. return false;
  10235. }
  10236.  
  10237. else if (item->GetValue(3) != pkItem->GetSubType())
  10238. {
  10239. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't wear a costume weapon who has different type of your weapon."));
  10240. return false;
  10241. }
  10242.  
  10243. else if (pkItem->GetType() == ITEM_ROD || pkItem->GetType() == ITEM_PICK) // // block fish rod and pick
  10244. {
  10245. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti pune skin de arma pe undita, esti nebun? :)) "));
  10246. return false;
  10247. }
  10248. }
  10249.  
  10250. #endif
  10251. #ifdef __EFFECT_SYSTEM__
  10252. if (item->GetType() == ITEM_ARMOR && item->GetSubType() == ARMOR_BODY)
  10253. {
  10254. LPITEM pkItem = GetWear(WEAR_EFFECT_ARMOR);
  10255. if (pkItem)
  10256. {
  10257. ChatPacket(CHAT_TYPE_INFO, "Pentru a schimba armura trebuie sa dai effectul jos.");
  10258. return false;
  10259. }
  10260. }
  10261. else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == USE_EFFECT)
  10262. {
  10263. {
  10264. LPITEM pkItem = GetWear(WEAR_BODY);
  10265. if (!pkItem)
  10266. {
  10267. ChatPacket(CHAT_TYPE_INFO, "Trebuie sa ai o armura echipata pentru a purta effectul.");
  10268. return false;
  10269. }
  10270. }
  10271. }
  10272. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
  10273. {
  10274. LPITEM pkItem = GetWear(WEAR_EFFECT_WEAPON);
  10275. if (pkItem)
  10276. {
  10277. ChatPacket(CHAT_TYPE_INFO, "Pentru a schimba arma trebuie sa dai effectul jos.");
  10278. return false;
  10279. }
  10280. }
  10281.  
  10282. else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == USE_EFFECT_TWO)
  10283. {
  10284. LPITEM pkItem = GetWear(WEAR_WEAPON);
  10285. if (!pkItem)
  10286. {
  10287. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa ai o arma echipata pentru a purta effectul."));
  10288. return false;
  10289. }
  10290. }
  10291. #endif
  10292. switch (GetJob())
  10293. {
  10294. case JOB_WARRIOR:
  10295. if (item->GetAntiFlag() & ITEM_ANTIFLAG_WARRIOR)
  10296. return false;
  10297. break;
  10298.  
  10299. case JOB_ASSASSIN:
  10300. if (item->GetAntiFlag() & ITEM_ANTIFLAG_ASSASSIN)
  10301. return false;
  10302. break;
  10303.  
  10304. case JOB_SHAMAN:
  10305. if (item->GetAntiFlag() & ITEM_ANTIFLAG_SHAMAN)
  10306. return false;
  10307. break;
  10308.  
  10309. case JOB_SURA:
  10310. if (item->GetAntiFlag() & ITEM_ANTIFLAG_SURA)
  10311. return false;
  10312. break;
  10313. }
  10314.  
  10315. for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
  10316. {
  10317. long limit = itemTable->aLimits[i].lValue;
  10318. switch (itemTable->aLimits[i].bType)
  10319. {
  10320. case LIMIT_LEVEL:
  10321. if (GetLevel() < limit)
  10322. {
  10323. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul tau este prea mic."));
  10324. return false;
  10325. }
  10326. break;
  10327.  
  10328. case LIMIT_STR:
  10329. if (GetPoint(POINT_ST) < limit)
  10330. {
  10331. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
  10332. return false;
  10333. }
  10334. break;
  10335.  
  10336. case LIMIT_INT:
  10337. if (GetPoint(POINT_IQ) < limit)
  10338. {
  10339. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
  10340. return false;
  10341. }
  10342. break;
  10343.  
  10344. case LIMIT_DEX:
  10345. if (GetPoint(POINT_DX) < limit)
  10346. {
  10347. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
  10348. return false;
  10349. }
  10350. break;
  10351.  
  10352. case LIMIT_CON:
  10353. if (GetPoint(POINT_HT) < limit)
  10354. {
  10355. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
  10356. return false;
  10357. }
  10358. break;
  10359. }
  10360. }
  10361.  
  10362. if (item->GetWearFlag() & WEARABLE_UNIQUE)
  10363. {
  10364. if ((GetWear(WEAR_UNIQUE1) && GetWear(WEAR_UNIQUE1)->IsSameSpecialGroup(item)) ||
  10365. (GetWear(WEAR_UNIQUE2) && GetWear(WEAR_UNIQUE2)->IsSameSpecialGroup(item)) ||
  10366. (GetWear(WEAR_COSTUME_MOUNT) && GetWear(WEAR_COSTUME_MOUNT)->IsSameSpecialGroup(item)))
  10367. {
  10368. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asa ceva!"));
  10369. return false;
  10370. }
  10371.  
  10372. if (marriage::CManager::instance().IsMarriageUniqueItem(item->GetVnum()) &&
  10373. !marriage::CManager::instance().IsMarried(GetPlayerID()))
  10374. {
  10375. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Puteti folosi acest item doar in prezenta partenerului."));
  10376. return false;
  10377. }
  10378.  
  10379. }
  10380. if (item->GetType() == ITEM_RING) // ring check for two same rings
  10381. {
  10382. LPITEM ringItems[2] = { GetWear(WEAR_RING1), GetWear(WEAR_RING2) };
  10383. for (int i = 0; i < 2; i++)
  10384. {
  10385. if (ringItems[i]) // if that item is equipped
  10386. {
  10387. if (ringItems[i]->GetVnum() == item->GetVnum())
  10388. {
  10389. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti echipa acest item de doua ori!"));
  10390. return false;
  10391. }
  10392. }
  10393. }
  10394. }
  10395. return true;
  10396. }
  10397.  
  10398. bool CHARACTER::CanUnequipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell) /*const*/
  10399. {
  10400. #ifdef BELT_INVENTORY_FIX
  10401. if (ITEM_BELT == item->GetType())
  10402. VERIFY_MSG(CBeltInventoryHelper::IsExistItemInBeltInventory(this), "<Belt>Elibereaza mai intai inventarul Belt.");
  10403. #endif
  10404.  
  10405. // ¿µ¿øÈ÷ ÇØÁ¦ÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛ
  10406. if (IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
  10407. return false;
  10408.  
  10409. #ifdef __EFFECT_SYSTEM__
  10410. if (item->GetType() == ITEM_ARMOR && item->GetSubType() == ARMOR_BODY)
  10411. {
  10412. LPITEM pkItem = GetWear(WEAR_EFFECT_ARMOR);
  10413. if (pkItem)
  10414. {
  10415. ChatPacket(CHAT_TYPE_INFO, "Dezachipeaza effectul armurii mai intai.");
  10416. return false;
  10417. }
  10418. }
  10419. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
  10420. {
  10421. LPITEM pkItem = GetWear(WEAR_EFFECT_WEAPON);
  10422. if (pkItem)
  10423. {
  10424. ChatPacket(CHAT_TYPE_INFO, "Dezachipeaza effectul armei mai intai.");
  10425. return false;
  10426. }
  10427. }
  10428. #endif
  10429.  
  10430. #ifdef __WEAPON_COSTUME_SYSTEM__
  10431. if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
  10432. {
  10433. LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
  10434. if (pkItem)
  10435. {
  10436. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
  10437. return false;
  10438. }
  10439. }
  10440. #endif
  10441.  
  10442. {
  10443. int pos = -1;
  10444.  
  10445. if (item->IsDragonSoul())
  10446. pos = GetEmptyDragonSoulInventory(item);
  10447. #ifdef ENABLE_SPECIAL_STORAGE
  10448. else if (item->IsBook())
  10449. pos = GetEmptyBookInventory(item);
  10450. else if (item->IsUpgradeItem())
  10451. pos = GetEmptyUpgradeInventory(item);
  10452. else if (item->IsStone())
  10453. pos = GetEmptyStoneInventory(item);
  10454. else if (item->IsDnd())
  10455. pos = GetEmptyDndInventory(item);
  10456. else if (item->IsGear())
  10457. pos = GetEmptyGearInventory(item);
  10458. #endif
  10459. else
  10460. pos = GetEmptyInventory(item->GetSize());
  10461.  
  10462. VERIFY_MSG(-1 == pos, "¼ÒÁöǰ¿¡ ºó °ø°£ÀÌ ¾ø½À´Ï´Ù.");
  10463. }
  10464.  
  10465. return true;
  10466. }
  10467.  
Add Comment
Please, Sign In to add comment