📄 forge.lua
字号:
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
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 )
--------道具数量判断
if ItemCount [1] ~= 1 or ItemCount [2] ~= 1 or ItemBagCount [1] ~= 1 or ItemBagCount [2] ~= 1 then
SystemNotice ( role ,"equipment quantity illegal ")
return 0
end
--------取出道具指针
local Item_Juanzhou = GetChaItem ( role , 2 , ItemBag [0] ) --卷轴指针
local Item_Waiguan = GetChaItem ( role , 2 , ItemBag [1] ) --外观道具指针
local Item_Shuxing = GetChaItem ( role , 2 , ItemBag [2] ) --属性道具指针
--------卷轴类型判断
local ItemType_Juanzhou = GetItemType ( Item_Juanzhou )
if ItemType_Juanzhou ~= 60 then
SystemNotice( role ,"Scroll usage error")
return 0
end
--------外观道具ID判断
local ItemID_Waiguan = GetItemID ( Item_Waiguan )
if ItemID_Waiguan <= 4999 or ItemID_Waiguan >= 6000 then
SystemNotice( role ,"Item cannot determined attribute")
return 0
end
--------外观道具耐久判断
local Item_URE = GetItemAttr ( Item_Waiguan , ITEMATTR_URE )
local Item_MAXENERGY = GetItemAttr ( Item_Waiguan , ITEMATTR_MAXENERGY )
if Item_URE < Item_MAXENERGY then
SystemNotice( role ,"Armors have not reach the durability limit, cannot assign attribute")
return 0
end
--------最初外观道具判断
local Item_FUSIONID_star = GetItemAttr ( Item_Shuxing , ITEMATTR_VAL_FUSIONID )
local ItemID_shuxing_star = GetItemID ( Item_Shuxing )
if Item_FUSIONID_star ==0 and ItemID_shuxing_star>=5000 then
SystemNotice( role ,"Equipment on right slot has not attribute. Unable to fuse!")
return 0
end
--------属性道具类型判断
local ItemType_Shuxing = GetItemType (Item_Shuxing)
if ItemType_Shuxing < 1 then
SystemNotice( role ," Current item stats cannot be transfer to another item")
return 0
elseif ItemType_Shuxing > 11 and ItemType_Shuxing < 20 then
SystemNotice( role ," Current item stats cannot be transfer to another item")
return 0
elseif ItemType_Shuxing > 24 and ItemType_Shuxing ~= 27 then
SystemNotice( role ," Current item stats cannot be transfer to another item")
return 0
end
--------外观和属性道具是否为同一类型
local ItemType_Shuxing = GetItemType ( Item_Shuxing )
local ItemType_Waiguan = GetItemType ( Item_Waiguan )
local star=0
if ItemType_Shuxing ~= 22 and ItemType_Shuxing ~=27 then ----既不是纹身也不是衣服
star = 1
end
if ItemType_Waiguan~=27 then
if ItemType_Shuxing ~= ItemType_Waiguan then
SystemNotice( role ,"Both equipment type mismatch" )
return 0
end
elseif ItemType_Waiguan==27 and star == 1 then
SystemNotice( role ,"Both equipment type mismatch" )
return 0
end
--------外观和属性道具是否为同一体型和职业限制
local Check_RongHe = 0
Check_RongHe = CheckFusionItem( Item_Waiguan , Item_Shuxing )
if Check_RongHe == LUA_FALSE then
SystemNotice( role ,"Both equipment type or class requirement does not match" )
return 0
end
--------是否放的是催化剂
if ItemBagCount[3] == 0 then
local Item_Waiguan_name = GetItemName ( ItemID_Waiguan )
LG("Ronghe_CuiHuaJi","Combine armors and weapons without catalyst ",Item_Waiguan_name,"No forging effect")
end
if ItemBagCount[3] ~= 0 then
local Item_Cuihuaji = GetChaItem ( role , 2 , ItemBag [3] )
local ItemType_Cuihuaji = GetItemType ( Item_Cuihuaji )
if ItemType_Cuihuaji ~= 61 then
SystemNotice( role ,"there is some problem with the catalyst, cannot be used " )
return 0
end
end
--------身上金钱判断
local Money_Need = getfusion_money_main ( Table )
local Money_Have = GetChaAttr ( role , ATTR_GD )
if Money_Need > Money_Have then
SystemNotice( role ,"Insufficient gold. Unable to undergo Fusion")
return 0
end
--SystemNotice(role ,"determination completed ")
return 1
end
--开始熔合,熔合主程序入口
function begin_fusion_item(...)
-- Notice("Starts Fusion")
--------是否可以融合检测
local Check_Canfusion = 0
Check_Canfusion = can_fusion_item_main ( arg )
if Check_Canfusion == 0 then
return 0
end
--------取出数据
local role = 0
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
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 Item_Juanzhou = GetChaItem ( role , 2 , ItemBag [0] )
local Item_Waiguan = GetChaItem ( role , 2 , ItemBag [1] )
local Item_Shuxing = GetChaItem ( role , 2 , ItemBag [2] )
local ItemID_Waiguan = GetItemID ( Item_Waiguan )
--------扣除金钱
local Money_Need = getfusion_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 )
--------熔合过程
Check_Ronghe_Item = ronghe_item ( arg )
if Check_Ronghe_Item == 0 then
SystemNotice ( role ,"Fusion failed , please check program")
end
--check_item_final_data ( Item_Waiguan )
SynChaKitbag(role,13)
--------Notice("Fusion has ended")
local cha_name = GetChaDefaultName ( role )
SystemNotice ( role ,"Fusion successful")
local Item_Waiguan_name = GetItemName ( ItemID_Waiguan )
LG( "Ronghe_ShiBai" , "Player"..cha_name.."Fusion successful"..Item_Waiguan_name )
return 1
end
--计算熔合费用
function get_item_fusion_money(...)
-- Notice("Fee calculation")
local Money = getfusion_money_main ( arg )
return Money
end
--计算精练费用主函数
function getfusion_money_main ( Table )
local role = 0
local ItemBag = {} --道具背包位置数组
local ItemCount = {} --道具数量数组
local ItemBagCount = {} --道具对象数量数组
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_Shuxing = ItemBag [2]
local Item_Shuxing = GetChaItem ( role , 2 , ItemBag_Shuxing )
local Shuxing_Lv = 0
local Shuxing_Lv = GetItemLv ( Item_Shuxing )
local Money_Need = Shuxing_Lv * 1000
-- Notice("Calculation completed")
return Money_Need
end
----相关函数--------------------------------------------------------------------------------------------------------
---开始熔合
function ronghe_item ( Table )
-- Notice("Ronghe_Item")
local role = 0
local ItemBag = {} --道具背包位置
local ItemCount = {} --道具数量
local ItemBagCount = {} --道具对象数量
local ItemBag_Num = 0
local ItemCount_Num = 0
local ItemBagCount_Num = 0
local ItemID_Cuihuaji = 0
role , ItemBag , ItemCount , ItemBagCount , ItemBag_Num , ItemCount_Num , ItemBagCount_Num = Read_Table ( Table )
local Item_Juanzhou = GetChaItem ( role , 2 , ItemBag [0] )
local Item_Waiguan = GetChaItem ( role , 2 , ItemBag [1] )
local Item_Shuxing = GetChaItem ( role , 2 , ItemBag [2] )
local ItemID_Juanzhou = GetItemID ( Item_Juanzhou )
local ItemID_Waiguan = GetItemID ( Item_Waiguan )
local ItemID_Shuxing = GetItemID ( Item_Shuxing )
local ItemID_star = ItemID_Shuxing
local flg=0
if ItemBagCount[3] ~= 0 then
local Item_Cuihuaji = GetChaItem ( role , 2 , ItemBag [3] )
ItemID_Cuihuaji = GetItemID ( Item_Cuihuaji )
flg=1
end
local Jinglianxinxi = GetItemForgeParam ( Item_Shuxing , 1 )
--------赋予熔合道具记录ID
if ItemID_Shuxing > 5000 then
ItemID_Shuxing = GetItemAttr( Item_Waiguan , ITEMATTR_VAL_FUSIONID )
SetItemAttr( Item_Waiguan , ITEMATTR_VAL_FUSIONID , ItemID_Shuxing )
else
SetItemAttr( Item_Waiguan , ITEMATTR_VAL_FUSIONID , ItemID_Shuxing )
end
--------熔合道具
local Check_FusionItem = FusionItem ( Item_Waiguan, Item_Shuxing )
--------赋予熔合道具等级
local star_lv=0
if flg==1 then
if ItemID_star < 5000 then
star_lv=10
else
star_lv=GetItemAttr ( Item_Shuxing , ITEMATTR_VAL_LEVEL ) -- 设置熔合道具等级
end
else
star_lv=10
end
--SystemNotice( role , "star_lv="..star_lv )
SetItemAttr ( Item_Waiguan , ITEMATTR_VAL_LEVEL , star_lv ) -- 设置熔合道具等级
--local i = GetItemAttr ( Item_Waiguan , ITEMATTR_VAL_LEVEL )
--SystemNotice( role , "Item Lv="..i )
local hole_num = Check_HasHole ( Item_Shuxing )
if Check_FusionItem == 0 then
SystemNotice( role , "Fusion failed")
return
-- else
-- for Check_FusionItem = 1 , 49 , 1 do
-- RO = GetItemAttr ( Item_Waiguan , Check_FusionItem )
-- SystemNotice( role , "Attribute"..Check_FusionItem.."="..RO )
-- end
end
--------移出道具
----------------------------------
----------------------------------此处打LG
local Item_Shuxing_ENERGY = GetItemAttr ( Item_Shuxing , ITEMATTR_ENERGY )
local Item_Shuxing_MAXURE = GetItemAttr ( Item_Shuxing , ITEMATTR_MAXURE )
local cha_name = GetChaDefaultName ( role )
local num={}
local numAttr={}
local b = 0
local a = {}
for b=1,5,1 do
num [b]=0
numAttr [b]=0
end
b = 0
for i=1,47,1 do
a [i]=GetItemAttr ( Item_Shuxing , i )
if a [i]~=0 then
-- SystemNotice( role , a [i] )
b = b + 1
num [b]=i
numAttr [b]=a[i]
end
end
--LG( "ZhuangBeiRH_XinXi" , cha_name , ItemID_Waiguan , ItemID_Shuxing , Item_Shuxing_ENERGY , Item_Shuxing_MAXURE , num[1],numAttr[1],num[2],numAttr[2],num[3],numAttr[3],num[4],numAttr[4],num[5],numAttr[5],Jinglianxinxi,flg)
LG( "ZhuangBeiRH_XinXi" , cha_name , ItemID_Waiguan , ItemID_Shuxing , Item_Shuxing_ENERGY , Item_Shuxing_MAXURE , STAR_ATTR[num[1]],numAttr[1],STAR_ATTR[num[2]],numAttr[2],STAR_ATTR[num[3]],numAttr[3],STAR_ATTR[num[4]],numAttr[4],STAR_ATTR[num[5]],numAttr[5],Jinglianxinxi,flg)
-----------取融合后道具的属性
local attr1=GetItemAttr ( Item_Waiguan , num[1] )
local attr2=GetItemAttr ( Item_Waiguan , num[2] )
local attr3=GetItemAttr ( Item_Waiguan , num[3] )
local attr4=GetItemAttr ( Item_Waiguan , num[4] )
local attr5=GetItemAttr ( Item_Waiguan , num[5] )
LG( "RHWaiguan_XinXi" , cha_name , ItemID_Waiguan , STAR_ATTR[num[1]],attr1,STAR_ATTR[num[2]],attr2,STAR_ATTR[num[3]],attr3,STAR_ATTR[num[4]],attr4,STAR_ATTR[num[5]],attr5)
--------------------重新设置融合装备耐久
SetItemAttr ( Item_Waiguan , ITEMATTR_MAXURE , 20000 )
SetItemAttr ( Item_Waiguan , ITEMATTR_URE , 20000 )
local R1 = 0
local R2 = 0
local R3 = 1
R1 = RemoveChaItem ( role , ItemID_Juanzhou , 1 , 2 , ItemBag [0] , 2 , 1 , 0 ) --移除卷轴道具
R2 = RemoveChaItem ( role , ItemID_Shuxing , 1 , 2 , ItemBag [2] , 2 , 1 , 0 ) --移除属性道具
if ItemID_Cuihuaji ~= 0 then
R3 = RemoveChaItem ( role , ItemID_Cuihuaji , 1 , 2 , ItemBag [3] , 2 , 1 , 0 ) --移出催化剂道具
end
if R1 == 0 or R2 == 0 or R3 == 0 then
SystemNotice( role , "moved item failed ")
return
end
--------赋予熔合道具精炼属性
if ItemID_Cuihuaji ~= 0 then
local Check_SetItemForgeParam = SetItemForgeParam( Item_Waiguan , 1 , Jinglianxinxi )
if Check_SetItemForgeParam == 0 then
SystemNotice( role , "Fail to set forging attribute settings")
return
end
else
local Part1_Jinglianxinxi = GetNum_Part1 ( Jinglianxinxi ) --Get Num Part 1 到 Part 7
local Part2_Jinglianxinxi = GetNum_Part2 ( Jinglianxinxi )
local Part3_Jinglianxinxi = GetNum_Part3 ( Jinglianxinxi )
local Part4_Jinglianxinxi = GetNum_Part4 ( Jinglianxinxi )
local Part5_Jinglianxinxi = GetNum_Part5 ( Jinglianxinxi )
local Part6_Jinglianxinxi = GetNum_Part6 ( Jinglianxinxi )
local Part7_Jinglianxinxi = GetNum_Part7 ( Jinglianxinxi )
Jinglianxinxi = SetNum_Part1 ( Jinglianxinxi , hole_num ) ----------二转标记
Jinglianxinxi = SetNum_Part2 ( Jinglianxinxi , 0 )
Jinglianxinxi = SetNum_Part3 ( Jinglianxinxi , 0 )
Jinglianxinxi = SetNum_Part4 ( Jinglianxinxi , 0 )
Jinglianxinxi = SetNum_Part5 ( Jinglianxinxi , 0 )
Jinglianxinxi = SetNum_Part6 ( Jinglianxinxi , 0 )
Jinglianxinxi = SetNum_Part7 ( Jinglianxinxi , 0 )
local Check_SetItemForgeParam = SetItemForgeParam( Item_Waiguan , 1 , Jinglianxinxi )
if Check_SetItemForgeParam == 0 then
SystemNotice( role , "Fail to set forging attribute settings")
return
end
end
end
-------------装备升级之强化升级部分
----装备升级之强化升级
---检测是否能够强化升级
function can_upgrade_item (...)
-- Notice ( "See if it can be reinforced")
if arg.n ~= 12 then
SystemNotice ( arg[1] , "parameter value illegal"..arg.n )
return 0
end
local Check = 0
Check = can_beuplv_item_main ( arg )
if Check == 1 then
return 1
else
return 0
end
end
--检测是否可以强化升级主函数
function can_beuplv_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_beuplv = ItemBagCount [1]
local ItemBag_beuplv = ItemBag [1]
local ItemNum_beuplv = ItemCount [1]
local Item_beuplv = GetChaItem ( role , 2 , ItemBag_beuplv ) ----取道具指针
local Item_beuplv_Type = GetItemType ( Item_beuplv ) ----取融合道具类型
local Item_beuplv_ID = GetItemID ( Item_beuplv ) ----取融合道具ID
local Item_ScItem = GetChaItem ( role , 2 , ItemBag [0] ) ----强化卷轴道具指针
local Item_YxItem = GetChaItem ( role , 2 , ItemBag [2] ) ----强化晶石道具指针
local Item_ScItem_ID = GetItemID ( Item_ScItem ) ----商城道具ID
local Item_YxItem_ID = GetItemID ( Item_YxItem ) ----游戏道具ID
local Item_ScItem_Type = GetItemType ( Item_ScItem ) ----取强化卷轴道具类型
local Item_YxItem_Type = GetItemType ( Item_YxItem ) ----取强化晶石道具类型
local Item_beuplv_Lv = Get_Itembeuplv_Lv ( Item_beuplv ) ---取融合住装备等级
local ItemAttr_Val_Fusionid = GetItemAttr ( Item_beuplv , ITEMATTR_VAL_FUSIONID ) -- 取道具装备熔合信息ID
if Item_beuplv_ID < 5001 or Item_beuplv_ID > 6000 then --判断融合道具是否为融合类型
SystemNotice( role ,"non fusion item ")
return 0
end
------------------------------------------- --未融合装备不能升级
if ItemAttr_Val_Fusionid == 0 then
SystemNotice( role , "Item cannot be upgraded as item has not undergo fusion")
return 0
end
-----------------------------------------------
if Item_beuplv_Lv >= 15 then --判断融合道具是否为最大等级
SystemNotice( role ,"Item level limit max. Unable to level again")
return 0
end
if ItemBagCount_beuplv ~= 1 then --第二栏放融合道具
SystemNotice( role , "Strengthening item level slot illegal ")
return 0
end
if Item_ScItem_Type ~= 62 then
SystemNotice( role , "Invalid Strengthening scroll type ")
return 0
end
if Item_YxItem_Type ~= 63 then
SystemNotice( role , "Strengthening gem type illegal ")
return 0
end
if ItemNum_beuplv ~= 1 then
SystemNotice( role , "Illegal force item upgrade number")
return 0
end
if ItemCount
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -