📄 forge.lua
字号:
LG( "JingLian_ShiBai" , "Player"..cha_name.."Forging of equipment failed. Equipment is not damaged"..Item_Jinglian_name )
SystemNotice ( role , "Sorry, forging has failed. Luckily equipment is not damage" )
end
------------------
local ItemID_Stone1 = GetItemID ( Item_Stone1 )
local ItemID_Stone2 = GetItemID ( Item_Stone2 )
local Stone1_Lv = Get_StoneLv ( Item_Stone1 )
local Stone2_Lv = Get_StoneLv ( Item_Stone2 )
local Jinglianshi_Lv = 0
if Stone1_Lv > Stone2_Lv then
Jinglianshi_Lv = Stone1_Lv
else
Jinglianshi_Lv = Stone2_Lv
end
local Jinglian_Lv = GetItem_JinglianLv ( Item_Jinglian )
local R1 = 0
local R2 = 0
R1 = RemoveChaItem ( role , ItemID_Stone1 , 1 , 2 , ItemBag [1] , 2 , 1 , 0 ) --移除宝石1
R2 = RemoveChaItem ( role , ItemID_Stone2 , 1 , 2 , ItemBag [2] , 2 , 1 , 0 ) --移除宝石2
if R1 == 0 or R2 == 0 then
LG( "Jinglian" , "Gem deletion failed" )
end
if CheckFaild == 0 then
return 2
end
check_item_final_data ( Item_Jinglian )
-- SystemNotice(role , "Return failed")
-- local a = 0.75
local b = Check_CG_Jinglian ( Jinglian_Lv , Jinglianshi_Lv , Sklv )
if b == 0 then
i = RemoveChaItem ( role , ItemID_Jinglian , 1 , 2 , ItemBag [0] , 2 , 1 , 0) --移除宝石
if i == 0 then
LG( "Hecheng_BS" , "Delete item failed" )
end
local cha_name = GetChaDefaultName ( role )
local Item_Jinglian_name = GetItemName ( ItemID_Jinglian )
LG( "JingLian_ShiBai" , "Player"..cha_name.."Forging of equipment failed"..Item_Jinglian_name )
SystemNotice( role , "Very sorry! Forging has failed. Item was destroyed…")
return 2
end
-- Notice("Forging completed")
local cha_name = GetChaDefaultName ( role )
local Item_Jinglian_name = GetItemName ( ItemID_Jinglian )
LG( "JingLian_ShiBai" , "Player"..cha_name.."Forging successful"..Item_Jinglian_name )
return 1
end
--计算精炼费用
function get_item_forge_money(...)
-- Notice("Fee calculation")
local Money = getforge_money_main ( arg )
return Money
end
--计算精练费用主函数
function getforge_money_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_Num = 0
local ItemCount_Num = 0
local ItemBagCount_Num = 0
role , ItemBag , ItemCount , ItemBagCount , ItemBag_Num , ItemCount_Num , ItemBagCount_Num = Read_Table ( Table )
local ItemBag_Jinglian = ItemBag [0]
local Item_Jinglian = GetChaItem ( role , 2 , ItemBag_Jinglian )
local Jinglian_Lv = 0
Jinglian_Lv = GetItem_JinglianLv ( Item_Jinglian )
Jinglian_Lv = Jinglian_Lv + 1
local Money_Need = Jinglian_Lv * 100000
-- Notice("Calculation completed")
return Money_Need
end
----相关函数--------------------------------------------------------------------------------------------------------
function Get_StoneLv ( Item ) --读取宝石等级
local Lv = GetItemAttr ( Item , ITEMATTR_VAL_BaoshiLV )
return Lv
end
function Set_StoneLv ( Item , Item_Lv ) --设置宝石等级
local i = 0
i = SetItemAttr ( Item , ITEMATTR_VAL_BaoshiLV , Item_Lv )
if i == 0 then
LG( "Hecheng_BS","Failed to set gem level" )
end
end
--检查装备是否可被精炼
function CheckItem_CanJinglian ( Item )
-- Notice ("CheckItem_CanJinglian ")
local Item_Type = GetItemType ( Item )
local i = 0
for i = 0 , Item_CanJinglian_Num , 1 do
if Item_Type == Item_CanJinglian_ID [i] then
return 1
end
end
return 0
end
---检查是否有足够的洞精炼
function CheckItem_HaveHole ( Item , Stone1 , Stone2)
-- Notice ("CheckItem_HaveHole")
local Num = GetItemForgeParam ( Item , 1 )
Num = TansferNum ( Num )
local Hole = GetNum_Part1 ( Num )
local Item_Stone = {}
local Stone1TypeID = 0
local Stone2TypeID = 0
Item_Stone[0] = GetNum_Part2 ( Num )
Item_Stone[1] = GetNum_Part4 ( Num )
Item_Stone[2] = GetNum_Part6 ( Num )
local i = 0
local Hole_empty = 0
for i = 0 , 2 , 1 do
if Item_Stone[i] == 0 then
Hole_empty = Hole_empty + 1
end
Stone1TypeID = GetStone_TypeID ( Stone1 )
Stone2TypeID = GetStone_TypeID ( Stone2 )
if Item_Stone[i] == Stone1TypeID or Item_Stone[i] == Stone2TypeID then
return 1
end
end
local Hole_Used = 3 - Hole_empty
if Hole_Used >= Hole then
return 0
else
return 1
end
end
--检查宝石等级是否足够
function Check_StoneLv ( Item , Stone1 , Stone2 )
-- Notice ("Check_StoneLv")
local Num = GetItemForgeParam ( Item , 1 )
Num = TansferNum ( Num )
-- Notice ( Num )
local Jinglian_Lv = GetItem_JinglianLv ( Item )
-- Notice ( Jinglian_Lv )
local Stone1Type = GetItemType ( Stone1 )
local Stone2Type = GetItemType ( Stone2 )
-- Notice (Stone1Type)
-- Notice (Stone2Type)
local Jinglianshi = 0
local Jinglianshi_Lv = 0
local Baoshi = 0
local Baoshi_Lv = 0
local Baoshi_NeedLv = 0
if Stone1Type == 50 then
Jinglianshi = Stone1
elseif Stone2Type == 50 then
Jinglianshi = Stone2
end
if Stone1Type == 49 then
Baoshi = Stone1
elseif Stone2Type == 49 then
Baoshi = Stone2
end
Jinglianshi_Lv = Get_StoneLv ( Jinglianshi )
Baoshi_Lv = Get_StoneLv ( Baoshi )
-- Notice("Jinglianshi_Lv= "..Jinglianshi_Lv)
-- Notice("Baoshi_Lv= "..Baoshi_Lv)
local Item_Stone = {}
local Item_StoneLv = {}
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 )
-- Notice("BaoshiType= "..BaoshiType)
local i = 0
for i = 0 , 2 ,1 do
if BaoshiType == Item_Stone[i] then
Baoshi_NeedLv = Item_StoneLv[i] + 1
end
end
local Jinglianshi_NeedLv = Baoshi_NeedLv
if Baoshi_Lv < Baoshi_NeedLv then
-- Notice("Gem Lv too low")
return 0
end
if Jinglianshi_Lv < Jinglianshi_NeedLv then
-- Notice("Refining Gem level does not match")
return 0
end
-- Notice("Return successful")
return 1
end
---开始精炼
function Jinglian_Item ( Item , Stone1 , Stone2 )
-- Notice("Jinglian_Item")
local Num = GetItemForgeParam ( Item , 1 )
Num = TansferNum ( Num )
local Jinglian_Lv = GetItem_JinglianLv ( Item )
local Stone1Type = GetItemType ( Stone1 )
local Stone2Type = GetItemType ( Stone2 )
local Baoshi = 0
local Num_New = Num
if Stone1Type == 49 then
Baoshi = Stone1
elseif Stone2Type == 49 then
Baoshi = Stone2
end
Num_New = SetJinglian_Lv ( Baoshi , Baoshi_Lv , Num )
-- Notice(Num_New)
local i = 0
i = SetItemForgeParam ( Item , 1 , Num_New )
if i == 0 then
LG( "Jinglian" , "set forging content failed" )
end
local Item_URE_Add = 0
local Item_MAXURE = GetItemAttr ( Item , ITEMATTR_MAXURE )
if Item_MAXURE < 600 then
Item_MAXURE = math.min ( ( Item_MAXURE + Item_URE_Add ) , 600 )
end
local j = 0
j = SetItemAttr ( Item , ITEMATTR_MAXURE , Item_MAXURE )
if j == 0 then
LG( "Jinglian" , "Forge setting maximum durability failed")
end
if Num_New == Num then
-- Notice("Set content has not been changed")
end
return 1
end
--设置武器上宝石的属性
function SetJinglian_Lv ( Baoshi , Baoshi_Lv , Num )
-- Notice ("SetJinglian_Lv")
-- Notice (Num)
local Baoshi_Lv = 0
Baoshi_Lv = Get_StoneLv ( Baoshi )
local Item_Stone = {}
local Item_StoneLv = {}
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 )
-- Notice("BaoshiType= "..BaoshiType)
local i = 0
local Stone_Check = 0
for i = 0 , 2 , 1 do
if BaoshiType == Item_Stone [i] then
Item_StoneLv [i] = Item_StoneLv [i] + 1
Stone_Check = i + 1
end
end
if Stone_Check == 1 then
Num = SetNum_Part3 ( Num , Item_StoneLv[0] )
elseif Stone_Check == 2 then
Num = SetNum_Part5 ( Num , Item_StoneLv[1] )
elseif Stone_Check == 3 then
Num = SetNum_Part7 ( Num , Item_StoneLv[2] )
elseif Stone_Check == 0 then
local Check_empty = 0
for i = 2 , 0 , -1 do
if Item_Stone[i] == 0 then
Check_empty = i + 1
end
end
if Check_empty == 1 then
Num = SetNum_Part2 ( Num , BaoshiType )
Num = SetNum_Part3 ( Num , 1 )
elseif Check_empty == 2 then
Num = SetNum_Part4 ( Num , BaoshiType )
Num = SetNum_Part5 ( Num , 1 )
elseif Check_empty == 3 then
Num = SetNum_Part6 ( Num , BaoshiType )
Num = SetNum_Part7 ( Num , 1 )
end
end
-- Notice("SetJinglian_Lv ended")
return Num
end
--取宝石类型ID
function GetStone_TypeID ( Stone )
-- Notice ("GetStone_TypeID")
local StoneID = GetItemID ( Stone )
local i = 0
for i = 1 , StoneTpye_ID_Num , 1 do
-- Notice ( StoneTpye_ID[i] )
if StoneTpye_ID[i] == StoneID then
return i
end
end
return -1
end
----变参内容解析
function Read_Table ( Table )
-- Notice("Read_Table")
local role = Table [1] --角色
-- Notice(role)
-- Notice(Table.n)
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
local Get_Count = 4
local ItemReadCount = 0
local ItemReadNow = 2
local ItemReadNext = 0
local ItemBag_Now = 0
local ItemCount_Now = 0
local ItemBagCount_New = 0
local i = 0
local j = 0
for i = 0 , Get_Count , 1 do
if ItemReadNow <= Table.n then
ItemBagCount [i] = Table [ItemReadNow]
-- SystemNotice ( role , "aaa "..ItemBagCount [i] )
ItemBagCount_New = ItemBagCount_New + 1
-- Notice("ItemBagCount= "..ItemBagCount [i])
ItemReadNow = ItemReadNow + 1
ItemReadNext = ItemReadNow + 2 * ( ItemBagCount [i] - 1 )
ItemReadCount = ItemReadNow
if ItemBagCount [i] ~= 0 then
for j = ItemReadCount , ItemReadNext , 2 do
ItemBag [ItemBag_Now] = Table [j]
-- SystemNotice(role , "aaa "..ItemBag [ItemBag_Now])
-- Notice("ItemBag= "..ItemBag [ItemBag_Now])
ItemBag_Now = ItemBag_Now + 1
ItemCount [ItemCount_Now] = Table [ j+1 ]
-- SystemNotice(role , "aaa "..ItemCount[ItemCount_Now])
-- Notice("ItemCount= "..ItemCount [ItemCount_Now])
ItemCount_Now = ItemCount_Now + 1
ItemReadNow = ItemReadNow + 2
end
end
else
ItemBagCount [i] = 0
-- SystemNotice ( role , "aaa "..ItemBagCount [i] )
-- Notice(ItemBagCount [i])
end
end
-- Notice("1111")
return role , ItemBag , ItemCount , ItemBagCount , ItemBag_Now , ItemCount_Now , ItemBagCount_New
end
--道具精炼属性重算
function check_item_final_data ( Item )
local Item_TypeCheck = GetItemType ( Item )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -