MrP0wers

Untitled

Sep 30th, 2025
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 80.62 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "config.h"
  3. #include "questmanager.h"
  4. #include "sectree_manager.h"
  5. #include "char.h"
  6. #include "char_manager.h"
  7. #include "affect.h"
  8. #include "item.h"
  9. #include "item_manager.h"
  10. #include "guild_manager.h"
  11. #include "war_map.h"
  12. #include "start_position.h"
  13. #include "marriage.h"
  14. #include "mining.h"
  15. #include "p2p.h"
  16. #include "polymorph.h"
  17. #include "desc_client.h"
  18. #include "messenger_manager.h"
  19. #include "log.h"
  20. #include "utils.h"
  21. #include "unique_item.h"
  22. #include "mob_manager.h"
  23.  
  24. #ifdef ENABLE_DAMAGE_TOP
  25. #include "damage_top.h"
  26. #endif
  27.  
  28. #include <cctype>
  29. #undef sys_err
  30. #ifndef __WIN32__
  31. #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
  32. #else
  33. #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
  34. #endif
  35.  
  36. extern int g_nPortalLimitTime;
  37. extern LPCLIENT_DESC db_clientdesc;
  38. const int ITEM_BROKEN_METIN_VNUM = 28960;
  39.  
  40. namespace quest
  41. {
  42. int pc_has_master_skill(lua_State* L)
  43. {
  44. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  45. bool bHasMasterSkill = false;
  46.  
  47. for (int i=0; i< SKILL_MAX_NUM; i++)
  48. if (ch->GetSkillMasterType(i) >= SKILL_MASTER && ch->GetSkillLevel(i) >= 21)
  49. {
  50. bHasMasterSkill = true;
  51. break;
  52. }
  53.  
  54. lua_pushboolean(L, bHasMasterSkill);
  55.  
  56. return 1;
  57. }
  58.  
  59. #ifdef ENABLE_DAMAGE_TOP
  60. int pc_open_damage_top(lua_State * L)
  61. {
  62. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  63. if (ch)
  64. {
  65. CDamageTop::instance().OpenDamageTop(ch);
  66. }
  67.  
  68. return 0;
  69. }
  70. #endif
  71.  
  72. int pc_remove_skill_book_no_delay(lua_State* L)
  73. {
  74. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  75. ch->RemoveAffect(AFFECT_SKILL_NO_BOOK_DELAY);
  76.  
  77. return 0;
  78. }
  79.  
  80. int pc_is_skill_book_no_delay(lua_State* L)
  81. {
  82. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  83.  
  84. lua_pushboolean(L, ch->FindAffect(AFFECT_SKILL_NO_BOOK_DELAY) ? true : false);
  85.  
  86. return 1;
  87. }
  88.  
  89. int pc_learn_grand_master_skill(lua_State* L)
  90. {
  91. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  92.  
  93. if (!lua_isnumber(L, 1))
  94. {
  95. sys_err("wrong skill index");
  96. return 0;
  97. }
  98.  
  99. lua_pushboolean(L, ch->LearnGrandMasterSkill((long)lua_tonumber(L, 1)));
  100.  
  101. return 1;
  102. }
  103.  
  104. #ifdef ENABLE_MESSENGER_BLOCK
  105. int pc_is_blocked(lua_State* L)
  106. {
  107. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  108.  
  109. if (!lua_isnumber(L, 1))
  110. {
  111. sys_err("wrong::pc_is_blocked");
  112. return 0;
  113. }
  114.  
  115. const char * arg1 = lua_tostring(L, 1);
  116. LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(arg1);
  117. if(!tch || !tch->IsPC())
  118. {
  119. sys_err("wrong::pc_is_blocked-2");
  120. return 0;
  121. }
  122.  
  123. lua_pushboolean(L, MessengerManager::instance().CheckMessengerList(ch->GetName(), tch->GetName(), SYST_BLOCK));
  124.  
  125. return 1;
  126. }
  127.  
  128. int pc_is_friend(lua_State* L)
  129. {
  130. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  131.  
  132. if (!lua_isnumber(L, 1))
  133. {
  134. sys_err("wrong::pc_is_blocked");
  135. return 0;
  136. }
  137.  
  138. const char * arg1 = lua_tostring(L, 1);
  139. LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(arg1);
  140. if(!tch || !tch->IsPC())
  141. {
  142. sys_err("wrong::pc_is_blocked-2");
  143. return 0;
  144. }
  145.  
  146. lua_pushboolean(L, MessengerManager::instance().CheckMessengerList(ch->GetName(), tch->GetName(), SYST_FRIEND));
  147.  
  148. return 1;
  149. }
  150. #endif
  151.  
  152. int pc_set_warp_location(lua_State * L)
  153. {
  154. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  155.  
  156. if (!lua_isnumber(L, 1))
  157. {
  158. sys_err("wrong map index");
  159. return 0;
  160. }
  161.  
  162. if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
  163. {
  164. sys_err("wrong coodinate");
  165. return 0;
  166. }
  167.  
  168. ch->SetWarpLocation((long)lua_tonumber(L,1), (long)lua_tonumber(L,2), (long)lua_tonumber(L,3));
  169.  
  170. return 0;
  171. }
  172.  
  173. int pc_set_warp_location_local(lua_State * L)
  174. {
  175. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  176.  
  177. if (!lua_isnumber(L, 1))
  178. {
  179. sys_err("wrong map index");
  180. return 0;
  181. }
  182.  
  183. if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
  184. {
  185. sys_err("wrong coodinate");
  186.  
  187. return 0;
  188. }
  189.  
  190. long lMapIndex = (long) lua_tonumber(L, 1);
  191. const TMapRegion * region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex);
  192.  
  193. if (!region)
  194. {
  195. sys_err("invalid map index %d", lMapIndex);
  196.  
  197. return 0;
  198. }
  199.  
  200. int x = (int) lua_tonumber(L, 2);
  201. int y = (int) lua_tonumber(L, 3);
  202.  
  203. if (x > region->ex - region->sx)
  204. {
  205. sys_err("x coordinate overflow max: %d input: %d", region->ex - region->sx, x);
  206.  
  207. return 0;
  208. }
  209.  
  210. if (y > region->ey - region->sy)
  211. {
  212. sys_err("y coordinate overflow max: %d input: %d", region->ey - region->sy, y);
  213.  
  214. return 0;
  215. }
  216.  
  217. ch->SetWarpLocation(lMapIndex, x, y);
  218.  
  219. return 0;
  220. }
  221.  
  222. int pc_get_start_location(lua_State * L)
  223. {
  224. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  225.  
  226. lua_pushnumber(L, g_start_map[ch->GetEmpire()]);
  227. lua_pushnumber(L, g_start_position[ch->GetEmpire()][0] / 100);
  228. lua_pushnumber(L, g_start_position[ch->GetEmpire()][1] / 100);
  229.  
  230. return 3;
  231. }
  232.  
  233. int pc_warp(lua_State * L)
  234. {
  235. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  236.  
  237. if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
  238. {
  239. lua_pushboolean(L, false);
  240. return 1;
  241. }
  242.  
  243. long map_index = 0;
  244.  
  245. if (lua_isnumber(L, 3))
  246. map_index = (int) lua_tonumber(L,3);
  247.  
  248. if ( ch->IsHack() )
  249. {
  250. lua_pushboolean(L, false);
  251. return 1;
  252. }
  253.  
  254. if ( test_server )
  255. ch->ChatPacket( CHAT_TYPE_INFO, "pc_warp %d %d %d",(int)lua_tonumber(L,1), (int)lua_tonumber(L,2),map_index );
  256.  
  257. ch->WarpSet((int)lua_tonumber(L, 1), (int)lua_tonumber(L, 2), map_index);
  258.  
  259. lua_pushboolean(L, true);
  260.  
  261. return 1;
  262. }
  263.  
  264. int pc_warp_local(lua_State * L)
  265. {
  266. if (!lua_isnumber(L, 1))
  267. {
  268. sys_err("no map index argument");
  269. return 0;
  270. }
  271.  
  272. if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
  273. {
  274. sys_err("no coodinate argument");
  275. return 0;
  276. }
  277.  
  278. long lMapIndex = (long) lua_tonumber(L, 1);
  279. const TMapRegion * region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex);
  280.  
  281. if (!region)
  282. {
  283. sys_err("invalid map index %d", lMapIndex);
  284. return 0;
  285. }
  286.  
  287. int x = (int) lua_tonumber(L, 2);
  288. int y = (int) lua_tonumber(L, 3);
  289.  
  290. if (x > region->ex - region->sx)
  291. {
  292. sys_err("x coordinate overflow max: %d input: %d", region->ex - region->sx, x);
  293. return 0;
  294. }
  295.  
  296. if (y > region->ey - region->sy)
  297. {
  298. sys_err("y coordinate overflow max: %d input: %d", region->ey - region->sy, y);
  299. return 0;
  300. }
  301.  
  302. CQuestManager::instance().GetCurrentCharacterPtr()->WarpSet(region->sx + x, region->sy + y);
  303.  
  304. return 0;
  305. }
  306.  
  307. int pc_warp_exit(lua_State * L)
  308. {
  309. CQuestManager::instance().GetCurrentCharacterPtr()->ExitToSavedLocation();
  310.  
  311. return 0;
  312. }
  313.  
  314. int pc_in_dungeon(lua_State * L)
  315. {
  316. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  317. lua_pushboolean(L, ch->GetDungeon()?1:0);
  318.  
  319. return 1;
  320. }
  321.  
  322. int pc_hasguild(lua_State * L)
  323. {
  324. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  325. lua_pushboolean(L, ch->GetGuild() ? 1 : 0);
  326.  
  327. return 1;
  328. }
  329.  
  330. int pc_getguild(lua_State * L)
  331. {
  332. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  333. lua_pushnumber(L, ch->GetGuild() ? ch->GetGuild()->GetID() : 0);
  334.  
  335. return 1;
  336. }
  337.  
  338. int pc_isguildmaster(lua_State * L)
  339. {
  340. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  341. CGuild * g = ch->GetGuild();
  342.  
  343. if (g)
  344. lua_pushboolean(L, (ch->GetPlayerID() == g->GetMasterPID()));
  345. else
  346. lua_pushboolean(L, 0);
  347.  
  348. return 1;
  349. }
  350.  
  351. int pc_destroy_guild(lua_State * L)
  352. {
  353. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  354. CGuild * g = ch->GetGuild();
  355.  
  356. if (g)
  357. g->RequestDisband(ch->GetPlayerID());
  358.  
  359. return 0;
  360. }
  361.  
  362. int pc_remove_from_guild(lua_State* L)
  363. {
  364. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  365. CGuild * g = ch->GetGuild();
  366.  
  367. if (g)
  368. g->RequestRemoveMember(ch->GetPlayerID());
  369.  
  370. return 0;
  371. }
  372.  
  373. int pc_give_gold(lua_State* L)
  374. {
  375. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  376.  
  377. if (!lua_isnumber(L, 1))
  378. {
  379. sys_err("QUEST : wrong argument");
  380. return 0;
  381. }
  382.  
  383. long long iAmount = (long long)lua_tonumber(L, 1);
  384.  
  385. if (iAmount <= 0)
  386. {
  387. sys_err("QUEST : gold amount less then zero");
  388.  
  389. return 0;
  390. }
  391.  
  392. DBManager::instance().SendMoneyLog(MONEY_LOG_QUEST, ch->GetPlayerID(), iAmount);
  393. ch->PointChange(POINT_GOLD, iAmount, true);
  394.  
  395. return 0;
  396. }
  397.  
  398. int pc_warp_to_guild_war_observer_position(lua_State* L)
  399. {
  400. luaL_checknumber(L, 1);
  401. luaL_checknumber(L, 2);
  402.  
  403. DWORD gid1 = (DWORD)lua_tonumber(L, 1);
  404. DWORD gid2 = (DWORD)lua_tonumber(L, 2);
  405.  
  406. CGuild* g1 = CGuildManager::instance().FindGuild(gid1);
  407. CGuild* g2 = CGuildManager::instance().FindGuild(gid2);
  408.  
  409. if (!g1 || !g2)
  410. {
  411. luaL_error(L, "no such guild with id %d %d", gid1, gid2);
  412. }
  413.  
  414. PIXEL_POSITION pos;
  415.  
  416. DWORD dwMapIndex = g1->GetGuildWarMapIndex(gid2);
  417.  
  418. if (!CWarMapManager::instance().GetStartPosition(dwMapIndex, 2, pos))
  419. {
  420. luaL_error(L, "not under warp guild war between guild %d %d", gid1, gid2);
  421. return 0;
  422. }
  423.  
  424. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  425.  
  426. if ( ch->IsHack() )
  427. return 0;
  428.  
  429. ch->SetQuestFlag("war.is_war_member", 0);
  430. ch->SaveExitLocation();
  431. ch->WarpSet(pos.x, pos.y, dwMapIndex);
  432.  
  433. return 0;
  434. }
  435.  
  436. int pc_give_item_from_special_item_group(lua_State* L)
  437. {
  438. luaL_checknumber(L, 1);
  439.  
  440. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  441.  
  442. DWORD dwGroupVnum = (DWORD) lua_tonumber(L,1);
  443.  
  444. std::vector <DWORD> dwVnums;
  445. std::vector <DWORD> dwCounts;
  446. std::vector <LPITEM> item_gets(NULL);
  447. int count = 0;
  448.  
  449. ch->GiveItemFromSpecialItemGroup(dwGroupVnum, dwVnums, dwCounts, item_gets, count);
  450.  
  451. for (int i = 0; i < count; i++)
  452. {
  453. if (!item_gets[i])
  454. {
  455. if (dwVnums[i] == 1)
  456. {
  457. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈 %d 냥을 획득했습니다."), dwCounts[i]);
  458. }
  459.  
  460. else if (dwVnums[i] == 2)
  461. {
  462. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("나무에서 부터 신비한 빛이 나옵니다."));
  463. ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%d의 경험치를 획득했습니다."), dwCounts[i]);
  464. }
  465. }
  466. }
  467.  
  468. return 0;
  469. }
  470.  
  471. int pc_enough_inventory(lua_State* L)
  472. {
  473. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  474. if (!lua_isnumber(L, 1))
  475. {
  476. lua_pushboolean(L, 0);
  477.  
  478. return 1;
  479. }
  480.  
  481. DWORD item_vnum = (DWORD)lua_tonumber(L, 1);
  482. TItemTable * pTable = ITEM_MANAGER::instance().GetTable(item_vnum);
  483. if (!pTable)
  484. {
  485. lua_pushboolean(L, 0);
  486.  
  487. return 1;
  488. }
  489.  
  490. bool bEnoughInventoryForItem = ch->GetEmptyInventory(pTable->bSize) != -1;
  491. lua_pushboolean(L, bEnoughInventoryForItem);
  492. return 1;
  493. }
  494.  
  495. int pc_give_item(lua_State* L)
  496. {
  497. PC* pPC = CQuestManager::instance().GetCurrentPC();
  498. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  499.  
  500. if (!lua_isstring(L, 1) || !(lua_isstring(L, 2)||lua_isnumber(L, 2)))
  501. {
  502. sys_err("QUEST : wrong argument");
  503. return 0;
  504. }
  505.  
  506. DWORD dwVnum;
  507.  
  508. if (lua_isnumber(L,2))
  509. dwVnum = (int) lua_tonumber(L, 2);
  510.  
  511. else if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L, 2), dwVnum))
  512. {
  513. sys_err("QUEST Make item call error : wrong item name : %s", lua_tostring(L,1));
  514. return 0;
  515. }
  516.  
  517. int icount = 1;
  518.  
  519. if (lua_isnumber(L, 3) && lua_tonumber(L, 3) > 0)
  520. {
  521. icount = (int)rint(lua_tonumber(L, 3));
  522.  
  523. if (icount <= 0)
  524. {
  525. sys_err("QUEST Make item call error : wrong item count : %g", lua_tonumber(L, 2));
  526.  
  527. return 0;
  528. }
  529. }
  530.  
  531. pPC->GiveItem(lua_tostring(L, 1), dwVnum, icount);
  532.  
  533. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), dwVnum, icount);
  534.  
  535. return 0;
  536. }
  537.  
  538. int pc_give_or_drop_item(lua_State* L)
  539. {
  540. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  541.  
  542. if (!lua_isstring(L, 1) && !lua_isnumber(L, 1))
  543. {
  544. sys_err("QUEST Make item call error : wrong argument");
  545. lua_pushnumber (L, 0);
  546.  
  547. return 1;
  548. }
  549.  
  550. DWORD dwVnum;
  551.  
  552. if (lua_isnumber(L, 1))
  553. {
  554. dwVnum = (int) lua_tonumber(L, 1);
  555. }
  556.  
  557. else if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L, 1), dwVnum))
  558. {
  559. sys_err("QUEST Make item call error : wrong item name : %s", lua_tostring(L,1));
  560. lua_pushnumber (L, 0);
  561.  
  562. return 1;
  563. }
  564.  
  565. int icount = 1;
  566. if (lua_isnumber(L,2) && lua_tonumber(L,2)>0)
  567. {
  568. icount = (int)rint(lua_tonumber(L,2));
  569. if (icount<=0)
  570. {
  571. sys_err("QUEST Make item call error : wrong item count : %g", lua_tonumber(L,2));
  572. lua_pushnumber (L, 0);
  573.  
  574. return 1;
  575. }
  576. }
  577.  
  578. sys_log(0, "QUEST [REWARD] item %s to %s", lua_tostring(L, 1), ch->GetName());
  579.  
  580. PC* pPC = CQuestManager::instance().GetCurrentPC();
  581.  
  582. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), dwVnum, icount);
  583.  
  584. LPITEM item = ch->AutoGiveItem(dwVnum, icount);
  585.  
  586. if ( dwVnum >= 80003 && dwVnum <= 80007 )
  587. {
  588. LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), QUEST, "quest: give_item2");
  589. }
  590.  
  591. if (NULL != item)
  592. lua_pushnumber (L, item->GetID());
  593. else
  594. lua_pushnumber (L, 0);
  595.  
  596. return 1;
  597. }
  598.  
  599. int pc_give_or_drop_item_and_select(lua_State* L)
  600. {
  601. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  602.  
  603. if (!lua_isstring(L, 1) && !lua_isnumber(L, 1))
  604. {
  605. sys_err("QUEST Make item call error : wrong argument");
  606. return 0;
  607. }
  608.  
  609. DWORD dwVnum;
  610.  
  611. if (lua_isnumber(L, 1))
  612. {
  613. dwVnum = (int) lua_tonumber(L, 1);
  614. }
  615.  
  616. else if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L, 1), dwVnum))
  617. {
  618. sys_err("QUEST Make item call error : wrong item name : %s", lua_tostring(L,1));
  619. return 0;
  620. }
  621.  
  622. int icount = 1;
  623. if (lua_isnumber(L,2) && lua_tonumber(L,2)>0)
  624. {
  625. icount = (int)rint(lua_tonumber(L,2));
  626. if (icount<=0)
  627. {
  628. sys_err("QUEST Make item call error : wrong item count : %g", lua_tonumber(L,2));
  629. return 0;
  630. }
  631. }
  632.  
  633. sys_log(0, "QUEST [REWARD] item %s to %s", lua_tostring(L, 1), ch->GetName());
  634.  
  635. PC* pPC = CQuestManager::instance().GetCurrentPC();
  636.  
  637. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), dwVnum, icount);
  638.  
  639. LPITEM item = ch->AutoGiveItem(dwVnum, icount);
  640.  
  641. if (NULL != item)
  642. CQuestManager::Instance().SetCurrentItem(item);
  643.  
  644. if ( dwVnum >= 80003 && dwVnum <= 80007 )
  645. {
  646. LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), QUEST, "quest: give_item2");
  647. }
  648.  
  649. return 0;
  650. }
  651.  
  652. int pc_get_current_map_index(lua_State* L)
  653. {
  654. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetMapIndex());
  655.  
  656. return 1;
  657. }
  658.  
  659. int pc_get_x(lua_State* L)
  660. {
  661. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  662. lua_pushnumber(L, ch->GetX()/100);
  663.  
  664. return 1;
  665. }
  666.  
  667. int pc_get_y(lua_State* L)
  668. {
  669. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  670. lua_pushnumber(L, ch->GetY()/100);
  671.  
  672. return 1;
  673. }
  674.  
  675. int pc_get_local_x(lua_State* L)
  676. {
  677. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  678. LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());
  679.  
  680. if (pMap)
  681. lua_pushnumber(L, (ch->GetX() - pMap->m_setting.iBaseX) / 100);
  682. else
  683. lua_pushnumber(L, ch->GetX() / 100);
  684.  
  685. return 1;
  686. }
  687.  
  688. int pc_get_local_y(lua_State* L)
  689. {
  690. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  691. LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());
  692.  
  693. if (pMap)
  694. lua_pushnumber(L, (ch->GetY() - pMap->m_setting.iBaseY) / 100);
  695. else
  696. lua_pushnumber(L, ch->GetY() / 100);
  697.  
  698. return 1;
  699. }
  700.  
  701. int pc_count_item(lua_State* L)
  702. {
  703. if (lua_isnumber(L, -1))
  704. lua_pushnumber(L,CQuestManager::instance().GetCurrentCharacterPtr()->CountSpecifyItem((DWORD)lua_tonumber(L, -1)));
  705.  
  706. else if (lua_isstring(L, -1))
  707. {
  708. DWORD item_vnum;
  709.  
  710. if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L,1), item_vnum))
  711. {
  712. sys_err("QUEST count_item call error : wrong item name : %s", lua_tostring(L,1));
  713. lua_pushnumber(L, 0);
  714. }
  715.  
  716. else
  717. {
  718. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->CountSpecifyItem(item_vnum));
  719. }
  720. }
  721.  
  722. else
  723. lua_pushnumber(L, 0);
  724.  
  725. return 1;
  726. }
  727.  
  728. int pc_remove_item(lua_State* L)
  729. {
  730. if (lua_gettop(L) == 1)
  731. {
  732. DWORD item_vnum;
  733.  
  734. if (lua_isnumber(L,1))
  735. {
  736. item_vnum = (DWORD)lua_tonumber(L, 1);
  737. }
  738.  
  739. else if (lua_isstring(L,1))
  740. {
  741. if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L,1), item_vnum))
  742. {
  743. sys_err("QUEST remove_item call error : wrong item name : %s", lua_tostring(L,1));
  744. return 0;
  745. }
  746. }
  747.  
  748. else
  749. {
  750. sys_err("QUEST remove_item wrong argument");
  751.  
  752. return 0;
  753. }
  754.  
  755. sys_log(0,"QUEST remove a item vnum %d of %s[%d]", item_vnum, CQuestManager::instance().GetCurrentCharacterPtr()->GetName(), CQuestManager::instance().GetCurrentCharacterPtr()->GetPlayerID());
  756. CQuestManager::instance().GetCurrentCharacterPtr()->RemoveSpecifyItem(item_vnum);
  757. }
  758.  
  759. else if (lua_gettop(L) == 2)
  760. {
  761. DWORD item_vnum;
  762.  
  763. if (lua_isnumber(L, 1))
  764. {
  765. item_vnum = (DWORD)lua_tonumber(L, 1);
  766. }
  767.  
  768. else if (lua_isstring(L, 1))
  769. {
  770. if (!ITEM_MANAGER::instance().GetVnum(lua_tostring(L,1), item_vnum))
  771. {
  772. sys_err("QUEST remove_item call error : wrong item name : %s", lua_tostring(L,1));
  773. return 0;
  774. }
  775. }
  776.  
  777. else
  778. {
  779. sys_err("QUEST remove_item wrong argument");
  780. return 0;
  781. }
  782.  
  783. DWORD item_count = (DWORD) lua_tonumber(L, 2);
  784. sys_log(0, "QUEST remove items(vnum %d) count %d of %s[%d]",
  785. item_vnum,
  786. item_count,
  787. CQuestManager::instance().GetCurrentCharacterPtr()->GetName(),
  788. CQuestManager::instance().GetCurrentCharacterPtr()->GetPlayerID());
  789.  
  790. CQuestManager::instance().GetCurrentCharacterPtr()->RemoveSpecifyItem(item_vnum, item_count);
  791. }
  792.  
  793. return 0;
  794. }
  795.  
  796. int pc_get_leadership(lua_State * L)
  797. {
  798. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetLeadershipSkillLevel());
  799. return 1;
  800. }
  801.  
  802. int pc_reset_point(lua_State * L)
  803. {
  804. CQuestManager::instance().GetCurrentCharacterPtr()->ResetPoint(CQuestManager::instance().GetCurrentCharacterPtr()->GetLevel());
  805. return 0;
  806. }
  807.  
  808. int pc_get_playtime(lua_State* L)
  809. {
  810. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetRealPoint(POINT_PLAYTIME));
  811. return 1;
  812. }
  813.  
  814. int pc_get_vid(lua_State* L)
  815. {
  816. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetVID());
  817. return 1;
  818. }
  819.  
  820. int pc_get_name(lua_State* L)
  821. {
  822. lua_pushstring(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetName());
  823. return 1;
  824. }
  825.  
  826. int pc_get_next_exp(lua_State* L)
  827. {
  828. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetNextExp());
  829. return 1;
  830. }
  831.  
  832. int pc_get_exp(lua_State* L)
  833. {
  834. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetExp());
  835. return 1;
  836. }
  837.  
  838. int pc_get_race(lua_State* L)
  839. {
  840. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetRaceNum());
  841. return 1;
  842. }
  843.  
  844. int pc_change_sex(lua_State* L)
  845. {
  846. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->ChangeSex());
  847. return 1;
  848. }
  849.  
  850. int pc_get_job(lua_State* L)
  851. {
  852. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetJob());
  853. return 1;
  854. }
  855.  
  856. int pc_get_max_sp(lua_State* L)
  857. {
  858. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetMaxSP());
  859. return 1;
  860. }
  861.  
  862. int pc_get_sp(lua_State * L)
  863. {
  864. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetSP());
  865. return 1;
  866. }
  867.  
  868. int pc_change_sp(lua_State * L)
  869. {
  870. if (!lua_isnumber(L, 1))
  871. {
  872. sys_err("invalid argument");
  873. lua_pushboolean(L, 0);
  874.  
  875. return 1;
  876. }
  877.  
  878. long val = (long) lua_tonumber(L, 1);
  879.  
  880. if (val == 0)
  881. {
  882. lua_pushboolean(L, 0);
  883.  
  884. return 1;
  885. }
  886.  
  887. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  888.  
  889. if (val > 0)
  890. ch->PointChange(POINT_SP, val);
  891.  
  892. else if (val < 0)
  893. {
  894. if (ch->GetSP() < -val)
  895. {
  896. lua_pushboolean(L, 0);
  897. return 1;
  898. }
  899.  
  900. ch->PointChange(POINT_SP, val);
  901. }
  902.  
  903. lua_pushboolean(L, 1);
  904.  
  905. return 1;
  906. }
  907.  
  908. int pc_get_max_hp(lua_State * L)
  909. {
  910. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetMaxHP());
  911. return 1;
  912. }
  913.  
  914. int pc_get_hp(lua_State * L)
  915. {
  916. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetHP());
  917. return 1;
  918. }
  919.  
  920. int pc_get_level(lua_State * L)
  921. {
  922. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetLevel());
  923. return 1;
  924. }
  925.  
  926. int pc_set_level(lua_State * L)
  927. {
  928. if (!lua_isnumber(L, 1))
  929. {
  930. sys_err("invalid argument");
  931. return 0;
  932. }
  933.  
  934. else
  935. {
  936. int newLevel = lua_tonumber(L, 1);
  937. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  938.  
  939.  
  940. sys_log(0,"QUEST [LEVEL] %s jumpint to level %d", ch->GetName(), (int)rint(lua_tonumber(L,1)));
  941.  
  942. PC* pPC = CQuestManager::instance().GetCurrentPC();
  943. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), newLevel, 0);
  944.  
  945. ch->PointChange(POINT_SKILL, newLevel - ch->GetLevel());
  946. ch->PointChange(POINT_SUB_SKILL, newLevel < 10 ? 0 : newLevel - MAX(ch->GetLevel(), 9));
  947. ch->PointChange(POINT_STAT, ((MINMAX(1, newLevel, 90) - ch->GetLevel()) * 3) + ch->GetPoint(POINT_LEVEL_STEP));
  948.  
  949. ch->PointChange(POINT_LEVEL, newLevel - ch->GetLevel());
  950.  
  951. ch->SetRandomHP((newLevel - 1) * number(JobInitialPoints[ch->GetJob()].hp_per_lv_begin, JobInitialPoints[ch->GetJob()].hp_per_lv_end));
  952. ch->SetRandomSP((newLevel - 1) * number(JobInitialPoints[ch->GetJob()].sp_per_lv_begin, JobInitialPoints[ch->GetJob()].sp_per_lv_end));
  953.  
  954. ch->PointChange(POINT_HP, ch->GetMaxHP() - ch->GetHP());
  955. ch->PointChange(POINT_SP, ch->GetMaxSP() - ch->GetSP());
  956.  
  957. ch->ComputePoints();
  958. ch->PointsPacket();
  959. ch->SkillLevelPacket();
  960.  
  961. return 0;
  962. }
  963. }
  964.  
  965. int pc_get_weapon(lua_State * L)
  966. {
  967. LPITEM item = CQuestManager::instance().GetCurrentCharacterPtr()->GetWear(WEAR_WEAPON);
  968.  
  969. if (!item)
  970. lua_pushnumber(L, 0);
  971. else
  972. lua_pushnumber(L, item->GetVnum());
  973.  
  974. return 1;
  975. }
  976.  
  977. int pc_get_armor(lua_State * L)
  978. {
  979. LPITEM item = CQuestManager::instance().GetCurrentCharacterPtr()->GetWear(WEAR_BODY);
  980.  
  981. if (!item)
  982. lua_pushnumber(L, 0);
  983. else
  984. lua_pushnumber(L, item->GetVnum());
  985.  
  986. return 1;
  987. }
  988.  
  989. int pc_get_wear(lua_State * L)
  990. {
  991. if (!lua_isnumber(L, 1))
  992. {
  993. sys_err("QUEST wrong set flag");
  994. return 0;
  995. }
  996.  
  997. BYTE bCell = (BYTE)lua_tonumber(L, 1);
  998.  
  999. LPITEM item = CQuestManager::instance().GetCurrentCharacterPtr()->GetWear(bCell);
  1000.  
  1001.  
  1002. if (!item)
  1003. lua_pushnil(L);
  1004. else
  1005. lua_pushnumber(L, item->GetVnum());
  1006.  
  1007. return 1;
  1008. }
  1009.  
  1010. int pc_get_money(lua_State * L)
  1011. {
  1012. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetGold());
  1013. return 1;
  1014. }
  1015.  
  1016. int pc_get_real_alignment(lua_State* L)
  1017. {
  1018. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetRealAlignment()/10);
  1019. return 1;
  1020. }
  1021.  
  1022. int pc_get_alignment(lua_State* L)
  1023. {
  1024. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetAlignment()/10);
  1025. return 1;
  1026. }
  1027.  
  1028. int pc_change_alignment(lua_State * L)
  1029. {
  1030. int alignment = (int)(lua_tonumber(L, 1)*10);
  1031. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1032.  
  1033. ch->UpdateAlignment(alignment);
  1034.  
  1035. return 0;
  1036. }
  1037.  
  1038. int pc_change_money(lua_State * L)
  1039. {
  1040. long long gold = (long long)lua_tonumber(L, -1);
  1041.  
  1042. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1043.  
  1044. if (gold + ch->GetGold() < 0)
  1045. sys_err("QUEST wrong ChangeGold %d (now %lld)", gold, ch->GetGold());
  1046. else
  1047. {
  1048. DBManager::instance().SendMoneyLog(MONEY_LOG_QUEST, ch->GetPlayerID(), gold);
  1049. ch->PointChange(POINT_GOLD, gold, true);
  1050. }
  1051.  
  1052. return 0;
  1053. }
  1054.  
  1055. int pc_set_another_quest_flag(lua_State* L)
  1056. {
  1057. if (!lua_isstring(L, 1) || !lua_isstring(L, 2) || !lua_isnumber(L, 3))
  1058. {
  1059. sys_err("QUEST wrong set flag");
  1060. return 0;
  1061. }
  1062.  
  1063. else
  1064. {
  1065. const char * sz = lua_tostring(L, 1);
  1066. const char * sz2 = lua_tostring(L, 2);
  1067.  
  1068. CQuestManager & q = CQuestManager::Instance();
  1069. PC * pPC = q.GetCurrentPC();
  1070. pPC->SetFlag(string(sz)+"."+sz2, int(rint(lua_tonumber(L,3))));
  1071.  
  1072. return 0;
  1073. }
  1074. }
  1075.  
  1076. int pc_get_another_quest_flag(lua_State* L)
  1077. {
  1078. if (!lua_isstring(L,1) || !lua_isstring(L,2))
  1079. {
  1080. sys_err("QUEST wrong get flag");
  1081.  
  1082. return 0;
  1083. }
  1084.  
  1085. else
  1086. {
  1087. const char* sz = lua_tostring(L,1);
  1088. const char* sz2 = lua_tostring(L,2);
  1089.  
  1090. CQuestManager& q = CQuestManager::Instance();
  1091. PC* pPC = q.GetCurrentPC();
  1092. if (!pPC)
  1093. {
  1094. return 0;
  1095. }
  1096.  
  1097. lua_pushnumber(L,pPC->GetFlag(string(sz)+"."+sz2));
  1098.  
  1099. return 1;
  1100. }
  1101. }
  1102.  
  1103. int pc_get_flag(lua_State* L)
  1104. {
  1105. if (!lua_isstring(L,-1))
  1106. {
  1107. sys_err("QUEST wrong get flag");
  1108.  
  1109. return 0;
  1110. }
  1111.  
  1112. else
  1113. {
  1114. const char* sz = lua_tostring(L,-1);
  1115.  
  1116. CQuestManager& q = CQuestManager::Instance();
  1117. PC* pPC = q.GetCurrentPC();
  1118. lua_pushnumber(L,pPC->GetFlag(sz));
  1119.  
  1120. return 1;
  1121. }
  1122. }
  1123.  
  1124. int pc_get_quest_flag(lua_State* L)
  1125. {
  1126. if (!lua_isstring(L,-1))
  1127. {
  1128. sys_err("QUEST wrong get flag");
  1129.  
  1130. return 0;
  1131. }
  1132.  
  1133. else
  1134. {
  1135. const char* sz = lua_tostring(L,-1);
  1136.  
  1137. CQuestManager& q = CQuestManager::Instance();
  1138. PC* pPC = q.GetCurrentPC();
  1139. lua_pushnumber(L,pPC->GetFlag(pPC->GetCurrentQuestName() + "."+sz));
  1140.  
  1141. if ( test_server )
  1142. sys_log( 0 ,"GetQF ( %s . %s )", pPC->GetCurrentQuestName().c_str(), sz );
  1143. }
  1144.  
  1145. return 1;
  1146. }
  1147.  
  1148. int pc_set_flag(lua_State* L)
  1149. {
  1150. if (!lua_isstring(L,1) || !lua_isnumber(L,2))
  1151. {
  1152. sys_err("QUEST wrong set flag");
  1153. }
  1154.  
  1155. else
  1156. {
  1157. const char* sz = lua_tostring(L,1);
  1158.  
  1159. CQuestManager& q = CQuestManager::Instance();
  1160. PC* pPC = q.GetCurrentPC();
  1161. pPC->SetFlag(sz, int(rint(lua_tonumber(L,2))));
  1162. }
  1163.  
  1164. return 0;
  1165. }
  1166.  
  1167. int pc_set_quest_flag(lua_State* L)
  1168. {
  1169. if (!lua_isstring(L,1) || !lua_isnumber(L,2))
  1170. {
  1171. sys_err("QUEST wrong set flag");
  1172. }
  1173.  
  1174. else
  1175. {
  1176. const char* sz = lua_tostring(L,1);
  1177.  
  1178. CQuestManager& q = CQuestManager::Instance();
  1179. PC* pPC = q.GetCurrentPC();
  1180. pPC->SetFlag(pPC->GetCurrentQuestName()+"."+sz, int(rint(lua_tonumber(L,2))));
  1181. }
  1182.  
  1183. return 0;
  1184. }
  1185.  
  1186. int pc_del_quest_flag(lua_State *L)
  1187. {
  1188. if (!lua_isstring(L, 1))
  1189. {
  1190. sys_err("argument error");
  1191. return 0;
  1192. }
  1193.  
  1194. const char * sz = lua_tostring(L, 1);
  1195.  
  1196. PC * pPC = CQuestManager::instance().GetCurrentPC();
  1197. pPC->DeleteFlag(pPC->GetCurrentQuestName()+"."+sz);
  1198.  
  1199. return 0;
  1200. }
  1201.  
  1202. int pc_give_exp2(lua_State* L)
  1203. {
  1204. CQuestManager& q = CQuestManager::instance();
  1205. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  1206.  
  1207. if (!lua_isnumber(L,1))
  1208. return 0;
  1209.  
  1210. sys_log(0,"QUEST [REWARD] %s give exp2 %d", ch->GetName(), (int)rint(lua_tonumber(L,1)));
  1211.  
  1212. DWORD exp = (DWORD)rint(lua_tonumber(L,1));
  1213.  
  1214. PC* pPC = CQuestManager::instance().GetCurrentPC();
  1215. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), exp, 0);
  1216. ch->PointChange(POINT_EXP, exp);
  1217.  
  1218. return 0;
  1219. }
  1220.  
  1221. int pc_give_exp(lua_State* L)
  1222. {
  1223. if (!lua_isstring(L,1) || !lua_isnumber(L,2))
  1224. return 0;
  1225.  
  1226. CQuestManager& q = CQuestManager::instance();
  1227. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  1228.  
  1229. sys_log(0,"QUEST [REWARD] %s give exp %s %d", ch->GetName(), lua_tostring(L,1), (int)rint(lua_tonumber(L,2)));
  1230.  
  1231. DWORD exp = (DWORD)rint(lua_tonumber(L,2));
  1232.  
  1233. PC* pPC = CQuestManager::instance().GetCurrentPC();
  1234.  
  1235. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), exp, 0);
  1236.  
  1237. pPC->GiveExp(lua_tostring(L,1), exp);
  1238.  
  1239. return 0;
  1240. }
  1241.  
  1242. int pc_give_exp_perc(lua_State* L)
  1243. {
  1244. CQuestManager & q = CQuestManager::instance();
  1245. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  1246.  
  1247. if (!ch || !lua_isstring(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
  1248. return 0;
  1249.  
  1250. int lev = (int)rint(lua_tonumber(L,2));
  1251. double proc = (lua_tonumber(L,3));
  1252.  
  1253. sys_log(0, "QUEST [REWARD] %s give exp %s lev %d percent %g%%", ch->GetName(), lua_tostring(L, 1), lev, proc);
  1254.  
  1255. DWORD exp = (DWORD)((exp_table[MINMAX(0, lev, PLAYER_EXP_TABLE_MAX)] * proc) / 100);
  1256. PC * pPC = CQuestManager::instance().GetCurrentPC();
  1257.  
  1258. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), exp, 0);
  1259.  
  1260. pPC->GiveExp(lua_tostring(L, 1), exp);
  1261.  
  1262. return 0;
  1263. }
  1264.  
  1265. int pc_get_empire(lua_State* L)
  1266. {
  1267. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetEmpire());
  1268. return 1;
  1269. }
  1270.  
  1271. int pc_get_part(lua_State* L)
  1272. {
  1273. CQuestManager& q = CQuestManager::instance();
  1274. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  1275. if (!lua_isnumber(L,1))
  1276. {
  1277. lua_pushnumber(L, 0);
  1278. return 1;
  1279. }
  1280.  
  1281. int part_idx = (int)lua_tonumber(L, 1);
  1282. lua_pushnumber(L, ch->GetPart(part_idx));
  1283.  
  1284. return 1;
  1285. }
  1286.  
  1287. int pc_set_part(lua_State* L)
  1288. {
  1289. CQuestManager& q = CQuestManager::instance();
  1290. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  1291. if (!lua_isnumber(L,1) || !lua_isnumber(L,2))
  1292. {
  1293. return 0;
  1294. }
  1295.  
  1296. int part_idx = (int)lua_tonumber(L, 1);
  1297. int part_value = (int)lua_tonumber(L, 2);
  1298.  
  1299. ch->SetPart(part_idx, part_value);
  1300. ch->UpdatePacket();
  1301.  
  1302. return 0;
  1303. }
  1304.  
  1305. int pc_get_skillgroup(lua_State* L)
  1306. {
  1307. lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetSkillGroup());
  1308. return 1;
  1309. }
  1310.  
  1311. int pc_set_skillgroup(lua_State* L)
  1312. {
  1313. if (!lua_isnumber(L, 1))
  1314. sys_err("QUEST wrong skillgroup number");
  1315.  
  1316. else
  1317. {
  1318. CQuestManager & q = CQuestManager::Instance();
  1319. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  1320.  
  1321. ch->SetSkillGroup((BYTE) rint(lua_tonumber(L, 1)));
  1322. }
  1323.  
  1324. return 0;
  1325. }
  1326.  
  1327. int pc_is_polymorphed(lua_State* L)
  1328. {
  1329. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1330. lua_pushboolean(L, ch->IsPolymorphed());
  1331.  
  1332. return 1;
  1333. }
  1334.  
  1335. int pc_remove_polymorph(lua_State* L)
  1336. {
  1337. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1338. ch->RemoveAffect(AFFECT_POLYMORPH);
  1339. ch->SetPolymorph(0);
  1340.  
  1341. return 0;
  1342. }
  1343.  
  1344. int pc_polymorph(lua_State* L)
  1345. {
  1346. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1347. DWORD dwVnum = (DWORD) lua_tonumber(L, 1);
  1348. int iDuration = (int) lua_tonumber(L, 2);
  1349. ch->AddAffect(AFFECT_POLYMORPH, POINT_POLYMORPH, dwVnum, AFF_POLYMORPH, iDuration, 0, true);
  1350.  
  1351. return 0;
  1352. }
  1353.  
  1354. int pc_is_mount(lua_State* L)
  1355. {
  1356. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1357. lua_pushboolean(L, ch->GetMountVnum());
  1358.  
  1359. return 1;
  1360. }
  1361.  
  1362. int pc_mount(lua_State* L)
  1363. {
  1364. if (!lua_isnumber(L, 1))
  1365. return 0;
  1366.  
  1367. int length = 60;
  1368.  
  1369. if (lua_isnumber(L, 2))
  1370. length = (int)lua_tonumber(L, 2);
  1371.  
  1372. DWORD mount_vnum = (DWORD)lua_tonumber(L, 1);
  1373.  
  1374. if (length < 0)
  1375. length = 60;
  1376.  
  1377. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1378.  
  1379. ch->RemoveAffect(AFFECT_MOUNT);
  1380. ch->RemoveAffect(AFFECT_MOUNT_BONUS);
  1381.  
  1382. if (ch->GetHorse())
  1383. ch->HorseSummon(false);
  1384.  
  1385. if (mount_vnum)
  1386. {
  1387. ch->AddAffect(AFFECT_MOUNT, POINT_MOUNT, mount_vnum, AFF_NONE, length, 0, true);
  1388. switch (mount_vnum)
  1389. {
  1390. case 20201:
  1391. case 20202:
  1392. case 20203:
  1393. case 20204:
  1394. case 20213:
  1395. case 20216:
  1396. ch->AddAffect(AFFECT_MOUNT, POINT_MOV_SPEED, 30, AFF_NONE, length, 0, true, true);
  1397. break;
  1398.  
  1399. case 20205:
  1400. case 20206:
  1401. case 20207:
  1402. case 20208:
  1403. case 20214:
  1404. case 20217:
  1405. ch->AddAffect(AFFECT_MOUNT, POINT_MOV_SPEED, 40, AFF_NONE, length, 0, true, true);
  1406. break;
  1407.  
  1408. case 20209:
  1409. case 20210:
  1410. case 20211:
  1411. case 20212:
  1412. case 20215:
  1413. case 20218:
  1414. ch->AddAffect(AFFECT_MOUNT, POINT_MOV_SPEED, 50, AFF_NONE, length, 0, true, true);
  1415. break;
  1416. }
  1417. }
  1418.  
  1419. return 0;
  1420. }
  1421.  
  1422. int pc_mount_bonus(lua_State* L)
  1423. {
  1424. BYTE applyOn = static_cast<BYTE>(lua_tonumber(L, 1));
  1425.  
  1426. long value = static_cast<long>(lua_tonumber(L, 2));
  1427. long duration = static_cast<long>(lua_tonumber(L, 3));
  1428.  
  1429. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1430.  
  1431. if( NULL != ch )
  1432. {
  1433. if (!ch->GetMountVnum())
  1434. return 0;
  1435.  
  1436. ch->RemoveAffect(AFFECT_MOUNT_BONUS);
  1437. ch->AddAffect(AFFECT_MOUNT_BONUS, aApplyInfo[applyOn].bPointType, value, AFF_NONE, duration, 0, false);
  1438. }
  1439.  
  1440. return 0;
  1441. }
  1442.  
  1443. int pc_unmount(lua_State* L)
  1444. {
  1445. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1446.  
  1447. ch->RemoveAffect(AFFECT_MOUNT);
  1448. ch->RemoveAffect(AFFECT_MOUNT_BONUS);
  1449.  
  1450. if (ch->IsHorseRiding())
  1451. ch->StopRiding();
  1452.  
  1453. return 0;
  1454. }
  1455.  
  1456. int pc_get_horse_level(lua_State* L)
  1457. {
  1458. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1459. lua_pushnumber(L, ch->GetHorseLevel());
  1460.  
  1461. return 1;
  1462. }
  1463.  
  1464. int pc_get_horse_hp(lua_State* L)
  1465. {
  1466. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1467. if (ch->GetHorseLevel())
  1468. lua_pushnumber(L, ch->GetHorseHealth());
  1469. else
  1470. lua_pushnumber(L, 0);
  1471.  
  1472. return 1;
  1473. }
  1474.  
  1475. int pc_get_horse_stamina(lua_State* L)
  1476. {
  1477. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1478. if (ch->GetHorseLevel())
  1479. lua_pushnumber(L, ch->GetHorseStamina());
  1480. else
  1481. lua_pushnumber(L, 0);
  1482.  
  1483. return 1;
  1484. }
  1485.  
  1486. int pc_is_horse_alive(lua_State* L)
  1487. {
  1488. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1489. lua_pushboolean(L, ch->GetHorseLevel() > 0 && ch->GetHorseHealth()>0);
  1490. return 1;
  1491. }
  1492.  
  1493. int pc_revive_horse(lua_State* L)
  1494. {
  1495. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1496. ch->ReviveHorse();
  1497. return 0;
  1498. }
  1499.  
  1500. int pc_have_map_scroll(lua_State* L)
  1501. {
  1502. if (!lua_isstring(L, 1))
  1503. {
  1504. lua_pushboolean(L, 0);
  1505. return 1;
  1506. }
  1507.  
  1508. const char * szMapName = lua_tostring(L, 1);
  1509. const TMapRegion * region = SECTREE_MANAGER::instance().FindRegionByPartialName(szMapName);
  1510.  
  1511. if (!region)
  1512. {
  1513. lua_pushboolean(L, 0);
  1514. return 1;
  1515. }
  1516.  
  1517. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1518.  
  1519. bool bFind = false;
  1520. for (int iCell = 0; iCell < INVENTORY_MAX_NUM; iCell++)
  1521. {
  1522. LPITEM item = ch->GetInventoryItem(iCell);
  1523. if (!item)
  1524. continue;
  1525.  
  1526. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TALISMAN && (item->GetValue(0) == 1 || item->GetValue(0) == 2))
  1527. {
  1528. int x = item->GetSocket(0);
  1529. int y = item->GetSocket(1);
  1530.  
  1531. if (region->sx <=x && region->sy <= y && x <= region->ex && y <= region->ey)
  1532. {
  1533. bFind = true;
  1534. break;
  1535. }
  1536. }
  1537. }
  1538.  
  1539. lua_pushboolean(L, bFind);
  1540.  
  1541. return 1;
  1542. }
  1543.  
  1544. int pc_get_war_map(lua_State* L)
  1545. {
  1546. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1547. lua_pushnumber(L, ch->GetWarMap() ? ch->GetWarMap()->GetMapIndex() : 0);
  1548.  
  1549. return 1;
  1550. }
  1551.  
  1552. int pc_have_pos_scroll(lua_State* L)
  1553. {
  1554. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1555.  
  1556. if (!lua_isnumber(L,1) || !lua_isnumber(L,2))
  1557. {
  1558. sys_err("invalid x y position");
  1559. lua_pushboolean(L, 0);
  1560. return 1;
  1561. }
  1562.  
  1563. if (!lua_isnumber(L,2))
  1564. {
  1565. sys_err("invalid radius");
  1566. lua_pushboolean(L, 0);
  1567. return 1;
  1568. }
  1569.  
  1570. int x = (int)lua_tonumber(L, 1);
  1571. int y = (int)lua_tonumber(L, 2);
  1572. float r = (float)lua_tonumber(L, 3);
  1573.  
  1574. bool bFind = false;
  1575. for (int iCell = 0; iCell < INVENTORY_MAX_NUM; iCell++)
  1576. {
  1577. LPITEM item = ch->GetInventoryItem(iCell);
  1578. if (!item)
  1579. continue;
  1580.  
  1581. if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TALISMAN && (item->GetValue(0) == 1 || item->GetValue(0) == 2))
  1582. {
  1583. int item_x = item->GetSocket(0);
  1584. int item_y = item->GetSocket(1);
  1585. if ((x-item_x)*(x-item_x)+(y-item_y)*(y-item_y)<r*r)
  1586. {
  1587. bFind = true;
  1588. break;
  1589. }
  1590. }
  1591. }
  1592.  
  1593. lua_pushboolean(L, bFind);
  1594.  
  1595. return 1;
  1596. }
  1597.  
  1598. int pc_get_equip_refine_level(lua_State* L)
  1599. {
  1600. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1601. int cell = (int) lua_tonumber(L, 1);
  1602.  
  1603. if (cell < 0 || cell >= WEAR_MAX_NUM)
  1604. {
  1605. sys_err("invalid wear position %d", cell);
  1606. lua_pushnumber(L, 0);
  1607.  
  1608. return 1;
  1609. }
  1610.  
  1611. LPITEM item = ch->GetWear(cell);
  1612. if (!item)
  1613. {
  1614. lua_pushnumber(L, 0);
  1615. return 1;
  1616. }
  1617.  
  1618. lua_pushnumber(L, item->GetRefineLevel());
  1619.  
  1620. return 1;
  1621. }
  1622.  
  1623. int pc_refine_equip(lua_State* L)
  1624. {
  1625. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1626. if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
  1627. {
  1628. sys_err("invalid argument");
  1629. lua_pushboolean(L, 0);
  1630.  
  1631. return 1;
  1632. }
  1633.  
  1634. int cell = (int) lua_tonumber(L, 1);
  1635. int level_limit = (int) lua_tonumber(L, 2);
  1636. int pct = lua_isnumber(L, 3) ? (int)lua_tonumber(L, 3) : 100;
  1637.  
  1638. LPITEM item = ch->GetWear(cell);
  1639. if (!item)
  1640. {
  1641. lua_pushboolean(L, 0);
  1642. return 1;
  1643. }
  1644.  
  1645. if (item->GetRefinedVnum() == 0)
  1646. {
  1647. lua_pushboolean(L, 0);
  1648. return 1;
  1649. }
  1650.  
  1651. if (item->GetRefineLevel()>level_limit)
  1652. {
  1653. lua_pushboolean(L, 0);
  1654. return 1;
  1655. }
  1656.  
  1657. if (pct == 100 || number(1, 100) <= pct)
  1658. {
  1659. lua_pushboolean(L, 1);
  1660.  
  1661. LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(item->GetRefinedVnum(), 1, 0, false);
  1662.  
  1663. if (pkNewItem)
  1664. {
  1665. for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
  1666. if (!item->GetSocket(i))
  1667. break;
  1668. else
  1669. pkNewItem->SetSocket(i, 1);
  1670.  
  1671. int set = 0;
  1672. for (int i=0; i<ITEM_SOCKET_MAX_NUM; i++)
  1673. {
  1674. long socket = item->GetSocket(i);
  1675. if (socket > 2 && socket != 28960)
  1676. {
  1677. pkNewItem->SetSocket(set++, socket);
  1678. }
  1679. }
  1680.  
  1681. item->CopyAttributeTo(pkNewItem);
  1682.  
  1683. ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
  1684.  
  1685. pkNewItem->EquipTo(ch, cell);
  1686.  
  1687. ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
  1688.  
  1689. LogManager::instance().ItemLog(ch, pkNewItem, "REFINE SUCCESS (QUEST)", pkNewItem->GetName());
  1690. }
  1691. }
  1692.  
  1693. else
  1694. {
  1695. lua_pushboolean(L, 0);
  1696. }
  1697.  
  1698. return 1;
  1699. }
  1700.  
  1701. int pc_get_skill_level(lua_State * L)
  1702. {
  1703. if (!lua_isnumber(L, 1))
  1704. {
  1705. sys_err("invalid argument");
  1706. lua_pushnumber(L, 0);
  1707.  
  1708. return 1;
  1709. }
  1710.  
  1711. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1712.  
  1713. DWORD dwVnum = (DWORD) lua_tonumber(L, 1);
  1714. lua_pushnumber(L, ch->GetSkillLevel(dwVnum));
  1715.  
  1716. return 1;
  1717. }
  1718.  
  1719. int pc_aggregate_monster(lua_State* L)
  1720. {
  1721. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1722. ch->AggregateMonster();
  1723. return 0;
  1724. }
  1725.  
  1726. int pc_forget_my_attacker(lua_State* L)
  1727. {
  1728. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1729. ch->ForgetMyAttacker();
  1730. return 0;
  1731. }
  1732.  
  1733. int pc_attract_ranger(lua_State* L)
  1734. {
  1735. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1736. ch->AttractRanger();
  1737. return 0;
  1738. }
  1739.  
  1740. int pc_select_pid(lua_State* L)
  1741. {
  1742. DWORD pid = (DWORD) lua_tonumber(L, 1);
  1743.  
  1744. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1745. LPCHARACTER new_ch = CHARACTER_MANAGER::instance().FindByPID(pid);
  1746.  
  1747. if (new_ch)
  1748. {
  1749. CQuestManager::instance().GetPC(new_ch->GetPlayerID());
  1750.  
  1751. lua_pushnumber(L, ch->GetPlayerID());
  1752. }
  1753.  
  1754. else
  1755. {
  1756. lua_pushnumber(L, 0);
  1757. }
  1758.  
  1759. return 1;
  1760. }
  1761.  
  1762. int pc_select_vid(lua_State* L)
  1763. {
  1764. DWORD vid = (DWORD) lua_tonumber(L, 1);
  1765.  
  1766. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1767. LPCHARACTER new_ch = CHARACTER_MANAGER::instance().Find(vid);
  1768.  
  1769. if (new_ch)
  1770. {
  1771. CQuestManager::instance().GetPC(new_ch->GetPlayerID());
  1772.  
  1773. lua_pushnumber(L, (DWORD)ch->GetVID());
  1774. }
  1775.  
  1776. else
  1777. {
  1778. lua_pushnumber(L, 0);
  1779. }
  1780.  
  1781. return 1;
  1782. }
  1783.  
  1784. int pc_get_sex(lua_State* L)
  1785. {
  1786. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1787. lua_pushnumber(L, GET_SEX(ch));
  1788.  
  1789. return 1;
  1790. }
  1791.  
  1792. int pc_is_engaged(lua_State* L)
  1793. {
  1794. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1795. lua_pushboolean(L, marriage::CManager::instance().IsEngaged(ch->GetPlayerID()));
  1796.  
  1797. return 1;
  1798. }
  1799.  
  1800. int pc_is_married(lua_State* L)
  1801. {
  1802. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1803. lua_pushboolean(L, marriage::CManager::instance().IsMarried(ch->GetPlayerID()));
  1804.  
  1805. return 1;
  1806. }
  1807.  
  1808. int pc_is_engaged_or_married(lua_State* L)
  1809. {
  1810. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1811. lua_pushboolean(L, marriage::CManager::instance().IsEngagedOrMarried(ch->GetPlayerID()));
  1812.  
  1813. return 1;
  1814. }
  1815.  
  1816. int pc_is_gm(lua_State* L)
  1817. {
  1818. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1819. lua_pushboolean(L, ch->GetGMLevel() >= GM_HIGH_WIZARD);
  1820.  
  1821. return 1;
  1822. }
  1823.  
  1824. int pc_get_gm_level(lua_State* L)
  1825. {
  1826. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1827. lua_pushnumber(L, ch->GetGMLevel());
  1828.  
  1829. return 1;
  1830. }
  1831.  
  1832. int pc_mining(lua_State* L)
  1833. {
  1834. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1835. LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
  1836. ch->mining(npc);
  1837.  
  1838. return 0;
  1839. }
  1840.  
  1841. int pc_diamond_refine(lua_State* L)
  1842. {
  1843. if (!lua_isnumber(L, 1))
  1844. {
  1845. lua_pushboolean(L, 0);
  1846. return 1;
  1847. }
  1848.  
  1849. int cost = (int) lua_tonumber(L, 1);
  1850. int pct = (int)lua_tonumber(L, 2);
  1851.  
  1852. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1853. LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
  1854. LPITEM item = CQuestManager::instance().GetCurrentItem();
  1855.  
  1856. if (item)
  1857. lua_pushboolean(L, mining::OreRefine(ch, npc, item, cost, pct, NULL));
  1858. else
  1859. lua_pushboolean(L, 0);
  1860.  
  1861. return 1;
  1862. }
  1863.  
  1864. int pc_ore_refine(lua_State* L)
  1865. {
  1866. if (!lua_isnumber(L, 1))
  1867. {
  1868. lua_pushboolean(L, 0);
  1869.  
  1870. return 1;
  1871. }
  1872.  
  1873. int cost = (int) lua_tonumber(L, 1);
  1874. int pct = (int)lua_tonumber(L, 2);
  1875. int metinstone_cell = (int)lua_tonumber(L, 3);
  1876.  
  1877. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1878. LPCHARACTER npc = CQuestManager::instance().GetCurrentNPCCharacterPtr();
  1879. LPITEM item = CQuestManager::instance().GetCurrentItem();
  1880.  
  1881. LPITEM metinstone_item = ch->GetInventoryItem(metinstone_cell);
  1882.  
  1883. if (item && metinstone_item)
  1884. lua_pushboolean(L, mining::OreRefine(ch, npc, item, cost, pct, metinstone_item));
  1885. else
  1886. lua_pushboolean(L, 0);
  1887.  
  1888. return 1;
  1889. }
  1890.  
  1891. int pc_clear_skill(lua_State* L)
  1892. {
  1893. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1894. if ( ch == NULL ) return 0;
  1895.  
  1896. ch->ClearSkill();
  1897.  
  1898. return 0;
  1899. }
  1900.  
  1901. int pc_clear_sub_skill(lua_State* L)
  1902. {
  1903. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1904. if ( ch == NULL ) return 0;
  1905.  
  1906. ch->ClearSubSkill();
  1907.  
  1908. return 0;
  1909. }
  1910.  
  1911. int pc_set_skill_point(lua_State* L)
  1912. {
  1913. if (!lua_isnumber(L, 1))
  1914. {
  1915. return 0;
  1916. }
  1917.  
  1918. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1919. int newPoint = (int) lua_tonumber(L, 1);
  1920.  
  1921. ch->SetRealPoint(POINT_SKILL, newPoint);
  1922. ch->SetPoint(POINT_SKILL, ch->GetRealPoint(POINT_SKILL));
  1923. ch->PointChange(POINT_SKILL, 0);
  1924. ch->ComputePoints();
  1925. ch->PointsPacket();
  1926.  
  1927. return 0;
  1928. }
  1929.  
  1930. int pc_clear_one_skill(lua_State* L)
  1931. {
  1932. int vnum = (int)lua_tonumber(L, 1);
  1933. sys_log(0, "%d skill clear", vnum);
  1934.  
  1935. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1936. if ( ch == NULL )
  1937. {
  1938. sys_log(0, "skill clear fail");
  1939. lua_pushnumber(L, 0);
  1940.  
  1941. return 1;
  1942. }
  1943.  
  1944. sys_log(0, "%d skill clear", vnum);
  1945.  
  1946. ch->ResetOneSkill(vnum);
  1947.  
  1948. return 0;
  1949. }
  1950.  
  1951. int pc_is_clear_skill_group(lua_State* L)
  1952. {
  1953. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1954.  
  1955. lua_pushboolean(L, ch->GetQuestFlag("skill_group_clear.clear") == 1);
  1956.  
  1957. return 1;
  1958. }
  1959.  
  1960. int pc_save_exit_location(lua_State* L)
  1961. {
  1962. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1963.  
  1964. ch->SaveExitLocation();
  1965.  
  1966. return 0;
  1967. }
  1968.  
  1969. int pc_teleport ( lua_State * L )
  1970. {
  1971. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  1972. int x=0,y=0;
  1973. if ( lua_isnumber(L, 1) )
  1974. {
  1975. const int TOWN_NUM = 10;
  1976. struct warp_by_town_name
  1977. {
  1978. const char* name;
  1979. DWORD x;
  1980. DWORD y;
  1981. }
  1982.  
  1983. ws[TOWN_NUM] =
  1984. {
  1985. {"영안읍성", 4743, 9548},
  1986. {"임지곡", 3235, 9086},
  1987. {"자양현", 3531, 8829},
  1988. {"조안읍성", 638, 1664},
  1989. {"승룡곡", 1745, 1909},
  1990. {"복정현", 1455, 2400},
  1991. {"평무읍성", 9599, 2692},
  1992. {"방산곡", 8036, 2984},
  1993. {"박라현", 8639, 2460},
  1994. {"서한산", 4350, 2143},
  1995. };
  1996.  
  1997. int idx = (int)lua_tonumber(L, 1);
  1998.  
  1999. x = ws[idx].x;
  2000. y = ws[idx].y;
  2001.  
  2002. goto teleport_area;
  2003. }
  2004.  
  2005. else
  2006. {
  2007. const char * arg1 = lua_tostring(L, 1);
  2008.  
  2009. LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(arg1);
  2010.  
  2011. if (!tch)
  2012. {
  2013. const CCI* pkCCI = P2P_MANAGER::instance().Find(arg1);
  2014.  
  2015. if (pkCCI)
  2016. {
  2017. if (pkCCI->bChannel != g_bChannel)
  2018. {
  2019. ch->ChatPacket(CHAT_TYPE_INFO, "Target is in %d channel (my channel %d)", pkCCI->bChannel, g_bChannel);
  2020. }
  2021.  
  2022. else
  2023. {
  2024. PIXEL_POSITION pos;
  2025.  
  2026. if (!SECTREE_MANAGER::instance().GetCenterPositionOfMap(pkCCI->lMapIndex, pos))
  2027. {
  2028. ch->ChatPacket(CHAT_TYPE_INFO, "Cannot find map (index %d)", pkCCI->lMapIndex);
  2029. }
  2030.  
  2031. else
  2032. {
  2033. ch->ChatPacket(CHAT_TYPE_INFO, "You warp to ( %d, %d )", pos.x, pos.y);
  2034. ch->WarpSet(pos.x, pos.y);
  2035. lua_pushnumber(L, 1 );
  2036. }
  2037. }
  2038. }
  2039.  
  2040. else if (NULL == CHARACTER_MANAGER::instance().FindPC(arg1))
  2041. {
  2042. ch->ChatPacket(CHAT_TYPE_INFO, "There is no one by that name");
  2043. }
  2044.  
  2045. lua_pushnumber(L, 0 );
  2046.  
  2047. return 1;
  2048. }
  2049.  
  2050. else
  2051. {
  2052. x = tch->GetX() / 100;
  2053. y = tch->GetY() / 100;
  2054. }
  2055. }
  2056.  
  2057. teleport_area:
  2058.  
  2059. x *= 100;
  2060. y *= 100;
  2061.  
  2062. ch->ChatPacket(CHAT_TYPE_INFO, "You warp to ( %d, %d )", x, y);
  2063. ch->WarpSet(x,y);
  2064. ch->Stop();
  2065. lua_pushnumber(L, 1 );
  2066.  
  2067. return 1;
  2068. }
  2069.  
  2070. int pc_set_skill_level(lua_State* L)
  2071. {
  2072. DWORD dwVnum = (DWORD)lua_tonumber(L, 1);
  2073. BYTE byLev = (BYTE)lua_tonumber(L, 2);
  2074.  
  2075. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2076. ch->SetSkillLevel(dwVnum, byLev);
  2077.  
  2078. ch->SkillLevelPacket();
  2079.  
  2080. return 0;
  2081. }
  2082.  
  2083. int pc_give_polymorph_book(lua_State* L)
  2084. {
  2085. if ( lua_isnumber(L, 1) != true && lua_isnumber(L, 2) != true && lua_isnumber(L, 3) != true && lua_isnumber(L, 4) != true )
  2086. {
  2087. sys_err("Wrong Quest Function Arguments: pc_give_polymorph_book");
  2088. return 0;
  2089. }
  2090.  
  2091. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2092.  
  2093. CPolymorphUtils::instance().GiveBook(ch, (DWORD)lua_tonumber(L, 1), (DWORD)lua_tonumber(L, 2), (BYTE)lua_tonumber(L, 3), (BYTE)lua_tonumber(L, 4));
  2094.  
  2095. return 0;
  2096. }
  2097.  
  2098. int pc_upgrade_polymorph_book(lua_State* L)
  2099. {
  2100. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2101. LPITEM pItem = CQuestManager::instance().GetCurrentItem();
  2102.  
  2103. bool ret = CPolymorphUtils::instance().BookUpgrade(ch, pItem);
  2104.  
  2105. lua_pushboolean(L, ret);
  2106.  
  2107. return 1;
  2108. }
  2109.  
  2110. int pc_get_premium_remain_sec(lua_State* L)
  2111. {
  2112. int remain_seconds = 0;
  2113. int premium_type = 0;
  2114. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2115.  
  2116. if (!lua_isnumber(L, 1))
  2117. {
  2118. sys_err("wrong premium index (is not number)");
  2119. return 0;
  2120. }
  2121.  
  2122. premium_type = (int)lua_tonumber(L,1);
  2123.  
  2124. switch (premium_type)
  2125. {
  2126. case PREMIUM_EXP:
  2127. case PREMIUM_ITEM:
  2128. case PREMIUM_SAFEBOX:
  2129. case PREMIUM_AUTOLOOT:
  2130. case PREMIUM_FISH_MIND:
  2131. case PREMIUM_MARRIAGE_FAST:
  2132. case PREMIUM_GOLD:
  2133. break;
  2134.  
  2135. default:
  2136. sys_err("wrong premium index %d", premium_type);
  2137. return 0;
  2138. }
  2139.  
  2140. remain_seconds = ch->GetPremiumRemainSeconds(premium_type);
  2141.  
  2142. lua_pushnumber(L, remain_seconds);
  2143. return 1;
  2144. }
  2145.  
  2146. int pc_send_block_mode(lua_State* L)
  2147. {
  2148. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2149.  
  2150. ch->SetBlockModeForce((BYTE)lua_tonumber(L, 1));
  2151.  
  2152. return 0;
  2153. }
  2154.  
  2155. int pc_change_empire(lua_State* L)
  2156. {
  2157. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2158.  
  2159. lua_pushnumber(L, ch->ChangeEmpire((unsigned char)lua_tonumber(L, 1)));
  2160.  
  2161. return 1;
  2162. }
  2163.  
  2164. int pc_get_change_empire_count(lua_State* L)
  2165. {
  2166. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2167.  
  2168. lua_pushnumber(L, ch->GetChangeEmpireCount());
  2169.  
  2170. return 1;
  2171. }
  2172.  
  2173. int pc_set_change_empire_count(lua_State* L)
  2174. {
  2175. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2176.  
  2177. ch->SetChangeEmpireCount();
  2178.  
  2179. return 0;
  2180. }
  2181.  
  2182. int pc_change_name(lua_State* L)
  2183. {
  2184. lua_pushnumber(L, 5);
  2185. return 1;
  2186.  
  2187. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2188.  
  2189. if ( ch->GetNewName().size() != 0 )
  2190. {
  2191. lua_pushnumber(L, 0);
  2192. return 1;
  2193. }
  2194.  
  2195. if ( lua_isstring(L, 1) != true )
  2196. {
  2197. lua_pushnumber(L, 1);
  2198. return 1;
  2199. }
  2200.  
  2201. const char * szName = lua_tostring(L, 1);
  2202.  
  2203. if ( check_name(szName) == false )
  2204. {
  2205. lua_pushnumber(L, 2);
  2206. return 1;
  2207. }
  2208.  
  2209. char szQuery[1024];
  2210. snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM player%s WHERE name='%s'", get_table_postfix(), szName);
  2211. std::unique_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery(szQuery));
  2212.  
  2213. if ( pmsg->Get()->uiNumRows > 0 )
  2214. {
  2215. MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
  2216.  
  2217. int count = 0;
  2218. str_to_number(count, row[0]);
  2219.  
  2220. if ( count != 0 )
  2221. {
  2222. lua_pushnumber(L, 3);
  2223. return 1;
  2224. }
  2225. }
  2226.  
  2227. DWORD pid = ch->GetPlayerID();
  2228. db_clientdesc->DBPacketHeader(HEADER_GD_FLUSH_CACHE, 0, sizeof(DWORD));
  2229. db_clientdesc->Packet(&pid, sizeof(DWORD));
  2230.  
  2231. MessengerManager::instance().RemoveAllList(ch->GetName());
  2232.  
  2233. #ifdef ENABLE_MESSENGER_BLOCK
  2234. MessengerManager::instance().RemoveAllBlockList(ch->GetName());
  2235. #endif
  2236.  
  2237. LogManager::instance().ChangeNameLog(pid, ch->GetName(), szName, ch->GetDesc()->GetHostName());
  2238.  
  2239. snprintf(szQuery, sizeof(szQuery), "UPDATE player%s SET name='%s' WHERE id=%u", get_table_postfix(), szName, pid);
  2240. SQLMsg * msg = DBManager::instance().DirectQuery(szQuery);
  2241. M2_DELETE(msg);
  2242.  
  2243. ch->SetNewName(szName);
  2244. lua_pushnumber(L, 4);
  2245.  
  2246. return 1;
  2247. }
  2248.  
  2249. int pc_is_dead(lua_State* L)
  2250. {
  2251. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2252.  
  2253. if ( ch != NULL )
  2254. {
  2255. lua_pushboolean(L, ch->IsDead());
  2256. return 1;
  2257. }
  2258.  
  2259. lua_pushboolean(L, true);
  2260.  
  2261. return 1;
  2262. }
  2263.  
  2264. int pc_reset_status( lua_State* L )
  2265. {
  2266. if ( lua_isnumber(L, 1) == true )
  2267. {
  2268. int idx = (int)lua_tonumber(L, 1);
  2269.  
  2270. if ( idx >= 0 && idx < 4 )
  2271. {
  2272. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2273. int point = POINT_NONE;
  2274. char buf[128];
  2275.  
  2276. switch ( idx )
  2277. {
  2278. case 0 : point = POINT_HT; break;
  2279. case 1 : point = POINT_IQ; break;
  2280. case 2 : point = POINT_ST; break;
  2281. case 3 : point = POINT_DX; break;
  2282. default : lua_pushboolean(L, false); return 1;
  2283. }
  2284.  
  2285. int old_val = ch->GetRealPoint(point);
  2286. int old_stat = ch->GetRealPoint(POINT_STAT);
  2287.  
  2288. ch->SetRealPoint(point, 1);
  2289. ch->SetPoint(point, ch->GetRealPoint(point));
  2290.  
  2291. ch->PointChange(POINT_STAT, old_val-1);
  2292.  
  2293. if ( point == POINT_HT )
  2294. {
  2295. BYTE job = ch->GetJob();
  2296. ch->SetRandomHP((ch->GetLevel()-1) * number(JobInitialPoints[job].hp_per_lv_begin, JobInitialPoints[job].hp_per_lv_end));
  2297. }
  2298.  
  2299. else if ( point == POINT_IQ )
  2300. {
  2301. BYTE job = ch->GetJob();
  2302. ch->SetRandomSP((ch->GetLevel()-1) * number(JobInitialPoints[job].sp_per_lv_begin, JobInitialPoints[job].sp_per_lv_end));
  2303. }
  2304.  
  2305. ch->ComputePoints();
  2306. ch->PointsPacket();
  2307.  
  2308. if ( point == POINT_HT )
  2309. {
  2310. ch->PointChange(POINT_HP, ch->GetMaxHP() - ch->GetHP());
  2311. }
  2312.  
  2313. else if ( point == POINT_IQ )
  2314. {
  2315. ch->PointChange(POINT_SP, ch->GetMaxSP() - ch->GetSP());
  2316. }
  2317.  
  2318. switch ( idx )
  2319. {
  2320. case 0 :
  2321. snprintf(buf, sizeof(buf), "reset ht(%d)->1 stat_point(%d)->(%d)", old_val, old_stat, ch->GetRealPoint(POINT_STAT));
  2322. break;
  2323.  
  2324. case 1 :
  2325. snprintf(buf, sizeof(buf), "reset iq(%d)->1 stat_point(%d)->(%d)", old_val, old_stat, ch->GetRealPoint(POINT_STAT));
  2326. break;
  2327.  
  2328. case 2 :
  2329. snprintf(buf, sizeof(buf), "reset st(%d)->1 stat_point(%d)->(%d)", old_val, old_stat, ch->GetRealPoint(POINT_STAT));
  2330. break;
  2331.  
  2332. case 3 :
  2333. snprintf(buf, sizeof(buf), "reset dx(%d)->1 stat_point(%d)->(%d)", old_val, old_stat, ch->GetRealPoint(POINT_STAT));
  2334. break;
  2335. }
  2336.  
  2337. LogManager::instance().CharLog(ch, 0, "RESET_ONE_STATUS", buf);
  2338.  
  2339. lua_pushboolean(L, true);
  2340.  
  2341. return 1;
  2342. }
  2343. }
  2344.  
  2345. lua_pushboolean(L, false);
  2346.  
  2347. return 1;
  2348. }
  2349.  
  2350. int pc_get_ht( lua_State* L )
  2351. {
  2352. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2353. lua_pushnumber(L, ch->GetRealPoint(POINT_HT));
  2354.  
  2355. return 1;
  2356. }
  2357.  
  2358. int pc_set_ht( lua_State* L )
  2359. {
  2360. if ( lua_isnumber(L, 1) == false )
  2361. return 1;
  2362.  
  2363. int newPoint = (int)lua_tonumber(L, 1);
  2364.  
  2365. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2366.  
  2367. int usedPoint = newPoint - ch->GetRealPoint(POINT_HT);
  2368.  
  2369. ch->SetRealPoint(POINT_HT, newPoint);
  2370. ch->PointChange(POINT_HT, 0);
  2371. ch->PointChange(POINT_STAT, -usedPoint);
  2372. ch->ComputePoints();
  2373. ch->PointsPacket();
  2374.  
  2375. return 1;
  2376. }
  2377.  
  2378. int pc_get_iq( lua_State* L )
  2379. {
  2380. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2381. lua_pushnumber(L, ch->GetRealPoint(POINT_IQ));
  2382.  
  2383. return 1;
  2384. }
  2385.  
  2386. int pc_set_iq( lua_State* L )
  2387. {
  2388. if ( lua_isnumber(L, 1) == false )
  2389. return 1;
  2390.  
  2391. int newPoint = (int)lua_tonumber(L, 1);
  2392.  
  2393. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2394.  
  2395. int usedPoint = newPoint - ch->GetRealPoint(POINT_IQ);
  2396.  
  2397. ch->SetRealPoint(POINT_IQ, newPoint);
  2398. ch->PointChange(POINT_IQ, 0);
  2399. ch->PointChange(POINT_STAT, -usedPoint);
  2400. ch->ComputePoints();
  2401. ch->PointsPacket();
  2402.  
  2403. return 1;
  2404. }
  2405.  
  2406. int pc_get_st( lua_State* L )
  2407. {
  2408. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2409. lua_pushnumber(L, ch->GetRealPoint(POINT_ST));
  2410. return 1;
  2411. }
  2412.  
  2413. int pc_set_st( lua_State* L )
  2414. {
  2415. if ( lua_isnumber(L, 1) == false )
  2416. return 1;
  2417.  
  2418. int newPoint = (int)lua_tonumber(L, 1);
  2419.  
  2420. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2421.  
  2422. int usedPoint = newPoint - ch->GetRealPoint(POINT_ST);
  2423.  
  2424. ch->SetRealPoint(POINT_ST, newPoint);
  2425. ch->PointChange(POINT_ST, 0);
  2426. ch->PointChange(POINT_STAT, -usedPoint);
  2427. ch->ComputePoints();
  2428. ch->PointsPacket();
  2429.  
  2430. return 1;
  2431. }
  2432.  
  2433. int pc_get_dx( lua_State* L )
  2434. {
  2435. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2436. lua_pushnumber(L, ch->GetRealPoint(POINT_DX));
  2437.  
  2438. return 1;
  2439. }
  2440.  
  2441. int pc_set_dx( lua_State* L )
  2442. {
  2443. if ( lua_isnumber(L, 1) == false )
  2444. return 1;
  2445.  
  2446. int newPoint = (int)lua_tonumber(L, 1);
  2447.  
  2448. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2449.  
  2450. int usedPoint = newPoint - ch->GetRealPoint(POINT_DX);
  2451.  
  2452. ch->SetRealPoint(POINT_DX, newPoint);
  2453. ch->PointChange(POINT_DX, 0);
  2454. ch->PointChange(POINT_STAT, -usedPoint);
  2455. ch->ComputePoints();
  2456. ch->PointsPacket();
  2457.  
  2458. return 1;
  2459. }
  2460.  
  2461. int pc_is_near_vid( lua_State* L )
  2462. {
  2463. if ( lua_isnumber(L, 1) != true || lua_isnumber(L, 2) != true )
  2464. {
  2465. lua_pushboolean(L, false);
  2466. }
  2467.  
  2468. else
  2469. {
  2470. LPCHARACTER pMe = CQuestManager::instance().GetCurrentCharacterPtr();
  2471. LPCHARACTER pOther = CHARACTER_MANAGER::instance().Find( (DWORD)lua_tonumber(L, 1) );
  2472.  
  2473. if ( pMe != NULL && pOther != NULL )
  2474. {
  2475. lua_pushboolean(L, (DISTANCE_APPROX(pMe->GetX() - pOther->GetX(), pMe->GetY() - pOther->GetY()) < (int)lua_tonumber(L, 2)*100));
  2476. }
  2477.  
  2478. else
  2479. {
  2480. lua_pushboolean(L, false);
  2481. }
  2482. }
  2483.  
  2484. return 1;
  2485. }
  2486.  
  2487. int pc_get_socket_items( lua_State* L )
  2488. {
  2489. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2490.  
  2491. lua_newtable( L );
  2492.  
  2493. if ( pChar == NULL ) return 1;
  2494.  
  2495. int idx = 1;
  2496.  
  2497. for ( int i=0; i < INVENTORY_MAX_NUM + WEAR_MAX_NUM; i++ )
  2498. {
  2499. LPITEM pItem = pChar->GetInventoryItem(i);
  2500.  
  2501. if ( pItem != NULL )
  2502. {
  2503. if ( pItem->IsEquipped() == false )
  2504. {
  2505. int j = 0;
  2506. for (; j < ITEM_SOCKET_MAX_NUM; j++ )
  2507. {
  2508. long socket = pItem->GetSocket(j);
  2509.  
  2510. if ( socket > 2 && socket != ITEM_BROKEN_METIN_VNUM )
  2511. {
  2512. TItemTable* pItemInfo = ITEM_MANAGER::instance().GetTable( socket );
  2513. if ( pItemInfo != NULL )
  2514. {
  2515. if ( pItemInfo->bType == ITEM_METIN ) break;
  2516. }
  2517. }
  2518. }
  2519.  
  2520. if ( j >= ITEM_SOCKET_MAX_NUM ) continue;
  2521.  
  2522. lua_newtable( L );
  2523.  
  2524. {
  2525. lua_pushstring( L, pItem->GetName() );
  2526. lua_rawseti( L, -2, 1 );
  2527.  
  2528. lua_pushnumber( L, i );
  2529. lua_rawseti( L, -2, 2 );
  2530. }
  2531.  
  2532. lua_rawseti( L, -2, idx++ );
  2533. }
  2534. }
  2535. }
  2536.  
  2537. return 1;
  2538. }
  2539.  
  2540. int pc_get_empty_inventory_count( lua_State* L )
  2541. {
  2542. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2543.  
  2544. if ( pChar != NULL )
  2545. {
  2546. lua_pushnumber(L, pChar->CountEmptyInventory());
  2547. }
  2548.  
  2549. else
  2550. {
  2551. lua_pushnumber(L, 0);
  2552. }
  2553.  
  2554. return 1;
  2555. }
  2556.  
  2557. int pc_get_logoff_interval( lua_State* L )
  2558. {
  2559. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2560.  
  2561. if ( pChar != NULL )
  2562. {
  2563. lua_pushnumber(L, pChar->GetLogOffInterval());
  2564. }
  2565.  
  2566. else
  2567. {
  2568. lua_pushnumber(L, 0);
  2569. }
  2570.  
  2571. return 1;
  2572. }
  2573.  
  2574. int pc_get_player_id( lua_State* L )
  2575. {
  2576. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2577.  
  2578. if ( pChar != NULL )
  2579. {
  2580. lua_pushnumber( L, pChar->GetPlayerID() );
  2581. }
  2582.  
  2583. else
  2584. {
  2585. lua_pushnumber( L, 0 );
  2586. }
  2587.  
  2588. return 1;
  2589. }
  2590.  
  2591. int pc_get_account_id( lua_State* L )
  2592. {
  2593. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2594.  
  2595. if ( pChar != NULL )
  2596. {
  2597. if ( pChar->GetDesc() != NULL )
  2598. {
  2599. lua_pushnumber( L, pChar->GetDesc()->GetAccountTable().id );
  2600. return 1;
  2601. }
  2602. }
  2603.  
  2604. lua_pushnumber( L, 0 );
  2605.  
  2606. return 1;
  2607. }
  2608.  
  2609. int pc_get_account( lua_State* L )
  2610. {
  2611. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2612.  
  2613. if( NULL != pChar )
  2614. {
  2615. if( NULL != pChar->GetDesc() )
  2616. {
  2617. lua_pushstring( L, pChar->GetDesc()->GetAccountTable().login );
  2618. return 1;
  2619. }
  2620. }
  2621.  
  2622. lua_pushstring( L, "" );
  2623.  
  2624. return 1;
  2625. }
  2626.  
  2627. int pc_is_riding(lua_State* L)
  2628. {
  2629. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2630.  
  2631. if( NULL != pChar )
  2632. {
  2633. bool is_riding = pChar->IsRiding();
  2634.  
  2635. lua_pushboolean(L, is_riding);
  2636.  
  2637. return 1;
  2638. }
  2639.  
  2640. lua_pushboolean(L, false);
  2641.  
  2642. return 1;
  2643. }
  2644.  
  2645. int pc_get_special_ride_vnum(lua_State* L)
  2646. {
  2647. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2648.  
  2649. if (NULL != pChar)
  2650. {
  2651. LPITEM Unique1 = pChar->GetWear(WEAR_UNIQUE1);
  2652. LPITEM Unique2 = pChar->GetWear(WEAR_UNIQUE2);
  2653.  
  2654. if (NULL != Unique1)
  2655. {
  2656. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique1->GetSpecialGroup())
  2657. {
  2658. lua_pushnumber(L, Unique1->GetVnum());
  2659. lua_pushnumber(L, Unique1->GetSocket(2));
  2660.  
  2661. return 2;
  2662. }
  2663. }
  2664.  
  2665. if (NULL != Unique2)
  2666. {
  2667. if (UNIQUE_GROUP_SPECIAL_RIDE == Unique2->GetSpecialGroup())
  2668. {
  2669. lua_pushnumber(L, Unique2->GetVnum());
  2670. lua_pushnumber(L, Unique2->GetSocket(2));
  2671.  
  2672. return 2;
  2673. }
  2674. }
  2675. }
  2676.  
  2677. lua_pushnumber(L, 0);
  2678. lua_pushnumber(L, 0);
  2679.  
  2680. return 2;
  2681. }
  2682.  
  2683. int pc_can_warp(lua_State* L)
  2684. {
  2685. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2686.  
  2687. if (NULL != pChar)
  2688. {
  2689. lua_pushboolean(L, pChar->CanWarp());
  2690. }
  2691.  
  2692. else
  2693. {
  2694. lua_pushboolean(L, false);
  2695. }
  2696.  
  2697. return 1;
  2698. }
  2699.  
  2700. int pc_dec_skill_point(lua_State* L)
  2701. {
  2702. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2703.  
  2704. if (NULL != pChar)
  2705. {
  2706. pChar->PointChange(POINT_SKILL, -1);
  2707. }
  2708.  
  2709. return 0;
  2710. }
  2711.  
  2712. int pc_get_skill_point(lua_State* L)
  2713. {
  2714. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2715.  
  2716. if (NULL != pChar)
  2717. {
  2718. lua_pushnumber(L, pChar->GetPoint(POINT_SKILL));
  2719. }
  2720.  
  2721. else
  2722. {
  2723. lua_pushnumber(L, 0);
  2724. }
  2725.  
  2726. return 1;
  2727. }
  2728.  
  2729. int pc_get_channel_id(lua_State* L)
  2730. {
  2731. lua_pushnumber(L, g_bChannel);
  2732.  
  2733. return 1;
  2734. }
  2735.  
  2736. int pc_give_poly_marble(lua_State* L)
  2737. {
  2738. const int dwVnum = lua_tonumber(L, 1);
  2739.  
  2740. const CMob* MobInfo = CMobManager::instance().Get(dwVnum);
  2741.  
  2742. if (NULL == MobInfo)
  2743. {
  2744. lua_pushboolean(L, false);
  2745. return 1;
  2746. }
  2747.  
  2748. if (0 == MobInfo->m_table.dwPolymorphItemVnum)
  2749. {
  2750. lua_pushboolean(L, false);
  2751. return 1;
  2752. }
  2753.  
  2754. LPITEM item = ITEM_MANAGER::instance().CreateItem( MobInfo->m_table.dwPolymorphItemVnum );
  2755.  
  2756. if (NULL == item)
  2757. {
  2758. lua_pushboolean(L, false);
  2759. return 1;
  2760. }
  2761.  
  2762. item->SetSocket(0, dwVnum);
  2763.  
  2764. const LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2765.  
  2766. int iEmptyCell = ch->GetEmptyInventory(item->GetSize());
  2767.  
  2768. if (-1 == iEmptyCell)
  2769. {
  2770. M2_DESTROY_ITEM(item);
  2771. lua_pushboolean(L, false);
  2772. return 1;
  2773. }
  2774.  
  2775. item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyCell));
  2776.  
  2777. const PC* pPC = CQuestManager::instance().GetCurrentPC();
  2778.  
  2779. LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), MobInfo->m_table.dwPolymorphItemVnum, dwVnum);
  2780.  
  2781. lua_pushboolean(L, true);
  2782.  
  2783. return 1;
  2784. }
  2785.  
  2786. int pc_get_sig_items (lua_State* L)
  2787. {
  2788. DWORD group_vnum = (DWORD)lua_tonumber (L, 1);
  2789. const LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2790. int count = 0;
  2791. for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
  2792. {
  2793. if (ch->GetInventoryItem(i) != NULL && ch->GetInventoryItem(i)->GetSIGVnum() == group_vnum)
  2794. {
  2795. lua_pushnumber(L, ch->GetInventoryItem(i)->GetID());
  2796. count++;
  2797. }
  2798. }
  2799.  
  2800. return count;
  2801. }
  2802.  
  2803. int pc_charge_cash(lua_State * L)
  2804. {
  2805. TRequestChargeCash packet;
  2806.  
  2807. int amount = lua_isnumber(L, 1) ? (int)lua_tonumber(L, 1) : 0;
  2808. std::string strChargeType = lua_isstring(L, 2) ? lua_tostring(L, 2) : "";
  2809.  
  2810. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2811.  
  2812. if (NULL == ch || NULL == ch->GetDesc() || 1 > amount || 50000 < amount)
  2813. {
  2814. lua_pushboolean(L, 0);
  2815. return 1;
  2816. }
  2817.  
  2818. packet.dwAID = ch->GetDesc()->GetAccountTable().id;
  2819. packet.dwAmount = (DWORD)amount;
  2820. packet.eChargeType = ERequestCharge_Cash;
  2821.  
  2822. if (0 < strChargeType.length())
  2823. std::transform(strChargeType.begin(), strChargeType.end(), strChargeType.begin(), (int(*)(int))std::tolower);
  2824.  
  2825. if ("mileage" == strChargeType)
  2826. packet.eChargeType = ERequestCharge_Mileage;
  2827.  
  2828. db_clientdesc->DBPacketHeader(HEADER_GD_REQUEST_CHARGE_CASH, 0, sizeof(TRequestChargeCash));
  2829. db_clientdesc->Packet(&packet, sizeof(packet));
  2830.  
  2831. lua_pushboolean(L, 1);
  2832.  
  2833. return 1;
  2834. }
  2835.  
  2836. int pc_give_award(lua_State* L)
  2837. {
  2838. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2839.  
  2840. if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isstring(L, 3) )
  2841. {
  2842. sys_err("QUEST give award call error : wrong argument");
  2843. lua_pushnumber (L, 0);
  2844.  
  2845. return 1;
  2846. }
  2847.  
  2848. DWORD dwVnum = (int) lua_tonumber(L, 1);
  2849.  
  2850. int icount = (int) lua_tonumber(L, 2);
  2851.  
  2852. sys_log(0, "QUEST [award] item %d to login %s", dwVnum, ch->GetDesc()->GetAccountTable().login);
  2853.  
  2854. DBManager::instance().Query("INSERT INTO item_award (login, vnum, count, given_time, why, mall)select '%s', %d, %d, now(), '%s', 1 from DUAL where not exists (select login, why from item_award where login = '%s' and why = '%s') ;",
  2855. ch->GetDesc()->GetAccountTable().login,
  2856. dwVnum,
  2857. icount,
  2858. lua_tostring(L,3),
  2859. ch->GetDesc()->GetAccountTable().login,
  2860. lua_tostring(L,3));
  2861.  
  2862. lua_pushnumber (L, 0);
  2863.  
  2864. return 1;
  2865. }
  2866. int pc_give_award_socket(lua_State* L)
  2867. {
  2868. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  2869.  
  2870. if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isstring(L, 3) || !lua_isstring(L, 4) || !lua_isstring(L, 5) || !lua_isstring(L, 6) )
  2871. {
  2872. sys_err("QUEST give award call error : wrong argument");
  2873. lua_pushnumber (L, 0);
  2874. return 1;
  2875. }
  2876.  
  2877. DWORD dwVnum = (int) lua_tonumber(L, 1);
  2878.  
  2879. int icount = (int) lua_tonumber(L, 2);
  2880.  
  2881. sys_log(0, "QUEST [award] item %d to login %s", dwVnum, ch->GetDesc()->GetAccountTable().login);
  2882.  
  2883. DBManager::instance().Query("INSERT INTO item_award (login, vnum, count, given_time, why, mall, socket0, socket1, socket2)select '%s', %d, %d, now(), '%s', 1, %s, %s, %s from DUAL where not exists (select login, why from item_award where login = '%s' and why = '%s') ;",
  2884. ch->GetDesc()->GetAccountTable().login,
  2885. dwVnum,
  2886. icount,
  2887. lua_tostring(L,3),
  2888. lua_tostring(L,4),
  2889. lua_tostring(L,5),
  2890. lua_tostring(L,6),
  2891. ch->GetDesc()->GetAccountTable().login,
  2892. lua_tostring(L,3));
  2893.  
  2894. lua_pushnumber (L, 0);
  2895.  
  2896. return 1;
  2897. }
  2898.  
  2899. int pc_get_informer_type(lua_State* L)
  2900. {
  2901. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2902.  
  2903. if( pChar != NULL )
  2904. {
  2905. lua_pushstring(L, pChar->GetItemAward_cmd() );
  2906. }
  2907.  
  2908. else
  2909. lua_pushstring(L, "" );
  2910.  
  2911. return 1;
  2912. }
  2913.  
  2914. int pc_get_informer_item(lua_State* L)
  2915. {
  2916. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2917.  
  2918. if( pChar != NULL )
  2919. {
  2920. lua_pushnumber(L, pChar->GetItemAward_vnum() );
  2921. }
  2922.  
  2923. else
  2924. lua_pushnumber(L,0);
  2925.  
  2926. return 1;
  2927. }
  2928.  
  2929. int pc_get_killee_drop_pct(lua_State* L)
  2930. {
  2931. LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
  2932. LPCHARACTER pKillee = pChar->GetQuestNPC();
  2933.  
  2934. int iDeltaPercent, iRandRange;
  2935. if (NULL == pKillee || !ITEM_MANAGER::instance().GetDropPct(pKillee, pChar, iDeltaPercent, iRandRange))
  2936. {
  2937. sys_err("killee is null");
  2938. lua_pushnumber(L, -1);
  2939. lua_pushnumber(L, -1);
  2940.  
  2941. return 2;
  2942. }
  2943.  
  2944. lua_pushnumber(L, iDeltaPercent);
  2945. lua_pushnumber(L, iRandRange);
  2946.  
  2947. return 2;
  2948. }
  2949.  
  2950. #ifdef __TITLE_SYSTEM__
  2951. int pc_set_title(lua_State * L)
  2952. {
  2953. bool _to_return = false;
  2954. if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
  2955. {
  2956. sys_err("Invalid argument.");
  2957. lua_pushboolean(L, _to_return);
  2958.  
  2959. return 1;
  2960. }
  2961.  
  2962. CQuestManager& q = CQuestManager::instance();
  2963. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  2964. if (!ch)
  2965. {
  2966. lua_pushboolean(L, _to_return);
  2967.  
  2968. return 1;
  2969. }
  2970.  
  2971. _to_return = true;
  2972. int iTitle = (int)lua_tonumber(L, 1);
  2973. BYTE bValue = (BYTE)lua_tonumber(L, 2);
  2974. ch->SetTitle(iTitle, bValue);
  2975. lua_pushboolean(L, _to_return);
  2976.  
  2977. return 1;
  2978. }
  2979.  
  2980. int pc_get_title(lua_State * L)
  2981. {
  2982. bool _to_return = false;
  2983. if (!lua_isnumber(L, 1))
  2984. {
  2985. sys_err("Invalid argument.");
  2986. lua_pushboolean(L, _to_return);
  2987.  
  2988. return 1;
  2989. }
  2990.  
  2991. CQuestManager& q = CQuestManager::instance();
  2992. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  2993. if (!ch)
  2994. {
  2995. lua_pushboolean(L, _to_return);
  2996.  
  2997. return 1;
  2998. }
  2999.  
  3000. int iTitle = (int)lua_tonumber(L, 1);
  3001. _to_return = ch->GetTitle(iTitle);
  3002. lua_pushboolean(L, _to_return);
  3003.  
  3004. return 1;
  3005. }
  3006.  
  3007. int pc_choose_title(lua_State * L)
  3008. {
  3009. bool _to_return = false;
  3010. if (!lua_isnumber(L, 1))
  3011. {
  3012. sys_err("Invalid argument.");
  3013. lua_pushboolean(L, _to_return);
  3014.  
  3015. return 1;
  3016. }
  3017.  
  3018. CQuestManager& q = CQuestManager::instance();
  3019. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  3020. if (!ch)
  3021. {
  3022. lua_pushboolean(L, _to_return);
  3023.  
  3024. return 1;
  3025. }
  3026.  
  3027. int iTitle = (int)lua_tonumber(L, 1);
  3028. _to_return = ch->ChooseTitle(iTitle);
  3029. lua_pushboolean(L, _to_return);
  3030.  
  3031. return 1;
  3032. }
  3033.  
  3034. int pc_choosed_title(lua_State * L)
  3035. {
  3036. CQuestManager& q = CQuestManager::instance();
  3037. LPCHARACTER ch = q.GetCurrentCharacterPtr();
  3038. if (!ch)
  3039. {
  3040. lua_pushnumber(L, 0);
  3041.  
  3042. return 1;
  3043. }
  3044.  
  3045. int _to_return = ch->ChoosedTitle();
  3046. lua_pushnumber(L, _to_return);
  3047.  
  3048. return 1;
  3049. }
  3050. #endif
  3051.  
  3052. #ifdef ENABLE_VIP_SYSTEM
  3053. int pc_system_verify_vip(lua_State * L)
  3054. {
  3055. if (!lua_isnumber(L, 1))
  3056. {
  3057. sys_err("[VIP Info] : Nu exista pid .");
  3058. return 0;
  3059. }
  3060.  
  3061. long int pid_char = lua_tonumber(L, 1);
  3062.  
  3063. std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM player.vip_system WHERE PID_VIP = %u", pid_char));
  3064. MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
  3065.  
  3066. BYTE exista = 0;
  3067. str_to_number(exista, row[0]);
  3068.  
  3069. if (exista)
  3070. lua_pushboolean(L, true);
  3071.  
  3072. return 1;
  3073. }
  3074.  
  3075. int pc_system_add_vip(lua_State * L)
  3076. {
  3077.  
  3078. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  3079.  
  3080. if (!lua_isnumber(L, 1))
  3081. {
  3082. sys_err("[VIP Info] : Timp invalid .");
  3083. return 0;
  3084. }
  3085.  
  3086. if (!lua_isnumber(L, 2))
  3087. {
  3088. sys_err("[VIP Info] : Fara timp invalid .");
  3089. return 0;
  3090. }
  3091.  
  3092. time_t t1 = time(0);
  3093. long long timp_calcuat = t1 +((int)lua_tonumber(L, 1) * 86400);
  3094. char query[1024];
  3095.  
  3096. sprintf(query, "INSERT INTO player.vip_system SET");
  3097. sprintf(query, "%s PID_VIP='%d'", query, ch->GetPlayerID());
  3098. sprintf(query, "%s, TIMP='%d'", query, timp_calcuat);
  3099. sprintf(query, "%s, FARA_TIMP='%d'", query, (int)lua_tonumber(L, 2));
  3100.  
  3101. DBManager::instance().DirectQuery(query);
  3102. ch->VipSystem();
  3103.  
  3104. return 0;
  3105. }
  3106.  
  3107. int lua_grant_vip_bonus(lua_State* L)
  3108. {
  3109. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  3110. if (!ch)
  3111. return 0;
  3112.  
  3113. int item_vnum = 0;
  3114. if (lua_isnumber(L, 1))
  3115. item_vnum = (int)lua_tonumber(L, 1);
  3116.  
  3117. if (ch->IsVIP())
  3118. {
  3119. ch->ChatPacket(CHAT_TYPE_INFO, "|cFFFFD700Ai primit deja bonusurile VIP!");
  3120. return 0;
  3121. }
  3122.  
  3123. ch->SetVIP();
  3124.  
  3125. ch->PointChange(POINT_HP, 3500);
  3126. ch->PointChange(POINT_CRITICAL_PCT, 10);
  3127. ch->PointChange(POINT_PENETRATE_PCT, 10);
  3128. ch->PointChange(POINT_ATTBONUS_HUMAN, 10);
  3129.  
  3130. ch->ChatPacket(CHAT_TYPE_INFO, "|cFFFFFF00[VIP]|cFFFFD700 Ai primit bonusurile VIP: +3500 HP, +10% Crit, +10% Penetrate, +10% Damage vs Human!");
  3131.  
  3132. if (item_vnum)
  3133. ch->RemoveSpecifyItem(item_vnum, 1);
  3134.  
  3135. return 0;
  3136. }
  3137.  
  3138. #endif
  3139.  
  3140. #ifdef ENABLE_PREMIUM_SYSTEM
  3141. int pc_system_verify_premium(lua_State * L)
  3142. {
  3143. if (!lua_isnumber(L, 1))
  3144. {
  3145. sys_err("[Premium Info] : Nu exista pid .");
  3146. return 0;
  3147. }
  3148.  
  3149. long int pid_char = lua_tonumber(L, 1);
  3150.  
  3151. std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM player.premium_system WHERE PID_PREMIUM = %u", pid_char));
  3152. MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
  3153.  
  3154. BYTE exista = 0;
  3155. str_to_number(exista, row[0]);
  3156.  
  3157. if (exista)
  3158. lua_pushboolean(L, true);
  3159.  
  3160. return 1;
  3161. }
  3162.  
  3163. int pc_system_add_premium(lua_State * L)
  3164. {
  3165.  
  3166. LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
  3167.  
  3168. if (!lua_isnumber(L, 1))
  3169. {
  3170. sys_err("[Premium Info] : Timp invalid .");
  3171. return 0;
  3172. }
  3173.  
  3174. if (!lua_isnumber(L, 2))
  3175. {
  3176. sys_err("[Premium Info] : Fara timp invalid .");
  3177. return 0;
  3178. }
  3179.  
  3180. time_t t1 = time(0);
  3181. long long timp_calcuat = t1 +((int)lua_tonumber(L, 1) * 86400);
  3182. char query[1024];
  3183.  
  3184. sprintf(query, "INSERT INTO player.premium_system SET");
  3185. sprintf(query, "%s PID_PREMIUM='%d'", query, ch->GetPlayerID());
  3186. sprintf(query, "%s, TIMP='%d'", query, timp_calcuat);
  3187. sprintf(query, "%s, FARA_TIMP='%d'", query, (int)lua_tonumber(L, 2));
  3188.  
  3189. DBManager::instance().DirectQuery(query);
  3190. ch->PremiumSystem();
  3191.  
  3192. return 0;
  3193. }
  3194. #endif
  3195.  
  3196. void RegisterPCFunctionTable()
  3197. {
  3198. luaL_reg pc_functions[] =
  3199. {
  3200. { "get_wear", pc_get_wear },
  3201. { "get_player_id", pc_get_player_id },
  3202. { "get_account_id", pc_get_account_id },
  3203. { "get_account", pc_get_account },
  3204. { "get_level", pc_get_level },
  3205. { "set_level", pc_set_level },
  3206. { "get_next_exp", pc_get_next_exp },
  3207. { "get_exp", pc_get_exp },
  3208. { "get_job", pc_get_job },
  3209. { "get_race", pc_get_race },
  3210. { "change_sex", pc_change_sex },
  3211. { "gethp", pc_get_hp },
  3212. { "get_hp", pc_get_hp },
  3213. { "getmaxhp", pc_get_max_hp },
  3214. { "get_max_hp", pc_get_max_hp },
  3215. { "getsp", pc_get_sp },
  3216. { "get_sp", pc_get_sp },
  3217. { "getmaxsp", pc_get_max_sp },
  3218. { "get_max_sp", pc_get_max_sp },
  3219. { "change_sp", pc_change_sp },
  3220. { "getmoney", pc_get_money },
  3221. { "get_money", pc_get_money },
  3222. { "get_real_alignment", pc_get_real_alignment },
  3223. { "get_alignment", pc_get_alignment },
  3224. { "getweapon", pc_get_weapon },
  3225. { "get_weapon", pc_get_weapon },
  3226. { "getarmor", pc_get_armor },
  3227. { "get_armor", pc_get_armor },
  3228. { "getgold", pc_get_money },
  3229. { "get_gold", pc_get_money },
  3230. { "changegold", pc_change_money },
  3231. { "changemoney", pc_change_money },
  3232. { "changealignment", pc_change_alignment },
  3233. { "change_gold", pc_change_money },
  3234. { "change_money", pc_change_money },
  3235. { "change_alignment", pc_change_alignment },
  3236. { "getname", pc_get_name },
  3237. { "get_name", pc_get_name },
  3238. { "get_vid", pc_get_vid },
  3239. { "getplaytime", pc_get_playtime },
  3240. { "get_playtime", pc_get_playtime },
  3241. { "getleadership", pc_get_leadership },
  3242. { "get_leadership", pc_get_leadership },
  3243. { "getqf", pc_get_quest_flag },
  3244. { "setqf", pc_set_quest_flag },
  3245. { "delqf", pc_del_quest_flag },
  3246. { "getf", pc_get_another_quest_flag },
  3247. { "setf", pc_set_another_quest_flag },
  3248. { "get_x", pc_get_x },
  3249. { "get_y", pc_get_y },
  3250. { "getx", pc_get_x },
  3251. { "gety", pc_get_y },
  3252. { "get_local_x", pc_get_local_x },
  3253. { "get_local_y", pc_get_local_y },
  3254. { "getcurrentmapindex", pc_get_current_map_index },
  3255. { "get_map_index", pc_get_current_map_index },
  3256. { "give_exp", pc_give_exp },
  3257. { "give_exp_perc", pc_give_exp_perc },
  3258. { "give_exp2", pc_give_exp2 },
  3259. { "give_item", pc_give_item },
  3260. { "give_item2", pc_give_or_drop_item },
  3261. { "give_item2_select", pc_give_or_drop_item_and_select },
  3262. { "give_gold", pc_give_gold },
  3263. { "count_item", pc_count_item },
  3264. { "remove_item", pc_remove_item },
  3265. { "countitem", pc_count_item },
  3266. { "removeitem", pc_remove_item },
  3267. { "reset_point", pc_reset_point },
  3268. { "has_guild", pc_hasguild },
  3269. { "hasguild", pc_hasguild },
  3270. { "get_guild", pc_getguild },
  3271. { "getguild", pc_getguild },
  3272. { "isguildmaster", pc_isguildmaster },
  3273. { "is_guild_master", pc_isguildmaster },
  3274. { "destroy_guild", pc_destroy_guild },
  3275. { "remove_from_guild", pc_remove_from_guild },
  3276. { "in_dungeon", pc_in_dungeon },
  3277. { "getempire", pc_get_empire },
  3278. { "get_empire", pc_get_empire },
  3279. { "get_skill_group", pc_get_skillgroup },
  3280. { "set_skill_group", pc_set_skillgroup },
  3281. { "warp", pc_warp },
  3282. { "warp_local", pc_warp_local },
  3283. { "warp_exit", pc_warp_exit },
  3284. { "set_warp_location", pc_set_warp_location },
  3285. { "set_warp_location_local", pc_set_warp_location_local },
  3286. { "get_start_location", pc_get_start_location },
  3287. { "has_master_skill", pc_has_master_skill },
  3288. { "set_part", pc_set_part },
  3289. { "get_part", pc_get_part },
  3290. { "is_polymorphed", pc_is_polymorphed },
  3291. { "remove_polymorph", pc_remove_polymorph },
  3292. { "is_mount", pc_is_mount },
  3293. { "polymorph", pc_polymorph },
  3294. { "mount", pc_mount },
  3295. { "mount_bonus", pc_mount_bonus },
  3296. { "unmount", pc_unmount },
  3297. { "warp_to_guild_war_observer_position", pc_warp_to_guild_war_observer_position },
  3298. { "give_item_from_special_item_group", pc_give_item_from_special_item_group },
  3299. { "learn_grand_master_skill", pc_learn_grand_master_skill },
  3300. { "is_skill_book_no_delay", pc_is_skill_book_no_delay},
  3301. { "remove_skill_book_no_delay", pc_remove_skill_book_no_delay},
  3302.  
  3303. #ifdef __TITLE_SYSTEM__
  3304. {"set_title", pc_set_title},
  3305. {"get_title", pc_get_title},
  3306. {"choose_title", pc_choose_title},
  3307. {"choosed_title", pc_choosed_title},
  3308. #endif
  3309. { "enough_inventory", pc_enough_inventory },
  3310. { "get_horse_level", pc_get_horse_level },
  3311. { "is_horse_alive", pc_is_horse_alive },
  3312. { "revive_horse", pc_revive_horse },
  3313. { "have_pos_scroll", pc_have_pos_scroll },
  3314. { "have_map_scroll", pc_have_map_scroll },
  3315. { "get_war_map", pc_get_war_map },
  3316. { "get_equip_refine_level", pc_get_equip_refine_level },
  3317. { "refine_equip", pc_refine_equip },
  3318. { "get_skill_level", pc_get_skill_level },
  3319. { "aggregate_monster", pc_aggregate_monster },
  3320. { "forget_my_attacker", pc_forget_my_attacker },
  3321. { "pc_attract_ranger", pc_attract_ranger },
  3322. { "select", pc_select_vid },
  3323. { "get_sex", pc_get_sex },
  3324. { "is_married", pc_is_married },
  3325. { "is_engaged", pc_is_engaged },
  3326. { "is_engaged_or_married", pc_is_engaged_or_married},
  3327. { "is_gm", pc_is_gm },
  3328. { "get_gm_level", pc_get_gm_level },
  3329. { "mining", pc_mining },
  3330. { "ore_refine", pc_ore_refine },
  3331. { "diamond_refine", pc_diamond_refine },
  3332.  
  3333. { "clear_one_skill", pc_clear_one_skill },
  3334.  
  3335. { "clear_skill", pc_clear_skill },
  3336. { "clear_sub_skill", pc_clear_sub_skill },
  3337. { "set_skill_point", pc_set_skill_point },
  3338.  
  3339. { "is_clear_skill_group", pc_is_clear_skill_group },
  3340.  
  3341. { "save_exit_location", pc_save_exit_location },
  3342. { "teleport", pc_teleport },
  3343.  
  3344. { "set_skill_level", pc_set_skill_level },
  3345.  
  3346. { "give_polymorph_book", pc_give_polymorph_book },
  3347. { "upgrade_polymorph_book", pc_upgrade_polymorph_book },
  3348. { "get_premium_remain_sec", pc_get_premium_remain_sec },
  3349.  
  3350. { "send_block_mode", pc_send_block_mode },
  3351.  
  3352. { "change_empire", pc_change_empire },
  3353. { "get_change_empire_count", pc_get_change_empire_count },
  3354. { "set_change_empire_count", pc_set_change_empire_count },
  3355.  
  3356. { "change_name", pc_change_name },
  3357.  
  3358. #ifdef ENABLE_MESSENGER_BLOCK
  3359. { "is_blocked", pc_is_blocked },
  3360. { "is_friend", pc_is_friend },
  3361. #endif
  3362. { "is_dead", pc_is_dead },
  3363.  
  3364. { "reset_status", pc_reset_status },
  3365. { "get_ht", pc_get_ht },
  3366. { "set_ht", pc_set_ht },
  3367. { "get_iq", pc_get_iq },
  3368. { "set_iq", pc_set_iq },
  3369. { "get_st", pc_get_st },
  3370. { "set_st", pc_set_st },
  3371. { "get_dx", pc_get_dx },
  3372. { "set_dx", pc_set_dx },
  3373.  
  3374. { "is_near_vid", pc_is_near_vid },
  3375.  
  3376. { "get_socket_items", pc_get_socket_items },
  3377. { "get_empty_inventory_count", pc_get_empty_inventory_count },
  3378.  
  3379. { "get_logoff_interval", pc_get_logoff_interval },
  3380.  
  3381. { "is_riding", pc_is_riding },
  3382. { "get_special_ride_vnum", pc_get_special_ride_vnum },
  3383.  
  3384. { "can_warp", pc_can_warp },
  3385.  
  3386. { "dec_skill_point", pc_dec_skill_point },
  3387. { "get_skill_point", pc_get_skill_point },
  3388.  
  3389. { "get_channel_id", pc_get_channel_id },
  3390.  
  3391. { "give_poly_marble", pc_give_poly_marble },
  3392. { "get_sig_items", pc_get_sig_items },
  3393.  
  3394. { "charge_cash", pc_charge_cash },
  3395.  
  3396. { "get_informer_type", pc_get_informer_type },
  3397. { "get_informer_item", pc_get_informer_item },
  3398.  
  3399. { "give_award", pc_give_award },
  3400. { "give_award_socket", pc_give_award_socket },
  3401.  
  3402. { "get_killee_drop_pct", pc_get_killee_drop_pct },
  3403.  
  3404. #ifdef ENABLE_VIP_SYSTEM
  3405. { "verify_vip_system", pc_system_verify_vip },
  3406. { "add_vip_system", pc_system_add_vip },
  3407. { "grant_vip_bonus", lua_grant_vip_bonus},
  3408. #endif
  3409.  
  3410. #ifdef ENABLE_PREMIUM_SYSTEM
  3411. { "verify_premium_system", pc_system_verify_premium },
  3412. { "add_premium_system", pc_system_add_premium },
  3413. #endif
  3414.  
  3415. #ifdef ENABLE_DAMAGE_TOP
  3416. { "open_damage_top", pc_open_damage_top },
  3417. #endif
  3418. { NULL, NULL }
  3419. };
  3420.  
  3421. CQuestManager::instance().AddLuaFunctionTable("pc", pc_functions);
  3422. }
  3423. };
  3424.  
Advertisement
Add Comment
Please, Sign In to add comment