quest dragon_lair_access begin
state start begin
function get_settings()
local settings = {}
settings.cooldown_time = 3600
settings.group_time = 300
settings.access_item = 30179
settings.dragon_vnum = 2430
settings.spawn = {}
settings.spawn.x = 181
settings.spawn.y = 173
settings.warp_in = {}
settings.warp_in.first = {}
settings.warp_in.last = {}
settings.warp_in.first.x = 843677
settings.warp_in.first.y = 1066206
settings.warp_in.last.x = 844027
settings.warp_in.last.y = 1067599
settings.warp_out = {}
settings.warp_out.first = {}
settings.warp_out.last = {}
settings.warp_out.first.x = 145900
settings.warp_out.first.y = 1323600
settings.warp_out.last.x = 10900
settings.warp_out.last.y = 1209100
settings.room_area = {}
settings.room_area.first = {}
settings.room_area.last = {}
settings.room_area.first.x = 833000
settings.room_area.first.y = 1062500
settings.room_area.last.x = 844100
settings.room_area.last.y = 1071500
settings.access_item_amount = game.get_event_flag("dragon_lair_amount")
if (settings.access_item_amount == 0) then
settings.access_item_amount = 3
elseif (settings.access_item_amount == -1) then
settings.access_item_amount = 0
end
return settings
end
function get_random_point(area_coordinates)
return math.random(area_coordinates.first.x, area_coordinates.last.x), math.random(area_coordinates.first.y, area_coordinates.last.y)
end
function warp_to_lair()
local settings = dragon_lair_access.get_settings()
local x, y = dragon_lair_access.get_random_point(settings.warp_ in)
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' WARPTOLAIR: x:'.. x ..', y:' .. y)
pc.warp(x,y)
end
function warp_from_lair()
local settings = dragon_lair_access.get_settings()
local x, y = dragon_lair_access.get_random_point(settings.warp_ out)
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' WARPFROMLAIR: x:'.. x ..', y:' .. y)
pc.warp(x,y)
end
function warp_all_from_lair()
local settings = dragon_lair_access.get_settings()
warp_all_in_area_to_area(settings.room_area.first. x, settings.room_area.first.y, settings.room_area.last.x, settings.room_area.last.y, settings.warp_out.first.x, settings.warp_out.first.y, settings.warp_out.last.x, settings.warp_out.last.y)
game.set_event_flag("dragon_lair_alive", 0) -- dragon is dead
char_log(0, 'LAIR', 'WARP ALL')
end
function get_time_remaining()
local settings = dragon_lair_access.get_settings()
return (game.get_event_flag("dragon_lair_time") + settings.cooldown_time - get_global_time())
end
function give_item_to_ghost()
local settings = dragon_lair_access.get_settings()
say_title("Fantasma de un Sura: ")
say("Te llevaré directamente a la cueva del dragón,[ENTER]si lo deseas. Dame ahora ")
say(settings.access_item_amount.."x: ")
say_item_vnum(settings.access_item)
local give_item = select("Dejeme entrar!", "Cancelar")
if give_item == 1 then
pc.remove_item(settings.access_item, settings.access_item_amount)
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' GIVE ITEM')
return true
else
return false
end
end
function show_time_remaining(time_remaining)
q.set_title("Derrota al Dragón Azul")
send_letter("Derrota al Dragón Azul")
q.set_clock("Tiempo restante: ", time_remaining)
timer("dragon_lair_timer", time_remaining)
notice_multiline(string.format("Aún tienes %d Minutos, para matar[ENTER]El Dragon Azul!", time_remaining / 60), notice)
q.start()
end
when enter or login begin
pc.setqf("is_leader", 0)
q.done()
if pc.get_map_index() == 208 and not pc.is_gm() then
dragon_lair_access.warp_from_lair()
end
end
when blue_dragon_timer.server_timer begin
game.set_event_flag("dragon_lair_timer_used", 0)
if game.get_event_flag("dragon_lair_alive") == 1 then
notice_all("El Dragón Azul sigue vivo!")
else
notice_all("El Dragón Azul ha vuelto! ")
end
dragon_lair_access.warp_all_from_lair()
end
when 30121.chat."Quiero Matar al dragón!" with pc.get_map_index() == 73 begin
local starttime = game.get_event_flag("dragon_lair_time")
local current_time = get_global_time()
local settings = dragon_lair_access.get_settings()
local time_remaining = dragon_lair_access.get_time_remaining()
if pc.count_item(settings.access_item) >= settings.access_item_amount then
if starttime + settings.group_time >= current_time then
local password_input;
repeat
say_title("Fantasma de una sura: ")
say("En el interior Del Templo del dragon, ya se encuentra un grupo.[ENTER]Dame la Clave secreta, o tendras que esperar[ENTER]que el Grupo salga de el Templo del Dragon! ")
password_input = tonumber(input())
if password_input != game.get_event_flag("dragon_lair_password") then
say_title("Fantasma de un Sura: ")
say("Diese Zahl war nicht die richtige! ")
local again = select("Dejeme entrar!", "Cancelar")
if again == 2 then
return
end
end
until password_input == game.get_event_flag("dragon_lair_password")
if not dragon_lair_access.give_item_to_ghost() then
return
end
-- right password
pc.setqf("time", starttime)
dragon_lair_access.warp_to_lair()
set_state(kill_dragon)
elseif time_remaining < 0 and npc.lock() then
say_title("Fantasma de un sura: ")
say("Usted es el primero que quiere entrar [ENTER]al templo del dragon para evitar problemas [ENTER]necesito que especifiques una clave [ENTER]Por ser el primero usted tendra una clave secreta [ENTER]Esta se la puedes dar al resto de tus compañeros[ENTER]no pueden tardar mas de cinco minutos para entrar [ENTER]o la sala sera cerrada. tienes 60 minutos antes que las llaves[ENTER] pierdan su poder y sean expulsados[ENTER] Estas listo para ingresar? ")
local abort = select("Dejeme entrar!", "Cancelar")
if abort == 2 then
npc.unlock()
return
end
local password_number;
repeat
say_title("Fantasma de un Sura:")
say("Entonces ahora coloca la clave secreta: ")
password_number = tonumber(input())
local again;
if type(password_number) != 'number' then
say_title("Fantasma de un Sura: ")
say("la clave solo puede contener Numeros. ")
again = select("Entrar", "Cancelar")
if again == 2 then
npc.unlock()
return
end
end
until type(password_number) == 'number'
if not dragon_lair_access.give_item_to_ghost() then
npc.unlock()
return
end
if dragon_lair_access.get_time_remaining() > 0 then
pc.give_item2(settings.access_item, settings.access_item_amount)
npc.unlock()
say_title("Sura Fantasma:")
say("Otro grupo que ya intentó [ENTER]matar el dragon azul. Usted tiene que esperar un poco,[ENTER]hasta que regrese el dragon al templo")
return
end
pc.setqf("password", password_number)
timer("dragon_lair_warptimer", pc.get_channel_id()*2)
npc.unlock()
else
say_title("Fantasma de un sura:")
say("Otro grupo que ya intentó [ENTER]matar el dragon azul. Usted tiene que esperar un poco,[ENTER]hasta que regrese el dragon al templo")
return
end
else
say_title("Sura Fantasma")
say("")
say("¿Qué es un portal? ")
say("¿Para poder utilizar este portal tienes que poseer[ENTER]Llaves en espiral.[ENTER] ")
say(settings.access_item_amount.."x: ")
say_item_vnum(settings.access_item)
return
end
end
when 30121.chat."Quiero salir de este lugar" with pc.get_map_index() == 208 begin
say_title("Fantasma de un sura")
say("Te llevaré de vuelta a la entrada")
local warp = select("Entrar", Salir)
if warp == 1 then
dragon_lair_access.warp_from_lair()
set_state(start)
end
end
when dragon_lair_warptimer.timer begin
local settings = dragon_lair_access.get_settings()
if dragon_lair_access.get_time_remaining() < 0 then
local starttime = get_global_time()
game.set_event_flag("dragon_lair_time", starttime)
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' SET STARTTIME: ' .. starttime)
pc.setqf("time", starttime)
pc.setqf("is_leader", 1)
game.set_event_flag("dragon_lair_password", pc.getqf("password")) -- set password
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' SET PASSWORD: '.. pc.getqf("password"))
server_timer("blue_dragon_timer", settings.cooldown_time)
dragon_lair_access.warp_to_lair()
set_state(spawn_dragon)
else
pc.give_item2(settings.access_item, settings.access_item_amount)
say_title("Fantasma de un Sura:")
say("Otro grupo que ya intentó [ENTER]matar el dragon azul. Usted tiene que esperar un poco,[ENTER]hasta que regrese el dragon al templo")
end
pc.setqf("password", 0)
end
end
state spawn_dragon begin
when login begin
local settings = dragon_lair_access.get_settings()
purge_area(settings.room_area.first.x, settings.room_area.first.y, settings.room_area.last.x, settings.room_area.last.y)
notice_multiline(string.format("El grupo de %s intenta matar el[ENTER] Dragon Azul! ", pc.name), notice_all)
-- spawn all mobs needed
regen_in_map(208, "locale/turkey/map/metin2_map_skipia_dungeon_boss/regen.txt")
mob.spawn_group(settings.dragon_vnum, settings.spawn.x, settings.spawn.y, 1, 1, 1) -- spawn the dragon
game.set_event_flag("dragon_lair_alive", 1) -- dragon is alive
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' SPAWN DRAGON')
notice_multiline(string.format("Tienes 5 minutos para ingresar el código %s[ENTER]para Entrar! ", game.get_event_flag("dragon_lair_password")), notice)
dragon_lair_access.show_time_remaining(settings.co oldown_time)
set_state(kill_dragon)
end
when 30121.chat."Quiero salir de este lugar! " with pc.get_map_index() == 208 begin
say_title("Sura Fantasma")
say("Te llevaré de vuelta a la entrada de Gruta. ")
local warp = select("Si sacame de aca cuanto antes. ", "No Gracias, En cambiado de idea. ")
if warp == 1 then
dragon_lair_access.warp_from_lair()
set_state(start)
end
end
end
state kill_dragon begin
when dragon_lair_timer.timer begin
set_state(start)
end
when login begin
if pc.getqf("time") != game.get_event_flag("dragon_lair_time") or dragon_lair_access.get_time_remaining() <= 0 then
set_state(start)
else
dragon_lair_access.show_time_remaining(dragon_lair _access.get_time_remaining())
end
end
when button or info begin
notice_multiline(string.format("Aún tienes %d Minutos, para matar[ENTER]El Dragon Azul!", dragon_lair_access.get_time_remaining() / 60), notice)
local settings = dragon_lair_access.get_settings()
if (pc.getqf("is_leader") == 1 and settings.cooldown_time-dragon_lair_access.get_time_remaining() < settings.group_time) then
notice_multiline(string.format("Tienes 5 minutos para ingresar el código %s[ENTER] para Entrar! ", game.get_event_flag("dragon_lair_password")), notice)
end
end
when 30121.chat."Quiero salir de este lugar! " with pc.get_map_index() == 208 begin
say_title("Sura Fantasma")
say("Te llevaré de vuelta a la entrada. ")
local warp = select("Sacame de este lugar. ", "No gracias. ")
if warp == 1 then
dragon_lair_access.warp_from_lair()
set_state(start)
end
end
when 20009.chat."Quiero volver al templo del dragón!" or 9012.chat."Quiero volver al templo del dragón!" or 30121.chat."Quiero volver al templo del dragón! " with pc.get_map_index() != 208 begin
if pc.getqf("time") > 0 and pc.getqf("time") == game.get_event_flag("dragon_lair_time") then
dragon_lair_access.warp_to_lair()
else
say_title("El Anciado: ")
say("Otro grupo que ya intentó [ENTER]matar el dragon azul. Usted tiene que esperar un poco,[ENTER]hasta que regrese el dragon al templo")
set_state(start)
end
end
when 2455.kill with pc.get_map_index() == 208 begin
char_log(pc.get_player_id(), 'LAIR', pc.get_channel_id() ..' DRAGON KILLED')
game.set_event_flag("dragon_lair_alive", 0)
local drop = number(1,10)
if drop <= 3 then
game.drop_item_with_ownership(71123)
elseif drop >= 4 and drop <= 8 then
game.drop_item_with_ownership(71129)
elseif drop >= 9 then
game.drop_item_with_ownership(71123)
game.drop_item_with_ownership(71129)
end
notice_multiline(string.format("El grupo de: %s entro a desafiar al Dragon Azul[ENTER] Y lo han logrado matar!! Felicidades a nuestros Valientes", pc.name), notice_all)
local settings = dragon_lair_access.get_settings()
purge_area(settings.room_area.first.x, settings.room_area.first.y, settings.room_area.last.x, settings.room_area.last.y)
end
end
end
and problem.
SYSERR: Jan 20 07:31:53 :: RunState: LUA_ERROR: locale/turkey/quest/object/state/dragon_lair_access:37: bad argument #2 to `random' (interval is empty)
SYSERR: Jan 20 07:31:53 :: WriteRunningStateToSyserr: LUA_ERROR: quest dragon_lair_access.start click