⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forge.lua

📁 top web admin panel (tales of pirates)
💻 LUA
📖 第 1 页 / 共 5 页
字号:
	if Item_TypeCheck == 59 then
		return
	end
--	Notice ("check_item_final_data")
	local Num = GetItemForgeParam ( Item , 1 )
	Num = TansferNum ( Num )
--	Notice(Num)
	local StoneInfo = {}
	local StoneLv = {}
	local ResetCheck = 0
	ResetCheck = ResetItemFinalAttr( Item )
	
	if ResetCheck == 0 then
--		Notice("ResetCheck Failed")
		LG("check_item_final","ResetCheck Failed")
		return
	end
	StoneInfo[0]=0
	StoneInfo[1]=0
	StoneInfo[2]=0
	StoneLv[0]=0
	StoneLv[1]=0
	StoneLv[2]=0
	StoneInfo[0],StoneInfo[1],StoneInfo[2],StoneLv[0],StoneLv[1],StoneLv[2] = CheckStoneInfo ( Num )

	local AddCheck = 0

	local i = 0
	local j = 0
	for i = 0 , 2 , 1 do
		if StoneInfo [i] ~= nil and StoneInfo [i] ~=0  then
--			Notice("StoneInfo"..i.."= "..StoneInfo [i])
			if StoneAttrType[StoneInfo [i]] == ITEMATTR_VAL_MNATK then
--				Notice("Add Attack")
				local Itemattr_Type1 = StoneAttrType[StoneInfo [i]]
				local Itemattr_Type2 = Itemattr_Type1 + 1
				local ItemAttrEff = 0
				local num_stone=0
				local lv_stone=0
				if StoneLv[i]>0 and StoneLv[i]<=9 then
					lv_stone=StoneLv[i]
				end
				if StoneInfo [i]>=0 and StoneInfo [i]<=StoneEff_Num then
					num_stone=StoneInfo [i]
					ItemAttrEff =StoneEff [num_stone] * lv_stone
				end
--				local Item_attr1 = GetItemAttr ( Item , Itemattr_Type1 )
--				local Item_attr2 = GetItemAttr ( Item , Itemattr_Type2 )

--				local Item_Newattr1 = Item_attr1 + ItemAttrEff
--				local Item_Newattr2 = Item_attr2 + ItemAttrEff
				
--				Notice ( "Itemattr_Type1= "..Itemattr_Type1.." Itemattr_Type2= "..Itemattr_Type2)
--				Notice ( "ItemAttrEff= "..ItemAttrEff)
				AddCheck = AddItemFinalAttr ( Item , Itemattr_Type1 , ItemAttrEff )
				if AddCheck == 0 then
					LG("check_item_final","AddCheck Failed")
				end
				AddCheck = AddItemFinalAttr ( Item , Itemattr_Type2 , ItemAttrEff )
				if AddCheck == 0 then
					LG("check_item_final","AddCheck Failed")
				end
			else
				local Itemattr_Type = StoneAttrType[StoneInfo [i]]
				local ItemAttrEff = 0
				local num_stone=0
				local lv_stone=0
				if StoneLv[i]>0 and StoneLv[i]<=9 then
					lv_stone=StoneLv[i]
				end
				if StoneInfo [i]>=0 and StoneInfo [i]<=StoneEff_Num then
					num_stone=StoneInfo [i]
					ItemAttrEff =StoneEff [num_stone] * lv_stone
				end
				--local ItemAttrEff = StoneEff[StoneInfo [i]] * StoneLv[i]

--				local Item_attr = GetItemAttr ( Item , Itemattr_Type )
--				local Item_Newattr = Item_attr + ItemAttrEff

				AddCheck = AddItemFinalAttr ( Item , Itemattr_Type , ItemAttrEff )
				if AddCheck == 0 then
					LG("check_item_final","AddCheck Failed")
				end

			end
		end
	end
end

--检查宝石可精炼道具类型

function Check_StoneItemType ( Item , Stone1 , Stone2 )
--	Notice ("Check_StoneItemType")
	local Stone1Type = GetItemType ( Stone1 )
	local Stone2Type = GetItemType ( Stone2 )
	local Baoshi = 0
	local ItemType = GetItemType ( Item )
	
	if Stone1Type == 49 then
		Baoshi = Stone1
	elseif Stone2Type == 49 then
		Baoshi = Stone2
	end

	local Baoshi_ID = GetItemID ( Baoshi )
	local i = 0
	local Baoshi_TypeID = 0
	
	for i = 1 , StoneAttrType_Num , 1 do
		if Baoshi_ID == StoneTpye_ID[i] then
			Baoshi_TypeID = i
		end
	end

	for i = 0 , 15 , 1 do
		if ItemType == StoneItemType[Baoshi_TypeID][i] then
			return 1
		end
		if StoneItemType[Baoshi_TypeID][i] == 0 then
--			Notice ("Return failed")
			return 0
		end
	end
	
--	Notice ("Return failed")
	return 0
end

--取精炼等级

function GetItem_JinglianLv ( Item )
--	Notice ("GetItem_JinglianLv")
	local Num = GetItemForgeParam ( Item , 1 )
	Num = TansferNum ( Num )
	local Item_StoneLv = {}
	local JinglianLv = 0
	
	Item_StoneLv[0] = GetNum_Part3 ( Num )
	Item_StoneLv[1] = GetNum_Part5 ( Num )
	Item_StoneLv[2] = GetNum_Part7 ( Num )

	JinglianLv = Item_StoneLv[0] + Item_StoneLv[1] + Item_StoneLv[2]

	return JinglianLv
end


--读取武器上宝石信息
function CheckStoneInfo( Num )

	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 )

	return Item_Stone[0],Item_Stone[1],Item_Stone[2],Item_StoneLv[0],Item_StoneLv[1],Item_StoneLv[2]
end



function Check_CG_HechengBS ( Item_Lv , Item_Type , Sklv )
	local a = 0
	local b = 0
	Item_Lv = Item_Lv - 1
	if Item_Type == 49 then
		a = math.max ( 0 , math.min ( 1 , ( 1 - Item_Lv * 0.10 + Sklv * 0.10 ) ) )
		b = Percentage_Random ( a )
		if Item_Lv < 3 then
			b = 1
		end
		return b
	elseif Item_Type == 50 then
		a = math.max ( 0 , math.min ( 1 , ( 1 - Item_Lv * 0.05 + Sklv * 0.15 ) ) )
		b = Percentage_Random ( a )
		return b
	else
		LG( "Hecheng_BS","probability check determine item type is not a gem" )
		return 0
	end
end

function Check_CG_Jinglian ( Jinglian_Lv , Stone_Lv , Sklv )
--	local a = 0
	local b = 0

--	a = math.max ( 0.02 , math.min ( 1 , ( 1 - Jinglian_Lv  * 0.05 + Sklv * 0.15 - 0.3 ) ) )
--	b = Percentage_Random ( a )
--	if Jinglian_Lv <= 8 then
		b = 1
--	end
	return b
end


--随机宝石种类——————————————————————————————————————
function Roll_DiamondId ( cha ) 
	local a = math.random ( 1 , 8 ) 
	local DiamondId = StoneTpye_ID [ a ] 
	return DiamondId  
end 


--1级宝石兑换卷————————————————————————————————————————————————————
function Transfer_DiamondScript_Lv1 ( role )			
	local cha = TurnToCha ( role ) 
	local x_give = 0 
	local y_give = 0 
	local script_count = CheckBagItem ( cha , 3877 )					--检查背包中兑换券数量
	local DiamondId = Roll_DiamondId ( cha )						--随机兑换宝石的种类
	if script_count >= 1 then 
		x_del = DelBagItem ( cha , 3877 , 1 ) 
		if x_del == 1 then 
			x_give = GiveItem ( cha , 0 , DiamondId , 1 , 101 )				--兑换宝石

			y_give = GiveItem ( cha , 0 , 885 , 1 , 101 )					--兑换精炼石


		else 
			SystemNotice ( cha , "Unable to deduct Gem Voucher" ) 
		end 
	else 
		SystemNotice ( cha , "You need to have a Lv 1 Gem Voucher in order to redeem"  ) 
	end 
	if x_give == 1 and y_give ==1 then 
		return 1 
	else 
		return 0 
	end 
end 


