Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Picking Pets - Example Source

Skilled Illusionist
Joined
Oct 31, 2008
Messages
341
Reaction score
294
Just a little Test I made for Pet Pick - u need to add a check if Item is in Inventory or smth.

it's not finished yet u need to fix somethings but should be a good basic.



PHP:
#include <Windows.h>
#include <vector>



#define INST_NOP 0x90 
#define INST_CALL 0xe8 
#define INST_JMP 0xe9 
#define INST_BYTE 0x00 
#define SHORT_JZ 0x74


void MemcpyEx(DWORD destination, DWORD source, int length)
{
	DWORD oldSource = 0;
	DWORD oldDestination = 0;
	VirtualProtect((LPVOID)source, length, PAGE_EXECUTE_READWRITE, &oldSource);
	VirtualProtect((LPVOID)destination, length, PAGE_EXECUTE_READWRITE, &oldDestination);
	memcpy((void*)destination, (void*)source, length);
	VirtualProtect((LPVOID)destination, length, oldDestination, &oldDestination);
	VirtualProtect((LPVOID)source, length, oldSource, &oldSource);
}
DWORD Intercept(BYTE instruction, DWORD lpSource, DWORD lpDest, int len)
{
	DWORD realtarget = 0;
	LPBYTE buffer = new BYTE[len];
	memset(buffer, 0x90, len); //Fill out with nops 
	if (instruction != INST_NOP && len >= 5){
		buffer[(len - 5)] = instruction;
		DWORD dwJMP = (DWORD)lpDest - (lpSource + 5 + (len - 5));
		memcpy(&realtarget, (void*)(lpSource + 1), 4);
		realtarget = realtarget + lpSource + 5;
		memcpy(buffer + 1 + (len - 5), &dwJMP, 4);
	}
	if (instruction == SHORT_JZ){
		buffer[0] = instruction;
		buffer[1] = (BYTE)lpDest;
	}
	if (instruction == INST_BYTE){
		buffer[0] = (BYTE)lpDest;
	}
	MemcpyEx(lpSource, (DWORD)buffer, len);
	delete[] buffer;
	return realtarget;
}

static int (__thiscall *CParty__GetRandomPlayer)(int Player) = (int (__thiscall*)(int Player))0x0044E7C0;
static int(__cdecl *CreateItem)(int Index, int Prefix, int Amount, int unknown) = (int(__cdecl*)(int Index, int Prefix, int Amount, int unknown))0x00426110;
static int(__cdecl* FindParty)(int PartyID) = (int(__cdecl*)(int PartyID))0x0044D4E0;
static int(__thiscall* GetPartySize)(int PartyID) = (int(__thiscall*)(int PartyID))0x00412ED0;
static int(__thiscall* GetPlayerList)(void* PartyID) = (int(__thiscall*)(void* PartyID))0x0044F390;
static int(__thiscall* BaseListPop)(void* unknown) = (int(__thiscall*)(void* unknown))0x00402430;
static int(__thiscall* unknown_libname_77)(void* unknown) = (int(__thiscall*)(void* unknown))0x0042F830;
static int (__thiscall *CInitMonster__DropItem)(DWORD *__this, int pMonster, int isParty, int PlayerID, int a5, int DropItemMask) = (int (__thiscall*)(DWORD *__this, int pMonster, int isParty, int PlayerID, int a5, int DropItemMask))0x00437D70; 
static int (__thiscall *CParty__GetLuckySize)(int a5) = (int (__thiscall*)(int a5))0x0044F440;
static int (__cdecl *CItem__CreateDropItem)(char a4, int a5) = (int (__cdecl*)(char a4, int a5))0x00426290; 
static void* (__cdecl* FindPlayerByID) (int ID) = (void* (__cdecl*) (int ID))0x00450810;
static int (__thiscall *InsertItem)(void *thispointer, int a2, void* Item) = (int (__thiscall*)(void *,int,void*))0x0045DE10;
static void (__cdecl* WriteRed)(char* text,  ...) = (void (__cdecl*)(char* text, ...))0x004328C0;



struct SItem
{
	int Index;
	int Amount;
	int Prefix;
};
std::vector<SItem> itemvec;
void __fastcall hkDropItem(DWORD* pItem,void* _edx, int pMonster, int isParty, int PlayerID, int a5, int DropItemMask)
{

	bool forward = true;
	
	if(isParty)
	{
		int* PartyID = (int*)FindParty(PlayerID);
		if(PartyID)
		{
			forward = false;
			for (int ItemArray = 0; ItemArray < pItem[29]; ++ItemArray )
			{
				int dropAnzahl = pItem[ItemArray + 24];
				if(pItem[16] == 4)
					dropAnzahl += CParty__GetLuckySize(0);
				else
					++dropAnzahl;
						 
				for(int DropCount = 0; DropCount < dropAnzahl; DropCount++)
				{
					int* item = (int*)CItem__CreateDropItem(pItem[ItemArray + 19],DropItemMask);
					if(item)
					{
						SItem newItem;
						newItem.Index = ((int*)item[10])[16];
						newItem.Amount = item[13];	
						newItem.Prefix = 0;
						if ( item[11] )
							newItem.Prefix = ((int*)item[11])[8];

						itemvec.push_back(newItem);
					}
				}
			 }
			for (int PartyPlayerIndex = GetPlayerList(PartyID); PartyPlayerIndex; PartyPlayerIndex = BaseListPop(reinterpret_cast<void*>(PartyPlayerIndex))) 
			{ 
				int ListPlayer = unknown_libname_77(reinterpret_cast<void*>(PartyPlayerIndex)); 
				if (ListPlayer)
				{
					std::vector<SItem>::iterator itemIterator;
					itemIterator = itemvec.begin();
					while(itemIterator != itemvec.end())
					{
						if(itemIterator->Index != 31)
							ListPlayer = CParty__GetRandomPlayer((int)PartyID);

						if(ListPlayer)
						{
							int* itemreturn = (int*)CreateItem(itemIterator->Index, itemIterator->Prefix, itemIterator->Amount, -1);
							if(itemreturn)
							InsertItem((int*)ListPlayer, 2, itemreturn);

							if(itemIterator->Index != 31)
							{
								itemIterator = itemvec.erase(itemIterator);
							}
							else
								++itemIterator;
						}
						
					}
				 }
			}
			itemvec.clear();
		}
	}
	else
	{
		int* pPlayer = (int*)FindPlayerByID(PlayerID);
		if(pPlayer)
		{
			forward = false;
					int i;
					for ( i = 0; i < pItem[29]; ++i )
					{
						int dropAnzahl = pItem[i + 24];
						 for(int ii = 0; ii < dropAnzahl; ii++)
						 {
							int* item = (int*)CItem__CreateDropItem(pItem[i + 19],DropItemMask);	
							if(item)
							{
								int Index = ((int*)item[10])[16];
								int Amount = item[13];	
								int Prefix = 0;
								if ( item[11] )
									Prefix =  ((int*)item[11])[8]; 

								int* itemreturn = (int*)CreateItem(Index, Prefix, Amount, -1);	
								InsertItem(pPlayer, 2, itemreturn);
							}
						 }
					}
		}
		
	}
	
	if(forward)
		CInitMonster__DropItem(pItem,pMonster,isParty,PlayerID,a5,DropItemMask);
}

unsigned long __stdcall thr(void* _d)
{

	Sleep(5000);
	WriteRed("---- Auto Picking Test ----");
	Intercept(INST_CALL,(unsigned long)0x004423D3,(unsigned long)hkDropItem,5);
	Intercept(INST_CALL,(unsigned long)0x0043F443,(unsigned long)hkDropItem,5);


	return TRUE;
}
void MainHook()
{
	CreateThread(0,0,thr,nullptr,0,0);
}
BOOL APIENTRY DllMain( HMODULE hModule, unsigned long  ul_reason_for_call, void* lpReserved )
{
	DisableThreadLibraryCalls(hModule);
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		MainHook();
		break;
	}
	return TRUE;
}
 

Attachments

You must be registered for see attachments list
Last edited:
Junior Spellweaver
Joined
Aug 19, 2006
Messages
106
Reaction score
162
good release :)

small modification

Code:
if(Server::CPlayer::CPlayer__GetInvenSize((void *)playerPtr) >= 60)
   forward=true;

otherwise, player who got picker-item and got full inv won't see drops and won't get his items :)

also, for party you can use:

Code:
    Server::CParty::CParty__StoreItem(partyPtr, itemPtr);
    Server:: CParty::CParty__DistributeItem((void *)partyPtr, playerPtr + 332);

this way, all players in party will see messages about "player x picked item .."
 
Last edited:
Skilled Illusionist
Joined
Oct 31, 2008
Messages
341
Reaction score
294
good release :)

small modification

Code:
if(Server::CPlayer::CPlayer__GetInvenSize((void *)playerPtr) >= 60)
   forward=true;

otherwise, player who got picker-item and got full inv won't see drops and won't get his items :)

oh yeah that's true- completly missed this point :X

Thanks :D
 
Experienced Elementalist
Joined
Mar 15, 2014
Messages
234
Reaction score
95
Sorry possible change to the DLL will be best for the many who do not know anything about C++
Like me I do not know anything about C++ I hope you will help us
 
Experienced Elementalist
Joined
Sep 29, 2014
Messages
214
Reaction score
20
we hope u will help us to release it for us .. cuz we dunno anything about c++ :(
 
Elite Diviner
Joined
Jun 17, 2012
Messages
422
Reaction score
149
Sorry possible change to the DLL will be best for the many who do not know anything about C++
Like me I do not know anything about C++ I hope you will help us

we hope u will help us to release it for us .. cuz we dunno anything about c++ :(

Here you go, I compiled it with vs2012 so you must install c++ redistributable 2012 to load it

note: it will work on old engine only.
hf.
 

Attachments

You must be registered for see attachments list
Elite Diviner
Joined
Jun 17, 2012
Messages
422
Reaction score
149
Experienced Elementalist
Joined
Sep 29, 2014
Messages
214
Reaction score
20
@Bloodx its not working on new engine with full addons !!.. mainserver didnt read it so i wont use it :(
i hope you guys do it for new engine too ! MaZoR good job
 
Skilled Illusionist
Joined
Oct 31, 2008
Messages
341
Reaction score
294
it is working for new engine - I did test it.

Server Side Addons dont have anything to do with the Client.

If it does not work, it is a problem with your addons
 
Skilled Illusionist
Joined
Oct 31, 2008
Messages
341
Reaction score
294
DLL in mainserver folder -> load it -> finish lol

I dont know if MaZor added a Message if it is loaded.


try to juse a Injector to load the dll.
 
Experienced Elementalist
Joined
Sep 29, 2014
Messages
214
Reaction score
20
ok i will check it in game but how can i make the pet to pick then
 
Elite Diviner
Joined
Jun 17, 2012
Messages
422
Reaction score
149
Code:
WriteRed("---- Auto Picking Test ----");

You will see this message if dll successfully loaded. Also you won't need any pet or item for it just kill any monster and you will get the drops instantly

About new engine r3v files, you won't see or get any drops with this dll.
 
Skilled Illusionist
Joined
Oct 31, 2008
Messages
341
Reaction score
294
Code:
WriteRed("---- Auto Picking Test ----");

You will see this message if dll successfully loaded. Also you won't need any pet or item for it just kill any monster and you will get the drops instantly

About new engine r3v files, you won't see or get any drops with this dll.

well than any Server addon is blocking the Hook for sure- may Increase the Timer to load the dll.

I dont know anything about R3v0 Files never saw them.
 
Back
Top