Thứ Hai, 25 tháng 11, 2013

[TLBB]Share code đục lỗ bất kỳ item nào

Trong TLBB khi sử dụng hàm đục lỗ trang bị, chúng ta chỉ có thể đục lỗ giới hạn một số loại trang bị.

Để có thể đục lỗ được bất kỳ trang bị nào hỗ trợ thì các bạn thực hiện chỉnh sửa ở database.

Nay, mình sẽ chia sẽ cách thức trên.


Chỉnh ở table t_iteminfo

Cột : giải thích
------------
p4 : qui định cố định/ không cố định
p5 : qui định đục lỗ
p1-3 : ngọc lỗ 1-3
p9 : qui định số * và trị số của thuộc tính
p10,p11: quy định các dòng thuộc tính, chỉ số thuộc tính (segvalue)
p12 : quy định chỉ số + của từng thuộc tính
p15 : thời gian đã khóa item
p16 : thời gian cần chờ khóa
--------------
Do đó, để đục lỗ item chỉ cần set giá trị p5 num
Với numlà số lỗ muốn có; giá trị p5 phải là giá trị ban đầu của item (không có lỗ)

- Cách thứ hai
ạn thử xem trong file EquipBase.txt xem xét cột thứ 4 (Item type) và cột thứ 6 (EquipPoint) giữa item cho phép đục lỗ và item không cho phép đục lỗ.
--Script khoan trang bị

--no script

x311200_g_ScriptId = 311200

function x311200_OnStiletto( sceneId, selfId, idBagPos, idBagPosStuff )

--Các thiết bị cho phép khoan
--0: vũ khí , 1: mão , 2: y phục , 3: thủ sáo , 4: hài
--5: yêu đái , 6: giới chỉ , 7: hạng liên , 12: hộ phù , 14: hộ uyển
--15: hộ kiên, 17 : ám khí, 18: pháp bảo
local tEquipGemTable = { 0, 1, 2, 3, 4, 5, 6, 7, 12, 14, 15,17,18 }

local Bore_Count = GetBagGemCount( sceneId, selfId, idBagPos )
local nLevel = GetBagItemLevel( sceneId, selfId, idBagPos )
local EquipType = LuaFnGetBagEquipType( sceneId, selfId, idBagPos )
local find = 0

for i, gem in tEquipGemTable do
if gem == EquipType then
find = 1
end
end
if find == 0 then
x311200_NotifyTip( sceneId, selfId, "Trang bị này không thể khoan" )
return
end

--ƠòƯừỳũỨẢ
ret = LuaFnStilettoCostExe( sceneId, selfId, nLevel*100+1+Bore_Count, idBagPosStuff )
if ret == -1 then
x311200_NotifyTip( sceneId, selfId, "Bảng kiểm tra thất bại, hỏi kế hoạch" )
return
elseif ret == -2 then
x311200_NotifyTip( sceneId, selfId, "Ngươi không có nguyên liệu thích hợp, không thể tiến hành thao tác này" )
return
elseif ret == -3 then
x311200_NotifyTip( sceneId, selfId, "Ngươi không đủ ngân lượng, không thể tiến hành thao tác này" )
return
elseif ret == -4 then
x311200_NotifyTip( sceneId, selfId, "Ngươi không đủ nguyên liệu, không thể tiến hành thao tác này" )
return
end

--ƠòƯừỷƠĐĐ
ret = AddBagItemSlot( sceneId, selfId, idBagPos )
if ret == -1 then
x311200_NotifyTip( sceneId, selfId, "Trang bị khoan thất bại" )
elseif ret == -2 then
x311200_NotifyTip( sceneId, selfId, "Sai nghiêm trọng" )
elseif ret == -3 then
x311200_NotifyTip( sceneId, selfId, "Cần phải đặt vào một trang bị" )
elseif ret == -4 then
x311200_NotifyTip( sceneId, selfId, "Không thể khoan được nữa" )
elseif ret == 1 then
x311200_NotifyTip( sceneId, selfId, "Trang bị khoan thành công" )
end

end

--**********************************
--script thông báo
--**********************************
function x311200_NotifyTip( sceneId, selfId, Msg )

BeginEvent( sceneId )
AddText( sceneId, Msg )
EndEvent( sceneId )
DispatchMissionTips( sceneId, selfId )

end

Thú cưỡi thì client nào cũng được. Chỉnh ở client và server như sau:
/home/tlbb/Public/Data/Script/event/stiletto/stiletto.lua :

Code:
   --×°±¸´ò¿×

--½Å±¾ºÅ
x311200_g_ScriptId    = 311200

function x311200_OnStiletto( sceneId, selfId, idBagPos, idBagPosStuff )

    --Các thiªt b¸ cho phép khoan
    --0: vû khí , 1: mão , 2: y phøc , 3: thü sáo , 4: hài 
    --5: yêu ðái , 6: gi¾i chï , 7: hÕng liên , 8: Thu cuoi, 12: hµ phù , 14: hµ uy¬n, 16: Thoi trang
    --15: hµ kiên, 17 : ám khí, 18: pháp bäo
    local    tEquipGemTable    = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 14, 15, 16, 17, 18 }

    local    Bore_Count            = GetBagGemCount( sceneId, selfId, idBagPos )
    local nLevel                    = GetBagItemLevel( sceneId, selfId, idBagPos )
    local EquipType                = LuaFnGetBagEquipType( sceneId, selfId, idBagPos )
    local find                        = 0

    for i, gem in tEquipGemTable do
        if gem == EquipType then
            find                            = 1
        end
    end
    if find == 0 then
        x311200_NotifyTip( sceneId, selfId, "Trang b¸ này không th¬ khoan" )
        return
    end

    --´ò¿×ÏûºÄ
    ret    = LuaFnStilettoCostExe( sceneId, selfId, nLevel*100+1+Bore_Count, idBagPosStuff )
    
    if ret == -1 then
        x311200_NotifyTip( sceneId, selfId, "Bäng ki¬m tra th¤t bÕi, höi kª hoÕch" )
        return
    elseif ret == -2 then
        x311200_NotifyTip( sceneId, selfId, "Ngß½i không có nguyên li®u thích hþp, không th¬ tiªn hành thao tác này" )
        return
    elseif ret == -3 then
        x311200_NotifyTip( sceneId, selfId, "Ngß½i không ðü ngân lßþng, không th¬ tiªn hành thao tác này" )
        return
    elseif ret == -4 then
        x311200_NotifyTip( sceneId, selfId, "Ngß½i không ðü nguyên li®u, không th¬ tiªn hành thao tác này" )
        return
    end

    --´ò¿×Ö´ÐÐ
    ret = AddBagItemSlot( sceneId, selfId, idBagPos )    
    if ret == -1 then
        x311200_NotifyTip( sceneId, selfId, "Trang b¸ khoan th¤t bÕi" )
    elseif ret == -2 then
        x311200_NotifyTip( sceneId, selfId, "Sai nghiêm tr÷ng" )
    elseif ret == -3 then
        x311200_NotifyTip( sceneId, selfId, "C¥n phäi ð£t vào mµt trang b¸" )
    elseif ret == -4 then
        x311200_NotifyTip( sceneId, selfId, "Không th¬ khoan ðßþc næa" )
    elseif ret == 1 then
        x311200_NotifyTip( sceneId, selfId, "Trang b¸ khoan thành công" )
    end

end

--**********************************
--ÐÑÄ¿Ìáʾ
--**********************************
function x311200_NotifyTip( sceneId, selfId, Msg )

    BeginEvent( sceneId )
        AddText( sceneId, Msg )
    EndEvent( sceneId )
    DispatchMissionTips( sceneId, selfId )

end 
Client Interface/Stiletto/Stiletto.lua:
    PHP Code:    local EQUIP_BUTTONS;
local EQUIP_QUALITY = -1;
local MATERIAL_BUTTONS;
local MATERIAL_QUALITY = -1;
local Need_Item = 0
local Need_Money =0
local Need_Item_Count = 0
local Bore_Count=0
local objCared = -1;
local MAX_OBJ_DISTANCE = 3.0;

local g_Object = -1;

