SergiuAndreiM

pvpquest

Apr 27th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.46 KB | None | 0 0
  1. quest pvp_manager begin
  2. state start begin
  3. when login with game.get_event_flag("budokan_open") > 0 and pc.get_map_index() != 115 begin
  4. q.set_icon("scroll_open_blue.tga")
  5. send_letter("*Intrã în arena Dojang")
  6. end
  7.  
  8. when button or info begin
  9. say_title("Turneul PvP:")
  10. if game.get_event_flag("budokan_open") == 1 then
  11. say("Arena Dojang este acum deschisã !")
  12. say("")
  13. say("Alãturã-te pentru pariuri sau participã în duelele")
  14. say("competitive cu alþi jucãtori pentru a obþine")
  15. say("glorie ºi bani.")
  16. say("")
  17. local s = select("Du-mã acolo acum.","Nu, mulþumesc.")
  18. if s == 1 then
  19. pc.warp(844800,0)
  20. end
  21. else
  22. say("Arena Dojang se va deschide în scurt timp.")
  23. say("")
  24. say("Alãturã-te pentru pariuri sau participã în duelele")
  25. say("competitive cu alþi jucãtori pentru a obþine")
  26. say("glorie ºi bani.")
  27. say("")
  28. say("Când intrarea este permisã te poþi duce acolo")
  29. say("prin acest quest. Pregãteºte-þi armele !")
  30. say("")
  31. end
  32. end
  33. when login with pc.get_map_index() == 115 and (pvp_attenders == nil or pvp_attenders[pvp_manager.get_my_attender_id()] == nil or (pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode != 1 and pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode != 2)) begin
  34. if pvp_attenders == nil then
  35. pvp_manager.guard_check_position()
  36. timer("pvp_guard_1", 20)
  37. return
  38. end
  39. if pvp_attenders[pvp_manager.get_my_attender_id()] == nil then
  40. pvp_manager.guard_check_position()
  41. timer("pvp_guard_1", 20)
  42. return
  43. end
  44. if pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode != 1 and pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode != 2 then
  45. pvp_manager.guard_check_position()
  46. timer("pvp_guard_1", 20)
  47. end
  48. end
  49. when pvp_guard_1.timer begin
  50. if pc.get_map_index() != 115 then
  51. return
  52. end
  53. pvp_manager.guard_check_position()
  54. timer("pvp_guard_2", 20)
  55. end
  56. when pvp_guard_2.timer begin
  57. if pc.get_map_index() != 115 then
  58. return
  59. end
  60. pvp_manager.guard_check_position()
  61. timer("pvp_guard_1", 20)
  62. end
  63. function guard_check_position()
  64. if pc.get_local_x() >= 84 and pc.get_local_y() >= 84 and pc.get_local_x() <= 116 and pc.get_local_y() <= 116 then --arena 1
  65. pvp_manager.guard_reset()
  66. end
  67. if pc.get_local_x() >= 84 and pc.get_local_y() >= 136 and pc.get_local_x() <= 116 and pc.get_local_y() <= 168 then --arena 2
  68. pvp_manager.guard_reset()
  69. end
  70. if pc.get_local_x() >= 136 and pc.get_local_y() >= 84 and pc.get_local_x() <= 168 and pc.get_local_y() <= 116 then --arena 3
  71. pvp_manager.guard_reset()
  72. end
  73. if pc.get_local_x() >= 136 and pc.get_local_y() >= 136 and pc.get_local_x() <= 168 and pc.get_local_y() <= 168 then --arena 4
  74. pvp_manager.guard_reset()
  75. end
  76. end
  77.  
  78. function guard_reset()
  79. notice_in_map("AUTOPVP-GUARD: "..pc.getname().." a fost dat afarã din arenã.")
  80. pc.warp_local(pc.get_map_index(), 126*100, 24*100)
  81. end
  82.  
  83. when 20378.chat."Închide Arena Dojang." with pc.is_gm() and pc.get_map_index() == 115 begin
  84. say_title("Dojang:")
  85. say("Intrarea în arena Dojand este închisã acum")
  86. say("Cu toþii vor fi teleportaþi în oraº...")
  87. say("")
  88. warp_all_to_village( pc.get_map_index() , 1 )
  89. game.set_event_flag("budokan_open", 0)
  90. end
  91.  
  92. when 20378.chat."Înapoi în oraº." with pc.get_map_index() == 115 begin
  93. say_title("Vesemir:")
  94. say("")
  95. say("Doreºti sã te întorci înapoi în oraº?")
  96. say("")
  97. local s = select("Da", "Nu")
  98. if s == 1 then
  99. warp_to_village()
  100. end
  101. end
  102.  
  103. when 20378.chat."GM: Anuleazã Turneul PvP" with pc.get_map_index() == 115 and pc.is_gm() and game.get_event_flag("pvp") != 0 begin
  104. say_title("Anuleazã Turneul PvP")
  105. say("Chiar doreºti sã opreºti turneul PvP?")
  106. say("")
  107. local s = select("Da", "Nu")
  108. if s == 1 then
  109. game.set_event_flag("pvp", 0)
  110. pvp_attenders = nil
  111. notice_all("Turneul PvP a fost anulat.")
  112. say_title("Turneu PvP anulat.")
  113. say("Turneul PvP a fost anulat.")
  114. say("")
  115. end
  116. end
  117.  
  118. when 20378.chat."GM: Porneºte Turneul PvP" with pc.get_map_index() == 115 and pc.is_gm() and game.get_event_flag("pvp") == 0 begin
  119. say_title("Porneºte Turneul PvP")
  120. say("Te rugãm sã setezi nivelele limitã pentru")
  121. say("Turneul PvP.")
  122. say("")
  123. say_reward("Nivel minim (minim 15):")
  124. local str_min_level = input()
  125. say_title("Începe Turneul PvP")
  126. local min_level = tonumber(str_min_level)
  127. if min_level == nil then
  128. say("Nu a fost introdus nici un numãr.")
  129. say("")
  130. return
  131. end
  132. if tonumber(str_min_level) < 15 then
  133. min_level = 15
  134. end
  135. say("Nivelul minim a fost setat la: "..tostring(min_level)..".")
  136. say("Te rugãm sã introduci nivelul maxim:")
  137. local str_max_level = input()
  138. say_title("Începe Turneul PvP")
  139. local max_level = tonumber(str_max_level)
  140. if max_level == nil then
  141. say("Nici un numãr nu a fost introdus.")
  142. say("")
  143. return
  144. end
  145. if tonumber(str_max_level) < min_level then
  146. say("Nivelul maxim trebuie sã fie mai mare decât")
  147. say("nivelul minim.")
  148. say("")
  149. return
  150. end
  151.  
  152. game.set_event_flag("pvp_minlevel", min_level)
  153. game.set_event_flag("pvp_maxlevel", max_level)
  154.  
  155. say("Nivelul minim a fost setat la "..tostring(min_level)..".")
  156. say("Nivelul maxim a fost setat la "..tostring(max_level)..".")
  157. say("")
  158. local s = select("Începe acum.", "Închide.")
  159. if s == 2 then
  160. return
  161. end
  162.  
  163. say_title("Începe Turneul PvP")
  164. say("Turneul PvP a început. Cei ce vor sã participe")
  165. say("se pot înscrie aici. Înscrierile pot fi")
  166. say("închise de aici..")
  167. say("")
  168. say_reward("Nivelele limitã curente: "..game.get_event_flag("pvp_minlevel").." - "..game.get_event_flag("pvp_maxlevel"))
  169. game.set_event_flag("pvp", 1)
  170. game.set_event_flag("budokan_open", 1)
  171. attender_count = 0
  172. game.set_event_flag("pvp_tournament", get_global_time())
  173. pvp_attenders = nil
  174. pvp_attenders = { }
  175.  
  176. arena = {
  177. -- arena 1
  178. {
  179. { 113, 100 },
  180. { 88, 100 },
  181. 0,
  182. "SLEEPING",
  183. 0,
  184. },
  185. -- arena 2
  186. {
  187. { 113, 152 },
  188. { 88, 152 },
  189. 0,
  190. "SLEEPING",
  191. 0,
  192. },
  193. -- arena 3
  194. {
  195. { 140, 152 },
  196. { 164, 152 },
  197. 0,
  198. "SLEEPING",
  199. 0,
  200. },
  201. -- arena 4
  202. {
  203. { 164, 100 },
  204. { 140, 100 },
  205. 0,
  206. "SLEEPING",
  207. 0,
  208. },
  209. }
  210.  
  211. notice_all("Înscrierile pentru turneul PvP au fost deschise. Echipeazã-te ºi vino în Arena Dojang.")
  212. notice_all("Nivelele limitã curente: "..game.get_event_flag("pvp_minlevel").." - "..game.get_event_flag("pvp_maxlevel"))
  213. end
  214. when 20378.chat."Înscrie-te în Turneul PvP" with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 1 begin
  215. say_title(mob_name(20378)..":")
  216. say("")
  217. if game.get_event_flag("pvp_tournament") == pc.getqf("pvp_tournament") then
  218. say("Eºti deja înscris în Turneul PvP.")
  219. say("")
  220. return
  221. end
  222. if pc.get_level() < 15 then
  223. say("Nivelul tãu este prea mic.")
  224. say("")
  225. return
  226. end
  227. if pc.get_level() < game.get_event_flag("pvp_minlevel") or pc.get_level() > game.get_event_flag("pvp_maxlevel") then
  228. say("Nivelul tãu trebuie sã fie între "..game.get_event_flag("pvp_minlevel").." ºi "..game.get_event_flag("pvp_maxlevel"))
  229. say("")
  230. return
  231. end
  232. ----"123456789012345678901234567890123456789012345678901234567890"|
  233.  
  234. say("Bun venit la Dojan. În acest turneu vei lupta")
  235. say("împotriva jucãtorilor de nivele similare cu al tãu")
  236. say("")
  237. say("Înfrânge fiecare inamic ºi intrã în istoria")
  238. say("Þinutului Mistic.")
  239. say("")
  240. say("Doreºti sã te înscrii în Turneul PvP?")
  241. say("")
  242. local s = select("Doresc sã particip", "N-am nici o ºansã ")
  243. say_title(mob_name(20378)..":")
  244. say("")
  245. if s == 1 then
  246. say("Vei fi chemat atunci când va veni rândul tãu, dar")
  247. say("trebuie sã stai aici, altfel vei fi descalificat.")
  248. say("")
  249. say("Mult succes !")
  250. say("")
  251.  
  252. pvp_attenders[attender_count+1] = {name = pc.getname(), level = pc.get_level(), partner = nil, winner = true, fight_mode = 0, arena = 0}
  253. pc.setqf("attender_id", attender_count+1)
  254. pc.setqf("pvp_tournament", game.get_event_flag("pvp_tournament"))
  255. attender_count = attender_count + 1
  256. elseif s == 2 then
  257. say("Întradevãr, pari foarte slab..")
  258. say("Unii ºi-au pierdut viaþa în acest turneu.")
  259. say("")
  260. end
  261. end
  262. when 20378.chat."Înscrierile pentru Turneul PvP" with pc.get_map_index() == 115 and pc.is_gm() and game.get_event_flag("pvp") == 1 begin
  263. say_title("Turneul PvP")
  264. say("Momentan sunt înscriºi "..tostring(attender_count).." de jucãtori.")
  265. say("Ar trebui închise înscrierile ºi pornite")
  266. say("pariurile?")
  267. say("")
  268. local s = select("Închide înscrierile", "Continuã cu înscrierile")
  269. if s == 1 then
  270. say_title("Închide înscrierile:")
  271. say("Înscrierile au fost închise.")
  272. say("Jucãtorii pot paria acum.")
  273. say("")
  274. game.set_event_flag("pvp", 2)
  275. betting_list = {}
  276. betting_state = {}
  277. end
  278. end
  279.  
  280. when 20378.chat."Pariazã pentru Turneul PvP" with pc.get_map_index() == 115 and pc.is_gm() and game.get_event_flag("pvp") == 2 begin
  281. say_title("Turneul PvP")
  282. say("Ar trebui oprite pariurile ºi pornit Turneul PvP?")
  283. say("")
  284. local s = select("Porneºte Turneul PvP acum", "Continuã cu pariurile")
  285. if s == 1 then
  286. say_title("Opreºte Pariurile:")
  287. say("Timpul pentru pariuri s-a terminat.")
  288. say("Duelele vor începe acum.")
  289. say("")
  290. game.set_event_flag("pvp", 3)
  291. pvp_manager.make_duel_list()
  292. duel_list_index = 0
  293. playerless_mode = false
  294. notice_all("Înscrierile pentru Turneul PvP au fost închise. Duelele vor începe acum !")
  295. pvp_round_num = 1
  296. pvp_manager.refresh_arenas()
  297. end
  298. end
  299.  
  300. when 20378.chat."Plaseazã un Pariu" with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 2 and betting_state != nil and betting_state[pc.get_player_id()] == nil begin
  301. say_title("Plaseazã un Pariu:")
  302. say("Pe ce jucãtor doreºti sã pariezi?")
  303. say("")
  304. local player = input()
  305. say_title("Plaseazã un Pariu:")
  306. say("")
  307. if pvp_manager.get_attender_id_by_name(player) == 0 then
  308. say("Acest jucãtor nu este înscris.")
  309. say("")
  310. return
  311. end
  312. say("Câþi bani doreºti sã pariezi?")
  313. say("")
  314. local bet_amount = tonumber(input())
  315. if bet_amount < 1 then
  316. say_title("Eroare:")
  317. say("Aceasta nu este o valoare validã.")
  318. say("")
  319. return
  320. end
  321. say_title("Confirmã:")
  322. say("Doreºti sã pariezi "..bet_amount.." Yang pe")
  323. say(player.."?")
  324. say("")
  325. if select("Da", "Nu") == 2 then
  326. return
  327. end
  328.  
  329. if pc.gold < bet_amount then
  330. say_title("Eroare:")
  331. say("Nu ai destui bani.")
  332. say("")
  333. return
  334. end
  335.  
  336. betting_state[pc.get_player_id()] = 1
  337. table.insert(betting_list, {pc.get_name(), bet_amount, player})
  338. pc.change_gold(-bet_amount)
  339.  
  340. say_title("Plaseazã un Pariu:")
  341. say("Pariul a fost plasat.")
  342. say("Mulþumim ºi mult succes !")
  343. say("")
  344. end
  345.  
  346. when 20378.chat."Cine participã?" with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 2 begin
  347. setskin(NOWINDOW)
  348. chat("Urmãtoarele persoane participã în Turneul PvP:")
  349. for i = 1, attender_count, 4 do
  350. local chatline = ""
  351. for j = i, i + 4, 1 do
  352. if pvp_attenders[j] != nil then
  353. chatline = chatline..pvp_attenders[j].name.." "
  354. end
  355. end
  356. syschat(chatline)
  357. end
  358. syschat("Total "..attender_count.." participanþi")
  359. end
  360.  
  361. when 20378.chat."Cu cine voi lupta în continuare?" with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 3 and game.get_event_flag("pvp_tournament") == pc.getqf("pvp_tournament") begin
  362. say_title(mob_name(20378)..":")
  363. say("")
  364. if pvp_manager.get_duel_partner() == nil then
  365. say("Nu existã nici un oponent disponibil momentan.")
  366. say("")
  367. say("Dacã nu gãsim pe nimeni disponibil vei merge în")
  368. say("urmãtoarea rundã în mod automat.")
  369. say("")
  370. return
  371. end
  372. say("Conform planului curent te vei duela cu:")
  373. say("")
  374. say_reward(""..pvp_manager.get_duel_partner().."")
  375. say("")
  376. end
  377.  
  378.  
  379. function make_duel_list()
  380. duel_list = { }
  381. local i = 0
  382. for ai = 1, attender_count, 1 do
  383. if pvp_attenders[ai] != nil and pvp_attenders[ai].partner == nil and pvp_attenders[ai].winner == true then
  384. local partner_id = pvp_manager.findpartner(tostring(pvp_attenders[ai].name), pvp_attenders[ai].level)
  385. if partner_id != nil then
  386. pvp_attenders[ai].partner = tostring(pvp_attenders[partner_id].name)
  387. pvp_attenders[partner_id].partner = tostring(pvp_attenders[ai].name)
  388. duel_list[i] = {fighter_id1 = ai, fighter_id2 = partner_id}
  389. i = i + 1
  390. end
  391. end
  392. end
  393.  
  394. for ai = 1, attender_count, 1 do
  395. if pvp_attenders[ai] != nil and pvp_attenders[ai].partner == nil and pvp_attenders[ai].winner == true then
  396. local partner_id = pvp_manager.findpartner_for_partnerless(tostring(pvp_attenders[ai].name), pvp_attenders[ai].level)
  397. if partner_id != nil then
  398. pvp_attenders[ai].partner = tostring(pvp_attenders[partner_id].name)
  399. pvp_attenders[partner_id].partner = tostring(pvp_attenders[ai].name)
  400. duel_list[i] = {fighter_id1 = ai, fighter_id2 = partner_id}
  401. i = i + 1
  402. end
  403. end
  404. end
  405. end
  406.  
  407.  
  408. function findpartner(name, level)
  409. local closest_level = nil
  410. local partner_id = nil
  411. for ai = 1, attender_count, 1 do
  412. if pvp_attenders[ai] != nil and pvp_attenders[ai].winner == true and tonumber(pvp_attenders[ai].level) <= level + 30 and tonumber(pvp_attenders[ai].level) >= level - 30 and tostring(pvp_attenders[ai].name) != name and pvp_attenders[ai].partner == nil and pvp_manager.is_player_in_map(tostring(pvp_attenders[ai].name)) == true then
  413. if closest_level == nil then
  414. closest_level = pvp_attenders[ai].level
  415. partner_id = ai
  416. elseif tonumber(pvp_attenders[ai].level) == tonumber(level) then
  417. closest_level = pvp_attenders[ai].level
  418. partner_id = ai
  419. elseif tonumber(level) < tonumber(closest_level) and tonumber(pvp_attenders[ai].level) < tonumber(closest_level) then
  420. closest_level = pvp_attenders[ai].level
  421. partner_id = ai
  422. elseif tonumber(level) > tonumber(closest_level) and tonumber(pvp_attenders[ai].level) > tonumber(closest_level) then
  423. closest_level = pvp_attenders[ai].level
  424. partner_id = ai
  425. end
  426. end
  427. end
  428. return tonumber(partner_id)
  429. end
  430.  
  431. function findpartner_for_partnerless(name, level)
  432. local closest_level = nil
  433. local partner_id = nil
  434. for ai = 1, attender_count, 1 do
  435. if pvp_attenders[ai] != nil and pvp_attenders[ai].winner == true and tostring(pvp_attenders[ai].name) != name and pvp_attenders[ai].partner == nil and pvp_manager.is_player_in_map(tostring(pvp_attenders[ai].name)) == true then
  436. if closest_level == nil then
  437. closest_level = pvp_attenders[ai].level
  438. partner_id = ai
  439. elseif pvp_attenders[ai].level == level then
  440. closest_level = pvp_attenders[ai].level
  441. partner_id = ai
  442. elseif tonumber(level) < tonumber(closest_level) and pvp_attenders[ai].level < closest_level then
  443. closest_level = pvp_attenders[ai].level
  444. partner_id = ai
  445. elseif tonumber(level) > tonumber(closest_level) and pvp_attenders[ai].level > closest_level then
  446. closest_level = pvp_attenders[ai].level
  447. partner_id = ai
  448. end
  449. end
  450. end
  451. return partner_id
  452. end
  453.  
  454. function is_player_in_map(name)
  455. if pc.getname() == name then
  456. return true
  457. end
  458. local myname = pc.getname()
  459. local target = find_pc_by_name(name)
  460. local t = pc.select(target)
  461. if pc.getname() == myname then
  462. pc.select(t)
  463. return false
  464. end
  465. pc.select(t)
  466. return true
  467. end
  468.  
  469.  
  470. when 20378.chat."GM: Actualizeazã ºi Curãþã Arena" with pc.is_gm() and game.get_event_flag("pvp") == 3 begin
  471. for aArena = 1, 4, 1 do
  472. arena[aArena][3] = 0
  473. arena[aArena][4] = "SLEEPING"
  474. end
  475. pvp_manager.refresh_arenas()
  476. end
  477.  
  478. -- not working
  479. --[[
  480. when 20378.chat."GM: Opreºte Lupta" with pc.is_gm() and game.get_event_flag("pvp") == 2 begin
  481. say_title("Opreºte Lupta:")
  482. say("În care arenã ar trebui sfârºitã lupta?")
  483. local s = select("Arena 1", "Arena 2", "Arena 3", "Arena 4", "Închide")
  484.  
  485. if s == 5 then
  486. return
  487. end
  488.  
  489. local fighter1 = nil
  490. local fighter2 = nil
  491. for ai = 1, attender_count, 1 do
  492. if pvp_attenders[ai].arena == s and pvp_attenders[ai].fight_mode != 0 then
  493. if fighter1 == nil then
  494. fighter1 = ai
  495. else
  496. fighter2 = ai
  497. end
  498. end
  499. end
  500.  
  501. if fighter1 == nil then
  502. say_title("Sfârºeºte lupta:")
  503. say("Nu existã nici un duel în arena respectivã în")
  504. say("acest moment.")
  505. say("")
  506. return
  507. end
  508.  
  509. say_title("Sfârºeºte Lupta:")
  510. say("Cine ar trebui considerat câºtigãtor când lupta în arena "..s.." ")
  511. say("va fi încheiatã?")
  512. local w = select(tostring(pvp_attenders[fighter1].name), tostring(pvp_attenders[fighter1].name), "Închide")
  513. if w == 3 then
  514. return
  515. end
  516.  
  517. if w == 1 then
  518. pvp_attenders[fighter2].winner = false
  519. notice_in_map(tostring(pvp_attenders[fighter1].name).." has won the battle against "..tostring(pvp_attenders[fighter2].name).."!", pc.get_map_index())
  520. pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter1].name, 126, 234))
  521. pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter2].name, 126, 24))
  522. else
  523. pvp_attenders[fighter1].winner = false
  524. notice_in_map(tostring(pvp_attenders[fighter2].name).." has won the battle against "..tostring(pvp_attenders[fighter1].name).."!", pc.get_map_index())
  525. pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter1].name, 126, 24))
  526. pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter2].name, 126, 234))
  527. end
  528.  
  529. pvp_attenders[fighter1].fight_mode = 0
  530. pvp_attenders[fighter2].fight_mode = 0
  531.  
  532.  
  533. arena[s][3] = 0
  534. pvp_manager.refresh_arenas()
  535.  
  536. say_title("Sfârºeºte duelul:")
  537. say("Duelul a luat sfârþit.")
  538. end
  539. --]]
  540.  
  541. when 20378.chat."GM: Recompensã Turneu PvP" with pc.is_gm() begin
  542. say_title("Recompensã:")
  543. say("Recompensã curentã: "..game.get_event_flag("pvp_price_count").."x "..item_name(game.get_event_flag("pvp_price_vnum")).." (vnum: "..game.get_event_flag("pvp_price_vnum")..")")
  544. say("")
  545. local s = select("Schimbã recompensa", "Închide")
  546. if s == 2 then
  547. return
  548. end
  549. say_title("Schimbã Recompensa:")
  550. say("Te rog introdu codul noii recompense:")
  551. say("")
  552. local vnum = input()
  553. say_title("Schimbã recompensa:")
  554. say("Te rog introdu cantitatea noii recompense:")
  555. say("")
  556. local count = input()
  557. game.set_event_flag("pvp_price_count", count)
  558. game.set_event_flag("pvp_price_vnum", vnum)
  559. say_title("Schimbã Recompensa:")
  560. say("Recompensa a fost schimbatã.")
  561. say("Noua recompensã: "..count.."x "..item_name(vnum).." (vnum: "..vnum..")")
  562. say("")
  563. end
  564.  
  565. when 20378.chat."GM: Yang/Rundã Turneu PvP" with pc.is_gm() begin
  566. say_title("Recompensã-Yang-Rundã:")
  567. say("Suma curentã: "..game.get_event_flag("pvp_round_gold"))
  568. say("")
  569. local s = select("Schimbã ", "Închide")
  570. if s == 2 then
  571. return
  572. end
  573. say_title("Schimbã Suma:")
  574. say("Te rugãm sã introduci suma de yang primitã pentru")
  575. say("câºtigãtorul unei runde:")
  576. say("")
  577. local gold = input()
  578. game.set_event_flag("pvp_round_gold", gold)
  579. say_title("Schimbã Suma:")
  580. say("Yang-ul primit a fost schimbat.")
  581. say("Yang actual pe rundã: "..gold)
  582. say("")
  583. end
  584.  
  585. function refresh_arenas()
  586. for aArena = 1, 4, 1 do
  587. if duel_list[duel_list_index] == nil then
  588. if playerless_mode == true then
  589. pvp_manager.init_next_round()
  590. else
  591. pvp_manager.fight_playerless()
  592. end
  593. return
  594. end
  595. if arena[aArena][3] == 0 then
  596. arena[aArena][3] = 1
  597. pvp_manager.fight_init(duel_list[duel_list_index].fighter_id1, duel_list[duel_list_index].fighter_id2, aArena)
  598. end
  599. end
  600. end
  601.  
  602.  
  603. function fight_init(pid1, pid2, arena_id)
  604. duel_list_index = duel_list_index + 1
  605. if pvp_manager.is_player_in_map(tostring(pvp_attenders[pid1].name)) == false then
  606. notice_in_map(tostring(pvp_attenders[pid1].name).." nu este online, prin urmare va fi descalificat/ã.", pc.get_map_index())
  607. pvp_attenders[pid1].winner = false
  608. pvp_attenders[pid2].partner = nil
  609. arena[arena_id][3] = 0
  610. pvp_manager.refresh_arenas()
  611. return
  612. end
  613. if pvp_manager.is_player_in_map(tostring(pvp_attenders[pid2].name)) == false then
  614. notice_in_map(tostring(pvp_attenders[pid2].name).." nu este online, prin urmare va fi descalificat/ã.", pc.get_map_index())
  615. pvp_attenders[pid2].winner = false
  616. pvp_attenders[pid1].partner = nil
  617. arena[arena_id][3] = 0
  618. pvp_manager.refresh_arenas()
  619. return
  620. end
  621.  
  622. notice_in_map(tostring(pvp_attenders[pid1].name).." ºi "..tostring(pvp_attenders[pid2].name).." vã rugãm sã intraþi în ring!", pc.get_map_index())
  623.  
  624. --[[
  625. local f1_accept = ask_fight(tostring(pvp_attenders[pid1].name), tostring(pvp_attenders[pid2].name))
  626. if f1_accept != CONFIRM_OK then
  627. notice_in_map(tostring(pvp_attenders[pid1].name).." nu a acceptat duelul împotriva lui "..tostring(pvp_attenders[pid2].name)..".", pc.get_map_index())
  628. pvp_attenders[pid1] = nil
  629. pvp_attenders[pid2].partner = nil
  630. pvp_manager.refresh_arenas()
  631. return
  632. end
  633.  
  634. local f2_accept = confirm(find_pc_by_name(tostring(pvp_attenders[pid2].name)), "Vei lupta împotriva lui "..tostring(pvp_attenders[pid1].name).. " ?", 15)
  635. if f2_accept != CONFIRM_OK then
  636. notice_in_map(tostring(pvp_attenders[pid2].name).." nu a acceptat duelul împotriva lui "..tostring(pvp_attenders[pid1].name)..".", pc.get_map_index())
  637. pvp_attenders[pid2] = nil
  638. pvp_attenders[pid1].partner = nil
  639. pvp_manager.refresh_arenas()
  640. return
  641. end
  642. ]]
  643.  
  644. pvp_attenders[pid1].fight_mode = 1
  645. pvp_attenders[pid2].fight_mode = 1
  646. pvp_attenders[pid1].arena = arena_id
  647. pvp_attenders[pid2].arena = arena_id
  648.  
  649. pvp_manager.local_pc_warp(tostring(pvp_attenders[pid1].name), arena[arena_id][1][1], arena[arena_id][1][2])
  650. pvp_manager.local_pc_warp(tostring(pvp_attenders[pid2].name), arena[arena_id][2][1], arena[arena_id][2][2])
  651.  
  652. end
  653.  
  654. when login with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 3 and pvp_manager.get_fight_mode() == 1 begin
  655. affect.add(apply.MOV_SPEED, -10000, 2)
  656. affect.add_collect(apply.HP_REGEN, 5000, 30)
  657. affect.add_collect(apply.SP_REGEN, 5000, 30)
  658. pvp_manager.set_fight_mode(2)
  659. if arena[pvp_manager.get_arena()][3] == 2 then
  660. arena[pvp_manager.get_arena()][5] = 30
  661. loop_timer("fight_start_countdown", 1)
  662. else
  663. timer("partner_timeout", 60)
  664. end
  665. arena[pvp_manager.get_arena()][3] = 2
  666. end
  667.  
  668. when partner_timeout.timer begin
  669. if pvp_manager.is_player_in_map(pvp_manager.get_duel_partner()) == true or game.get_event_flag("pvp") != 2 or pvp_manager.get_fight_mode() != 2 then
  670. return
  671. end
  672. pvp_manager.set_fight_mode(3)
  673. if arena[pvp_manager.get_arena()][3] == 3 then
  674. return
  675. end
  676. arena[pvp_manager.get_arena()][3] = 3
  677. notice_in_map(pc.getname().." a câºtigat împotriva lui "..pvp_manager.get_duel_partner().." prin abandon !", pc.get_map_index())
  678. pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].fight_mode = 3
  679. pvp_attenders[pvp_manager.get_my_attender_id()].winner = true
  680. pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].winner = false
  681. pc.warp_local(pc.get_map_index(), 12600, 23400)
  682. end
  683.  
  684. when fight_start_countdown.timer begin
  685. if arena[pvp_manager.get_arena()][5] == -1 then
  686. return
  687. end
  688. local partner_vid = find_pc_by_name(pvp_manager.get_duel_partner())
  689. local my_vid = pc.get_vid()
  690. if arena[pvp_manager.get_arena()][5] == 0 then
  691. arena[pvp_manager.get_arena()][5] = -1
  692. pc.select(partner_vid)
  693. command("pvp "..my_vid)
  694. pc.select(my_vid)
  695. command("pvp "..partner_vid)
  696. notice_in_map("Duelul dintre "..pvp_manager.get_duel_partner().." ºi "..pc.get_name().." începe !", pc.get_map_index())
  697. timer("fight_start_countdown_shutdown", 1)
  698. else
  699. pc.select(partner_vid)
  700. if math.mod(arena[pvp_manager.get_arena()][5], 5) == 0 then
  701. syschat("Duelul începe în "..tostring(arena[pvp_manager.get_arena()][5]).." secunde.")
  702. end
  703. affect.add(apply.MOV_SPEED, -10000, 2)
  704. pc.select(my_vid)
  705. if math.mod(arena[pvp_manager.get_arena()][5], 5) == 0 then
  706. syschat("Duelul începe în "..tostring(arena[pvp_manager.get_arena()][5]).." secunde.")
  707. end
  708. affect.add(apply.MOV_SPEED, -10000, 2)
  709. arena[pvp_manager.get_arena()][5] = arena[pvp_manager.get_arena()][5] - 1
  710. end
  711. end
  712.  
  713. when fight_start_countdown_shutdown.timer begin
  714. cleartimer("fight_start_countdown")
  715. end
  716.  
  717. when logout with game.get_event_flag("pvp") == 3 and pc.get_map_index() == 115 and pvp_manager.get_fight_mode() == 2 begin
  718. pvp_manager.set_fight_mode(3)
  719. arena[pvp_manager.get_arena()][3] = 3
  720. notice_in_map(pvp_manager.get_duel_partner().." a câºtigat împotriva lui "..pc.getname().."!", pc.get_map_index())
  721. pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].fight_mode = 3
  722. pvp_attenders[pvp_manager.get_my_attender_id()].winner = false
  723. pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].winner = true
  724.  
  725. local target = find_pc_by_name(pvp_manager.get_duel_partner())
  726. local t = pc.select(target)
  727. pc.change_gold(game.get_event_flag("pvp_round_gold")*pvp_round_num)
  728. pc.select(t)
  729.  
  730. pvp_manager.local_pc_warp(pvp_manager.get_duel_partner(), 126, 24)
  731. end
  732.  
  733. when kill with game.get_event_flag("pvp") == 3 and pc.get_map_index() == 115 and npc.is_pc() and pvp_manager.get_fight_mode() == 2 begin
  734. pvp_manager.set_fight_mode(3)
  735. if arena[pvp_manager.get_arena()][3] == 3 then
  736. return
  737. end
  738. arena[pvp_manager.get_arena()][3] = 3
  739. notice_in_map(pc.getname().." a câºtigat împotriva lui "..pvp_manager.get_duel_partner().."!", pc.get_map_index())
  740. pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].fight_mode = 3
  741. pvp_attenders[pvp_manager.get_my_attender_id()].winner = true
  742. pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].winner = false
  743.  
  744. pc.change_gold(game.get_event_flag("pvp_round_gold")*pvp_round_num)
  745.  
  746. timer("fight_end", 5)
  747. end
  748.  
  749. when fight_end.timer begin
  750. pc.warp_local(pc.get_map_index(), 12600, 23400)
  751. pvp_manager.local_pc_warp(pvp_manager.get_duel_partner(), 126, 24)
  752. end
  753.  
  754. when letter with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 3 and pvp_manager.get_fight_mode() == 3 begin
  755. pvp_manager.set_fight_mode(0)
  756.  
  757. if pvp_attenders[pvp_manager.get_my_attender_id()].winner == true then
  758. arena[pvp_manager.get_arena()][3] = 0
  759. pvp_manager.refresh_arenas()
  760. end
  761. end
  762.  
  763. when login with pc.get_map_index() == 115 or pc.get_map_index() == 114 or pc.get_map_index() == 121 or pc.get_map_index() == 125 or pc.get_map_index() == 110 or pc.get_map_index() == 111 begin
  764. loop_timer("horse_block",1)
  765. end
  766.  
  767. when horse_block.timer begin
  768.  
  769. if horse.is_riding() then
  770.  
  771. pc.unmount()
  772. horse.unsummon()
  773. syschat("Nu poþi folosi calul aici !")
  774.  
  775. end
  776. end
  777.  
  778. function fight_playerless()
  779. for aArena = 1, 4, 1 do
  780. if arena[aArena][3] != 0 then
  781. return
  782. end
  783. end
  784. playerless_mode = true
  785.  
  786.  
  787. pvp_manager.make_duel_list()
  788. pvp_manager.refresh_arenas()
  789. end
  790.  
  791. function init_next_round()
  792. for aArena = 1, 4, 1 do
  793. if arena[aArena][3] != 0 then
  794. return
  795. end
  796. end
  797. playerless_mode = false
  798.  
  799. local winner_count = 0
  800. local winner_id = 0
  801. for ai = 1, attender_count, 1 do
  802. pvp_attenders[ai].partner = nil
  803. pvp_attenders[ai].fight_mode = 0
  804. if pvp_attenders[ai] != nil and pvp_attenders[ai].winner == true then
  805. winner_count = winner_count + 1
  806. winner_id = ai
  807. end
  808. end
  809.  
  810. if winner_count == 1 then
  811. notice_all(pvp_attenders[winner_id].name.." a câºtigat Turneul PvP ! Avem o nouã legendã în Þinutul Mistic !")
  812. notice_all(pvp_attenders[winner_id].name.." primeºte "..game.get_event_flag("pvp_price_count").."x "..item_name(game.get_event_flag("pvp_price_vnum")).." ca ºi recompensã !")
  813.  
  814. pvp_manager.distribute_bets(pvp_attenders[winner_id].name)
  815.  
  816. local target = find_pc_by_name(pvp_attenders[winner_id].name)
  817. local t = pc.select(target)
  818. pc.give_item2(game.get_event_flag("pvp_price_vnum"), game.get_event_flag("pvp_price_count"))
  819. pc.select(t)
  820. notice_all("Turneul PvP a luat sfârºit. Vã aºteptãm la urmãtorul Turneu !")
  821. game.set_event_flag("pvp", 0)
  822. pvp_attenders = nil
  823. return
  824. end
  825.  
  826.  
  827. pvp_manager.make_duel_list()
  828. duel_list_index = 0
  829. if winner_count == 2 then
  830. notice_all("Runda finalã a Turnelului PvP începe acum !")
  831. elseif winner_count <= 4 then
  832. notice_all("Runda semi-finalã a Turnelului PvP începe acum !")
  833. else
  834. notice_all("Urmãtoarea rundã a Turneului PvP începe acum !")
  835. end
  836. pvp_round_num = pvp_round_num + 1
  837. pvp_manager.refresh_arenas()
  838. end
  839.  
  840. function distribute_bets(winner_name)
  841. --table.insert(betting_list, {pc.get_name(), bet_amount, player})
  842. local jackpot = 0
  843. local jackpot_winner_only = 0
  844. local winners = 0
  845. for i = 1, table.getn(betting_list), 1 do
  846. if betting_list[i][3] == winner_name then
  847. jackpot_winner_only = jackpot_winner_only + betting_list[i][2]
  848. end
  849. jackpot = jackpot + betting_list[i][2]
  850. winners = winners + 1
  851. end
  852.  
  853. for i = 1, table.getn(betting_list), 1 do
  854. if betting_list[i][3] == winner_name then
  855. pvp_manager.give_jackpot_gold(betting_list[i][1], math.ceil( (betting_list[i][2] / jackpot_winner_only)*jackpot ))
  856. end
  857. end
  858.  
  859. end
  860.  
  861. function give_jackpot_gold(name, amount)
  862. local target = find_pc_by_name(name)
  863. if target == 0 then
  864. return
  865. end
  866. local t = pc.select(target)
  867. pc.change_money(amount)
  868. pc.select(t)
  869. end
  870.  
  871. function local_pc_warp(name, x, y)
  872. local target = find_pc_by_name(name)
  873. local t = pc.select(target)
  874. pc.warp_local(pc.get_map_index(), x*100, y*100)
  875. pc.select(t)
  876. end
  877.  
  878. function setqf_by_name(name, flag, value)
  879. local target = find_pc_by_name(name)
  880. local t = pc.select(target)
  881. pc.setqf(flag, value)
  882. pc.select(t)
  883. end
  884.  
  885. function getqf_by_name(name, flag)
  886. local target = find_pc_by_name(name)
  887. local t = pc.select(target)
  888. local rflag = pc.getqf(flag)
  889. pc.select(t)
  890. return rflag
  891. end
  892.  
  893. function get_attender_id_by_name(name)
  894. for ai = 1, attender_count, 1 do
  895. if tostring(pvp_attenders[ai].name) == name then
  896. return ai
  897. end
  898. end
  899. return 0
  900. end
  901.  
  902. function get_my_attender_id()
  903. return pvp_manager.get_attender_id_by_name(pc.get_name())
  904. end
  905.  
  906. function get_duel_partner()
  907. if pvp_attenders[pvp_manager.get_my_attender_id()] != nil and pvp_attenders[pvp_manager.get_my_attender_id()].partner != nil then
  908. return pvp_attenders[pvp_manager.get_my_attender_id()].partner
  909. else
  910. return nil
  911. end
  912. end
  913.  
  914. function get_fight_mode()
  915. if pvp_attenders != nil and pvp_manager.get_my_attender_id() != 0 and pvp_attenders[pvp_manager.get_my_attender_id()] != nil and pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode != nil then
  916. return pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode
  917. else
  918. return 0
  919. end
  920. end
  921.  
  922. function set_fight_mode(fmode)
  923. pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode = fmode
  924. end
  925.  
  926. function get_arena()
  927. return pvp_attenders[pvp_manager.get_my_attender_id()].arena
  928. end
  929.  
  930. function set_arena(id)
  931. pvp_attenders[pvp_manager.get_my_attender_id()].arena = id
  932. end
  933.  
  934. function ask_fight(asker, target)
  935. return confirm(find_pc_by_name(target), "Vei lupta împotriva lui "..asker.. "?", 15)
  936. end
  937. end
  938. end
Advertisement
Add Comment
Please, Sign In to add comment