Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- quest pvp_manager begin
- state start begin
- when login with game.get_event_flag("budokan_open") > 0 and pc.get_map_index() != 115 begin
- q.set_icon("scroll_open_blue.tga")
- send_letter("*Intră în arena Dojang")
- end
- when button or info begin
- say_title("Turneul PvP:")
- if game.get_event_flag("budokan_open") == 2 then
- say("Arena Dojang este acum deschisă !")
- say("")
- say("Alătură-te pentru pariuri sau participă în duelele")
- say("competitive cu alţi jucători pentru a obţine")
- say("glorie şi bani.")
- say("")
- local s = select("Du-mă acolo acum.","Nu, mulţumesc.")
- if s == 1 then
- pc.warp(844800,0)
- end
- else
- say("Arena Dojang se va deschide în scurt timp.")
- say("")
- say("Alătură-te pentru pariuri sau participă în duelele")
- say("competitive cu alţi jucători pentru a obţine")
- say("glorie şi bani.")
- say("")
- say("Când intrarea este permisă te poţi duce acolo")
- say("prin acest quest. Pregăteşte-ţi armele !")
- say("")
- end
- end
- 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
- if pvp_attenders == nil then
- pvp_manager.guard_check_position()
- timer("pvp_guard_1", 20)
- return
- end
- if pvp_attenders[pvp_manager.get_my_attender_id()] == nil then
- pvp_manager.guard_check_position()
- timer("pvp_guard_1", 20)
- return
- end
- 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
- pvp_manager.guard_check_position()
- timer("pvp_guard_1", 20)
- end
- end
- when pvp_guard_1.timer begin
- if pc.get_map_index() != 115 then
- return
- end
- pvp_manager.guard_check_position()
- timer("pvp_guard_2", 20)
- end
- when pvp_guard_2.timer begin
- if pc.get_map_index() != 115 then
- return
- end
- pvp_manager.guard_check_position()
- timer("pvp_guard_1", 20)
- end
- function guard_check_position()
- 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
- pvp_manager.guard_reset()
- end
- 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
- pvp_manager.guard_reset()
- end
- 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
- pvp_manager.guard_reset()
- end
- 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
- pvp_manager.guard_reset()
- end
- end
- function guard_reset()
- notice_in_map("AUTOPVP-GUARD: "..pc.getname().." a fost dat afară din arenă.")
- pc.warp_local(pc.get_map_index(), 126*100, 24*100)
- end
- when 20378.chat."Închide Arena Dojang." with pc.is_gm() and pc.get_map_index() == 115 begin
- say_title("Dojang:")
- say("Intrarea în arena Dojand este închisă acum")
- say("Cu toţii vor fi teleportaţi în oraş...")
- say("")
- warp_all_to_village( pc.get_map_index() , 1 )
- game.set_event_flag("budokan_open", 0)
- end
- when 20378.chat."Înapoi în oraş." with pc.get_map_index() == 115 begin
- say_title("Vesemir:")
- say("")
- say("Doreşti să te întorci înapoi în oraş?")
- say("")
- local s = select("Da", "Nu")
- if s == 1 then
- warp_to_village()
- end
- end
- 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
- say_title("Anulează Turneul PvP")
- say("Chiar doreşti să opreşti turneul PvP?")
- say("")
- local s = select("Da", "Nu")
- if s == 1 then
- game.set_event_flag("pvp", 0)
- pvp_attenders = nil
- notice_all("Turneul PvP a fost anulat.")
- say_title("Turneu PvP anulat.")
- say("Turneul PvP a fost anulat.")
- say("")
- end
- end
- 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
- say_title("Porneşte Turneul PvP")
- say("Te rugăm să setezi nivelele limită pentru")
- say("Turneul PvP.")
- say("")
- say_reward("Nivel minim (minim 15):")
- local str_min_level = input()
- say_title("Începe Turneul PvP")
- local min_level = tonumber(str_min_level)
- if min_level == nil then
- say("Nu a fost introdus nici un număr.")
- say("")
- return
- end
- if tonumber(str_min_level) < 15 then
- min_level = 15
- end
- say("Nivelul minim a fost setat la: "..tostring(min_level)..".")
- say("Te rugăm să introduci nivelul maxim:")
- local str_max_level = input()
- say_title("Începe Turneul PvP")
- local max_level = tonumber(str_max_level)
- if max_level == nil then
- say("Nici un număr nu a fost introdus.")
- say("")
- return
- end
- if tonumber(str_max_level) < min_level then
- say("Nivelul maxim trebuie să fie mai mare decât")
- say("nivelul minim.")
- say("")
- return
- end
- game.set_event_flag("pvp_minlevel", min_level)
- game.set_event_flag("pvp_maxlevel", max_level)
- say("Nivelul minim a fost setat la "..tostring(min_level)..".")
- say("Nivelul maxim a fost setat la "..tostring(max_level)..".")
- say("")
- local s = select("Începe acum.", "Închide.")
- if s == 2 then
- return
- end
- say_title("Începe Turneul PvP")
- say("Turneul PvP a început. Cei ce vor să participe")
- say("se pot înscrie aici. Înscrierile pot fi")
- say("închise de aici..")
- say("")
- say_reward("Nivelele limită curente: "..game.get_event_flag("pvp_minlevel").." - "..game.get_event_flag("pvp_maxlevel"))
- game.set_event_flag("pvp", 1)
- attender_count = 0
- game.set_event_flag("pvp_tournament", get_global_time())
- pvp_attenders = nil
- pvp_attenders = { }
- arena = {
- -- arena 1
- {
- { 113, 100 },
- { 88, 100 },
- 0,
- "SLEEPING",
- 0,
- },
- -- arena 2
- {
- { 113, 152 },
- { 88, 152 },
- 0,
- "SLEEPING",
- 0,
- },
- -- arena 3
- {
- { 140, 152 },
- { 164, 152 },
- 0,
- "SLEEPING",
- 0,
- },
- -- arena 4
- {
- { 164, 100 },
- { 140, 100 },
- 0,
- "SLEEPING",
- 0,
- },
- }
- notice_all("Înscrierile pentru turneul PvP au fost deschise. Echipează-te şi vino în Arena Dojang.")
- notice_all("Nivelele limită curente: "..game.get_event_flag("pvp_minlevel").." - "..game.get_event_flag("pvp_maxlevel"))
- end
- when 20378.chat."Înscrie-te în Turneul PvP" with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 1 begin
- say_title(mob_name(20378)..":")
- say("")
- if game.get_event_flag("pvp_tournament") == pc.getqf("pvp_tournament") then
- say("Eşti deja înscris în Turneul PvP.")
- say("")
- return
- end
- if pc.get_level() < 15 then
- say("Nivelul tău este prea mic.")
- say("")
- return
- end
- if pc.get_level() < game.get_event_flag("pvp_minlevel") or pc.get_level() > game.get_event_flag("pvp_maxlevel") then
- say("Nivelul tău trebuie să fie între "..game.get_event_flag("pvp_minlevel").." şi "..game.get_event_flag("pvp_maxlevel"))
- say("")
- return
- end
- ----"123456789012345678901234567890123456789012345678901234567890"|
- say("Bun venit la Dojan. În acest turneu vei lupta")
- say("împotriva jucătorilor de nivele similare cu al tău")
- say("")
- say("Înfrânge fiecare inamic şi intră în istoria")
- say("Ţinutului Mistic.")
- say("")
- say("Doreşti să te înscrii în Turneul PvP?")
- say("")
- local s = select("Doresc să particip", "N-am nici o şansă ")
- say_title(mob_name(20378)..":")
- say("")
- if s == 1 then
- say("Vei fi chemat atunci când va veni rândul tău, dar")
- say("trebuie să stai aici, altfel vei fi descalificat.")
- say("")
- say("Mult succes !")
- say("")
- pvp_attenders[attender_count+1] = {name = pc.getname(), level = pc.get_level(), partner = nil, winner = true, fight_mode = 0, arena = 0}
- pc.setqf("attender_id", attender_count+1)
- pc.setqf("pvp_tournament", game.get_event_flag("pvp_tournament"))
- attender_count = attender_count + 1
- elseif s == 2 then
- say("Întradevăr, pari foarte slab..")
- say("Unii şi-au pierdut viaţa în acest turneu.")
- say("")
- end
- end
- 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
- say_title("Turneul PvP")
- say("Momentan sunt înscrişi "..tostring(attender_count).." de jucători.")
- say("Ar trebui închise înscrierile şi pornite")
- say("pariurile?")
- say("")
- local s = select("Închide înscrierile", "Continuă cu înscrierile")
- if s == 1 then
- say_title("Închide înscrierile:")
- say("Înscrierile au fost închise.")
- say("Jucătorii pot paria acum.")
- say("")
- game.set_event_flag("pvp", 2)
- betting_list = {}
- betting_state = {}
- end
- end
- 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
- say_title("Turneul PvP")
- say("Ar trebui oprite pariurile şi pornit Turneul PvP?")
- say("")
- local s = select("Porneşte Turneul PvP acum", "Continuă cu pariurile")
- if s == 1 then
- say_title("Opreşte Pariurile:")
- say("Timpul pentru pariuri s-a terminat.")
- say("Duelele vor începe acum.")
- say("")
- game.set_event_flag("pvp", 3)
- pvp_manager.make_duel_list()
- duel_list_index = 0
- playerless_mode = false
- notice_all("Înscrierile pentru Turneul PvP au fost închise. Duelele vor începe acum !")
- pvp_round_num = 1
- pvp_manager.refresh_arenas()
- end
- end
- 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
- say_title("Plasează un Pariu:")
- say("Pe ce jucător doreşti să pariezi?")
- say("")
- local player = input()
- say_title("Plasează un Pariu:")
- say("")
- if pvp_manager.get_attender_id_by_name(player) == 0 then
- say("Acest jucător nu este înscris.")
- say("")
- return
- end
- say("Câţi bani doreşti să pariezi?")
- say("")
- local bet_amount = tonumber(input())
- if bet_amount < 1 then
- say_title("Eroare:")
- say("Aceasta nu este o valoare validă.")
- say("")
- return
- end
- say_title("Confirmă:")
- say("Doreşti să pariezi "..bet_amount.." Yang pe")
- say(player.."?")
- say("")
- if select("Da", "Nu") == 2 then
- return
- end
- if pc.gold < bet_amount then
- say_title("Eroare:")
- say("Nu ai destui bani.")
- say("")
- return
- end
- betting_state[pc.get_player_id()] = 1
- table.insert(betting_list, {pc.get_name(), bet_amount, player})
- pc.change_gold(-bet_amount)
- say_title("Plasează un Pariu:")
- say("Pariul a fost plasat.")
- say("Mulţumim şi mult succes !")
- say("")
- end
- when 20378.chat."Cine participă?" with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 2 begin
- setskin(NOWINDOW)
- chat("Următoarele persoane participă în Turneul PvP:")
- for i = 1, attender_count, 4 do
- local chatline = ""
- for j = i, i + 4, 1 do
- if pvp_attenders[j] != nil then
- chatline = chatline..pvp_attenders[j].name.." "
- end
- end
- syschat(chatline)
- end
- syschat("Total "..attender_count.." participanţi")
- end
- 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
- say_title(mob_name(20378)..":")
- say("")
- if pvp_manager.get_duel_partner() == nil then
- say("Nu există nici un oponent disponibil momentan.")
- say("")
- say("Dacă nu găsim pe nimeni disponibil vei merge în")
- say("următoarea rundă în mod automat.")
- say("")
- return
- end
- say("Conform planului curent te vei duela cu:")
- say("")
- say_reward(""..pvp_manager.get_duel_partner().."")
- say("")
- end
- function make_duel_list()
- duel_list = { }
- local i = 0
- for ai = 1, attender_count, 1 do
- if pvp_attenders[ai] != nil and pvp_attenders[ai].partner == nil and pvp_attenders[ai].winner == true then
- local partner_id = pvp_manager.findpartner(tostring(pvp_attenders[ai].name), pvp_attenders[ai].level)
- if partner_id != nil then
- pvp_attenders[ai].partner = tostring(pvp_attenders[partner_id].name)
- pvp_attenders[partner_id].partner = tostring(pvp_attenders[ai].name)
- duel_list[i] = {fighter_id1 = ai, fighter_id2 = partner_id}
- i = i + 1
- end
- end
- end
- for ai = 1, attender_count, 1 do
- if pvp_attenders[ai] != nil and pvp_attenders[ai].partner == nil and pvp_attenders[ai].winner == true then
- local partner_id = pvp_manager.findpartner_for_partnerless(tostring(pvp_attenders[ai].name), pvp_attenders[ai].level)
- if partner_id != nil then
- pvp_attenders[ai].partner = tostring(pvp_attenders[partner_id].name)
- pvp_attenders[partner_id].partner = tostring(pvp_attenders[ai].name)
- duel_list[i] = {fighter_id1 = ai, fighter_id2 = partner_id}
- i = i + 1
- end
- end
- end
- end
- function findpartner(name, level)
- local closest_level = nil
- local partner_id = nil
- for ai = 1, attender_count, 1 do
- 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
- if closest_level == nil then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- elseif tonumber(pvp_attenders[ai].level) == tonumber(level) then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- elseif tonumber(level) < tonumber(closest_level) and tonumber(pvp_attenders[ai].level) < tonumber(closest_level) then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- elseif tonumber(level) > tonumber(closest_level) and tonumber(pvp_attenders[ai].level) > tonumber(closest_level) then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- end
- end
- end
- return tonumber(partner_id)
- end
- function findpartner_for_partnerless(name, level)
- local closest_level = nil
- local partner_id = nil
- for ai = 1, attender_count, 1 do
- 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
- if closest_level == nil then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- elseif pvp_attenders[ai].level == level then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- elseif tonumber(level) < tonumber(closest_level) and pvp_attenders[ai].level < closest_level then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- elseif tonumber(level) > tonumber(closest_level) and pvp_attenders[ai].level > closest_level then
- closest_level = pvp_attenders[ai].level
- partner_id = ai
- end
- end
- end
- return partner_id
- end
- function is_player_in_map(name)
- if pc.getname() == name then
- return true
- end
- local myname = pc.getname()
- local target = find_pc_by_name(name)
- local t = pc.select(target)
- if pc.getname() == myname then
- pc.select(t)
- return false
- end
- pc.select(t)
- return true
- end
- when 20378.chat."GM: Actualizează şi Curăţă Arena" with pc.is_gm() and game.get_event_flag("pvp") == 3 begin
- for aArena = 1, 4, 1 do
- arena[aArena][3] = 0
- arena[aArena][4] = "SLEEPING"
- end
- pvp_manager.refresh_arenas()
- end
- -- not working
- --[[
- when 20378.chat."GM: Opreşte Lupta" with pc.is_gm() and game.get_event_flag("pvp") == 2 begin
- say_title("Opreşte Lupta:")
- say("În care arenă ar trebui sfârşită lupta?")
- local s = select("Arena 1", "Arena 2", "Arena 3", "Arena 4", "Închide")
- if s == 5 then
- return
- end
- local fighter1 = nil
- local fighter2 = nil
- for ai = 1, attender_count, 1 do
- if pvp_attenders[ai].arena == s and pvp_attenders[ai].fight_mode != 0 then
- if fighter1 == nil then
- fighter1 = ai
- else
- fighter2 = ai
- end
- end
- end
- if fighter1 == nil then
- say_title("Sfârşeşte lupta:")
- say("Nu există nici un duel în arena respectivă în")
- say("acest moment.")
- say("")
- return
- end
- say_title("Sfârşeşte Lupta:")
- say("Cine ar trebui considerat câştigător când lupta în arena "..s.." ")
- say("va fi încheiată?")
- local w = select(tostring(pvp_attenders[fighter1].name), tostring(pvp_attenders[fighter1].name), "Închide")
- if w == 3 then
- return
- end
- if w == 1 then
- pvp_attenders[fighter2].winner = false
- notice_in_map(tostring(pvp_attenders[fighter1].name).." has won the battle against "..tostring(pvp_attenders[fighter2].name).."!", pc.get_map_index())
- pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter1].name, 126, 234))
- pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter2].name, 126, 24))
- else
- pvp_attenders[fighter1].winner = false
- notice_in_map(tostring(pvp_attenders[fighter2].name).." has won the battle against "..tostring(pvp_attenders[fighter1].name).."!", pc.get_map_index())
- pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter1].name, 126, 24))
- pvp_manager.local_pc_warp(tostring(pvp_attenders[fighter2].name, 126, 234))
- end
- pvp_attenders[fighter1].fight_mode = 0
- pvp_attenders[fighter2].fight_mode = 0
- arena[s][3] = 0
- pvp_manager.refresh_arenas()
- say_title("Sfârşeşte duelul:")
- say("Duelul a luat sfârţit.")
- end
- --]]
- when 20378.chat."GM: Recompensă Turneu PvP" with pc.is_gm() begin
- say_title("Recompensă:")
- 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")..")")
- say("")
- local s = select("Schimbă recompensa", "Închide")
- if s == 2 then
- return
- end
- say_title("Schimbă Recompensa:")
- say("Te rog introdu codul noii recompense:")
- say("")
- local vnum = input()
- say_title("Schimbă recompensa:")
- say("Te rog introdu cantitatea noii recompense:")
- say("")
- local count = input()
- game.set_event_flag("pvp_price_count", count)
- game.set_event_flag("pvp_price_vnum", vnum)
- say_title("Schimbă Recompensa:")
- say("Recompensa a fost schimbată.")
- say("Noua recompensă: "..count.."x "..item_name(vnum).." (vnum: "..vnum..")")
- say("")
- end
- when 20378.chat."GM: Yang/Rundă Turneu PvP" with pc.is_gm() begin
- say_title("Recompensă-Yang-Rundă:")
- say("Suma curentă: "..game.get_event_flag("pvp_round_gold"))
- say("")
- local s = select("Schimbă ", "Închide")
- if s == 2 then
- return
- end
- say_title("Schimbă Suma:")
- say("Te rugăm să introduci suma de yang primită pentru")
- say("câştigătorul unei runde:")
- say("")
- local gold = input()
- game.set_event_flag("pvp_round_gold", gold)
- say_title("Schimbă Suma:")
- say("Yang-ul primit a fost schimbat.")
- say("Yang actual pe rundă: "..gold)
- say("")
- end
- function refresh_arenas()
- for aArena = 1, 4, 1 do
- if duel_list[duel_list_index] == nil then
- if playerless_mode == true then
- pvp_manager.init_next_round()
- else
- pvp_manager.fight_playerless()
- end
- return
- end
- if arena[aArena][3] == 0 then
- arena[aArena][3] = 1
- pvp_manager.fight_init(duel_list[duel_list_index].fighter_id1, duel_list[duel_list_index].fighter_id2, aArena)
- end
- end
- end
- function fight_init(pid1, pid2, arena_id)
- duel_list_index = duel_list_index + 1
- if pvp_manager.is_player_in_map(tostring(pvp_attenders[pid1].name)) == false then
- notice_in_map(tostring(pvp_attenders[pid1].name).." nu este online, prin urmare va fi descalificat/ă.", pc.get_map_index())
- pvp_attenders[pid1].winner = false
- pvp_attenders[pid2].partner = nil
- arena[arena_id][3] = 0
- pvp_manager.refresh_arenas()
- return
- end
- if pvp_manager.is_player_in_map(tostring(pvp_attenders[pid2].name)) == false then
- notice_in_map(tostring(pvp_attenders[pid2].name).." nu este online, prin urmare va fi descalificat/ă.", pc.get_map_index())
- pvp_attenders[pid2].winner = false
- pvp_attenders[pid1].partner = nil
- arena[arena_id][3] = 0
- pvp_manager.refresh_arenas()
- return
- end
- 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())
- --[[
- local f1_accept = ask_fight(tostring(pvp_attenders[pid1].name), tostring(pvp_attenders[pid2].name))
- if f1_accept != CONFIRM_OK then
- notice_in_map(tostring(pvp_attenders[pid1].name).." nu a acceptat duelul împotriva lui "..tostring(pvp_attenders[pid2].name)..".", pc.get_map_index())
- pvp_attenders[pid1] = nil
- pvp_attenders[pid2].partner = nil
- pvp_manager.refresh_arenas()
- return
- end
- local f2_accept = confirm(find_pc_by_name(tostring(pvp_attenders[pid2].name)), "Vei lupta împotriva lui "..tostring(pvp_attenders[pid1].name).. " ?", 15)
- if f2_accept != CONFIRM_OK then
- notice_in_map(tostring(pvp_attenders[pid2].name).." nu a acceptat duelul împotriva lui "..tostring(pvp_attenders[pid1].name)..".", pc.get_map_index())
- pvp_attenders[pid2] = nil
- pvp_attenders[pid1].partner = nil
- pvp_manager.refresh_arenas()
- return
- end
- ]]
- pvp_attenders[pid1].fight_mode = 1
- pvp_attenders[pid2].fight_mode = 1
- pvp_attenders[pid1].arena = arena_id
- pvp_attenders[pid2].arena = arena_id
- pvp_manager.local_pc_warp(tostring(pvp_attenders[pid1].name), arena[arena_id][1][1], arena[arena_id][1][2])
- pvp_manager.local_pc_warp(tostring(pvp_attenders[pid2].name), arena[arena_id][2][1], arena[arena_id][2][2])
- end
- when login with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 3 and pvp_manager.get_fight_mode() == 1 begin
- affect.add(apply.MOV_SPEED, -10000, 2)
- affect.add_collect(apply.HP_REGEN, 5000, 30)
- affect.add_collect(apply.SP_REGEN, 5000, 30)
- pvp_manager.set_fight_mode(2)
- if arena[pvp_manager.get_arena()][3] == 2 then
- arena[pvp_manager.get_arena()][5] = 30
- loop_timer("fight_start_countdown", 1)
- else
- timer("partner_timeout", 60)
- end
- arena[pvp_manager.get_arena()][3] = 2
- end
- when partner_timeout.timer begin
- 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
- return
- end
- pvp_manager.set_fight_mode(3)
- if arena[pvp_manager.get_arena()][3] == 3 then
- return
- end
- arena[pvp_manager.get_arena()][3] = 3
- notice_in_map(pc.getname().." a câştigat împotriva lui "..pvp_manager.get_duel_partner().." prin abandon !", pc.get_map_index())
- pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].fight_mode = 3
- pvp_attenders[pvp_manager.get_my_attender_id()].winner = true
- pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].winner = false
- pc.warp_local(pc.get_map_index(), 12600, 23400)
- end
- when fight_start_countdown.timer begin
- if arena[pvp_manager.get_arena()][5] == -1 then
- return
- end
- local partner_vid = find_pc_by_name(pvp_manager.get_duel_partner())
- local my_vid = pc.get_vid()
- if arena[pvp_manager.get_arena()][5] == 0 then
- arena[pvp_manager.get_arena()][5] = -1
- pc.select(partner_vid)
- command("pvp "..my_vid)
- pc.select(my_vid)
- command("pvp "..partner_vid)
- notice_in_map("Duelul dintre "..pvp_manager.get_duel_partner().." şi "..pc.get_name().." începe !", pc.get_map_index())
- timer("fight_start_countdown_shutdown", 1)
- else
- pc.select(partner_vid)
- if math.mod(arena[pvp_manager.get_arena()][5], 5) == 0 then
- syschat("Duelul începe în "..tostring(arena[pvp_manager.get_arena()][5]).." secunde.")
- end
- affect.add(apply.MOV_SPEED, -10000, 2)
- pc.select(my_vid)
- if math.mod(arena[pvp_manager.get_arena()][5], 5) == 0 then
- syschat("Duelul începe în "..tostring(arena[pvp_manager.get_arena()][5]).." secunde.")
- end
- affect.add(apply.MOV_SPEED, -10000, 2)
- arena[pvp_manager.get_arena()][5] = arena[pvp_manager.get_arena()][5] - 1
- end
- end
- when fight_start_countdown_shutdown.timer begin
- cleartimer("fight_start_countdown")
- end
- when logout with game.get_event_flag("pvp") == 3 and pc.get_map_index() == 115 and pvp_manager.get_fight_mode() == 2 begin
- pvp_manager.set_fight_mode(3)
- arena[pvp_manager.get_arena()][3] = 3
- notice_in_map(pvp_manager.get_duel_partner().." a câştigat împotriva lui "..pc.getname().."!", pc.get_map_index())
- pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].fight_mode = 3
- pvp_attenders[pvp_manager.get_my_attender_id()].winner = false
- pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].winner = true
- local target = find_pc_by_name(pvp_manager.get_duel_partner())
- local t = pc.select(target)
- pc.change_gold(game.get_event_flag("pvp_round_gold")*pvp_round_num)
- pc.select(t)
- pvp_manager.local_pc_warp(pvp_manager.get_duel_partner(), 126, 24)
- end
- 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
- pvp_manager.set_fight_mode(3)
- if arena[pvp_manager.get_arena()][3] == 3 then
- return
- end
- arena[pvp_manager.get_arena()][3] = 3
- notice_in_map(pc.getname().." a câştigat împotriva lui "..pvp_manager.get_duel_partner().."!", pc.get_map_index())
- pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].fight_mode = 3
- pvp_attenders[pvp_manager.get_my_attender_id()].winner = true
- pvp_attenders[pvp_manager.get_attender_id_by_name(pvp_manager.get_duel_partner())].winner = false
- pc.change_gold(game.get_event_flag("pvp_round_gold")*pvp_round_num)
- timer("fight_end", 5)
- end
- when fight_end.timer begin
- pc.warp_local(pc.get_map_index(), 12600, 23400)
- pvp_manager.local_pc_warp(pvp_manager.get_duel_partner(), 126, 24)
- end
- when letter with pc.get_map_index() == 115 and game.get_event_flag("pvp") == 3 and pvp_manager.get_fight_mode() == 3 begin
- pvp_manager.set_fight_mode(0)
- if pvp_attenders[pvp_manager.get_my_attender_id()].winner == true then
- arena[pvp_manager.get_arena()][3] = 0
- pvp_manager.refresh_arenas()
- end
- end
- 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
- loop_timer("horse_block",1)
- end
- when horse_block.timer begin
- if horse.is_riding() then
- pc.unmount()
- horse.unsummon()
- syschat("Nu poţi folosi calul aici !")
- end
- end
- function fight_playerless()
- for aArena = 1, 4, 1 do
- if arena[aArena][3] != 0 then
- return
- end
- end
- playerless_mode = true
- pvp_manager.make_duel_list()
- pvp_manager.refresh_arenas()
- end
- function init_next_round()
- for aArena = 1, 4, 1 do
- if arena[aArena][3] != 0 then
- return
- end
- end
- playerless_mode = false
- local winner_count = 0
- local winner_id = 0
- for ai = 1, attender_count, 1 do
- pvp_attenders[ai].partner = nil
- pvp_attenders[ai].fight_mode = 0
- if pvp_attenders[ai] != nil and pvp_attenders[ai].winner == true then
- winner_count = winner_count + 1
- winner_id = ai
- end
- end
- if winner_count == 1 then
- notice_all(pvp_attenders[winner_id].name.." a câştigat Turneul PvP ! Avem o nouă legendă în Ţinutul Mistic !")
- 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ă !")
- pvp_manager.distribute_bets(pvp_attenders[winner_id].name)
- local target = find_pc_by_name(pvp_attenders[winner_id].name)
- local t = pc.select(target)
- pc.give_item2(game.get_event_flag("pvp_price_vnum"), game.get_event_flag("pvp_price_count"))
- pc.select(t)
- notice_all("Turneul PvP a luat sfârşit. Vă aşteptăm la următorul Turneu !")
- game.set_event_flag("pvp", 0)
- pvp_attenders = nil
- return
- end
- pvp_manager.make_duel_list()
- duel_list_index = 0
- if winner_count == 2 then
- notice_all("Runda finală a Turnelului PvP începe acum !")
- elseif winner_count <= 4 then
- notice_all("Runda semi-finală a Turnelului PvP începe acum !")
- else
- notice_all("Următoarea rundă a Turneului PvP începe acum !")
- end
- pvp_round_num = pvp_round_num + 1
- pvp_manager.refresh_arenas()
- end
- function distribute_bets(winner_name)
- --table.insert(betting_list, {pc.get_name(), bet_amount, player})
- local jackpot = 0
- local jackpot_winner_only = 0
- local winners = 0
- for i = 1, table.getn(betting_list), 1 do
- if betting_list[i][3] == winner_name then
- jackpot_winner_only = jackpot_winner_only + betting_list[i][2]
- end
- jackpot = jackpot + betting_list[i][2]
- winners = winners + 1
- end
- for i = 1, table.getn(betting_list), 1 do
- if betting_list[i][3] == winner_name then
- pvp_manager.give_jackpot_gold(betting_list[i][1], math.ceil( (betting_list[i][2] / jackpot_winner_only)*jackpot ))
- end
- end
- end
- function give_jackpot_gold(name, amount)
- local target = find_pc_by_name(name)
- if target == 0 then
- return
- end
- local t = pc.select(target)
- pc.change_money(amount)
- pc.select(t)
- end
- function local_pc_warp(name, x, y)
- local target = find_pc_by_name(name)
- local t = pc.select(target)
- pc.warp_local(pc.get_map_index(), x*100, y*100)
- pc.select(t)
- end
- function setqf_by_name(name, flag, value)
- local target = find_pc_by_name(name)
- local t = pc.select(target)
- pc.setqf(flag, value)
- pc.select(t)
- end
- function getqf_by_name(name, flag)
- local target = find_pc_by_name(name)
- local t = pc.select(target)
- local rflag = pc.getqf(flag)
- pc.select(t)
- return rflag
- end
- function get_attender_id_by_name(name)
- for ai = 1, attender_count, 1 do
- if tostring(pvp_attenders[ai].name) == name then
- return ai
- end
- end
- return 0
- end
- function get_my_attender_id()
- return pvp_manager.get_attender_id_by_name(pc.get_name())
- end
- function get_duel_partner()
- if pvp_attenders[pvp_manager.get_my_attender_id()] != nil and pvp_attenders[pvp_manager.get_my_attender_id()].partner != nil then
- return pvp_attenders[pvp_manager.get_my_attender_id()].partner
- else
- return nil
- end
- end
- function get_fight_mode()
- 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
- return pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode
- else
- return 0
- end
- end
- function set_fight_mode(fmode)
- pvp_attenders[pvp_manager.get_my_attender_id()].fight_mode = fmode
- end
- function get_arena()
- return pvp_attenders[pvp_manager.get_my_attender_id()].arena
- end
- function set_arena(id)
- pvp_attenders[pvp_manager.get_my_attender_id()].arena = id
- end
- function ask_fight(asker, target)
- return confirm(find_pc_by_name(target), "Vei lupta împotriva lui "..asker.. "?", 15)
- end
- end
- end
Add Comment
Please, Sign In to add comment