Files
2026-06-01 12:46:52 +02:00

232 lines
5.2 KiB
Lua

-- fTameProbability = pMonster->GetTamePercetage();
-- fTameProbability *= ( pSkill->GetVar( 0 ) * pMonster->GetTamingSkillLevel() + pSkill->GetVar( 1 ) * pSkill->GetEnhance() + 1 ) * 100;
--( fTameProbability.get() < static_cast< int >( XRandom( 1, 1000000 ) ) )
function tame()
texte_tab = {"Id = " , "TameCode = ", "name = " ,"TameItemCode = " ,"TamePercetage = " }
info = get_monster_info()
--for i = 1 , table.getn(info) do
--cprint(texte_tab[i] .. info[i])
--end
if info == 0 then
cprint("No Monster Target")
return
end
chance = info[5]
emblem = 0
if get_wear_item_handle( 25 ) > 0 then
emblem = 0.01
end
bonus_tame = 0.02 -- 0.02 2% base
chance = chance * ( 0.06 * get_cur_skill_level(4003) + 0.03 * get_cur_skill_enchant(4003) + 1 ) + emblem + bonus_tame
--cprint("chance de tame = " .. math.floor(chance*100) .. "%" )
trigger1 = 'taming_count()'
text = sconv("<size:10><b>%a : %b <br>%c" ,"%a" , "@1853" , "%b" , "@"..info[3] ,"%c" , "@1584" , "#@value@#" , math.floor(chance*100) )
--1853 Name
--1584 Chances de succès #@value@#%
dlg_special( 'confirm_window', trigger1 , text )
end
function taming_count()
text = sconv("<size:10><b>%a" ,"%a" , "@906" )
--basic 99 906 Sélectionner une quantité.
info = get_monster_info()
handle = 0
handlelist = get_item_handle_list(tonumber(info[4]) )
for i = 1 , table.getn(handlelist ) do
if get_item_flag(handlelist[i],31) == 0 then
handle = handlelist[i]
end
end
if handle == 0 then private_notice("no card for tame") return end
item_cnt = get_item_count(handle)
menu1 = '<size:10><b>1'
menu2 = '<size:10><b>5'
menu3 = '<size:10><b>10'
menu4 = '<size:10><b>All ('.. item_cnt ..')'
trigger1 = 'taming_use_ba( 1, '.. handle.. ')'
trigger2 = 'taming_use_ba( 5, '.. handle.. ')'
trigger3 = 'taming_use_ba( 10, '.. handle.. ')'
if item_cnt > 100 then
trigger4 = 'taming_use_ba(100, '.. handle.. ')'
else
trigger4 = 'taming_use_ba('.. item_cnt ..', '.. handle.. ')'
end
dlg_special_menu( text , 'Warp', menu1, trigger1, menu2, trigger2, menu3, trigger3, menu4, trigger4)
end
function taming_use_ba( count , handle )
text = sconv("<size:10><b>%a" ,"%a" , "@6424" , "#@item_name@#" , "@" .. get_item_name_id (960021) )
--<size:13>Utiliser BA ?
info = get_monster_info()
menu1 = '@21' --<size:10><b>yes
menu2 = '@22' -- <size:10><b>No
trigger1 = 'taming_question( '.. count ..' ,'.. handle.. ', "yes")'
trigger2 = 'taming_question( '.. count ..' ,'.. handle.. ', "no")'
if find_item(960021) >= 1 then
dlg_special_menu( text , 'Warp', menu1, trigger1, menu2, trigger2)
else
taming_question(count, handle , "no" )
end
end
function taming_question(count, handle , ba )
info = get_monster_info()
chance = info[5]
emblem = 0
if get_wear_item_handle( 25 ) > 0 then
emblem = 0.01
end
bonus_tame = 0.02
chance = chance * ( 0.06 * get_cur_skill_level(4003) + 0.03 * get_cur_skill_enchant(4003) + 1 ) + emblem + bonus_tame
--cprint("chance de tame = " .. math.floor(chance*100) .. "%" )
text = sconv("<size:13><br>%a : %b x%c<br>%d <br>%e = %f" ,"%a" , "@1853" , "%b" , "@"..info[3] ,"%c" , count ,"%d" , "@1584" , "#@value@#" , math.floor(chance*100) ,"%e" , "@" .. get_item_name_id (960021) , "%f" , ba )
--basic 0 2101000052 <size:13><br>Tamé = %s (%1%)<br> Count = %2 <br>Ba = %3
dlg_special( 'confirm_window', 'taming_confirm('.. count ..' ,'.. handle.. ' , "'.. ba ..'" )', text )
end
function taming_confirm(count, handle ,ba)
--cprint("taming_confirm = ")
info = get_monster_info()
--message("Tame = " .. info[3])
--message("Count = " .. count)
--message("Ba = " .. ba)
chance = info[5]
emblem = 0
if get_wear_item_handle( 25 ) > 0 then
emblem = 0.01
end
bonus_tame = 0.02
chance = chance * ( 0.06 * get_cur_skill_level(4003) + 0.03 * get_cur_skill_enchant(4003) + 1 ) + emblem + bonus_tame
rem = 0
success = 0
for i = 1 , count do
if ba == "yes" and find_item(960021) < 1 then
private_notice("No More BA")
break
end
if get_item_count(handle) < 1 then
private_notice("No More Card")
break
end
if ba == "yes" then
delete_item(get_item_handle(960021) , 1)
else
delete_item( handle , 1)
end
rem = rem + 1
if math.random() < chance then
delete_item( handle , 1)
success = success + 1
handle_sum = insert_summon_by_monster_id(info[1] , gv("name") )
end
end
if ba == "yes" then
cprint(rip("<#F78181><b>") .. rip("@930126") .. rip(" " .. rem .." ") .. rip("@" .. get_item_name_id (960021) ) .. rip_end())
else
cprint(rip("<#F78181><b>") .. rip("@930126") .. rip(" " .. count .." ") .. rip("@" .. get_item_name_id (info[4]) ) .. rip_end())
end
if handle_sum >= 0 then
info = get_monster_info()
name_monster = "@"..info[3]
--message(rip("<#58ACFA><bold>") .. rip("@930218") .. rip(" x" .. success .. " " .. get_item_name(handle_sum) .. " Apprivoisé") .. rip_end())
--message(rip("<#58ACFA><bold>") .. rip("@930218") .. rip(" x" .. success .. " " .. get_item_name(handle_sum) .. " Apprivoisé") .. rip_end())
cprint(sconv("<#58ACFA><bold>%a x%x" ,"%a" , "@328" , "#@creature_name@#" , name_monster , "%x" , success ) )
end
end
function XRandom( min , max )
if ( min == max ) then return min end
if( min > max ) then
temp = min
min = max
max = temp
end
rdm = ( math.random() % (max-min+1) + min )
cprint(rdm)
return rdm
end