Files
Leviathan/GameServer/Resource/script/System/player_hooks.lua
T
2026-06-01 12:46:52 +02:00

275 lines
7.7 KiB
Lua

-- Lua player_hooks module
function get_module_name()
return "player_hooks"
end
function on_player_dead( name, lost_exp )
local player_level = get_value( "level" )
if player_level > 5 then
message(sconv("@90019004", "#@lost_exp@#",tostring(lost_exp)))
else
message("@90019005")
end
save()
end
-- Revive type according to revive_type value
-- 0: just die on the field and respawn
-- 1: Resurrected from Death during a match in the Dalian chapter (existing Dalian system)
-- 2: Resurrected from Death during a match by a new match system related to 1:1 PVP
-- 3: Resurrected from Death during Dungeon Siege
function revive_in_town( revive_type )
local current_x = get_value("x")
local current_y = get_value("y")
local is_training_camp = false
local race = get_value( "race" )
if current_x >= 161280 and current_x <= 177408 then
if current_y >= 48384 and current_y <= 64512 then
is_training_camp = true
end -- if current_y >= 48384 and current_y <= 64512 then
end -- if current_x >= 161280 and current_x <= 177408 then
if is_training_camp then
local is_auto, quest_count
quest_count, is_auto = anti_auto_quest_check()
if is_auto then
if race == 4 then
RunTeleport_Auto_TO_City( 6625 , 6980 )
elseif race == 5 then
RunTeleport_Auto_TO_City( 116799 , 58205 )
else
RunTeleport_Auto_TO_City( 153506 , 77175 )
end
else
warp_to_revive_position()
end -- if is_auto then
else
-- If it is not a trainee's island, fly to the set area.
warp_to_revive_position()
end
kick_auto_to_another_world()
-- The value of the conditional statement that determines the recovery HP at the time of resurrection is commented at the top.
if revive_type == 0 then
set_value( "hp" , get_value( "max_hp" ) ) -- Recover 100% by returning to town after being killed by a monster in a normal field
elseif revive_type == 1 then
set_value( "hp" , get_value( "max_hp" ) * 0.1 ) -- Recovers only 10% HP when choosing to revive in place after sparring in the arena.
elseif revive_type == 2 then
set_value( "hp" , get_value( "max_hp" ) * 0.1 ) -- After duel, only 10% HP is recovered when choosing to revive in place.
elseif revive_type == 3 then
set_value( "hp" , get_value( "max_hp" ) * 0.1 ) -- When resurrected after death during the dungeon siege, only 10% of HP is recovered and resurrected at the nearest owned strategic base.
else
set_value( "hp" , get_value( "max_hp" ) ) -- Recovers to max HP when resurrecting after normal death.
end
return
end
function on_player_kill( killer, is_killer_pk_on, victim, is_victim_pk_on )
local killer_pk, victim_pk
if is_killer_pk_on == 1 then killer_pk = "ON" else killer_pk = "OFF" end
if is_victim_pk_on == 1 then victim_pk = "ON" else victim_pk = "OFF" end
notice( "[DEVELOPMENT_NOTICE] " .. killer .. " just killed " .. victim .. "! " .. killer .. " has PK mode " .. killer_pk .. "! " .. victim .. " has PK mode " .. victim_pk .. "!" )
end
function on_player_update( name )
private_notice("[DEVELOPMENT_NOTICE] on_player_update(" .. name .. ") triggered")
end
-- Being called on leveling up JP
function on_player_level_joblevel_guide()
on_player_joblevel_up(0,0,gv("job_level"))
end
function on_player_joblevel_up( jp_spent, jp_total, current_job_level )
local lv = get_value( "level" )
local job_dp = get_value( "job_depth" )
if job_dp == 0 and lv >= 10 and current_job_level >= 10 then
cprint( "@1200" )
cprint( "@1201" )
elseif lv == 20 then
cprint( "@1202" )
elseif lv == 50 then
cprint( "@1204" )
cprint( "@1205" )
elseif job_dp== 1 and lv >= 50 and current_job_level >= 40 then
cprint( "@1206" )
cprint( "@1207" )
cprint( "@1208" )
elseif lv == 80 then
cprint( "@1209" )
cprint( "@1210" )
elseif lv == 100 then
cprint( "@1211" )
cprint( "@1212" )
end
end
function on_player_level_up()
local lv = get_value( "level" )
local max_reached_level = gv( "max_reached_level" )
local state_code = get_local_info()
local i
for i = max_reached_level + 1 , lv do
if i == 10 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 20 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 30 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 40 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 50 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 60 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 70 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 80 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 90 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 100 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 110 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 120 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 130 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 140 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
elseif i == 150 then
private_notice( sconv( "@690000140" , "#@index_lv@#", i ) )
end
end
if lv == 5 then
if (gv('rx') == nil or gv('rx') == "") and (gv('ry') == nil or gv('ry') == "") then
current_x = get_flag( "rx" )
else
current_x = gv( "rx" )
end
if (gv('rx') == nil or gv('rx') == "") and (gv('ry') == nil or gv('ry') == "") then
set_flag( "rx", 172543 + math.random(0,100))
set_flag( "ry", 51847 + math.random(0,100))
else
sv( "rx", 172543 + math.random(0,100))
sv( "ry", 51847 + math.random(0,100))
end
end
local current_x = gv("x")
local current_y = gv("y")
local race = get_value( "race" )
if lv >= 18 then
if current_x >= 161280 and current_x <= 177408 then
if current_y >= 48384 and current_y <= 64512 then
local is_auto, quest_count
quest_count, is_auto = anti_auto_quest_check()
if is_auto then
if race == 4 then
RunTeleport_Auto_TO_City( 6625 , 6980 )
elseif race == 5 then
RunTeleport_Auto_TO_City( 116799 , 58205 )
else
RunTeleport_Auto_TO_City( 153506 , 77175 )
end
end -- if is_auto then
local current_rx = gv("rx")
local current_ry = gv("ry")
if ( current_rx == nil or current_rx '' ) and ( current_ry == nil or current_ry == '' ) then
sv("rx", get_flag( "rx" ))
sv("ry", get_flag( "ry" ))
end
-- Check if return point is Trainee¡¯s Island
if current_rx == 173183 and current_ry == 52299 then
if race == 4 then
sv( "rx", 6625 + math.random(0,100))
sv( "ry", 6980 + math.random(0,100))
elseif race == 5 then
sv( "rx", 116799 + math.random(0,100))
sv( "ry", 58205 + math.random(0,100))
else
sv( "rx", 153513 + math.random(0,100))
sv( "ry", 77203 + math.random(0,100))
end
-- Sent a message that, because the player is on Trainee¡¯s Island and is level 18 or higher, they are forcibly returned to their race¡¯s village
message( "@235")
end
end -- if current_y >= 48384 and current_y <= 64512 then
end -- if current_x >= 161280 and current_x <= 177408 then
end -- if lv >= 18 then
kick_auto_to_another_world()
local race = get_value( "race" )
on_player_level_joblevel_guide()
if lv > max_reached_level then
update_title_condition( 9002001, lv )
end
end
function auto_star()
local starbuff_flag = get_flag("aSb")
if starbuff_flag == nil or starbuff_flag == '' then starbuff_flag = 1 end
if starbuff_flag == 1 then
add_state(201085,1,1000)
end
end