Jump to content

Edited Equipment Viewer


Recommended Posts

Download Center

This is the hidden content, please

 

Hi guys

Am using TMP4 files.

There are many forums, where people dont understand why doesnt work BELT or COSTUMES, but work just basic items.

This edit is WITHOUT Weapon costume and scarf system. ( Why ? Because from this topic you can write it by yourself )

https://metin2.download/picture/Jib4GEsWRzkOfE60xwUM2J1F5467nauM/.gif

So here is little edited code from:  xP3NG3Rx

 

 

In length.h (server/common):

You must find:   enum EWearPositions

Why ?  Because you need to know your index numbers like: 0,1 etc.. 23.

aaaaa.png
  
  Soo my ending number is 23. For EQ.Viewer

 

In cmd_general.cpp (server/game):

Spoiler
In original can see EQ just GM, so this is for all players:

If you want the inventory to be visible to players too

Find:

ACMD(do_view_equip)

Find:
    if (ch->GetGMLevel() <= GM_PLAYER)
        return;
        
and comment like this:

    //if (ch->GetGMLevel() <= GM_PLAYER)
        //return;

 

In char.cpp  (server/game):

Spoiler
Here you write all your positions from length.h
#int pos[24] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }; -these are all from 24 = 0 - 23 or what you have in length.h

    #for (int i = 0; i < 24; i++) <--- 24 is ending position from length.h in common again: 24 = 0 - 23

#I have 24 so int pos 24 and for i < 24 

Open char.cpp and search for this: "void CHARACTER::SendEquipment(LPCHARACTER ch)" and replace the event with this:
#######################################################################

void CHARACTER::SendEquipment(LPCHARACTER ch)
{
    TPacketViewEquip p;
    p.header = HEADER_GC_VIEW_EQUIP;
    p.vid    = GetVID();
    int pos[24] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
    for (int i = 0; i < 24; i++)
    {
        LPITEM item = GetWear(pos[i]);
        if (item)
        {
            p.equips[i].vnum = item->GetVnum();
            p.equips[i].count = item->GetCount();

            thecore_memcpy(p.equips[i].alSockets, item->GetSockets(), sizeof(p.equips[i].alSockets));
            thecore_memcpy(p.equips[i].aAttr, item->GetAttributes(), sizeof(p.equips[i].aAttr));
        }
        else
        {
            p.equips[i].vnum = 0;
        }
    }
    ch->GetDesc()->Packet(&p, sizeof(p));
}

 

In packet.h  (server/game):

Spoiler
equips[24]; ---> your max from length.h which is 0-23 (again) equips[XX] = writen in char.cpp

Open /game/packet.h than search for: "typedef struct pakcet_view_equip" and replace all structure with this:
#######################################################################

typedef struct pakcet_view_equip
{
    BYTE    header;
    DWORD    vid;
    struct {
        DWORD    vnum;
        BYTE    count;
        long    alSockets[ITEM_SOCKET_MAX_NUM];
        TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
    } equips[24];
} TPacketViewEquip;

 

In Packet.h (Binary/client):

Spoiler
#See ? You again calling your number in client --> equips[24];

Open UserInterfacePacket.h than search for this: "typedef struct pakcet_view_equip" and replace with this:
#######################################################################

typedef struct pakcet_view_equip
{
    BYTE    header;
    DWORD    dwVID;
    TEquipmentItemSet equips[24];
} TPacketGCViewEquip;

 

In PythonNetworkStreamPhaseGame (Binary/client):

Spoiler
#Here is again your number : for (int i = 0; i < 24; ++i) // < 24; ++i)  from char.cpp

Open UserInterfacePythonNetworkStreamPhaseGame.cpp than search for this: "bool CPythonNetworkStream::RecvViewEquipPacket()" and replace with this:
#######################################################################

