Noticias:

SMF - Just Installed!

Menú principal

Source Right Click Mouse v2

Publicado por Dakosmu, Mayo 11, 2024, 07:06 AM

Tema anterior - Siguiente tema

Dakosmu

Source Right Click Mouse v2

LADO MAIN

stdafx.h


#define clic_right        1 //clic_right

post_item.cpp

Dentro de void PostItem::Hook()


#if clic_right
    SetCompleteHook(0xE9, 0x0083B7E4 + 0x150, &Equipments);//1.04D->0x0083B7E4
#endif


Dentro de void PostItem::PostItemToWorldChatChannelImp

Los visitantes no pueden visualizar imágenes en los mensajes, por favor Regístrate o Inicia Sesión



#if clic_right
    //Click Derecho
    else if (GetKeyState(VK_RBUTTON) & 0x8000
        && GetTickCount() >= gPostItem.last_tickcount_moveitem_ + 300)
    {
        ObjectItem* lItem = (ObjectItem*)item_data;

        if (lItem->ItemID < 0) { return; }

        PMSG_ITEM_MOVE_RECV pMsg = { 0 };

        pMsg.h.set(0x79, 0x01, sizeof(pMsg));
        pMsg.Target = -1;

        /*if (gInterface.CheckWindow(NPC_ChaosMix) && gInterface.CheckWindow(Inventory))
        {
            if ((pCursorX > 460))
            {
                pMsg.sFlag = 0;
                pMsg.tFlag = 3;
                pMsg.Target = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12;
            }
            else if (gInterface.CheckWindow(ExpandInventory) && pCursorX > 260)
            {
                pMsg.sFlag = 0;
                pMsg.tFlag = 3;
                pMsg.Target = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12 + 64;
                if (pCursorY > 130)
                    pMsg.Source += 32;
            }
            else
            {
                pMsg.sFlag = 3;
                pMsg.tFlag = 0;
                pMsg.Target = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8;
            }
        }
        else */if (gInterface.CheckWindow(ChaosBox) && gInterface.CheckWindow(Inventory))
        {
            if ((pCursorX > 460))
            {
                pMsg.sFlag = 0;
                pMsg.tFlag = 3;
                pMsg.Target = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12;
            }
            else if (gInterface.CheckWindow(ExpandInventory) && pCursorX > 260)
            {
                pMsg.sFlag = 0;
                pMsg.tFlag = 3;
                pMsg.Target = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12 + 64;
                if (pCursorY > 130)
                    pMsg.Source += 32;
            }
            else
            {
                pMsg.sFlag = 3;
                pMsg.tFlag = 0;
                pMsg.Target = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8;
            }
        }
        else
        {
            float v1 = 0;
            if (gInterface.CheckWindow(Character))
                v1 = *(float*)(0x00D24E88);
            if ((pCursorX > 460 - v1))
            {
                pMsg.sFlag = 0;
                pMsg.tFlag = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12;

            }
            else if (gInterface.CheckWindow(ExpandInventory) && pCursorX > 260 - v1)
            {
                pMsg.sFlag = 0;
                pMsg.tFlag = 0;
                pMsg.Source = lItem->PosX + lItem->PosY * 8 + 12 + 64;
                if (pCursorY > 130)
                    pMsg.Source += 32;
            }
            pMsg.Target = 0;
        }

        DataSend((BYTE*)&pMsg, pMsg.h.size);
        gPostItem.last_tickcount_moveitem_ = GetTickCount();
    }
#endif




#if clic_right
//clic right
void __declspec (naked) PostItem::Equipments()
{
    static DWORD mem = 0;
    _asm {
        mov eax, dword ptr ds : [ebp - 04]
        mov mem, eax
    }
    RemoveEquipment((void*)mem);
    _asm {
        mov esp, ebp
        pop ebp
        ret 0004
    }
}
#endif