function Stiletto_PreLoad()

    this:RegisterEvent("UPDATE_STILETTO");
    this:RegisterEvent("UI_COMMAND");
    this:RegisterEvent("OBJECT_CARED_EVENT");
    this:RegisterEvent("PACKAGE_ITEM_CHANGED");
    this:RegisterEvent("RESUME_ENCHASE_GEM");
    

end

function Stiletto_OnLoad()
    EQUIP_BUTTONS = Stiletto_Item
    MATERIAL_BUTTONS = Stiletto_Material
end

function Stiletto_OnEvent(event)

        --PushDebugMessage(event)
    if ( event == "UI_COMMAND" and tonumber(arg0) == 25) then
            this:Show();
            -- Çå¿ÕÎïÆ•²Û zchw
            Stiletto_Clear();
            local xx = Get_XParam_INT(0);
            objCared = DataPool : GetNPCIDByServerID(xx);
            AxTrace(0,1,"xx="..xx .. " objCared="..objCared)
            if objCared == -1 then
                    PushDebugMessage("Dæ li®u cüa server truy«n tr• lÕi có v¤n ð«");
                    return;
            end
            BeginCareObject_Stiletto(objCared)
    elseif (event == "OBJECT_CARED_EVENT" and this:IsVisible()) then
        if(tonumber(arg0) ~= objCared) then
            return;
        end
        
        --Èç¹ûºÍNPCµÄ¾àÀë´óÓÚÒ»¶¨¾àÀë»òÕß±»É¾³ý£¬×Ô¶¯¹Ø±Õ
        if(arg1 == "distance" and tonumber(arg2)>MAX_OBJ_DISTANCE or arg1=="destroy") then
            
            --È¡Ïû¹ØÐÄ
            Stiletto_Cancel_Clicked()
        end

    elseif ( event == "PACKAGE_ITEM_CHANGED" and this:IsVisible() ) then

        if( arg0~= nil and -1 == tonumber(arg0)) then
            return;
        end

        
        if (EQUIP_QUALITY == tonumber(arg0) ) then
            Stiletto_Clear()
            Stiletto_Update(1,tonumber(arg0))
        end
            
        if (MATERIAL_QUALITY == tonumber(arg0) ) then
            Stiletto_Clear()
            Stiletto_Update(2,tonumber(arg0))
        end
    
        
    elseif ( event == "RESUME_STILETTO_EQUIP" ) then
        Resume_Equip(1);
    elseif( event == "UPDATE_STILETTO") then
        AxTrace(0,1,"arg0="..arg0)
        if arg0 == nil or arg1 == nil then
            return
        end

        Stiletto_Update(tonumber(arg0),tonumber(arg1));        

    elseif( event == "RESUME_ENCHASE_GEM" and this:IsVisible() ) then
        if(arg0~=nil and tonumber(arg0) == 3) then
            Resume_Equip_Stiletto(1);
        elseif(arg0~=nil and tonumber(arg0) == 35) then
            Resume_Equip_Stiletto(2);
        end
        
    end
end

function Stiletto_OnShown()
    Stiletto_Clear()
end

function Stiletto_Clear()
    if(EQUIP_QUALITY ~= -1) then
        EQUIP_BUTTONS : SetActionItem(-1);
        LifeAbility : Lock_Packet_Item(EQUIP_QUALITY,0);
        EQUIP_QUALITY = -1;
    end
    
--    Stiletto_Material_Bak : SetProperty("Image", "set:CommonItem image:ActionBK"); 
--    Stiletto_Material_Bak    : SetToolTip("")
    if(MATERIAL_QUALITY ~= -1) then
        MATERIAL_BUTTONS : SetActionItem(-1);
        LifeAbility : Lock_Packet_Item(MATERIAL_QUALITY,0);
        MATERIAL_QUALITY = -1;
    end
    Stiletto_Money : SetProperty("MoneyNumber", "");
    Stiletto_State: SetText("")
end