bool CPythonNetworkStream::RecvViewEquipPacket()
{
    TPacketGCViewEquip kViewEquipPacket;
    if (!Recv(sizeof(kViewEquipPacket), &kViewEquipPacket))
        return false;

    PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OpenEquipmentDialog", Py_BuildValue("(i)", kViewEquipPacket.dwVID));
    for (int i = 0; i < 24; ++i)
    {
        TEquipmentItemSet & rItemSet = kViewEquipPacket.equips[i];
        PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetEquipmentDialogItem", Py_BuildValue("(iiii)", kViewEquipPacket.dwVID, i, rItemSet.vnum, rItemSet.count));

        for (int j = 0; j < ITEM_SOCKET_SLOT_MAX_NUM; ++j)
            PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetEquipmentDialogSocket", Py_BuildValue("(iiii)", kViewEquipPacket.dwVID, i, j, rItemSet.alSockets[j]));

        for (int k = 0; k < ITEM_ATTRIBUTE_SLOT_MAX_NUM; ++k)
            PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetEquipmentDialogAttr", Py_BuildValue("(iiiii)", kViewEquipPacket.dwVID, i, k, rItemSet.aAttr[k].bType, rItemSet.aAttr[k].sValue));
    }

    return true;
}

 

In root/interfaceModule.py:

Spoiler
Open interfaceModule.py and search for this: "def OpenEquipmentDialog(self, vid):" if you found it replace that function with this:
#######################################################################
find: 

    def OpenEquipmentDialog(self, vid):
        dlg = uiEquipmentDialog.EquipmentDialog()
        dlg.SetItemToolTip(self.tooltipItem)
        dlg.SetCloseEvent(ui.__mem_func__(self.CloseEquipmentDialog))
        dlg.Open(vid)

        self.equipmentDialogDict[vid] = dlg

and replace with this:

    def OpenEquipmentDialog(self, vid):
        if self.equipmentDialogDict.has_key(vid):
            self.equipmentDialogDict[vid].Destroy()
            self.CloseEquipmentDialog(vid)

        dlg = uiEquipmentDialog.EquipmentDialog()
        dlg.SetItemToolTip(self.tooltipItem)
        dlg.SetCloseEvent(ui.__mem_func__(self.CloseEquipmentDialog))
        dlg.Open(vid)

        self.equipmentDialogDict[vid] = dlg

 

In root/uiequipmentdialog.py:

Spoiler
#Compare it with your code:

#Why ? Because here is class CostumeEquipmentDialog ( You probably don't have this )

# in def RefreshSlot(self):
        #You have numbers of your costumes so for me is : for i in [19, 20]: again from length.h

import ui
import chr
import player

