283 lines
8.7 KiB
Lua
283 lines
8.7 KiB
Lua
function get_module_name()
|
|
return "cube_combiner_contact"
|
|
end
|
|
|
|
function cube_combiner_contact() ---contact_script!
|
|
local npc_name = "@"..get_npc_type().."|@"..get_npc_name()
|
|
dlg_title(npc_name)
|
|
dlg_text( "Welcome to the Cube Combiner!<br>I combine Cube with the same formula as written on the pieces of Cube" )
|
|
dlg_menu( "Combine attack cube", "combine_atk_contact()")
|
|
dlg_menu( "Combat defense Cube", "combine_def_contact()")
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
function combine_atk_contact()
|
|
dlg_title(npc_name)
|
|
dlg_text( "Welcome to the ATK-Cube Combination Menu!" )
|
|
dlg_menu( "Normal Cube", "combine_atk_contact_2(1)")
|
|
dlg_menu( "Improved Cube", "combine_atk_contact_2(2)")
|
|
dlg_menu( "Blessed Cube", "combine_atk_contact_2(3)")
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
function combine_atk_contact_2(typ)
|
|
local types ={"Normal","Improved","Blessed"}
|
|
dlg_title(npc_name)
|
|
dlg_text( "They have "..types[typ].."Cube chosen!<br>Now choose the desired rank!" )
|
|
dlg_menu( "Rank 2", "combine_atk_contact_3("..typ..",2)")
|
|
dlg_menu( "Rank 3", "combine_atk_contact_3("..typ..",3)")
|
|
dlg_menu( "Rank 4", "combine_atk_contact_3("..typ..",4)")
|
|
dlg_menu( "Rank 5", "combine_atk_contact_3("..typ..",5)")
|
|
dlg_menu( "Rank 6", "combine_atk_contact_3("..typ..",6)")
|
|
dlg_menu( "Rank 7", "combine_atk_contact_3("..typ..",7)")
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
function combine_atk_contact_3(typ,rank)
|
|
local stck_array= {701001,701002,701003}
|
|
local mat_1_poss = math.floor(find_item(stck_array[typ])/rank)
|
|
local mat_2_poss = math.floor(find_item(1100103)/(rank*(2^typ)))
|
|
local types ={"Normal","Improved","Blessed"}
|
|
local possis
|
|
if mat_1_poss >= mat_2_poss then
|
|
possis = mat_2_poss
|
|
elseif mat_2_poss >= mat_1_poss then
|
|
possis = mat_1_poss
|
|
end
|
|
|
|
dlg_title(npc_name)
|
|
dlg_text( "You have rank "..rank.." "..types[typ].." Cube chosen!<br>Now select the desired number" )
|
|
if possis >= 1 then
|
|
dlg_menu( "x1", "combine_atk_cubes_"..typ.."("..rank..",1)")
|
|
end
|
|
if possis >= 5 then
|
|
dlg_menu( "x5", "combine_atk_cubes_"..typ.."("..rank..",5)")
|
|
end
|
|
if possis >= 10 then
|
|
dlg_menu( "x10", "combine_atk_cubes_"..typ.."("..rank..",10)")
|
|
end
|
|
if possis >= 20 then
|
|
dlg_menu( "x20", "combine_atk_cubes_"..typ.."("..rank..",20)")
|
|
end
|
|
if possis >= 30 then
|
|
dlg_menu( "x30", "combine_atk_cubes_"..typ.."("..rank..",30)")
|
|
end
|
|
if possis >= 50 then
|
|
dlg_menu( "x50", "combine_atk_cubes_"..typ.."("..rank..",50)")
|
|
end
|
|
if possis >= 100 then
|
|
dlg_menu( "x100", "combine_atk_cubes_"..typ.."("..rank..",100)")
|
|
end
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
function combine_def_contact()
|
|
dlg_title(npc_name)
|
|
dlg_text( "Welcome to the DEF-Cube Combination Menu!" )
|
|
dlg_menu( "Normal Cube", "combine_def_contact_2(1)")
|
|
dlg_menu( "Improved Cube", "combine_def_contact_2(2)")
|
|
dlg_menu( "Blessed Cube", "combine_def_contact_2(3)")
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
function combine_def_contact_2(typ)
|
|
local types ={"Normal","Improved","Blessed"}
|
|
dlg_title(npc_name)
|
|
dlg_text( "They have "..types[typ].."Cube selected! <br> Now choose the desired rank!" )
|
|
dlg_menu( "Rank 2", "combine_def_contact_3("..typ..",2)")
|
|
dlg_menu( "Rank 3", "combine_def_contact_3("..typ..",3)")
|
|
dlg_menu( "Rank 4", "combine_def_contact_3("..typ..",4)")
|
|
dlg_menu( "Rank 5", "combine_def_contact_3("..typ..",5)")
|
|
dlg_menu( "Rank 6", "combine_def_contact_3("..typ..",6)")
|
|
dlg_menu( "Rank 7", "combine_def_contact_3("..typ..",7)")
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
function combine_def_contact_3(typ,rank)
|
|
local stck_array= {702001,702002,702003}
|
|
local mat_1_poss = math.floor(find_item(stck_array[typ])/rank)
|
|
local mat_2_poss = math.floor(find_item(1100103)/(rank*(2^(typ-1))))
|
|
local types ={"Normal","Improved","Blessed"}
|
|
local possis
|
|
if mat_1_poss >= mat_2_poss then
|
|
possis = mat_2_poss
|
|
elseif mat_2_poss >= mat_1_poss then
|
|
possis = mat_1_poss
|
|
end
|
|
|
|
dlg_title(npc_name)
|
|
dlg_text( "You have rank "..rank.." "..types[typ].."Cube selected!<br>Now select the desired number!" )
|
|
if possis >= 1 then
|
|
dlg_menu( "x1", "combine_def_cubes_"..typ.."("..rank..",1)")
|
|
end
|
|
if possis >= 5 then
|
|
dlg_menu( "x5", "combine_def_cubes_"..typ.."("..rank..",5)")
|
|
end
|
|
if possis >= 10 then
|
|
dlg_menu( "x10", "combine_def_cubes_"..typ.."("..rank..",10)")
|
|
end
|
|
if possis >= 20 then
|
|
dlg_menu( "x20", "combine_def_cubes_"..typ.."("..rank..",20)")
|
|
end
|
|
if possis >= 30 then
|
|
dlg_menu( "x30", "combine_def_cubes_"..typ.."("..rank..",30)")
|
|
end
|
|
if possis >= 50 then
|
|
dlg_menu( "x50", "combine_def_cubes_"..typ.."("..rank..",50)")
|
|
end
|
|
if possis >= 100 then
|
|
dlg_menu( "x100", "combine_def_cubes_"..typ.."("..rank..",100)")
|
|
end
|
|
dlg_menu( "@90010002", " " )
|
|
dlg_show()
|
|
end
|
|
|
|
|
|
function combine_atk_cubes_1(rank,amount)
|
|
local mat_1 = find_item(701001) --Cube Chip - Strike
|
|
local mat_2 = find_item(1100103) --Extreme Power
|
|
local output = 0
|
|
local target_cube,i
|
|
if rank == 7 then
|
|
target_cube = 700112
|
|
elseif rank >= 2 and rank <= 6 then
|
|
target_cube = 700100 + rank
|
|
else
|
|
return "Combination Error!"
|
|
end
|
|
for i=1,amount do
|
|
if mat_1 >= rank and mat_2 >= (rank*2) then
|
|
local luck = math.random(1,10)
|
|
delete_item(get_item_handle(701001),rank)
|
|
delete_item(get_item_handle(1100103),rank*2)
|
|
if luck == 1 or luck == 2 then
|
|
else
|
|
output = output + 1
|
|
end
|
|
end
|
|
end
|
|
insert_item(target_cube, output)
|
|
message("You have <b>"..output.." times "..get_item_name_by_code(target_cube).."</b> successfully received!")
|
|
|
|
|
|
end
|
|
|
|
function combine_atk_cubes_2(rank,amount)
|
|
local mat_1 = find_item(701002) --Lucky Cube Chip - Strike
|
|
local mat_2 = find_item(1100103) --Extreme Power
|
|
local output = 0
|
|
local i
|
|
for i=1,amount do
|
|
if mat_1 >= rank and mat_2 >= (rank*4) then
|
|
local luck = math.random(1,10)
|
|
delete_item(get_item_handle(701002),rank)
|
|
delete_item(get_item_handle(1100103),rank*4)
|
|
if luck == 1 or luck == 2 or luck == 3 then
|
|
else
|
|
output = output + 1
|
|
end
|
|
end
|
|
end
|
|
insert_item(700600 + rank, output)
|
|
message("You have <b>"..output.." times "..get_item_name_by_code(700600+rank).."</b> successfully received!")
|
|
|
|
end
|
|
|
|
function combine_atk_cubes_3(rank,amount)
|
|
local mat_1 = find_item(701003) --Fortune Cube Chip - Strike
|
|
local mat_2 = find_item(1100103) --Extreme Power
|
|
local output = 0
|
|
local i
|
|
for i=1,amount do
|
|
if mat_1 >= rank and mat_2 >= (rank*8) then
|
|
local luck = math.random(1,10)
|
|
delete_item(get_item_handle(701003),rank)
|
|
delete_item(get_item_handle(1100103),rank*8)
|
|
if luck == 1 or luck == 2 or luck == 3 or luck == 4 then
|
|
else
|
|
output = output + 1
|
|
end
|
|
end
|
|
end
|
|
insert_item(700650 + rank, output)
|
|
message("You have <b>"..output.." times "..get_item_name_by_code(700650+rank).."</b> successfully received!")
|
|
end
|
|
|
|
|
|
function combine_def_cubes_1(rank,amount)
|
|
local mat_1 = find_item(702001) --Cube Chip - Defense
|
|
local mat_2 = find_item(1100103) --Extreme Power
|
|
local output = 0
|
|
local target_cube,i
|
|
if rank == 7 then
|
|
target_cube = 700212
|
|
elseif rank >= 2 and rank <= 6 then
|
|
target_cube = 700200 + rank
|
|
else
|
|
return "Combination Error!"
|
|
end
|
|
for i=1,amount do
|
|
if mat_1 >= rank and mat_2 >= (rank) then
|
|
local luck = math.random(1,10)
|
|
delete_item(get_item_handle(702001),rank)
|
|
delete_item(get_item_handle(1100103),rank)
|
|
if luck == 1 or luck == 2 then
|
|
else
|
|
output = output + 1
|
|
end
|
|
end
|
|
end
|
|
insert_item(target_cube, output)
|
|
message("You have <b>"..output.." times "..get_item_name_by_code(target_cube).."</b> successfully received!")
|
|
|
|
end
|
|
|
|
function combine_def_cubes_2(rank,amount)
|
|
local mat_1 = find_item(702002) --Lucky Cube Chip - Defense
|
|
local mat_2 = find_item(1100103) --Extreme Power
|
|
local output = 0
|
|
local i
|
|
for i=1,amount do
|
|
if mat_1 >= rank and mat_2 >= (rank*2) then
|
|
local luck = math.random(1,10)
|
|
delete_item(get_item_handle(702002),rank)
|
|
delete_item(get_item_handle(1100103),rank*2)
|
|
if luck == 1 or luck == 2 or luck == 3 then
|
|
else
|
|
output = output + 1
|
|
end
|
|
end
|
|
end
|
|
insert_item(700700 + rank, output)
|
|
message("You have <b>"..output.." times "..get_item_name_by_code(700700+rank).."</b> successfully received!")
|
|
|
|
end
|
|
|
|
function combine_def_cubes_3(rank,amount)
|
|
|
|
local mat_1 = find_item(702003) --Fortune Cube Chip - Defense
|
|
local mat_2 = find_item(1100103) --Extreme Power
|
|
local output = 0
|
|
local i
|
|
for i=1,amount do
|
|
if mat_1 >= rank and mat_2 >= (rank*4) then
|
|
local luck = math.random(1,10)
|
|
delete_item(get_item_handle(702003),rank)
|
|
delete_item(get_item_handle(1100103),rank*4)
|
|
if luck == 1 or luck == 2 or luck == 3 or luck == 4 then
|
|
else
|
|
output = output + 1
|
|
end
|
|
end
|
|
end
|
|
insert_item(700750 + rank, output)
|
|
message("You have <b>"..output.." times "..get_item_name_by_code(700750+rank).."</b> successfully received!")
|
|
|
|
|
|
end |