function Stiletto_Update(pos1,pos0)
    local pos_packet,pos_ui;
    pos_packet = tonumber(pos0);
    pos_ui         = tonumber(pos1);
    EquipPoint = LifeAbility : Get_Equip_Point(pos_packet);    
    
    local theAction = EnumAction(pos_packet, "packageitem");
    if pos_ui == 1 then
        if theAction:GetID() ~= 0 then
            
            local Bore_Count1 = 0;
          local Need_Item1 = -1;
          local Need_Money1 = 0;
          local Need_Item_Count1 =0;
            
            --Need_Item,Need_Money,Need_Item_Count,Bore_Count=LifeAbility : Stiletto_Preparation(pos_packet);
            Need_Item1,Need_Money1,Need_Item_Count1,Bore_Count1=LifeAbility : Stiletto_Preparation(pos_packet, 1); --1±íʾȡµÚÒ»×éÏûºÄÖµ
            
                    
            if Bore_Count1 > 2 then --add:lby 20080521 
                PushDebugMessage("— ðây chï có th¬ ðøc ðßþc 3 l²")
                return
            end
            
            if (Need_Item1 < -1 and (EquipPoint ~= 8 and  EquipPoint ~= 16 and  EquipPoint ~= 17 and EquipPoint ~= 18))then
                PushDebugMessage("V§t ph¦m này không có cách nào tång thêm máng lõm")
                return
            end                        
            
            if Need_Item1 == -2 then
              Need_Item1 = 0;
              Bore_Count1 = 0;
            end
            
            Need_Item = Need_Item1
            Need_Money = Need_Money1 
            Need_Item_Count = Need_Item_Count1
            Bore_Count = Bore_Count1
            
            
            --ÈÃ֮ǰµÄ¶«Î÷±äÁÁ
            if EQUIP_QUALITY ~= -1 then
                LifeAbility : Lock_Packet_Item(EQUIP_QUALITY,0);
                Stiletto_Money : SetProperty("MoneyNumber", "");
                Stiletto_State: SetText("")
            end

            EQUIP_BUTTONS:SetActionItem(theAction:GetID());
            EQUIP_QUALITY = pos_packet;
            LifeAbility : Lock_Packet_Item(EQUIP_QUALITY,1);
        else
            EQUIP_BUTTONS:SetActionItem(-1);
            LifeAbility : Lock_Packet_Item(EQUIP_QUALITY,0);
            EQUIP_QUALITY = -1;
            Stiletto_Money : SetProperty("MoneyNumber", "");
            Stiletto_State: SetText("")
            return;
        end
        Stiletto_Money : SetProperty("MoneyNumber", tostring(Need_Money));
        Stiletto_State : SetText("S¯ máng lõm hi®n tÕi: "..Bore_Count.."; có th¬ tång thêm s¯ máng lõm: "..tostring(3-Bore_Count))
    elseif pos_ui == 2 then
        
        local Item_Class = PlayerPackage : GetItemSubTableIndex(pos_packet,0)
        local Item_Quality = PlayerPackage : GetItemSubTableIndex(pos_packet,1)
        local Item_Type = PlayerPackage : GetItemSubTableIndex(pos_packet,2)
        
        local itemindex = PlayerPackage : GetItemTableIndex(pos_packet)
        
        
        
      if itemindex == 20109101 or itemindex == 20310111 then  --add:lby 20080521µã½ðÖ®¼ä²»ÄÜ•ÅÈ룬º®Óñ¾«´â²»ÄÜ•ÅÈë
             PushDebugMessage("V§t ph¦m này không th¬ sØ døng • ðây")
             return
      end

        if Item_Class ~= 2 or Item_Quality ~= 1 or Item_Type ~= 9 then
            return
        end
        
        if theAction:GetID() ~= 0 then
            MATERIAL_BUTTONS:SetActionItem(theAction:GetID());
            if MATERIAL_QUALITY ~= -1 then
                LifeAbility : Lock_Packet_Item(MATERIAL_QUALITY,0);
            end
            --ÈÃ֮ǰµÄ¶«Î÷±äÁÁ
            MATERIAL_QUALITY = pos_packet;
            LifeAbility : Lock_Packet_Item(MATERIAL_QUALITY,1);
        else
            MATERIAL_BUTTONS:SetActionItem(-1);
            LifeAbility : Lock_Packet_Item(MATERIAL_QUALITY,0);
            MATERIAL_QUALITY = -1;
            return;
        end
        
    end
    

--add here

end

function Stiletto_Buttons_Clicked()
    if MATERIAL_QUALITY == -1 then
        PushDebugMessage("M¶i thêm vào v§t li®u ðøc l²")
        return
    end
    if EQUIP_QUALITY ~= -1 then
        if Need_Item == -2 then
            PushDebugMessage("V§t ph¦m này không có cách nào tång thêm máng lõm")
        elseif Need_Item == -3 then
            PushDebugMessage("Máng lõm ðã ðÕt ðªn s¯ lßþng to nh¤t")
--        elseif DataPool:GetPlayerMission_ItemCountNow(Need_Item) < Need_Item_Count then
--            PushDebugMessage("ȱÉÙ²ÄÁÏ")
        elseif Player:GetData("MONEY")  < Need_Money then
            PushDebugMessage("Ngân lßþng không ðü")
        else
            
            Clear_XSCRIPT();
                Set_XSCRIPT_Function_Name("OnStiletto");
                Set_XSCRIPT_ScriptID(311200);
                Set_XSCRIPT_Parameter(0,EQUIP_QUALITY);
                Set_XSCRIPT_Parameter(1,MATERIAL_QUALITY);
                Set_XSCRIPT_ParamCount(2);
            Send_XSCRIPT();
        end
    else
        PushDebugMessage("M¶i cho vào 1 thiªt b¸ l¡p ð£t.")
    end
    
end

function Stiletto_Close()
    --²¢ÉèÖã¬Èñ³°üÀïµÄλÖñäÁÁ
    this:Hide();
    Stiletto_Clear();
    StopCareObject_Stiletto(objCared)
end

function Stiletto_Cancel_Clicked()
    Stiletto_Close();
    return;
end

--=========================================================
--¿ªÊ¼¹ØÐÄNPC£¬
--ÔÚ¿ªÊ¼¹ØÐÄ֮ǰÐèÒªÏÈÈ•¶¨Õâ¸ö½çÃæÊDz»ÊÇÒѾ¬ÓС°¹ØÐÄ¡±µÄNPC£¬
--Èç¹ûÓеĻ°£¬ÏÈÈ¡ÏûÒѾ¬Óеġ°¹ØÐÄ¡±
--=========================================================
function BeginCareObject_Stiletto(objCaredId)

    g_Object = objCaredId;
    this:CareObject(g_Object, 1, "Stiletto");

end

--=========================================================
--Í£Ö¹¶ÔijNPCµÄ¹ØÐÄ
--=========================================================
function StopCareObject_Stiletto(objCaredId)
    this:CareObject(objCaredId, 0, "Stiletto");
    g_Object = -1;

end

function Resume_Equip_Stiletto(nIndex)

    if( this:IsVisible() ) then
    
        if(nIndex == 1) then
            if(EQUIP_QUALITY ~= -1) then
                LifeAbility : Lock_Packet_Item(EQUIP_QUALITY,0);
                EQUIP_BUTTONS : SetActionItem(-1);
                EQUIP_QUALITY    = -1;
                Stiletto_Money : SetProperty("MoneyNumber", "");
                Stiletto_State: SetText("")
            end
        else
            if(MATERIAL_QUALITY ~= -1) then
                LifeAbility : Lock_Packet_Item(MATERIAL_QUALITY,0);
                MATERIAL_BUTTONS : SetActionItem(-1);
                MATERIAL_QUALITY    = -1;
            end    
        end
        
    end
    
end


Chú ý: 
1. Ở đây mới là đục lỗ thui hêy, và cũng chỉ mới được cho thú cưỡi thôi. Còn các thứ khác thì chưa thành công. 
2. Cơ chế để đục được trang bị thì server qui định vào thuộc tính Equip_Point
Nguồn sưu tầm, tác giả rikudo
Gốc http://forum.gamezone.gs/showthread....%BA%A7m)/page2
Chúc các bạn vui !

Không có nhận xét nào:

Đăng nhận xét