LegendDragon
Utente Emerald
Codice:
quest faction_system begin
state start begin
----------------------------------------------------------------------
-- FUNZIONI DI CONTROLLO LIVELLO
----------------------------------------------------------------------
function check_corruption_level()
if not pc.is_pc() then return end
local corruption = pc.getqf("corruption_points") or 0
local last_level = pc.getqf("corruption_last_level") or 0
local new_level = 0
if corruption >= 500 then new_level = 5
elseif corruption >= 400 then new_level = 4
elseif corruption >= 350 then new_level = 3
elseif corruption >= 31 then new_level = 2
elseif corruption >= 1 then new_level = 1
end
if new_level > last_level then
pc.setqf("corruption_last_level", new_level)
if new_level == 2 then
syschat("Sei diventato GUERRIERO OSCURO!")
notice_all(pc.get_name() .. " e' diventato GUERRIERO OSCURO!")
elseif new_level == 3 then
syschat("Sei diventato SIGNORE DEMONE!")
notice_all(pc.get_name() .. " e' diventato SIGNORE DEMONE!")
elseif new_level == 4 then
syschat("Sei diventato SIGNORE SUPREMO!")
notice_all(pc.get_name() .. " e' diventato SIGNORE SUPREMO!")
elseif new_level == 5 then
syschat("HAI RAGGIUNTO IL POTERE MASSIMO!")
notice_all("!!! " .. pc.get_name() .. " HA RAGGIUNTO IL MASSIMO POTERE!!!")
end
end
end
function check_purity_level()
if not pc.is_pc() then return end
local points = pc.getqf("pure_points") or 0
local last_level = pc.getqf("pure_last_level") or 0
local new_level = 0
if points >= 500 then new_level = 5
elseif points >= 400 then new_level = 4
elseif points >= 350 then new_level = 3
elseif points >= 100 then new_level = 2
elseif points >= 1 then new_level = 1
end
if new_level > last_level then
pc.setqf("pure_last_level", new_level)
if new_level == 2 then
syschat("Sei diventato PALADINO!")
notice_all(pc.get_name() .. " e' diventato PALADINO!")
elseif new_level == 3 then
syschat("Sei diventato GUARDIANO DELLA LUCE!")
notice_all(pc.get_name() .. " e' diventato GUARDIANO DELLA LUCE!")
elseif new_level == 4 then
syschat("Sei diventato SIGNORE DELLA PUREZZA!")
notice_all(pc.get_name() .. " e' diventato SIGNORE DELLA PUREZZA!")
elseif new_level == 5 then
syschat("HAI RAGGIUNTO LA MASSIMA PUREZZA!")
notice_all("!!! " .. pc.get_name() .. " HA RAGGIUNTO LA MASSIMA PUREZZA!!!!")
end
end
end
----------------------------------------------------------------------
-- PROTEZIONE EVENTI NPC
----------------------------------------------------------------------
when 9700.click or 9433.click or 33009.click or 30123.click begin
-- Evento click gestito automaticamente dai chat events
end
----------------------------------------------------------------------
-- LOGIN INIT
----------------------------------------------------------------------
when login begin
local corruption = pc.getqf("corruption_points") or 0
local purity = pc.getqf("pure_points") or 0
if corruption < 0 then pc.setqf("corruption_points", 0) end
if corruption > 500 then pc.setqf("corruption_points", 500) end
if purity < 0 then pc.setqf("pure_points", 0) end
if purity > 500 then pc.setqf("pure_points", 500) end
local faction = pc.getqf("faction") or 0
if faction == 1 then
pc.setqf("is_corrupted", 1)
pc.setqf("is_pure", 0)
elseif faction == 2 then
pc.setqf("is_pure", 1)
pc.setqf("is_corrupted", 0)
end
loop_timer("check_levels", 600)
end
when check_levels.timer begin
local faction = pc.getqf("faction") or 0
if faction == 1 then
check_corruption_level()
elseif faction == 2 then
check_purity_level()
end
end
----------------------------------------------------------------------
-- NPC 9700: MAESTRO OSCURO (CORRUZIONE)
----------------------------------------------------------------------
when 9700.chat."Abbraccia il Potere Oscuro" begin
local faction = pc.getqf("faction") or 0
-- NUOVO: Controlla se ha fatto la quest introduttiva
if pc.getqf("demone_contact") == 0 then
say_title("Maestro Oscuro:")
say("")
say("Non sei ancora pronto per questo potere...")
say("")
say("Devi prima essere contattato dal Signore Demone.")
say("Torna quando avrai raggiunto il livello 60.")
return
end
-- Se ha già la corruzione
if faction == 1 then
say("Hai già abbracciato l'oscurità.")
say("Corruzione: " .. pc.getqf("corruption_points") .. "/500")
return
end
-- Se ha scelto la luce
if faction == 2 then
say_title("Maestro Oscuro:")
say("")
say("IMPOSSIBILE!")
say("Hai gia' abbracciato la Luce.")
say("")
return
end
-- QUESTO NON DOVREBBE MAI ACCADERE
-- (Se demone_contact = 1, la quest ha già settato faction = 1 o 2)
say_title("Maestro Oscuro:")
say("")
say("La tua scelta e' gia' stata fatta...")
say("Non puoi cambiarla qui.")
end
when 9700.chat."Abbandona il Potere Oscuro" begin
local faction = pc.getqf("faction") or 0
if faction ~= 1 then
say("Non sei corrotto.")
return
end
say_title("Maestro Oscuro:")
say("")
say("Vuoi davvero abbandonare l'oscurità?")
say("")
say("ATTENZIONE:")
say("- Perderai tutti i punti corruzione")
say("- Perderai tutti gli oggetti oscuri")
say("")
if select("Si, voglio abbandonare", "No, ci ripensero") == 1 then
while pc.count_item(54111) > 0 do
pc.remove_item(54111, 1)
end
while pc.count_item(54112) > 0 do
pc.remove_item(54112, 1)
end
while pc.count_item(54114) > 0 do
pc.remove_item(54114, 1)
end
while pc.count_item(54115) > 0 do
pc.remove_item(54115, 1)
end
pc.setqf("faction", 0)
pc.setqf("is_corrupted", 0)
pc.setqf("corruption_points", 0)
pc.setqf("corruption_last_level", 0)
say_title("Maestro Oscuro:")
say("")
say("Hai abbandonato l'oscurità.")
say("")
syschat("La tua corruzione è stata rimossa!")
notice_all(pc.get_name() .. " ha abbandonato il Potere Oscuro!")
end
end
----------------------------------------------------------------------
-- NPC 9433: GUARDIANO DELLA LUCE (PUREZZA)
----------------------------------------------------------------------
when 9433.chat."Abbraccia la Luce" begin
local faction = pc.getqf("faction") or 0
-- NUOVO: Controlla se ha fatto la quest introduttiva
if pc.getqf("demone_contact") == 0 then
say_title("Guardiano della Luce:")
say("")
say("Non sei ancora pronto per questa scelta...")
say("")
say("Devi prima affrontare una prova importante.")
say("Torna quando avrai raggiunto il livello 60.")
return
end
-- Se ha già la luce
if faction == 2 then
say("Hai gia' scelto la via della Luce.")
say("Punti Luce: " .. pc.getqf("pure_points") .. "/500")
return
end
-- Se ha scelto la corruzione
if faction == 1 then
say_title("Guardiano della Luce:")
say("")
say("IMPOSSIBILE!")
say("Sei gia' stato corrotto dall'oscurita'.")
say("")
return
end
-- QUESTO NON DOVREBBE MAI ACCADERE
-- (Se demone_contact = 1, la quest ha già settato faction = 1 o 2)
say_title("Guardiano della Luce:")
say("")
say("La tua scelta e' gia' stata fatta...")
say("Non puoi cambiarla qui.")
end
when 9433.chat."Abbandona la Luce" begin
local faction = pc.getqf("faction") or 0
if faction ~= 2 then
say("Non sei puro.")
return
end
say_title("Guardiano della Luce:")
say("")
say("Vuoi davvero abbandonare la Luce?")
say("")
say("ATTENZIONE:")
say("- Perderai tutti i punti luce")
say("- Perderai tutti gli oggetti della luce")
say("")
if select("Si, voglio abbandonare", "No, ci ripensero") == 1 then
while pc.count_item(31786) > 0 do
pc.remove_item(31786, 1)
end
while pc.count_item(31787) > 0 do
pc.remove_item(31787, 1)
end
while pc.count_item(31784) > 0 do
pc.remove_item(31784, 1)
end
while pc.count_item(31785) > 0 do
pc.remove_item(31785, 1)
end
pc.setqf("faction", 0)
pc.setqf("is_pure", 0)
pc.setqf("pure_points", 0)
pc.setqf("pure_last_level", 0)
say_title("Guardiano della Luce:")
say("")
say("Hai abbandonato la Luce.")
say("")
syschat("La tua purezza e' stata rimossa!")
notice_all(pc.get_name() .. " ha abbandonato la Luce!")
end
end
----------------------------------------------------------------------
-- EVENTI CORRUZIONE
----------------------------------------------------------------------
when kill with npc.is_pc() begin
local faction = pc.getqf("faction") or 0
local victim_faction = npc.getqf("faction") or 0
if faction == 1 and victim_faction == 2 then
-- Corrotto uccide SOLO puri
local corruption = pc.getqf("corruption_points") or 0
pc.setqf("corruption_points", math.min(corruption + 15, 500))
syschat("Hai guadagnato 15 punti corruzione per aver sconfitto un puro!")
check_corruption_level()
elseif faction == 2 and victim_faction == 1 then
-- Puro uccide corrotti
local points = pc.getqf("pure_points") or 0
local new_points = math.min(points + 15, 500)
pc.setqf("pure_points", new_points)
syschat("Hai guadagnato 15 punti luce per aver sconfitto un corrotto! ["..new_points.."/500]")
check_purity_level()
end
end
when 9042.kill begin
local faction = pc.getqf("faction") or 0
if faction == 1 then
local corruption = pc.getqf("corruption_points") or 0
local new_c = math.min(corruption + 10, 500)
pc.setqf("corruption_points", new_c)
syschat("Innocente ucciso! +10 [" .. new_c .. "/500]")
check_corruption_level()
end
end
when 7557.kill or 9044.kill or 9045.kill begin
local faction = pc.getqf("faction") or 0
if faction == 2 then
local points = pc.getqf("pure_points") or 0
local new_points = math.min(points + 10, 500)
pc.setqf("pure_points", new_points)
syschat("Hai guadagnato 10 punti luce! ["..new_points.."/500]")
check_purity_level()
end
end
----------------------------------------------------------------------
-- NEGOZI
----------------------------------------------------------------------
when 33009.chat."Gestione Potere Oscuro" begin
local faction = pc.getqf("faction") or 0
if faction ~= 1 then
say("Non sei corrotto.")
return
end
local corruption = pc.getqf("corruption_points") or 0
local menu = select("Controlla Stato", "Negozio", "Chiudi")
if menu == 1 then
say_title("Stato Corruzione:")
say("Punti: " .. corruption .. "/500")
elseif menu == 2 then
say_title("Negozio Oscuro:")
local s = select(
"Elmo Corrotto Maschio (400)",
"Elmo Corrotto Femmina (400)",
"Costume Corrotto Maschio (500)",
"Costume Corrotto Femmina (500)",
"Chiudi"
)
if s == 1 and corruption >= 400 then
if pc.count_item(54114) == 0 then
pc.give_item2(54114, 1)
say("Hai ricevuto l'Elmo Corrotto Maschio!")
else
say("Hai gia' questo Elmo Corrotto!")
end
elseif s == 2 and corruption >= 400 then
if pc.count_item(54115) == 0 then
pc.give_item2(54115, 1)
say("Hai ricevuto l'Elmo Corrotto Femmina!")
else
say("Hai gia' questo Elmo Corrotto!")
end
elseif s == 3 and corruption >= 500 then
if pc.count_item(54111) == 0 then
pc.give_item2(54111, 1)
say("Hai ricevuto Corazza Corrotta Maschio!")
else
say("Hai gia' questa Corazza Corrotta!")
end
elseif s == 4 and corruption >= 500 then
if pc.count_item(54112) == 0 then
pc.give_item2(54112, 1)
say("Hai ricevuto Corazza Corrotta Femmina!")
else
say("Hai gia' questa Corazza Corrotta!")
end
else
say("Requisiti non rispettati.")
end
end
end
when 30123.chat."Gestione Luce" begin
local faction = pc.getqf("faction") or 0
if faction ~= 2 then
say("Non sei della fazione della Luce.")
return
end
local points = pc.getqf("pure_points") or 0
local menu = select("Controlla Stato", "Negozio Luce", "Chiudi")
if menu == 1 then
say_title("Stato Punti Luce:")
say("Punti: " .. points .. "/500")
elseif menu == 2 then
say_title("Negozio della Luce:")
local s = select(
"Elmo Purezza Maschio (400)",
"Elmo Purezza Femmina (400)",
"Corazza Purezza Maschio (500)",
"Corazza Purezza Femmina (500)",
"Chiudi"
)
if s == 1 and points >= 400 then
if pc.count_item(31786) == 0 then
pc.give_item2(31786, 1)
say("Hai ricevuto l'Elmo Purezza Maschio!")
else
say("Hai gia' questo Elmo Purezza!")
end
elseif s == 2 and points >= 400 then
if pc.count_item(31787) == 0 then
pc.give_item2(31787, 1)
say("Hai ricevuto l'Elmo Purezza Femmina!")
else
say("Hai già questo Elmo Purezza!")
end
elseif s == 3 and points >= 500 then
if pc.count_item(31784) == 0 then
pc.give_item2(31784, 1)
say("Hai ricevuto Corazza Purezza Maschio!")
else
say("Hai gia' questa Corazza Purezza!")
end
elseif s == 4 and points >= 500 then
if pc.count_item(31785) == 0 then
pc.give_item2(31785, 1)
say("Hai ricevuto Corazza Purezza Femmina!")
else
say("Hai gia' questa Corazza Purezza!")
end
else
say("Requisiti non rispettati.")
end
end
end
end
end
mi esce questo errore:
SYSERR: Dec 23 04:27:36 :: RunState: LUA_ERROR: [string "faction_system"]:2: attempt to call field `getqf' (a nil value)
SYSERR: Dec 23 04:27:36 :: WriteRunningStateToSyserr: LUA_ERROR: quest faction_system.start click