class CostumeEquipmentDialog(ui.ScriptWindow):
    def __init__(self, wndEquipment):
        if not wndEquipment:
            import exception
            exception.Abort("wndEquipment parameter must be set to CostumeEquipmentDialog")
            return

        ui.ScriptWindow.__init__(self)

        self.isLoaded = 0
        self.wndEquipment = wndEquipment;

        self.wndCostumeEquipmentLayer = None
        self.wndCostumeEquipmentSlot = None
        self.expandBtn = None
        self.minBtn = None

        self.__LoadWindow()

    def __del__(self):
        ui.ScriptWindow.__del__(self)

    def Show(self):
        self.__LoadWindow()
        ui.ScriptWindow.Show(self)

        self.CloseCostumeEquipment()

    def Close(self):
        self.Hide()

    def IsOpenedCostumeEquipment(self):
        return self.wndCostumeEquipmentLayer.IsShow()

    def OpenCostumeEquipment(self):
        self.wndCostumeEquipmentLayer.Show()
        self.expandBtn.Hide()

        self.AdjustPositionAndSize()
        self.RefreshSlot()

    def CloseCostumeEquipment(self):
        self.wndCostumeEquipmentLayer.Hide()
        self.expandBtn.Show()

        self.AdjustPositionAndSize()

    def GetBasePosition(self):
        x, y = self.wndEquipment.GetGlobalPosition()
        return x - 139, y + 30

    def AdjustPositionAndSize(self):
        bx, by = self.GetBasePosition()

        if self.IsOpenedCostumeEquipment():
            self.SetPosition(bx, by)
            self.SetSize(self.ORIGINAL_WIDTH, self.GetHeight())

        else:
            self.SetPosition(bx + 129, by);
            self.SetSize(10, self.GetHeight())

    def __LoadWindow(self):
        if self.isLoaded == 1:
            return

        self.isLoaded = 1

        try:
            pyScrLoader = ui.PythonScriptLoader()
            pyScrLoader.LoadScriptFile(self, "UIScript/CostumeEquipmentDialog.py")
        except:
            import exception
            exception.Abort("CostumeEquipmentDialog.LoadWindow.LoadObject")

        try:
            self.ORIGINAL_WIDTH = self.GetWidth()
            wndCostumeEquipmentSlot = self.GetChild("CostumeEquipmentSlot")
            self.wndCostumeEquipmentLayer = self.GetChild("CostumeEquipmentLayer")
            self.expandBtn = self.GetChild("ExpandButton")
            self.minBtn = self.GetChild("MinimizeButton")

            self.expandBtn.SetEvent(ui.__mem_func__(self.OpenCostumeEquipment))
            self.minBtn.SetEvent(ui.__mem_func__(self.CloseCostumeEquipment))

        except:
            import exception
            exception.Abort("CostumeEquipmentDialog.LoadWindow.BindObject")

        wndCostumeEquipmentSlot.SetOverInItemEvent(ui.__mem_func__(self.wndEquipment.OverInItem))
        wndCostumeEquipmentSlot.SetOverOutItemEvent(ui.__mem_func__(self.wndEquipment.OverOutItem))
        self.wndCostumeEquipmentSlot = wndCostumeEquipmentSlot

    def RefreshSlot(self):
        equipmentDict = self.wndEquipment.itemDataDict
        for i in [19, 20]:
            if equipmentDict.has_key(i):
                self.wndCostumeEquipmentSlot.SetItemSlot(i, equipmentDict[i][0], equipmentDict[i][1])


class EquipmentDialog(ui.ScriptWindow):

    def __init__(self):
        print "NEW EQUIPMENT DIALOG ----------------------------------------------------------------------------"
        ui.ScriptWindow.__init__(self)
        self.__LoadDialog()

        self.vid = None
        self.eventClose = None
        self.itemDataDict = {}
        self.tooltipItem = None

    def __del__(self):
        print "---------------------------------------------------------------------------- DELETE EQUIPMENT DIALOG "
        ui.ScriptWindow.__del__(self)

    def __LoadDialog(self):
        try:
            PythonScriptLoader = ui.PythonScriptLoader()
            PythonScriptLoader.LoadScriptFile(self, "UIScript/EquipmentDialog.py")

            getObject = self.GetChild
            self.board = getObject("Board")
            self.slotWindow = getObject("EquipmentSlot")

            self.wndCostumeEquipment = CostumeEquipmentDialog(self)

        except:
            import exception
            exception.Abort("EquipmentDialog.LoadDialog.BindObject")

        self.board.SetCloseEvent(ui.__mem_func__(self.Close))
        self.slotWindow.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
        self.slotWindow.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))

    def Open(self, vid):

        self.vid = vid
        self.itemDataDict = {}

        name = chr.GetNameByVID(vid)
        self.board.SetTitleName(name)

        self.SetCenterPosition()
        self.SetTop()
        self.Show()

        if self.wndCostumeEquipment:
            self.wndCostumeEquipment.Show()

    def Close(self):
        self.itemDataDict = {}
        self.tooltipItem = None
        self.Hide()

        if self.eventClose:
            self.eventClose(self.vid)

        if self.wndCostumeEquipment:
            self.wndCostumeEquipment.Close()

    def Destroy(self):
        self.eventClose = None

        self.Close()
        self.ClearDictionary()

        self.board = None
        self.slotWindow = None

        if self.wndCostumeEquipment:
            self.wndCostumeEquipment.Destroy()
            self.wndCostumeEquipment = None

    def SetEquipmentDialogItem(self, slotIndex, vnum, count):
        if count <= 1:
            count = 0
        self.slotWindow.SetItemSlot(slotIndex, vnum, count)

        emptySocketList = []
        emptyAttrList = []
        for i in xrange(player.METIN_SOCKET_MAX_NUM):
            emptySocketList.append(0)
        for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
            emptyAttrList.append((0, 0))
        self.itemDataDict[slotIndex] = (vnum, count, emptySocketList, emptyAttrList)

    def SetEquipmentDialogSocket(self, slotIndex, socketIndex, value):
        if not slotIndex in self.itemDataDict:
            return
        if socketIndex < 0 or socketIndex > player.METIN_SOCKET_MAX_NUM:
            return
        self.itemDataDict[slotIndex][2][socketIndex] = value

    def SetEquipmentDialogAttr(self, slotIndex, attrIndex, type, value):
        if not slotIndex in self.itemDataDict:
            return
        if attrIndex < 0 or attrIndex > player.ATTRIBUTE_SLOT_MAX_NUM:
            return
        self.itemDataDict[slotIndex][3][attrIndex] = (type, value)

    def SetItemToolTip(self, tooltipItem):
        self.tooltipItem = tooltipItem

    def SetCloseEvent(self, event):
        self.eventClose = event

    def OverInItem(self, slotIndex):

        if None == self.tooltipItem:
            return

        if not slotIndex in self.itemDataDict:
            return

        itemVnum = self.itemDataDict[slotIndex][0]
        if 0 == itemVnum:
            return

        self.tooltipItem.ClearToolTip()
        metinSlot = self.itemDataDict[slotIndex][2]
        attrSlot = self.itemDataDict[slotIndex][3]
        self.tooltipItem.AddItemData(itemVnum, metinSlot, attrSlot)
        self.tooltipItem.ShowToolTip()

    def OverOutItem(self):
        if None != self.tooltipItem:
            self.tooltipItem.HideToolTip()

    def OnPressEscapeKey(self):
        self.Close()
        return True

    def OnMoveWindow(self, x, y):
        if self.wndCostumeEquipment:
            self.wndCostumeEquipment.AdjustPositionAndSize()

 

In root/uitarget.py:

Spoiler
Search:
#######################################################################

        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])

Add:
#######################################################################

        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT])

Search:

    BUTTON_NAME_LIST = ( 

        under  localeInfo.TARGET_BUTTON_EXIT_OBSERVER,

        add    localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT,

in def ShowDefaultButton(self):

find:
        def ShowDefaultButton(self):
        
under this:
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
add this:

        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT])

soo its looks like this :
    def ShowDefaultButton(self):

        self.isShowButton = True
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW])
        for button in self.showingButtonList:
            button.Show()


If you would like to see just for GM do it like this:

    def ShowDefaultButton(self):

        self.isShowButton = True
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT])
        if str(player.GetName())[0] == "[":
            self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT])
        self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW])
        for button in self.showingButtonList:
            button.Show()

 

in uiscript/equipmentdialog.py:

Spoiler
import uiScriptLocale

window = {
    "name" : "EquipmentDialog",
    "style" : ("movable", "float",),

    "x" : 0,
    "y" : 0,

    "width" : 180,
    "height" : 230,

    "children" :
    (
        {
            "name" : "Board",
            "type" : "board_with_titlebar",

            "x" : 0,
            "y" : 0,

            "width" : 180,
            "height" : 230,

            "title" : "Character Name",

            "children" :
            (
                {
                    "name":"EquipmentBaseImage",
                    "type":"image",
                    "style" : ("attach",),

                    "x" : 0,
                    "y" : 9,
                    "horizontal_align" : "center",
                    "vertical_align" : "center",

                    "image" : "d:/ymir work/ui/equipment_bg_OGZZ.tga",

                    "children" :
                    (

                        {
                            "name" : "EquipmentSlot",
                            "type" : "slot",

                            "x" : 3,
                            "y" : 3,

                            "width" : 150,
                            "height" : 182,

                            "slot" : (
                                        {"index":0, "x":39, "y":37, "width":32, "height":64},
                                        {"index":1, "x":39, "y":2, "width":32, "height":32},
                                        {"index":2, "x":39, "y":145, "width":32, "height":32},
                                        {"index":3, "x":75, "y":67, "width":32, "height":32},
                                        {"index":4, "x":3, "y":3, "width":32, "height":96},
                                        {"index":5, "x":114, "y":67, "width":32, "height":32},
                                        {"index":6, "x":114, "y":35, "width":32, "height":32},
                                        {"index":7, "x":2, "y":145, "width":32, "height":32},
                                        {"index":8, "x":75, "y":145, "width":32, "height":32},
                                        {"index":9, "x":114, "y":2, "width":32, "height":32},
                                        {"index":10, "x":75, "y":35, "width":32, "height":32},

                                        ## ring 1

                                        ##{"index":21, "x":2, "y":106, "width":32, "height":32},

                                        ## ring 2

                                        ##{"index":22, "x":75, "y":106, "width":32, "height":32},

                                        ## Belt
                                        
                                        {"index":23, "x":39, "y":106, "width":32, "height":32},
                              
                              ## as you can see again you looking from length.h    -    enum EWearPositions [ unexpectedly index are numbers from length.h ]
                              ## but ! Costumes you have in costumeequipmentdialog.py

                                    ),
                        },

                    ),

                },
            ),
        },
    ),
}

 

add  costumeequipmentdialog.py in uiscript:

Spoiler
import uiScriptLocale

window = {
    "name" : "CostumeEquipmentDialog",

    "x" : 0,
    "y" : 0,

    "width" : 139,
    "height" : 145,

    "children" :
    (
        {
            "name" : "ExpandButton",
            "type" : "button",

            "x" : 2,
            "y" : 15,

            "default_image" : "d:/ymir work/ui/game/belt_inventory/btn_expand_normal.tga",
            "over_image" : "d:/ymir work/ui/game/belt_inventory/btn_expand_over.tga",
            "down_image" : "d:/ymir work/ui/game/belt_inventory/btn_expand_down.tga",
            "disable_image" : "d:/ymir work/ui/game/belt_inventory/btn_expand_disabled.tga",
        },

        {
            "name" : "CostumeEquipmentLayer",

            "x" : 5,
            "y" : 0,

            "width" : 139,
            "height" : 145,

            "children" :
            (
                {
                    "name" : "MinimizeButton",
                    "type" : "button",

                    "x" : 2,
                    "y" : 15,

                    "default_image" : "d:/ymir work/ui/game/belt_inventory/btn_minimize_normal.tga",
                    "over_image" : "d:/ymir work/ui/game/belt_inventory/btn_minimize_over.tga",
                    "down_image" : "d:/ymir work/ui/game/belt_inventory/btn_minimize_down.tga",
                    "disable_image" : "d:/ymir work/ui/game/belt_inventory/btn_minimize_disabled.tga",
                },

                {
                    "name" : "CostumeEquipmentBoard",
                    "type" : "board",
                    "style" : ("attach", "float"),

                    "x" : 10,
                    "y" : 0,

                    "width" : 129,
                    "height" : 145,

                    "children" :
                    (
                        {
                            "name" : "Costume_Base",
                            "type" : "image",

                            "x" : 8,
                            "y" : 8,

                            "image" : uiScriptLocale.LOCALE_UISCRIPT_PATH + "costume/costume_bg.jpg",

                            "children" :
                            (
                                {
                                    "name" : "CostumeEquipmentSlot",
                                    "type" : "slot",

                                    "x" : 3,
                                    "y" : 3,

                                    "width" : 127,
                                    "height" : 145,

                                    "slot" : (
                                        {"index":19, "x":61, "y":45, "width":32, "height":64},
                                        {"index":20, "x":61, "y": 8, "width":32, "height":32},
                                        #{"index":, "x":5, "y":145, "width":32, "height":32}, THIS IS FOR WEAPON COSTUME/MOUNT/SCARF - I HAVENT 
                                        # see ? numbers 19 and 20 are costumes in length.h... MAGIC...
                                    ),
                                },
                            ),
                        },
                    ),
                },
            ),
        },
    ),
}

 

 

You have in  DOWNLOAD LINK folder ymir work, read TXT:)

enjoy 

Sorry for my bad  english.

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 21
  • Good 5
  • Love 1
  • Love 3
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.