#if clic_right
void PostItem::RemoveEquipment(void* item_data)
{

    if (gInterface.CheckWindow(Trade) ||
        gInterface.CheckWindow(Warehouse) ||
        gInterface.CheckWindow(Shop) ||
        gInterface.CheckWindow(Store) ||
        gInterface.CheckWindow(OtherStore) ||
        gInterface.CheckWindow(CashShop) ||
        gInterface.CheckWindow(ExpandWarehouse)) {
        return;
    }
    if (GetKeyState(VK_RBUTTON) & 0x8000 && GetTickCount() >= gPostItem.last_tickcount_moveitem_ + 250) {

        ObjectItem* lItem = (ObjectItem*)item_data;

        if (lItem->ItemID < 0) { return; }

        PMSG_ITEM_MOVE_RECV pMsg = { 0 };

        pMsg.h.set(0x79, 0x01, sizeof(pMsg));

        pMsg.sFlag = 0;
        pMsg.tFlag = 0;
        pMsg.Source = lItem->PosX;
        pMsg.Target = 0;

        DataSend((BYTE*)&pMsg, pMsg.h.size);

        gPostItem.last_tickcount_moveitem_ = GetTickCount();
    }
}
#endif


post_item.h

Dentro de class PostItem ""En public:"


#if clic_right
    //Right click

    static void Equipments();
    static void RemoveEquipment(void* item_data);
#endif



#if clic_right
    //Right Click
    DWORD last_tickcount_moveitem_;
    void* item_post_;
#endif


Protocol.cpp

Dentro de case 0xF3:


#if clic_right
        case 0xEE:
            SetChaosBoxState((PMSG_SET_CHAOSBOX_STATE*)lpMsg);
            return 1;
#endif



#if clic_right
void SetChaosBoxState(PMSG_SET_CHAOSBOX_STATE* Data) {
    pChaosBoxState = Data->state;
    return;
}
#endif


Protocol.h


#if clic_right
struct PMSG_SET_CHAOSBOX_STATE
{
    PSBMSG_HEAD header; // C1:32
    BYTE state;
};

struct PMSG_ITEM_MOVE_RECV
{
    PSBMSG_HEAD h;
    BYTE sFlag;
    BYTE tFlag;
    BYTE Source;
    BYTE Target;
};
#endif




#if clic_right
void SetChaosBoxState(PMSG_SET_CHAOSBOX_STATE* Data);
#endif

































Bon Dia

Dakosmu

#1
Lado Gameserver


stdafx.h


#define    clic_right        1


User.h


#if clic_right
#define OBJMAX_RANGE(aIndex)        (((aIndex) < 0 )?FALSE:( (aIndex) > MAX_OBJECT-1 )?FALSE:TRUE)
#endif


Protocol.cpp

Los visitantes no pueden visualizar imágenes en los mensajes, por favor Regístrate o Inicia Sesión



#if clic_right
        case 0x79:
            switch (lpMsg[3])
            {
            case 0x01:
                gItemManager.CGMoveItemProc((PMSG_MOVEITEM*)lpMsg, aIndex);
                break;
            }
            break;
#endif



OtemManager.h


#if clic_right
struct PMSG_MOVEITEM {
    PSBMSG_HEAD h;
    BYTE sFlag;
    BYTE tFlag;
    BYTE Source;
    BYTE Target;
};

struct PMSG_SET_CHAOSBOX_STATE
{
    PSBMSG_HEAD header; // C1:32
    BYTE state;
};
#endif



#if clic_right
    BYTE InventoryCheckInsertItem(int aIndex, WORD item); // OK
    void CGMoveItemProc(PMSG_MOVEITEM* aRecv, short aIndex);
    bool CheckItemNotSlot(int index); // OK
    bool CheckItemRequireClassUnick(WORD Class, int index); // OK
#endif


ItemManager.cpp


#if clic_right
#include "ChaosBox.h"
#include "CustomWing.h"
#endif



#if clic_right
bool CheckWings(int ItemIndex)
{
    if ((ItemIndex >= GET_ITEM(12, 0) && ItemIndex <= GET_ITEM(12, 6))
        || (ItemIndex >= GET_ITEM(12, 36) && ItemIndex <= GET_ITEM(12, 43))
        || (ItemIndex >= GET_ITEM(12, 130) && ItemIndex <= GET_ITEM(12, 135))
        || (ItemIndex == GET_ITEM(13, 30))
        || (ItemIndex == GET_ITEM(12, 40))
        || (ItemIndex == GET_ITEM(12, 49))
        || (ItemIndex == GET_ITEM(12, 50))
        || gCustomWing.CheckCustomWingByItem(ItemIndex))
    {
        return true;
    }

    return false;
}
#endif



