FUENTE LEGADO BASE PIKE 4.3 (MUSERVER+DB+CLIENTE+SOURCE) - Source Mu - Mu Server Files
 

FUENTE LEGADO BASE PIKE 4.3 (MUSERVER+DB+CLIENTE+SOURCE)

Publicado por Dakosmu, Dic 01, 2025, 02:29 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Dakosmu

✅ Guía Paso a Paso: Implementando el FIX Anti-Auto-Wear (Post Item / Jewel Bank)

<div style="width: 100%; height: 0px; position: relative; padding-bottom: 64.337%;"><iframe src="Regístrate para ver el enlace" frameborder="0" width="100%" height="100%" allowfullscreen style="width: 100%; height: 100%; position: absolute;"></iframe></div>



Esta guía detalla la implementación de un FIX de código que resuelve el conflicto de acciones al hacer Clic Derecho en el inventario, evitando que el juego intente equipar automáticamente (Auto-Wear) un objeto cuando se desea enlazarlo (Post Item con CTRL) o depositarlo (Jewel Bank con SHIFT).

---

1️⃣ Problema a Solucionar

El juego, por defecto, prioriza el Auto-Wear (equipamiento automático) al usar el Clic Derecho. Esto causa una interferencia cuando el jugador intenta usar:
  • CTRL + Clic Derecho: Para la función Post Item (enlazar el objeto en el chat).
  • SHIFT + Clic Derecho: Para depositar joyas en el Jewel Bank.
El FIX añade un bloqueo preventivo para asegurar que la acción deseada (Post Item o Jewel Bank) se ejecute sin el Auto-Wear.

---

2️⃣ Modificación en ItemMove.cpp (El Bloqueo del Auto-Wear)

El cambio crucial se realiza en el archivo ItemMove.cpp, dentro de la función RightClickMoveItem().

