gia_muvn
15-12-16, 08:34 AM
Mọi người cho mình hỏi là muốn chỉnh cho thợ rèn nó không bị mệt thì chỉnh như nào với ạ
function onFoundryItem()
if( isCompoundableToday() == 1 ) then
FoundryItem();
else
Say( "L·o phu h«m nay mÖt råi, mai tr¸ng sÜ ghÐ ®óc luyÖn trang bÞ nha!", 1, "§îc! VËy ta ®i tríc ®©y!/onCancel" );
end
end
function Compound( arynNecessaryItemIdx, arynAlternativeItemIdx, bPreview )
if( isCompoundableToday() ~= 1 ) then
Say( "Thî rÌn thÇn bÝ: H«m nay l·o phu ®· qu¸ mÖt mái, ngµy mai hiÖp sÜ h·y ®Õn ®óc trang bÞ!", 0 );
return -1, RESULT_FAIL;
end
-- ³õʼ»¯Êý¾Ý
if( initData ~= nil ) then
initData();
end
-- УÑéÔÁÏÊÇ·ñ·ûºÏ[ºÏ³É]¹æÔò£¨Í¬Ê±´æ´¢Ò»Ð©ÔÁÏÊý¾ Ý£©
local nResult = verifySrcItems( arynNecessaryItemIdx, arynAlternativeItemIdx );
if( nResult ~= RESULT_SUCCEED ) then
return -1, nResult;
end
-- Ö§¸¶[ºÏ³É]·ÑÓÃ
if( COMPOUND_COST == nil or Pay( COMPOUND_COST ) ~= 1 ) then
return -1, RESULT_NO_MONEY;
end
-- ¼ÆËãËùÓÐÔÁϼÛÖµÁ¿×ܺÍ
local nNecItemValSum = sumItemsVal( arynNecessaryItemIdx );
local nAltItemValSum = sumItemsVal( arynAlternativeItemIdx );
local dAltItemFinalVal = nAltItemValSum;
if( sumMainItemVal ~= nil ) then
nMainItemValSum = sumMainItemVal( arynNecessaryItemIdx );
dAltItemFinalVal = calcAltItemFinalVal( nMainItemValSum, nAltItemValSum );
end
local nSrcItemValSum = nNecItemValSum + dAltItemFinalVal;
-- Msg2Player( "<color=yellow>-----------------------------------" );
-- Msg2Player( "<color=gold>TotalSrcSum: "..nNecItemValSum.."+"..dAltItemFinalVal.."="..nSrcItemValSum );
-- Msg2Player( "<color=yellow>-----------------------------------" );
-- Éú³ÉÄ¿±êÎïÆ·ÐÅÏ¢
local aryDesItemInfo = genDesItemsInfo( arynNecessaryItemIdx );
-- ¼ÆËãÿ¸öÄ¿±êÎïÆ·µÄ¼ÛÖµÁ¿
local arydDesItemVal = {};
local nDesItemCount = getn( aryDesItemInfo );
for i = 1, nDesItemCount do
arydDesItemVal[i] = funitem_calcItemValue(aryDesItemInfo[i]);
--Msg2Player( "<color=green>DesValue"..i..": "..arydDesItemVal[i] );
end
-- Msg2Player( "<color=yellow>-----------------------------------" );
if( bPreview == 1 ) then -- Ô¤ÀÀ[ºÏ³É]µÄ³É¹¦ÂÊ
if( previewProb ~= nil ) then
previewProb( arynNecessaryItemIdx, arynAlternativeItemIdx, nSrcItemValSum, aryDesItemInfo, arydDesItemVal );
end
return -1, RESULT_SUCCEED;
else -- ½øÐÐ[ºÏ³É]²Ù×÷
-- Íê³ÉÑ¡ÔñÄ¿±êÎïÆ·¡¢É¾³ýÔÁ ϵÈÊÕβ²Ù×÷
nResultDesItemIdx, nResult = finalCompound( arynNecessaryItemIdx, arynAlternativeItemIdx, nSrcItemValSum, aryDesItemInfo, arydDesItemVal );
-- ·µ»ØÉú³ÉÎïÆ·Ë÷Òý£¬[ºÏ³É]½á¹û
return nResultDesItemIdx, nResult;
end
end
function onFoundryItem()
if( isCompoundableToday() == 1 ) then
FoundryItem();
else
Say( "L·o phu h«m nay mÖt råi, mai tr¸ng sÜ ghÐ ®óc luyÖn trang bÞ nha!", 1, "§îc! VËy ta ®i tríc ®©y!/onCancel" );
end
end
function Compound( arynNecessaryItemIdx, arynAlternativeItemIdx, bPreview )
if( isCompoundableToday() ~= 1 ) then
Say( "Thî rÌn thÇn bÝ: H«m nay l·o phu ®· qu¸ mÖt mái, ngµy mai hiÖp sÜ h·y ®Õn ®óc trang bÞ!", 0 );
return -1, RESULT_FAIL;
end
-- ³õʼ»¯Êý¾Ý
if( initData ~= nil ) then
initData();
end
-- УÑéÔÁÏÊÇ·ñ·ûºÏ[ºÏ³É]¹æÔò£¨Í¬Ê±´æ´¢Ò»Ð©ÔÁÏÊý¾ Ý£©
local nResult = verifySrcItems( arynNecessaryItemIdx, arynAlternativeItemIdx );
if( nResult ~= RESULT_SUCCEED ) then
return -1, nResult;
end
-- Ö§¸¶[ºÏ³É]·ÑÓÃ
if( COMPOUND_COST == nil or Pay( COMPOUND_COST ) ~= 1 ) then
return -1, RESULT_NO_MONEY;
end
-- ¼ÆËãËùÓÐÔÁϼÛÖµÁ¿×ܺÍ
local nNecItemValSum = sumItemsVal( arynNecessaryItemIdx );
local nAltItemValSum = sumItemsVal( arynAlternativeItemIdx );
local dAltItemFinalVal = nAltItemValSum;
if( sumMainItemVal ~= nil ) then
nMainItemValSum = sumMainItemVal( arynNecessaryItemIdx );
dAltItemFinalVal = calcAltItemFinalVal( nMainItemValSum, nAltItemValSum );
end
local nSrcItemValSum = nNecItemValSum + dAltItemFinalVal;
-- Msg2Player( "<color=yellow>-----------------------------------" );
-- Msg2Player( "<color=gold>TotalSrcSum: "..nNecItemValSum.."+"..dAltItemFinalVal.."="..nSrcItemValSum );
-- Msg2Player( "<color=yellow>-----------------------------------" );
-- Éú³ÉÄ¿±êÎïÆ·ÐÅÏ¢
local aryDesItemInfo = genDesItemsInfo( arynNecessaryItemIdx );
-- ¼ÆËãÿ¸öÄ¿±êÎïÆ·µÄ¼ÛÖµÁ¿
local arydDesItemVal = {};
local nDesItemCount = getn( aryDesItemInfo );
for i = 1, nDesItemCount do
arydDesItemVal[i] = funitem_calcItemValue(aryDesItemInfo[i]);
--Msg2Player( "<color=green>DesValue"..i..": "..arydDesItemVal[i] );
end
-- Msg2Player( "<color=yellow>-----------------------------------" );
if( bPreview == 1 ) then -- Ô¤ÀÀ[ºÏ³É]µÄ³É¹¦ÂÊ
if( previewProb ~= nil ) then
previewProb( arynNecessaryItemIdx, arynAlternativeItemIdx, nSrcItemValSum, aryDesItemInfo, arydDesItemVal );
end
return -1, RESULT_SUCCEED;
else -- ½øÐÐ[ºÏ³É]²Ù×÷
-- Íê³ÉÑ¡ÔñÄ¿±êÎïÆ·¡¢É¾³ýÔÁ ϵÈÊÕβ²Ù×÷
nResultDesItemIdx, nResult = finalCompound( arynNecessaryItemIdx, arynAlternativeItemIdx, nSrcItemValSum, aryDesItemInfo, arydDesItemVal );
-- ·µ»ØÉú³ÉÎïÆ·Ë÷Òý£¬[ºÏ³É]½á¹û
return nResultDesItemIdx, nResult;
end
end