#if clic_right
void CItemManager::CGMoveItemProc(PMSG_MOVEITEM* aRecv, short aIndex)
{
    if (OBJMAX_RANGE(aIndex) == 0) { return; }

    LPOBJ lpObj = &gObj[aIndex];

    if (aRecv->Target == -1) { return; }

    if (aRecv->tFlag == 3 && aRecv->sFlag == 0 && lpObj->Inventory[aRecv->Source].IsItem()) //check input item
    {
        if (gLuckyItem.IsLuckyItem(&lpObj->Inventory[aRecv->Source]))
        {
            return;
        }

        BYTE btItemType = 0;
        btItemType |= (lpObj->Inventory[aRecv->Source].m_Index & 0x1E00) >> 5;

        if ((btItemType + 2) == lpObj->Inventory[aRecv->Source].m_ItemOptionEx)
        {
            return;
        }
    }

    PMSG_ITEM_MOVE_RECV pMsg = { 0 };

    pMsg.TargetSlot = -1;

    if (aRecv->tFlag == 3 && aRecv->sFlag == 0) //move Inv -> ChaosBox
    {
        if (!lpObj->Inventory[aRecv->Source].IsItem() || lpObj->IsChaosMixCompleted == 1)
        {
            return; //no item
        }
        int p = 0, c = 0, d = 0, w = 0, h = 0, n = 0;
        int Target = -1;
        int TargetMap[CHAOS_BOX_SIZE] = { '\0' };

        ITEM_INFO ItemInfo;

        for (n = 0; n < CHAOS_BOX_SIZE; n++)
        {
            if (lpObj->ChaosBox[n].IsItem())
            {
                if (this->GetInfo(lpObj->ChaosBox[n].m_Index, &ItemInfo) == 0)
                {
                    return; //invalid item.
                }
                w = ItemInfo.Width;
                h = ItemInfo.Height;

                for (c = 0; c < w; c++)
                {
                    for (d = 0; d < h; d++)
                    {
                        p = c + d * 8 + n;
                        if (p < CHAOS_BOX_SIZE)
                        {
                            TargetMap[p] = 1;
                        }
                    }
                }
            }
        }

        for (n = 0; n < CHAOS_BOX_SIZE; n++)
        {
            if (!TargetMap[n])
            {
                Target = n;
                if (this->GetInfo(lpObj->Inventory[aRecv->Source].m_Index, &ItemInfo) == 0)
                {
                    return; //invalid item.
                }
                w = ItemInfo.Width;
                h = ItemInfo.Height;
                for (c = 0; c < w; c++) {
                    for (d = 0; d < h; d++) {
                        p = c + d * 8 + n;
                        if (p >= CHAOS_BOX_SIZE || TargetMap[p] || (n % 8) + c > 7) //  8) = 8
                        {
                            Target = -1;
                        }
                    }
                }
                if (Target != -1)
                    break;
            }
        }
        if (Target != -1)
        {
            pMsg.TargetSlot = Target;
            this->ItemByteConvert(pMsg.ItemInfo, lpObj->Inventory[aRecv->Source]);
        }
        else {
            return; //no more empty slot to add.
        }
    }
    else if (aRecv->tFlag == 0 && aRecv->sFlag == 3) //move ChaosBox -> Inv
    {
        if (!lpObj->ChaosBox[aRecv->Source].IsItem())
            return; //no item

        this->ItemByteConvert(pMsg.ItemInfo, lpObj->ChaosBox[aRecv->Source]);

        int Target = this->InventoryCheckInsertItem(aIndex, lpObj->ChaosBox[aRecv->Source].m_Index);

        if (Target == 0xFF)
        {
            return;
        }

        pMsg.TargetSlot = Target;
    }
    else if (aRecv->tFlag == 0 && aRecv->sFlag == 0) //equip/unequip item
    {
        if (!lpObj->Inventory[aRecv->Source].IsItem())
            return;
        this->ItemByteConvert(pMsg.ItemInfo, lpObj->Inventory[aRecv->Source]);

        if (aRecv->Source > 11)
        { //wear equipment case
            ITEM_INFO ItemInfo;
            if (this->GetInfo(lpObj->Inventory[aRecv->Source].m_Index, &ItemInfo) == 0)
            {
                return; //invalid item.
            }

            if (CheckItemNotSlot(lpObj->Inventory[aRecv->Source].m_Index))
            {
                return; //Items invalidos.
            }

            lpObj->Inventory[aRecv->Source].m_Class;

            pMsg.TargetSlot = ItemInfo.Slot;

            if (pMsg.TargetSlot == 0)
            {
                if (lpObj->Inventory[0].IsItem() //slot 0 already has item
                    && !lpObj->Inventory[1].IsItem() //slot 1 is empty
                    && lpObj->Inventory[aRecv->Source].m_Index < GET_ITEM(6, 0)
                    && (lpObj->Class != CLASS_DL && lpObj->Class != CLASS_DW && lpObj->Class != CLASS_FE && lpObj->Class != CLASS_SU))
                {
                    if (lpObj->Class == CLASS_RF)
                    {
                        if (ItemInfo.RequireClass[CLASS_RF] == 0)
                        {
                            return;
                        }
                        //verificamos si el item de la mano izquierda o derecha es solo para RF, y el otro item no
                        if ((CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[aRecv->Source].m_Index) == false && CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[0].m_Index) == true)
                            || (CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[aRecv->Source].m_Index) == true && CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[0].m_Index) == false))
                        {
                            return;
                        }
                    }
                    pMsg.TargetSlot = 1;
                }
                else
                {
                    //verificamos slot 0 vacio
                    if (!lpObj->Inventory[0].IsItem() && lpObj->Inventory[1].IsItem()) //slot 0 vacio - slot 1 tiene item
                    {
                        if (lpObj->Class == CLASS_RF)
                        {
                            if ((CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[aRecv->Source].m_Index) == false && CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[1].m_Index) == true) ||
                                (CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[aRecv->Source].m_Index) == true && CheckItemRequireClassUnick(CLASS_RF, lpObj->Inventory[1].m_Index) == false))
                            {
                                return;
                            }
                        }
                    }
                }
            }
            else if (pMsg.TargetSlot == 10
                && lpObj->Inventory[10].IsItem() //slot 10 already has item
                && !lpObj->Inventory[11].IsItem()) //slot 11 empty
            {
                pMsg.TargetSlot = 11;
            }
            else if (pMsg.TargetSlot == 8) //slot 10 already has item
            {
                if ((lpObj->Map == MAP_ICARUS && lpObj->Inventory[aRecv->Source].m_Index == GET_ITEM(13, 2))
                    || (lpObj->Map == MAP_ATLANS && (lpObj->Inventory[aRecv->Source].m_Index == GET_ITEM(13, 2) || lpObj->Inventory[aRecv->Source].m_Index == GET_ITEM(13, 3))))
                {
                    return;
                }
            }
            else if (lpObj->Inventory[ItemInfo.Slot].IsItem())
            {
                return;
            }//already has item this slot
        }
        else
        { //unequipment case

            if (lpObj->Map == MAP_ICARUS && CheckWings(lpObj->Inventory[aRecv->Source].m_Index))
            {
                return;
            }

            if (lpObj->Map == MAP_ICARUS && (lpObj->Inventory[aRecv->Source].m_Index == GET_ITEM(13, 2)
                || lpObj->Inventory[aRecv->Source].m_Index == GET_ITEM(13, 3) || lpObj->Inventory[aRecv->Source].m_Index == GET_ITEM(13, 37)))
            {
                return;
            }

            int Target = this->InventoryCheckInsertItem(aIndex, lpObj->Inventory[aRecv->Source].m_Index);

            if (Target == 0xFF)
            {
                return;
            }

            pMsg.TargetSlot = Target;
        }
    }
    else
    {
        return; //invalid case
    }

    pMsg.SourceFlag = aRecv->sFlag;
    pMsg.TargetFlag = aRecv->tFlag;
    pMsg.SourceSlot = aRecv->Source;


    this->CGItemMoveRecv(&pMsg, aIndex);

    if (aRecv->tFlag == 0 && aRecv->sFlag == 3)
    {
        gChaosBox.GCChaosBoxSend(lpObj, 0);

        //update chaosBox by new packet????
        PMSG_SET_CHAOSBOX_STATE pMsg = { 0 };

        pMsg.header.set(0xF3, 0xEE, sizeof(pMsg));

        pMsg.state = 0; //0 = allow mix || 2 = disable mix

        if (lpObj->IsChaosMixCompleted == 1 && !this->ChaosBoxHasItem(lpObj)) //desactivar mix si ya se combino
        {
            pMsg.state = 2;
        }

        DataSend(aIndex, (LPBYTE)&pMsg, pMsg.header.size);
    }
    else if ((aRecv->tFlag == 3 && aRecv->sFlag == 0) || (aRecv->tFlag == 0 && aRecv->sFlag == 0))
    {
        if (!lpObj->Inventory[aRecv->Source].IsItem())
        {
            this->GCItemDeleteSend(aIndex, aRecv->Source, aRecv->sFlag);
        }
    }

    return;
}
bool CItemManager::CheckItemRequireClassUnick(WORD Class, int index) // OK
{
    ITEM_INFO ItemInfo;

    if (this->GetInfo(index, &ItemInfo) == 0)
    {
        return false;
    }

    if (CHECK_RANGE(Class, MAX_CLASS) == 0)
    {
        return false;
    }
    int isClass = 0;
    int classes = 0;

    if (ItemInfo.RequireClass[Class] != 0)
    {
        isClass++;
    }

    for (int i = 0; i < MAX_CLASS; i++) {

        if (ItemInfo.RequireClass[i] != 0 && i != Class) {
            classes++;
        }
    }

    if (classes != 0)
    {
        return false;
    }

    if (isClass != 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

bool CItemManager::CheckItemNotSlot(int index) // OK
{
    ITEM_INFO ItemInfo;

    if (this->GetInfo(index, &ItemInfo) == 0)
    {
        return false;
    }

    if (ItemInfo.Slot == -1)
    {
        return true;
    }

    return false;
}
#endif



#if clic_right
BYTE CItemManager::InventoryCheckInsertItem(int aIndex, WORD item) // OK
{
    ITEM_INFO ItemInfo;

    if (this->GetInfo(item, &ItemInfo) == 0)
    {
        return 0xFF;
    }

    int MaxY = (this->GetInventoryMaxValue(&gObj[aIndex]) - INVENTORY_WEAR_SIZE) / 8;

    for (int y = 0; y < MaxY; y++)
    {
        for (int x = 0; x < 8; x++)
        {
            if (gObj[aIndex].InventoryMap[((y * 8) + x)] == 0xFF) // y *  8
            {
                BYTE slot = this->InventoryRectCheck(aIndex, x, y, ItemInfo.Width, ItemInfo.Height);

                if (slot != 0xFF)
                {
                    return slot;
                }
            }
        }
    }

    return 0xFF;
}
#endif
































Bon Dia

Dakosmu

hi everyone! I don't know if this question (problem) is still current, but by adding this change I decided to share it with you:


[Item.cpp]

bool CItem::IsIcarusPet()
{
if (this->m_Index == GET_ITEM(13, 3) ||this->m_Index == GET_ITEM(13, 37)) // Dinorant,Fenrir,Unria
{
return 1;
}
return 0;
}
// ------------------
[Item.h]

bool IsIcarusPet();
// ------------------

[ItemManager.cpp]
void CItemManager::CGMoveItemProc(PMSG_MOVEITEM* aRecv, short aIndex)
{
//..Code
{ //unequipment case
int Target = this->InventoryCheckInsertItem(aIndex, lpObj->Inventory[aRecv->Source].m_Index);

if (Target == 0xFF)
{
return;
}
//Fix right click undequip item (wing and pet on icarus)
if (lpObj->Map == MAP_ICARUS && lpObj->Inventory[7].IsItem() || lpObj->Map == MAP_ICARUS && lpObj->Inventory[8].IsIcarusPet())
{
gNotice.GCNoticeSend(lpObj->Index, 1, 0, 0, 0, 0, 0, "Can't unequip this item on this map!");
return;
}

pMsg.TargetSlot = Target;
}
}

 creditos
stark98
Bon Dia

Boquadangnhap

Sorry other post

Please add more picture in game


iamzirc

Can somebody tells me whats this is for?
Thanks


🡱 🡳