Guest User

Untitled

a guest
Nov 7th, 2016
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. quest questscroll5 begin
  2. state start begin
  3. when 50317.use begin
  4. local s=0
  5. local t=select("Aa", "Ab", "Ba", "Bb", "Bc", "Ca", "Cb", "Cc", "Cd", "Da", "Db")
  6. if 1==t then
  7. s=select(
  8. questscroll5.get_menu(1),
  9. questscroll5.get_menu(2),
  10. questscroll5.get_menu(3),
  11. questscroll5.get_menu(4),
  12. questscroll5.get_menu(5),
  13. questscroll5.get_menu(6)
  14. )+1-1
  15. elseif 2==t then
  16. s=select(
  17. questscroll5.get_menu(7),
  18. questscroll5.get_menu(8),
  19. questscroll5.get_menu(9),
  20. questscroll5.get_menu(10),
  21. questscroll5.get_menu(11)
  22. )+7-1
  23. elseif 3==t then
  24. s=select(
  25. questscroll5.get_menu(12),
  26. questscroll5.get_menu(13),
  27. questscroll5.get_menu(14),
  28. questscroll5.get_menu(15)
  29. )+12-1
  30. elseif 4==t then
  31. s=select(
  32. questscroll5.get_menu(16),
  33. questscroll5.get_menu(17),
  34. questscroll5.get_menu(18),
  35. questscroll5.get_menu(19),
  36. questscroll5.get_menu(20),
  37. questscroll5.get_menu(21)
  38. )+16-1
  39. elseif 5==t then
  40. s=select(
  41. questscroll5.get_menu(22),
  42. questscroll5.get_menu(23),
  43. questscroll5.get_menu(24),
  44. questscroll5.get_menu(25)
  45. )+22-1
  46. elseif 6==t then
  47. s=select(
  48. questscroll5.get_menu(26),
  49. questscroll5.get_menu(27),
  50. questscroll5.get_menu(28),
  51. questscroll5.get_menu(29),
  52. questscroll5.get_menu(30),
  53. questscroll5.get_menu(31)
  54. )+26-1
  55. elseif 7==t then
  56. s=select(
  57. questscroll5.get_menu(32),
  58. questscroll5.get_menu(33),
  59. questscroll5.get_menu(34),
  60. questscroll5.get_menu(35)
  61. )+32-1
  62. elseif 8==t then
  63. s=select(
  64. questscroll5.get_menu(36),
  65. questscroll5.get_menu(37),
  66. questscroll5.get_menu(38),
  67. questscroll5.get_menu(39),
  68. questscroll5.get_menu(40),
  69. questscroll5.get_menu(41)
  70. )+36-1
  71. elseif 9==t then
  72. s=select(
  73. questscroll5.get_menu(42),
  74. questscroll5.get_menu(43),
  75. questscroll5.get_menu(44),
  76. questscroll5.get_menu(45),
  77. questscroll5.get_menu(46),
  78. questscroll5.get_menu(47),
  79. questscroll5.get_menu(48),
  80. questscroll5.get_menu(49)
  81. )+42-1
  82. elseif 10==t then
  83. s=select(
  84. questscroll5.get_menu(50),
  85. questscroll5.get_menu(51),
  86. questscroll5.get_menu(52),
  87. questscroll5.get_menu(53)
  88. )+50-1
  89. elseif 11==t then
  90. s=select(
  91. questscroll5.get_menu(54),
  92. questscroll5.get_menu(55),
  93. questscroll5.get_menu(56)
  94. )+54-1
  95. end
  96. questscroll5.set_mission(s)
  97. item.remove()
  98. end
  99. when 50318.use begin
  100. local s=0
  101. if is_test_server() then
  102. test_chat(gameforge.questscroll5._30_chat)
  103. s=select(
  104. questscroll5.get_menu(1),
  105. questscroll5.get_menu(2),
  106. questscroll5.get_menu(3),
  107. questscroll5.get_menu(4),
  108. questscroll5.get_menu(5),
  109. questscroll5.get_menu(6),
  110. questscroll5.get_menu(7),
  111. questscroll5.get_menu(8),
  112. questscroll5.get_menu(9),
  113. questscroll5.get_menu(10),
  114. questscroll5.get_menu(11)
  115. )+1-1
  116. else
  117. s=number(1, 11)
  118. end
  119. questscroll5.set_mission(s)
  120. item.remove()
  121. end
  122. when 50319.use begin
  123. local s=0
  124. if is_test_server() then
  125. test_chat(gameforge.questscroll5._40_chat)
  126. s=select(
  127. questscroll5.get_menu(12),
  128. questscroll5.get_menu(13),
  129. questscroll5.get_menu(14),
  130. questscroll5.get_menu(15),
  131. questscroll5.get_menu(16),
  132. questscroll5.get_menu(17),
  133. questscroll5.get_menu(18),
  134. questscroll5.get_menu(19),
  135. questscroll5.get_menu(20),
  136. questscroll5.get_menu(21),
  137. questscroll5.get_menu(22),
  138. questscroll5.get_menu(23),
  139. questscroll5.get_menu(24),
  140. questscroll5.get_menu(25)
  141. )+12-1
  142. else
  143. s=number(12, 25)
  144. end
  145. questscroll5.set_mission(s)
  146. item.remove()
  147. end
  148. when 50320.use begin
  149. local s=0
  150. if is_test_server() then
  151. test_chat(gameforge.questscroll5._50_chat)
  152. s=select(
  153. questscroll5.get_menu(26),
  154. questscroll5.get_menu(27),
  155. questscroll5.get_menu(28),
  156. questscroll5.get_menu(29),
  157. questscroll5.get_menu(30),
  158. questscroll5.get_menu(31),
  159. questscroll5.get_menu(32),
  160. questscroll5.get_menu(33),
  161. questscroll5.get_menu(34),
  162. questscroll5.get_menu(35),
  163. questscroll5.get_menu(36),
  164. questscroll5.get_menu(37),
  165. questscroll5.get_menu(38),
  166. questscroll5.get_menu(39),
  167. questscroll5.get_menu(40),
  168. questscroll5.get_menu(41),
  169. questscroll5.get_menu(42),
  170. questscroll5.get_menu(43),
  171. questscroll5.get_menu(44),
  172. questscroll5.get_menu(45),
  173. questscroll5.get_menu(46),
  174. questscroll5.get_menu(47),
  175. questscroll5.get_menu(48),
  176. questscroll5.get_menu(49)
  177. )+26-1
  178. else
  179. s=number(26, 49)
  180. end
  181. questscroll5.set_mission(s)
  182. item.remove()
  183. end
  184. when 50321.use begin
  185. local s=0
  186. if is_test_server() then
  187. test_chat(gameforge.questscroll5._60_chat)
  188. s=select(
  189. questscroll5.get_menu(50),
  190. questscroll5.get_menu(51),
  191. questscroll5.get_menu(52),
  192. questscroll5.get_menu(53),
  193. questscroll5.get_menu(54),
  194. questscroll5.get_menu(55),
  195. questscroll5.get_menu(56)
  196. )+50-1
  197. else
  198. s=number(50, 56)
  199. end
  200. questscroll5.set_mission(s)
  201. item.remove()
  202. end
  203. function get_menu(mission_index)
  204. return locale.questscroll5.mission[mission_index][3]
  205. end
  206. function set_mission(mission_index)
  207. pc.setqf("mission_index", mission_index)
  208.  
  209. local mission_type=questscroll5.get_mission_type()
  210. if mission_type==QUEST_SCROLL_TYPE_KILL_MOB then
  211. test_chat(gameforge.questscroll5._70_chat)
  212. set_state("kill1")
  213. elseif mission_type==QUEST_SCROLL_TYPE_KILL_MOB2 then
  214. test_chat(gameforge.questscroll5._80_chat)
  215. set_state("kill2")
  216. end
  217. end
  218. function get_mission_type()
  219. return questscroll5.get_mission()[1]
  220. end
  221. function notify_already_running()
  222. say_title(gameforge.questscroll5._90_sayTitle)
  223. say(gameforge.questscroll5._100_say)
  224. end
  225. function show_mission_menu()
  226. local s= select(gameforge.locale.levelup.prev_quest_go, gameforge.locale.cancel)
  227. if s==2 then
  228. say_title(string.format(gameforge.questscroll5._110_sayTitle, questscroll5.get_title()))
  229. say(gameforge.questscroll5._120_say)
  230. local a= select(gameforge.questscroll5._130_select, gameforge.locale.guild.no)
  231. if a==1 then
  232. say(string.format(gameforge.questscroll5._140_say, questscroll5.get_title()))
  233. restart_quest()
  234. end
  235. end
  236. end
  237. end
  238. state kill1 begin
  239. when questscroll1.use or
  240. 50317.use or
  241. 50318.use or
  242. 50319.use or
  243. 50320.use or
  244. 50321.use or
  245. 50322.use or
  246. 50323.use or
  247. 50324.use or
  248. 50325.use begin
  249. questscroll5.notify_already_running()
  250. end
  251. when letter begin
  252. send_letter(questscroll5.get_title())
  253. end
  254. when button or info begin
  255. say_title(questscroll5.get_title())
  256. say(questscroll5.get_desc())
  257. say_reward(questscroll5.get_summ())
  258. say_reward(string.format(gameforge.questscroll5._150_sayReward, questscroll5.get_mob1_name(), questscroll5.get_mob1_rest_kill_count() ))
  259. questscroll5.show_mission_menu()
  260. end
  261. when enter begin
  262. pc.setqf("mob1_kill_count", 0)
  263. end
  264. when leave begin
  265. pc.setqf("mob1_kill_count", 0)
  266. end
  267. when letter begin
  268. q.set_counter(questscroll5.get_mob1_name(), questscroll5.get_mob1_rest_kill_count())
  269. end
  270. when kill begin
  271. test_chat(string.format(gameforge.questscroll5._160_chat, npc.get_race().." [ENTER]questscroll5.dest_race:"..questscroll5.get_mob1_vnum()))
  272. if npc.get_race()==questscroll5.get_mob1_vnum() then
  273. local mob1_kill_count=questscroll5.get_mob1_cur_kill_count()+1
  274. questscroll5.set_mob1_cur_kill_count(mob1_kill_count)
  275. q.set_counter(questscroll5.get_mob1_name(), questscroll5.get_mob1_rest_kill_count())
  276. if mob1_kill_count>=questscroll5.get_mob1_max_kill_count() then
  277. set_state(reward)
  278. end
  279. end
  280. end
  281. end
  282. state kill2 begin
  283. when questscroll1.use or
  284. 50317.use or
  285. 50318.use or
  286. 50319.use or
  287. 50320.use or
  288. 50321.use or
  289. 50322.use or
  290. 50323.use or
  291. 50324.use or
  292. 50325.use begin
  293.  
  294. questscroll5.notify_already_running()
  295. end
  296. when letter begin
  297. send_letter(questscroll5.get_title())
  298. end
  299. when button or info begin
  300. say_title(questscroll5.get_title())
  301. say(questscroll5.get_desc())
  302. say_reward(questscroll5.get_summ())
  303. say_reward(string.format(gameforge.questscroll5._170_sayReward, questscroll5.get_mob1_name(), questscroll5.get_mob1_rest_kill_count(), questscroll5.get_mob2_name(), questscroll5.get_mob2_rest_kill_count() ))
  304. questscroll5.show_mission_menu()
  305. end
  306. when enter begin
  307. pc.setqf("mob1_kill_count", 0)
  308. pc.setqf("mob2_kill_count", 0)
  309. end
  310. when leave begin
  311. pc.setqf("mob1_kill_count", 0)
  312. pc.setqf("mob2_kill_count", 0)
  313. end
  314. when letter begin
  315. q.set_counter(questscroll5.get_mob1_name(), questscroll5.get_mob1_rest_kill_count())
  316. end
  317. when kill begin
  318. local npc_race=npc.get_race()
  319. local mob1_kill_count=questscroll5.get_mob1_cur_kill_count()
  320. local mob2_kill_count=questscroll5.get_mob2_cur_kill_count()
  321.  
  322. test_chat(string.format(gameforge.questscroll5._180_chat, npc_race.." [ENTER]questscroll5.dest_race1: ["..questscroll5.get_mob1_vnum().."] [ENTER]questscroll5.dest_race2: ["..questscroll5.get_mob2_vnum()))
  323. if npc_race==questscroll5.get_mob1_vnum() then
  324. mob1_kill_count=mob1_kill_count+1
  325. questscroll5.set_mob1_cur_kill_count(mob1_kill_count)
  326. q.set_counter(questscroll5.get_mob1_name(), questscroll5.get_mob1_rest_kill_count())
  327. elseif npc_race==questscroll5.get_mob2_vnum() then
  328. mob2_kill_count=mob2_kill_count+1
  329. questscroll5.set_mob2_cur_kill_count(mob2_kill_count)
  330. q.set_counter(questscroll5.get_mob2_name(), questscroll5.get_mob2_rest_kill_count())
  331. end
  332.  
  333. if mob1_kill_count>=questscroll5.get_mob1_max_kill_count() and
  334. mob2_kill_count>=questscroll5.get_mob2_max_kill_count() then
  335. set_state(reward)
  336. end
  337. end
  338. end
  339. state reward begin
  340. when letter begin
  341. send_letter(questscroll5.get_complete_title())
  342. end
  343. when button or info begin
  344. restart_quest()
  345.  
  346. say_title(questscroll5.get_complete_title())
  347.  
  348. say(gameforge.questscroll5._190_say)
  349. local reward_type=questscroll5.get_reward_type()
  350. if number(0, 100)<=90 then
  351. local s=number(1, 3)
  352. if 1==s then
  353. questscroll5.reward_exp(reward_type)
  354. questscroll5.reward_money(reward_type)
  355. elseif 2==s then
  356. questscroll5.reward_money(reward_type)
  357. questscroll5.reward_item(reward_type)
  358. elseif 3==s then
  359. questscroll5.reward_exp(reward_type)
  360. questscroll5.reward_item(reward_type)
  361. end
  362. else
  363. questscroll5.reward_exp(reward_type)
  364. questscroll5.reward_money(reward_type)
  365. questscroll5.reward_item(reward_type)
  366. end
  367.  
  368. end
  369. -- pimped according mantis #118754 to prevent mantis #0042898
  370. function get_mission()
  371. -- add addtional check routine for player that have a invalid mission index
  372. local mission_index = pc.getqf("mission_index")
  373.  
  374. if mission_index > 56 then
  375. mission_index = number(50, 56)
  376. questscroll5.set_mission(mission_index)
  377. end
  378.  
  379. return locale.questscroll5.mission[mission_index]
  380. end
  381.  
  382. function get_title()
  383. return questscroll5.get_mission()[3]
  384. end
  385. function get_complete_title()
  386. return string.format(gameforge.questscroll5._200_stringFormat, questscroll5.get_title())
  387. end
  388. function get_desc()
  389. return "[WINDOW_SIZE width;360|height;280]"..questscroll5.get_mission()[4]
  390. end
  391. function get_summ()
  392. return questscroll5.get_mission()[5]
  393. end
  394. function get_mob1_name()
  395. return mob_name(questscroll5.get_mob1_vnum())
  396. end
  397. function get_mob1_max_kill_count()
  398. return questscroll5.get_mission()[7]
  399. end
  400. function get_mob1_vnum()
  401. return tonumber(questscroll5.get_mission()[6])
  402. end
  403. function get_mob1_rest_kill_count()
  404. local ret=questscroll5.get_mob1_max_kill_count()-questscroll5.get_mob1_cur_kill_count()
  405. if ret<0 then return 0 end
  406. return ret
  407. end
  408. function set_mob1_cur_kill_count(value)
  409. pc.setqf("mob1_kill_count", value)
  410. end
  411. function get_mob1_cur_kill_count()
  412. return pc.getqf("mob1_kill_count")
  413. end
  414.  
  415. function get_mob2_name()
  416. return mob_name(questscroll5.get_mob2_vnum())
  417. end
  418. function get_mob2_max_kill_count()
  419. return questscroll5.get_mission()[9]
  420. end
  421. function get_mob2_vnum()
  422. return tonumber(questscroll5.get_mission()[8])
  423. end
  424. function get_mob2_rest_kill_count()
  425. local ret=questscroll5.get_mob2_max_kill_count()-questscroll5.get_mob2_cur_kill_count()
  426. if ret<0 then return 0 end
  427. return ret
  428. end
  429. function set_mob2_cur_kill_count(value)
  430. pc.setqf("mob2_kill_count", value)
  431. end
  432. function get_mob2_cur_kill_count()
  433. return pc.getqf("mob2_kill_count")
  434. end
  435.  
  436. function reward_table_get_prob_sum(item_array)
  437. local sum=0
  438. for i=1, table.getn(item_array) do
  439. sum=sum+item_array[i][2]
  440. end
  441. return sum
  442. end
  443. function reward_table_get_value(item_array)
  444. local prob_sum=questscroll5.reward_table_get_prob_sum(item_array)
  445. local prob_pos=number(0, prob_sum)
  446.  
  447. test_chat(string.format(gameforge.questscroll5._210_chat, prob_pos))
  448. for i=1, table.getn(item_array) do
  449. prob_cur=item_array[i][2]
  450. if prob_pos<=prob_cur then
  451. return item_array[i][1]
  452. end
  453. prob_pos=prob_pos-prob_cur
  454. end
  455.  
  456. chat(gameforge.questscroll5._220_chat)
  457. return 0
  458. end
  459. function get_reward_type()
  460. return questscroll5.get_mission()[2]
  461. end
  462. function get_reward_money(reward_type)
  463. return questscroll5.reward_table_get_value(locale.questscroll5.reward_money[reward_type])
  464. end
  465. function get_reward_exp(reward_type)
  466. return questscroll5.reward_table_get_value(locale.questscroll5.reward_exp[reward_type])
  467. end
  468. function get_reward_item(reward_type)
  469. return questscroll5.reward_table_get_value(locale.questscroll5.reward_item[reward_type])
  470. end
  471. function reward_money(reward_type)
  472. local reward_money=questscroll5.get_reward_money(reward_type)
  473. if reward_money>1000 and reward_money<=200000 then
  474. pc.change_money(reward_money)
  475. say_reward(string.format(gameforge.questscroll5._230_sayReward, reward_money))
  476. else
  477. chat(string.format(gameforge.questscroll5._240_chat, reward_type))
  478. end
  479. end
  480. function reward_exp(reward_type)
  481. local reward_exp=questscroll5.get_reward_exp(reward_type)
  482. if reward_exp>1000 and reward_exp<=300000 then
  483. pc.give_exp2(reward_exp)
  484. set_quest_state("levelup", "run")
  485. say_reward(string.format(gameforge.questscroll5._250_sayReward, reward_exp))
  486. else
  487. chat(string.format(gameforge.questscroll5._260_chat, reward_type))
  488. end
  489. end
  490. function reward_item(reward_type)
  491. local reward_item=questscroll5.get_reward_item(reward_type)
  492. pc.give_item2(reward_item)
  493. say_reward(string.format(gameforge.questscroll5._270_sayReward, item_name(reward_item)))
  494. end
  495. end
  496. end
RAW Paste Data