Instrucción: Añade el siguiente bloque de código al inicio de la función, justo después de la apertura de la llave ({):

void RightClickMoveItem()
{
    // ============================================================
    // ✅ FIX: Block auto-wear if CTRL is pressed (PK mode)
    // ============================================================
    if (GetKeyState(VK_CONTROL) & 0x8000)
    {
        return; // Do NOT auto-equip the item
    }

    // ============================================================
    // ✅ ORIGINAL RIGHT-CLICK LOGIC
    // ============================================================
//... El resto del código original continúa aquí sin modificaciones.

  • Explicación: La línea if (GetKeyState(VK_CONTROL) & 0x8000) verifica si la tecla CTRL está presionada. Si es así, la función return; detiene la ejecución del código de equipamiento/movimiento automático que sigue a continuación.

---

3️⃣ Implementación de Prioridad en post_item.cpp

El siguiente paso es asegurarse de que las funciones Post Item y Jewel Bank se ejecuten con prioridad si se presionan sus respectivas teclas modificadoras.

Instrucción: Ubica la función HookRenderItemToolTip() en post_item.cpp y verifica que la lógica de comprobación y ejecución esté estructurada de la siguiente manera:

// ...
        //
        // CTRL + Right Click (block equip / block move)
        if ((GetKeyState(VK_RBUTTON) & 0x8000) && (GetKeyState(VK_CONTROL) & 0x8000))
        {
            JCItemPublic.PostItemProc(uniqId); // your link item function
            return; // IMPORTANT: block default MU behavior
        }

        else
        {
            // === Right click = Jewel Bank ===
            if (GetKeyState(VK_RBUTTON) & 0x8000 && GetKeyState(VK_SHIFT) & 0x8000)
            {
                // panel: normal / expanded / 2nd inventory
                int panel = *(DWORD*)(a1 + 44);


                if (panel == 200 || panel == 44 || panel == 131)
                {
                    int start = (panel == 200) ? 12 : (panel == 44) ? 76 : 108;
                    int Slot = item->PosX + (item->PosY * 8) + start;

                    gCustomJewelBank.JewelBankSend(Slot);
                    return;
                }
            }
            // === Default Right click = move / equip etc ===
            if (!pIsKeyRepeat(VK_CONTROL))
            {
                JCItemPublic.CDActionItem(item);
                return;
            }
        }
// ...
[list] [li][b]Secuencia de Prioridad:[/b] Este código garantiza que si se presiona [b]CTRL[/b] (Post Item) o [b]SHIFT[/b] (Jewel Bank), la acción por defecto del Clic Derecho ([b]Auto-Wear/movimiento[/b]) sea bloqueada mediante el uso de [b]return;[/b] inmediatamente después de ejecutar la función específica.[/li] [/list]

[okay]4️⃣ Finalización y Compilación[/okay]

Una vez que hayas aplicado las modificaciones en [b]ItemMove.cpp[/b] y [b]post_item.cpp[/b], simplemente compila tu proyecto.

[list] [li]El resultado será un juego donde el uso de [b]CTRL + Clic Derecho[/b] únicamente enlazará el objeto, [b]sin equiparlo[/b] por accidente, eliminando un error común en contextos PvP y de Post Item.[/li] [/list]

[b]¡100% Funcional![/b]


[okay]Codigo completo[/okay]

[info]ItemMove.cpp[/info]
[code]void RightClickMoveItem()
{
    // ============================================================
    // ✅ FIX: Block auto-wear if CTRL is pressed (PK mode)
    // ============================================================
    if (GetKeyState(VK_CONTROL) & 0x8000)
    {
        return; // Do NOT auto-equip the item
    }

    // ============================================================
    // ✅ ORIGINAL RIGHT-CLICK LOGIC
    // ============================================================

    if (!ppMousePress(VK_RBUTTON) || PickedItem || ItemMove)
    {
        return;
    }

    if (pCheckWindow(pWindowThis(), 9) == 0 && pCheckWindow(pWindowThis(), 13) == 0) // ChaosBox ~ Inventory
    {
        return;
    }

    ItemMove = false;
    SourceFlag = -1;

    SourceSlot = *(DWORD*)((DWORD)InventoryThis(pWindowThis()) + 284);
    TargetSlot = -1;

    if (SourceSlot >= 0 && SourceSlot < INVENTORY_WEAR_SIZE)
    {
        if (*(DWORD*)MAIN_CURRENT_MAP == 10 || *(DWORD*)MAIN_CURRENT_MAP == 39)
        {
            if (SourceSlot == 7 &&
                GetItemEquipedIndex(8) != GET_ITEM(13, 3) &&
                GetItemEquipedIndex(8) != GET_ITEM(13, 4) &&
                GetItemEquipedIndex(8) != GET_ITEM(13, 37))
            {
                return;
            }

            if (SourceSlot == 8 &&
                (GetItemEquipedIndex(8) == GET_ITEM(13, 3) ||
                    GetItemEquipedIndex(8) == GET_ITEM(13, 4) ||
                    GetItemEquipedIndex(8) == GET_ITEM(13, 37)) &&
                GetItemEquipedIndex(7) == 0xFFFF)
            {
                return;
            }
        }

        DWORD ItemStruct = GetItemEquiped(SourceSlot);

        if (ItemStruct && GetItemEquipedIndex(SourceSlot) != 0xFFFF)
        {
            ITEM_INFO2* lpItemInfo = GetItemInfo(*(WORD*)ItemStruct);

            TargetSlot = InventoryFindEmptySlot(InventoryThis(pWindowThis()), lpItemInfo->Width, lpItemInfo->Height);

            if (TargetSlot != -1)
            {
                SendRequestEquipmentItem(0, SourceSlot, ItemStruct, 0, INVENTORY_WEAR_SIZE + TargetSlot);
                ResetMouseRButton();
                ItemMove = true;
                SourceFlag = 0;
            }
        }
    }
    else
    {
        int InventoryMain = InventoryFindItemSlot(GetMyInventoryCtrl(InventoryThis(pWindowThis()), 0), pCursorX, pCursorY);
        int InventoryExpand1 = InventoryFindItemSlot(GetMyInventoryCtrl(InventoryThis(pWindowThis()), 1), pCursorX, pCursorY);
        int InventoryExpand2 = InventoryFindItemSlot(GetMyInventoryCtrl(InventoryThis(pWindowThis()), 2), pCursorX, pCursorY);

        if (pCheckWindow(pWindowThis(), 9) != 0)
        {
            DWORD MixItemStruct = (DWORD)InventoryFindItem(MixGetMyInventoryCtrl(MixInventoryThis(pWindowThis())), pCursorX, pCursorY);

            if (MixItemStruct)
            {
                ITEM_INFO2* lpItemInfo = GetItemInfo(*(WORD*)MixItemStruct);

                SourceSlot = InventoryFindItemSlot(MixGetMyInventoryCtrl(MixInventoryThis(pWindowThis())), pCursorX, pCursorY);
                TargetSlot = InventoryFindEmptySlot(InventoryThis(pWindowThis()), lpItemInfo->Width, lpItemInfo->Height);

                if (SourceSlot != -1 && TargetSlot != -1)
                {
                    SendRequestEquipmentItem(3, SourceSlot, MixItemStruct, 0, INVENTORY_WEAR_SIZE + TargetSlot);
                    ResetMouseRButton();
                    ItemMove = true;
                    SourceFlag = 1;
                }
            }
            else
            {
                DWORD InventoryCtrl = -1;

                DWORD ItemStruct = (DWORD)InventoryFindItemAtPt(InventoryThis(pWindowThis()), pCursorX, pCursorY, &InventoryCtrl);

                if (ItemStruct)
                {
                    ITEM_INFO2* lpItemInfo = GetItemInfo(*(WORD*)ItemStruct);

                    if (InventoryMain != -1)
                        SourceSlot = INVENTORY_WEAR_SIZE + InventoryMain;
                    else if (InventoryExpand1 != -1)
                        SourceSlot = INVENTORY_EXT1_SIZE + InventoryExpand1;
                    else if (InventoryExpand2 != -1)
                        SourceSlot = INVENTORY_EXT2_SIZE + InventoryExpand2;

                    TargetSlot = InventoryMixFindEmptySlot(MixGetMyInventoryCtrl(MixInventoryThis(pWindowThis())), lpItemInfo->Width, lpItemInfo->Height);

                    if (SourceSlot != -1 && TargetSlot != -1)
                    {
                        SendRequestEquipmentItem(0, SourceSlot, ItemStruct, 3, TargetSlot);
                        ResetMouseRButton();
                        ItemMove = true;
                        SourceFlag = 0;
                    }
                }
            }
        }
        else
        {
            if (pCheckWindow(pWindowThis(), 7) != 0 || pCheckWindow(pWindowThis(), 8) != 0) // Trade ~ Warehouse
            {
                return;
            }

            DWORD InventoryCtrl = -1;

            DWORD ItemStruct = (DWORD)InventoryFindItemAtPt(InventoryThis(pWindowThis()), pCursorX, pCursorY, &InventoryCtrl);

            if (ItemStruct)
            {
                if (InventoryMain != -1)
                    SourceSlot = INVENTORY_WEAR_SIZE + InventoryMain;
                else if (InventoryExpand1 != -1)
                    SourceSlot = INVENTORY_EXT1_SIZE + InventoryExpand1;
                else if (InventoryExpand2 != -1)
                    SourceSlot = INVENTORY_EXT2_SIZE + InventoryExpand2;

                TargetSlot = GetInventoryWearSlot(*(WORD*)ItemStruct);

                if (SourceSlot != -1 && TargetSlot != 0xFF)
                {
                    SendRequestEquipmentItem(0, SourceSlot, ItemStruct, 0, TargetSlot);
                    ResetMouseRButton();
                    ItemMove = true;
                    SourceFlag = 0;
                }
            }
        }
    }
}

CustomJewelBank.cpp

void InvetoryItemOver(int This)
{
    lpItemObj item = (lpItemObj) * (DWORD*)(This + 84);

    if (item)
    {
        if (GetKeyState(VK_RBUTTON) & 0x8000 && GetKeyState(VK_SHIFT) & 0x8000)
        {
            int start = 12;
            if (*(DWORD*)(This + 44) == 200)
            {
                start = 12;
            }
            else if (*(DWORD*)(This + 44) == 44)
            {
                start = 76;
            }
            else if (*(DWORD*)(This + 44) == 131)
            {
                start = 108;
            }

            int Slot = item->PosX + (item->PosY * 8) + start;

            gCustomJewelBank.JewelBankSend(Slot);
        }
    }

    ((void(__thiscall*)(int))0x007DCF20)(This);
}

void CCustomJewelBank::Load()
{
    //SetCompleteHook(0xE8, 0x007DD0D9, &InvetoryItemOver);
}

post_item.cpp

void HookRenderItemToolTip(int a1)
{
    ((void(__cdecl*)()) 0x007DCF20)();
    lpItemObj item = (lpItemObj) * (DWORD*)(a1 + 84);
    //===Fix Move Item

    //===
    if (gInterface.CheckWindow(8))
    {
        return;
    }
    DWORD uniqId = 0;
    if (item) {
        int pos = -1;
        if (a1 == *(DWORD*)(*(DWORD*)0x098670B8 + 0x18))
        {
            uniqId = item->UniqueID;
        }
        else if (a1 == *(DWORD*)(*(DWORD*)0x098670B8 + 0x1C))
        {
            uniqId = item->UniqueID + 0x10000000;
        }
        else if (a1 == *(DWORD*)(*(DWORD*)0x098670B8 + 0x20))
        {
            uniqId = item->UniqueID + 0x20000000;
        }
        //
        // CTRL + Right Click (block equip / block move)
        if ((GetKeyState(VK_RBUTTON) & 0x8000) && (GetKeyState(VK_CONTROL) & 0x8000))
        {
            JCItemPublic.PostItemProc(uniqId); // your link item function
            return; // IMPORTANT: block default MU behavior
        }

        else
        {
            // === Right click = Jewel Bank ===
            if (GetKeyState(VK_RBUTTON) & 0x8000 && GetKeyState(VK_SHIFT) & 0x8000)
            {
                // panel: normal / expanded / 2nd inventory
                int panel = *(DWORD*)(a1 + 44);


                if (panel == 200 || panel == 44 || panel == 131)
                {
                    int start = (panel == 200) ? 12 : (panel == 44) ? 76 : 108;
                    int Slot = item->PosX + (item->PosY * 8) + start;

                    gCustomJewelBank.JewelBankSend(Slot);
                    return;
                }
            }
            // === Default Right click = move / equip etc ===
            if (!pIsKeyRepeat(VK_CONTROL))
            {
                JCItemPublic.CDActionItem(item);
                return;
            }
        }
    }
}

Bon Dia

🡱 🡳
Real Time Web Analytics