--2级宝石兑换卷————————————————————————————————————————————————————
function Transfer_DiamondScript_Lv2 ( role )			
	local cha = TurnToCha ( role ) 
	local x_give = 0 
	local y_give = 0 
	local script_count = CheckBagItem ( cha , 3878 )					--检查背包中兑换券数量
	local DiamondId = Roll_DiamondId ( cha )						--随机兑换宝石的种类
	if script_count >= 1 then 
		x_del = DelBagItem ( cha , 3878 , 1 ) 
		if x_del == 1 then 
			x_give = GiveItem ( cha , 0 , DiamondId , 1 , 102 )				--兑换宝石

			y_give = GiveItem ( cha , 0 , 885 , 1 , 102 )					--兑换精炼石


		else 
			SystemNotice ( cha , "Unable to deduct Gem Voucher" ) 
		end 
	else 
		SystemNotice ( cha , "Requires Lv 2 Refining Gem Voucher to redeem"  ) 
	end 
	if x_give == 1 and y_give ==1 then 
		return 1 
	else 
		return 0 
	end 
end 
-------------------------------Christmas Greeting Card
function GetChaName_0 ( role,npc )
	local cha_name = GetChaDefaultName ( role )
	local Money_Need = 1000
	local Money_Have = GetChaAttr ( role , ATTR_GD )
	local Item_ID = GetItemID (role)
	if Money_Need > Money_Have and Item_ID == 2887 then
		SystemNotice( role ,"Insufficient gold. Unable to dedicate")
	else
	TakeMoney(role,nil,Money_Need)
	end
	local am1 = CheckBagItem( role, 2887 )			
	if am1 < 1 then
		SystemNotice( role ,"You does not seems to bring any Christmas Greeting Cards")
	else 
	end
	local am2 =TakeItem( role, 0,2887, 1 )			                   
		if am2==0  then
			SystemNotice ( role ,"Collection of Christmas Card failed")
	else
	PlayEffect( npc, 361 )
	Notice(" comes from "..cha_name.."'s blessing: May God bless you on this Christmas season! The Goddess of Mercy protect you! God of Fortune hugs you! Cupid shoots you!God of Cookery bites you!")
	end
end
-------------------------------------------
function GetChaName_1 ( role,npc )
	local cha_name = GetChaDefaultName ( role )
	
	local Money_Need = 1000
	local Money_Have = GetChaAttr ( role , ATTR_GD )
	local Item_ID = GetItemID (role)
	if Money_Need > Money_Have and Item_ID == 2887 then
		SystemNotice( role ,"Insufficient gold. Unable to dedicate")
	else
	TakeMoney(role,nil,Money_Need)
	end
	local am1 = CheckBagItem( role, 2887 )			
	if am1 < 1 then
		SystemNotice( role ,"You does not seems to bring any Christmas Greeting Cards")
	else 
	end
	local am2 =TakeItem( role, 0,2887, 1 )			                   
		if am2==0  then
			SystemNotice ( role ,"Collection of Christmas Card failed")
	else
	PlayEffect( npc, 361 )
	Notice(" comes from "..cha_name.."'s blessing: Due to consideration of the upcoming world event...")
	end
end
---------------------------------------
function GetChaName_2 ( role,npc )
	local cha_name = GetChaDefaultName ( role )
	
	local Money_Need = 1000
	local Money_Have = GetChaAttr ( role , ATTR_GD )
	local Item_ID = GetItemID (role)
	if Money_Need > Money_Have and Item_ID == 2887 then
		SystemNotice( role ,"Insufficient gold. Unable to dedicate")
	else
	TakeMoney(role,nil,Money_Need)
	end
	local am1 = CheckBagItem( role, 2887 )			
	if am1 < 1 then
		SystemNotice( role ,"You does not seems to bring any Christmas Greeting Cards")
	else 
	end
	local am2 =TakeItem( role, 0,2887, 1 )			                   
		if am2==0  then
			SystemNotice ( role ,"Collection of Christmas Card failed")
	else
	PlayEffect( npc, 361 )
	Notice(" comes from "..cha_name.."'s beautiful wish: To spend Christmas eve with you, holding your hands and listen to the chimes of the midnight clock. Do you wish to fulfill the wish?")
	end
end

function GetChaName_3 ( role,npc )
	local cha_name = GetChaDefaultName ( role )
	
	local Money_Need = 1000
	local Money_Have = GetChaAttr ( role , ATTR_GD )
	local Item_ID = GetItemID (role)
	if Money_Need > Money_Have and Item_ID == 2887 then
		SystemNotice( role ,"Insufficient gold. Unable to dedicate")
	else
	TakeMoney(role,nil,Money_Need)
	end
	local am1 = CheckBagItem( role, 2887 )			
	if am1 < 1 then
		SystemNotice( role ,"You does not seems to bring any Christmas Greeting Cards")
	else 
	end
	local am2 =TakeItem( role, 0,2887, 1 )			                   
		if am2==0  then
			SystemNotice ( role ,"Collection of Christmas Card failed")
	else
	PlayEffect( npc, 361 )
	Notice(" comes from "..cha_name.."'s well wishes: After a year has past, we once again welcome this Christmas Night. This moment is the time to be happy; to reminisce old friends; to care; and for dreams to come true... Merry Christmas!")
	end
