Files
Leviathan/GameServer/AziaMafiaScriptsBackup/Other/ETC_revival_token.lua
T
2026-06-01 12:46:52 +02:00

89 lines
2.5 KiB
Lua

function set_resurrect()
set_flag("aR", 1)
cprint("<b>As the Revival Token disolves in your hand you have the sudden sensation of invulnerability as if you could cheat death itself.</b>")
end
function resurrect_by_token()
local currentExp, lostExp, max_hp, max_mp, currentTime, lastTime, timeDiff, penalty, returnExp, returnHP, returnMP
-- Set some important values
lostExp = tonumber(get_flag("LXPL"))
currentTime = get_os_time()
penalty = 0
-- Calculate return values
max_hp = get_value("max_hp")
max_mp = get_value("max_mp")
-- If EXP was actually lost (not a duel / PK)
if lostExp > 0 then
-- Check if the user has used the item before
lastTime = tonumber(get_flag("LXPLT"))
if lastTime ~= nil and lastTime > 0 then
timeDiff = currentTime - lastTime
if timeDiff < 300 then -- Less than five minutes passed
penalty = .25
elseif timeDiff > 300 and timeDiff <= 600 then -- More than five minutes, less than ten minutes passed
penalty = .50
end
end
-- Get the players current exp value
currentExp = get_value("exp")
-- If the value is valide
if currentExp > 0 then
-- Determine the penalty
if penalty == 0 then
returnExp = lostExp
else
returnExp = lostExp - (lostExp * penalty)
end
-- Determine the return hp/mp based on penalty
returnHP = max_hp - (max_hp * penalty)
returnMP = max_mp - (max_mp * penalty)
-- Notify the user
if penalty == .25 then
cprint("You have been revived with a penalty of <b>25%</b> reduction to your returned exp/hp/mp.")
cprint("To avoid a 50% penalty you should wait <b>five minutes</b> before using the Revival Token again!")
elseif penalty == .50 then
cprint("You have been revived with a penalty of <b>50%</b> reduction to your returned exp/hp/mp.")
cprint("To avoid another 50% penalty you should wait <b>ten minutes</b> before using the Revival Token again!")
end
else
cprint("Error: 2, Contact <b>Alucard</b> with this error immediately")
end
else -- Set the hp/mp to max (this was a pk)
returnHp = max_hp
returnMp = max_mp
returnExp = 0
cprint("You have been revived with no penalty!")
end
-- Write the flags
set_flag("LXPL", 0)
set_flag("LXPLT", currentTime)
set_flag("aR", 0)
-- Set the values
if returnExp > 0 then
add_exp_jp(returnExp)
end
dlg_special('confirm_window','set_value("hp",'.. returnHP..')set_value("mp",'..returnMP..')',"Do you want to revive?")
-- set_value("hp", returnHP)
-- set_value("mp", returnMP)
end