#Gamble Refresh

1 messages · Page 1 of 1 (latest)

rotund narwhal
#

How can I Gamble Refresh with keydown? I find this code

/*
    Function: INVENTORY_ShopInventoryCleanUp
    Adress: D2Client.6FAF60A0
*/
void __usercall INVENTORY_ShopInventoryCleanUp(/*EAX*/ D2UnitStrc* pVendor)

but I don't known where I get the pVendor.

gloomy jolt
#

the vendor unit ID is stored in a global variable on d2client here:

VARPTR(D2CLIENT, RecentInteractId, DWORD, 0x11971D)

The address is for 1.13c

#

from the unit ID, you can get pVendor using this:

int nVendorId = *p_D2CLIENT_RecentInteractId;
UnitAny* pVendor = D2CLIENT_GetUnitFromTypeAndGUID_STUB(nVendorId & 0x7F, nVendorId, p_D2CLIENT_UnitTable + 0x80, UNIT_MONSTER);
#

and the getunit function is this:

__declspec(naked) UnitAny* __stdcall D2CLIENT_GetUnitFromTypeAndGUID_STUB(int nUnitTableOffset, int nUnitGUID, UnitAny** pUnitTable, int nUnitType)
{
    __asm
    {
        push ECX
        push EDX
        mov EAX, [esp + 12]                                  // nUnitTableOffset
        mov ECX, [esp + 16]                                  // nUnitGUID
        mov EDX, [esp + 20]                                  // pUnitTable
        push[esp + 24]                                      // nUnitType
        call D2CLIENT_GetUnitFromTypeAndGUID                 // 0xA4E20
        pop EDX
        pop ECX
        retn 16
    }
}
rotund narwhal
gloomy jolt
#

VARPTR(D2CLIENT, UnitTable, UnitAny*, 0x10A608);

rotund narwhal
gloomy jolt
#

not sure what you mean

rotund narwhal
#

I defend is right?:

#

#define D2CLIENT_GetUnitFromTypeAndGUID(nUnitTableOffset, nUnitGUID, pUnitTable, nUnitType) ((UnitAny *)D2CLIENT_GetUnitFromTypeAndGUID_STUB(nUnitTableOffset, nUnitGUID, pUnitTable, nUnitType))

rotund narwhal
rotund narwhal
#
ASMPTR(D2CLIENT, GetUnitFromTypeAndGUID,0xA4E20)

like this?

#

I think when D2CLIENT_ShopInventoryCleanUp then need call other CODE can refresh the Gamble?
because when I call D2CLIENT_ShopInventoryCleanUp the GHeed shop items will gone.

rotund narwhal
#

Maybe My "ShopInventoryCleanUp" defind was wrong?

FUNCPTR(D2CLIENT, ShopInventoryCleanUp, void __fastcall, (UnitAny* pVendor), 0x460A0)
#

How can I hook the "__usercall"?

rotund narwhal
#

I find out my reason.I need code the sever side too.Thank you.

gloomy jolt
#

Sorry, I was sleeping but yes ASMPTR(D2CLIENT, GetUnitFromTypeAndGUID,0xA4E20) would be correct. My example is using the D2Template format

rotund narwhal
#

It's OK,How do I judge in the gamble shop?

rotund narwhal
gloomy jolt
#

you need to check the ui variable for the NPC shop and there is a global var on the client if you are in the gamble screen:

#define UI_NPCSHOP                0x0C
VARPTR(D2CLIENT, IsInGambleScreen, DWORD, 0x1197A8)

__declspec(naked) int __stdcall D2CLIENT_GetUIVar_STUB(int nUIVar)
{
    __asm
    {
        mov EAX, [esp + 4]                                   // nUIVar
        call D2CLIENT_GetUIVar                               // 0xBE400
        retn 4
    }
}

if (D2CLIENT_GetUIVar_STUB(UI_NPCSHOP) && *p_D2CLIENT_IsInGambleScreen)
{
  // we are in the gamble screen
}
rotund narwhal
#

thank you,got it。

#

how do you find that global var ? such as IsInGambleScreen

gloomy jolt
#

there are packets for opening a dialogue/trade with a vendor and I followed the packet logic through the disassembler and that global variable is set 1 when you successfully open gamble window and set to 0 when you close it