end
---------------------------------Leo StarofUnity
function Transfer_TeamStar( role , level )
	local cha = TurnToCha ( role )  
	local script_count = CheckBagItem ( cha , 1034 )--取背包数量			
	local chaLV =  GetChaAttr( cha , ATTR_LV)--取等级
	local job = GetChaAttr( role, ATTR_JOB) --取职业

	if script_count >= 1 then
		if chaLV < 41 then
			SystemNotice(role,"Your Star of Unity has not expired. Come back after Lv41.")
		else
			if job ~= 12 and job ~= 9 and job ~= 16 and job ~= 8 and job ~= 13 and job ~=14 then
				SystemNotice(role,"Can only be used by characters that have completed second advancement. Please look for class trainers NPC of each city to complete your rebirth quest before redemption.")
			else
				local x_del = DelBagItem ( cha , 1034 , 1 ) 
				if x_del == 1 then 
					if job == 12 then	--狙击
						GiveItem( role , 0 , 1409  , 1 , 22 )
					elseif job == 9	then --双剑
						GiveItem( role , 0 , 1392  , 1 , 22 )
					elseif job == 16 then	--航海
						GiveItem( role , 0 , 1419  , 1 , 22 )
					elseif job == 8	then --巨剑
						GiveItem( role , 0 , 1382  , 1 , 22 )
					elseif job == 13 then	--圣职
						GiveItem( role , 0 ,1433  , 1 , 22 )
					elseif job == 14 then	--封印
						GiveItem( role , 0 , 1467  , 1 , 22 )
					end
				else 
					SystemNotice ( cha , "Unable to deduct Star of Unity" ) 
				end 
			end
		end
	else 
		SystemNotice ( cha , "Need to possess Star of Unity to receive"  ) 
	end 
end

--宝石兑换卷
--Lv1 一级宝石兑换券
--Lv2 二级宝石兑换券
--Lv3 精炼石兑换券
--Lv4 宝石兑换券
function TransferDiamond( role , level )
	local ret = KitbagLock(role,0)
	if ret ~= LUA_TRUE then
		SystemNotice(role,"Inventory is binded. Unable to redeem")
		return
	end
	local retbag

	if level == 1 then
		retbag = HasLeaveBagGrid( role, 2)
			if retbag ~= LUA_TRUE then
				SystemNotice(role,"Inventory requires at least 2 empty slots to redeem")
				return 
			end	
		Transfer_DiamondScript_Lv1 ( role )
	elseif level == 2 then 
		retbag = HasLeaveBagGrid( role, 2)
			if retbag ~= LUA_TRUE then
				SystemNotice(role,"Inventory requires at least 2 empty slots to redeem")
				return 
			end	
		Transfer_DiamondScript_Lv2 ( role )
	elseif level == 3 then
		retbag = HasLeaveBagGrid( role, 1)
			if retbag ~= LUA_TRUE then
				SystemNotice(role,"Insufficent inventory space to redeem")
				return 
			end	
		Transfer_OneStoneScript ( role )
	elseif level == 4 then
		retbag = HasLeaveBagGrid( role, 1)
			if retbag ~= LUA_TRUE then
				SystemNotice(role,"Insufficent inventory space to redeem")
				return 
			end	
		Transfer_OneDiamondScript ( role )
	else
		LG( "BSduihuan","Wrong coupon used" )
	end
end

--精炼石兑换卷

function Transfer_OneStoneScript ( role )
	local cha = TurnToCha ( role ) 
	local y_give = 0 
	
	local script_count = CheckBagItem ( cha , 3885 )					--检查背包中兑换券数量

	if script_count >= 1 then 
		x_del = DelBagItem ( cha , 3885 , 1 ) 
		if x_del == 1 then 
			y_give = GiveItem ( cha , 0 , 885 , 1 , 101 )					--兑换精炼石
		else 
			SystemNotice ( cha , "Unable to deduct Gem Voucher" ) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -