📄 forge.lua
字号:
----宝石合成
---检测是否能够合成
function can_unite_item (...)
-- Notice("Starts to determine")
if arg.n ~= 12 then
-- Notice("parameter value illegal"..arg.n)
return 0
end
local kkk = 0
-- for kkk = 2 , arg.n ,1 do
-- SystemNotice ( arg[1] , arg[kkk])
-- end
local Check = 0
-- SystemNotice( arg[1] , "transfer combine test main function")
Check = can_unite_item_main ( arg )
if Check == 1 then
-- SystemNotice (arg[1] , "Return 1 ")
return 1
else
-- SystemNotice (arg[1] , "Return 0 ")
return 0
end
end
--检测是否可以合成主函数
function can_unite_item_main ( Table )
-- SystemNotice ( Table[1] , "Entering combining main function")
local role = 0
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
local Get_Count = 4
local ItemReadCount = 0
local ItemReadNow = 1
local ItemReadNext = 0
local ItemBag_Now = 0
local ItemCount_Now = 0
local ItemBagCount_Num = 0
-- SystemNotice( arg[1] , "start transfer parameter analysis")
role , ItemBag , ItemCount , ItemBagCount , ItemBag_Now , ItemCount_Now , ItemBagCount_Num = Read_Table ( Table )
-- for kkk = 0 , 2 , 1 do
-- SystemNotice ( role , ItemBagCount[kkk])
-- SystemNotice ( role , ItemBag[kkk])
-- SystemNotice ( role , ItemCount[kkk])
-- end
-- Notice(role , "11111")
local i = 0
for i = 0 , 2 , 1 do --判断道具对象个数和道具个数是否和法
if ItemBagCount[i] ~= 1 or ItemCount[i] ~= 1 then
-- SystemNotice( role , "ItemBagCount[i] = "..ItemBagCount[i])
-- SystemNotice( role , "ItemCount[i] = "..ItemCount[i])
SystemNotice( role , "Item target unit and item unit illegal")
return 0
end
end
local BagItem1 = ItemBag [0]
local BagItem2 = ItemBag [1]
local BagItem3 = ItemBag [2]
local Item1 = GetChaItem ( role , 2 , BagItem1 ) --取道具指针
local Item2 = GetChaItem ( role , 2 , BagItem2 )
local Item3 = GetChaItem ( role , 2 , BagItem3 )
local ItemID1 = GetItemID ( Item1 ) --取道具编号
local ItemID2 = GetItemID ( Item2 )
local ItemID3 = GetItemID ( Item3 )
local ItemType1 = GetItemType ( Item1 )
local ItemType2 = GetItemType ( Item2 )
local ItemType3 = GetItemType ( Item3 )
if ItemType1 ~= 47 then --判断卷轴是否正确
SystemNotice( role ,"This is not a combining scroll")
return 0
end
if ItemType2 ~= 49 or ItemType3 ~= 49 then --判断是否是宝石
if ItemType2 ~= 50 or ItemType3 ~= 50 then
SystemNotice( role , "This is not a Gem")
return 0
end
end
if ItemID2 ~= ItemID3 then --判断两个宝石是否同类
SystemNotice(role ,"Gem mismatch")
return 0
end
local Item2_Lv = Get_StoneLv ( Item2 ) --取宝石等级
local Item3_Lv = Get_StoneLv ( Item3 )
if ItemType2 == 49 and ItemType3 == 49 then
if Item2_Lv >= 9 or Item3_Lv >= 9 then
SystemNotice ( role , "Gem Lv max")
return 0
end
end
if Item2_Lv ~= Item3_Lv then
SystemNotice(role ,"Level of 2 gems does not match")
return 0
end
-- SystemNotice ( role , "determination successful")
local Money_Need = getunite_money_main ( Table )
local Money_Have = GetChaAttr ( role , ATTR_GD )
if Money_Need > Money_Have then
SystemNotice( role ,"Insufficient gold. Unable to combine")
return 0
end
return 1
end
--开始合成
function begin_unite_item (...)
-- Notice("Start Combining")
local Check_CanUnite = 0
-- SystemNotice ( arg[1] , "transfer detect can it be combined into main function")
Check_CanUnite = can_unite_item_main ( arg )
if Check_CanUnite == 0 then
return 0
end
local role = 0
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
local Get_Count = 4
local ItemReadCount = 0
local ItemReadNow = 1
local ItemReadNext = 0
local ItemBag_Now = 0
local ItemCount_Now = 0
local ItemBagCount_Num = 0
role , ItemBag , ItemCount , ItemBagCount , ItemBag_Now , ItemCount_Now , ItemBagCount_Num = Read_Table ( arg )
local BagItem1 = ItemBag [0]
local BagItem2 = ItemBag [1]
local BagItem3 = ItemBag [2]
local BagItem1 = arg [3] --取道具背包位置
local BagItem2 = arg [6]
local BagItem3 = arg [9]
local Item1 = GetChaItem ( role , 2 , BagItem1 ) --取道具指针
local Item2 = GetChaItem ( role , 2 , BagItem2 )
local Item3 = GetChaItem ( role , 2 , BagItem3 )
local ItemID1 = GetItemID ( Item1 ) --取道具编号
local ItemID2 = GetItemID ( Item2 )
local ItemID3 = GetItemID ( Item3 )
local ItemType2 = GetItemType ( Item2 )
local Item2_Lv = Get_StoneLv ( Item2 ) --取宝石等级
local Item3_Lv = Get_StoneLv ( Item3 )
local i = 0
local j = 0
i = RemoveChaItem ( role , ItemID1 , 1 , 2 , BagItem1 , 2 , 1 , 0) --移除卷轴
j = RemoveChaItem ( role , ItemID3 , 1 , 2 , BagItem3 , 2 , 1 , 0) --移除一颗宝石
if i == 0 or j == 0 then
LG( "Hecheng_BS" , "Delete item failed" )
end
Item2_Lv =Item2_Lv + 1
Set_StoneLv ( Item2 , Item2_Lv )
local Money_Need = getunite_money_main ( arg )
local Money_Have = GetChaAttr ( role , ATTR_GD )
-- Notice ("Currently there are"..Money_Have.."So much gold")
-- Notice ("Must deduct"..Money_Need.."So much gold")
Money_Have = Money_Have - Money_Need
SetCharaAttr ( Money_Have , role , ATTR_GD )
ALLExAttrSet( role )
local Sklv = 1
local StateLv = GetChaStateLv ( role , STATE_HCGLJB )
Sklv = Sklv + StateLv
local b = Check_CG_HechengBS ( Item2_Lv , ItemType2 , Sklv )
if b == 0 then
i = RemoveChaItem ( role , ItemID2 , 1 , 2 , BagItem2 , 2 , 1 , 0) --移除宝石
if i == 0 then
LG( "Hecheng_BS" , "Delete item failed" )
end
local cha_name = GetChaDefaultName ( role )
LG( "JingLian_ShiBai" , "Player"..cha_name.."Gem combining failed" )
SystemNotice( role , "Very sorry, combining has failed. Gem has vanished…")
return 0 --// Changed Combining Rate - MoMo
end
local cha_name = GetChaDefaultName ( role )
LG( "JingLian_ShiBai" , "Player"..cha_name.."Gem combining successful" )
return 1
end
--计算需要金钱
function get_item_unite_money (...)
-- SystemNotice ( arg[1] , "starts to calculate money" )
local Money = getunite_money_main ( arg )
-- SystemNotice ( arg[1] , "Calculation completed"..Money )
return 0
end
--计算需要金钱主函数
function getunite_money_main ( Table )
-- SystemNotice ( Table[1] , "starts to count money" )
return 50000
end
--精炼
--判断是否能够精炼
function can_forge_item(...)
-- Notice ( "Determin if it can be forged")
if arg.n ~= 12 then
SystemNotice ( arg[1] , "parameter value illegal"..arg.n )
return 0
end
-- local kkk = 0
-- for kkk = 2 , arg.n ,1 do
-- SystemNotice ( arg[1] , arg[kkk])
-- end
local Check = 0
Check = can_forge_item_main ( arg )
if Check == 1 then
return 1
else
return 0
end
end
--检测是否可以精炼主函数
function can_forge_item_main ( Table )
local role = 0
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
local Get_Count = 4
local ItemReadCount = 0
local ItemReadNow = 1
local ItemReadNext = 0
local ItemBag_Now = 0
local ItemCount_Now = 0
local ItemBagCount_Num = 0
role , ItemBag , ItemCount , ItemBagCount , ItemBag_Now , ItemCount_Now , ItemBagCount_Num = Read_Table ( Table )
local ItemBagCount_Jinglian = ItemBagCount [0]
local ItemBag_Jinglian = ItemBag [0]
local ItemNum_Jinglian = ItemCount [0]
local Item_Jinglian = GetChaItem ( role , 2 , ItemBag_Jinglian )
local Check = 0
if ItemBagCount_Jinglian ~= 1 then
SystemNotice( role , "Forging item related slot illegal")
return 0
end
if ItemNum_Jinglian ~= 1 then
SystemNotice( role , "Forging item quantity illegal")
return 0
end
Check = CheckItem_CanJinglian ( Item_Jinglian )
if Check == 0 then
SystemNotice( role ,"Item cannot be forged")
return 0
end
if ItemCount [1] ~= 1 or ItemCount [2] ~= 1 or ItemBagCount [1] ~= 1 or ItemBagCount [2] ~= 1 then
SystemNotice ( role ,"Illegal Gem quantity")
return 0
end
local Item_Stone1 = GetChaItem ( role , 2 , ItemBag [1] )
local Item_Stone2 = GetChaItem ( role , 2 , ItemBag [2] )
local Check_Hole = 0
Check_Hole = CheckItem_HaveHole ( Item_Jinglian , Item_Stone1 , Item_Stone2)
if Check_Hole == 0 then
SystemNotice( role ,"Does not have enough socket to forge" )
return 0
end
local Check_Stone = 0
Check_Stone = Check_StoneLv ( Item_Jinglian , Item_Stone1 , Item_Stone2 )
if Check_Stone == 0 then
SystemNotice ( role , "Gem or Refining Gem level does not match" )
return 0
end
local Check_StoneItem = 0
Check_StoneItem = Check_StoneItemType ( Item_Jinglian , Item_Stone1 , Item_Stone2 )
if Check_StoneItem == 0 then
SystemNotice ( role , "Gem and forging item does not match" )
return 0
end
local Money_Need = getforge_money_main ( Table )
local Money_Have = GetChaAttr ( role , ATTR_GD )
if Money_Need > Money_Have then
SystemNotice( role ,"Insufficient Gold. Unable to forge.")
return 0
end
--SystemNotice(role ,"determination completed ")
return 1
end
--开始精炼
function begin_forge_item(...)
-- Notice("Start to forge")
local Check_CanForge = 0
Check_CanForge = can_forge_item_main ( arg )
if Check_CanForge == 0 then
return 0
end
local role = 0
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
local Get_Count = 4
local ItemReadCount = 0
local ItemReadNow = 1
local ItemReadNext = 0
local ItemBag_Num = 0
local ItemCount_Num = 0
local ItemBagCount_Num = 0
role , ItemBag , ItemCount , ItemBagCount , ItemBag_Num , ItemCount_Num , ItemBagCount_Num = Read_Table ( arg )
local ItemBag_Jinglian = ItemBag [0]
local Item_Jinglian = GetChaItem ( role , 2 , ItemBag_Jinglian )
local Item_Stone1 = GetChaItem ( role , 2 , ItemBag [1] )
local Item_Stone2 = GetChaItem ( role , 2 , ItemBag [2] )
local Check_Jinglian_Item = 0
local Money_Need = getforge_money_main ( arg )
local Money_Have = GetChaAttr ( role , ATTR_GD )
-- Notice ("Currently there are"..Money_Have.."So much gold")
-- Notice ("Must deduct"..Money_Need.."So much gold")
Money_Have = Money_Have - Money_Need
SetCharaAttr ( Money_Have , role , ATTR_GD )
ALLExAttrSet( role )
local ItemID_Jinglian = GetItemID ( Item_Jinglian )
----------------
local Jinglian_Lv_Now = GetItem_JinglianLv ( Item_Jinglian )
----------------
local Num = GetItemForgeParam ( Item_Jinglian , 1 )
Num = TansferNum ( Num )
local Stone1Type = GetItemType ( Item_Stone1 )
local Stone2Type = GetItemType ( Item_Stone2 )
local Baoshi = 0
if Stone1Type == 49 then
Baoshi = Item_Stone1
elseif Stone2Type == 49 then
Baoshi = Item_Stone2
end
local Item_Stone = {}
local Item_StoneLv = {}
local Baoshi_NeedLv = 1
Item_Stone[0] = GetNum_Part2 ( Num )
Item_Stone[1] = GetNum_Part4 ( Num )
Item_Stone[2] = GetNum_Part6 ( Num )
Item_StoneLv[0] = GetNum_Part3 ( Num )
Item_StoneLv[1] = GetNum_Part5 ( Num )
Item_StoneLv[2] = GetNum_Part7 ( Num )
BaoshiType = GetStone_TypeID ( Baoshi )
for i = 0 , 2 ,1 do
if BaoshiType == Item_Stone[i] then
Baoshi_NeedLv = Item_StoneLv[i] + 1
end
end
----------------
local Sklv = 1
local StateLv = GetChaStateLv ( role , STATE_JLGLJB )
Sklv = Sklv + StateLv
local Check_A = math.max ( 0.02 , math.min ( 1 , ( 1 - Baoshi_NeedLv * 0.1 + Sklv * 0.15 - 0.3 ) ) )
local CheckFaild = Percentage_Random ( Check_A )
if Baoshi_NeedLv < 9 then --// changed forge level check -MoMo
CheckFaild = 1
end
if CheckFaild == 1 then
Check_Jinglian_Item = Jinglian_Item ( Item_Jinglian , Item_Stone1 , Item_Stone2 )
else
local cha_name = GetChaDefaultName ( role )
local Item_Jinglian_name = GetItemName ( ItemID_Jinglian )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -