Jump to content

Recommended Posts

Posted (edited)

L2Server extend part

IlExt.dll

invoke CNpcSpeedLoad::Initialize() in dllmain

Spoiler

NpcSpeedLoad.h


#pragma once

class CNpcSpeedLoad {
public:

	static void Initialize() {
		g_HookManager.WriteMemoryBYTE(0x6F1E28, 0xFF);
		g_HookManager.WriteMemoryDWORD(0x6F1F74, 100);
	}

};

 

 

L2Npc Extend part

NpcExt.dll

invoke CNpcSpeedLoad::Initialize() in dllmain

Spoiler

NpcSpeedLoad.h


#pragma once

//C - class name
//M - method name
//A - address
//RT - return type
//... - method signature
#define mdef(C, M, A, CC, RT, ...)\
	const uintptr_t M_##C##__##M = (uintptr_t) A;\
	typedef RT ( CC * M_##C##__##M##_T ) (C*, __VA_ARGS__);

//C - class name
//M - method name
//This - pointer to C
//... method parameters
#define invoke(C, M, This, ...)\
	( M_##C##__##M##_T ( M_##C##__##M ) ) (This, __VA_ARGS__)

class CNpcMakerDB;
class CNpcSpeedLoad;
class CNpcEx;

mdef(CNpcMakerDB, ProcessOneNpcMaker, 0x5517D0, __fastcall, bool)
mdef(CNpcMakerDB, ProcessOneNpcMakerEx, 0x551BF0, __fastcall, bool)
mdef(CNpcMakerDB, AddTimer, 0x47F0D0, __fastcall, bool, int, int)
mdef(CNpcMakerDB, TimerExpired, 0x551A10, __fastcall, void, int)

mdef(CNpcEx, AddTimer, 0x47F0D0, __fastcall, bool, int, int);

class CNpcSpeedLoad {
public:

	static void Initialize();

};


class CNpcEx {
public:
	bool AddTimer(int delay, int id) {
		return invoke(CNpcEx, AddTimer, this, delay, id);
	}

	static bool EnterWorld__AddTimer(CNpcEx* This, int delay, int id) {
		return This->AddTimer(0, id);
	}
};

class CNpcMakerDB {
public:

	bool ProcessOneNpcMaker() {
		return invoke(CNpcMakerDB, ProcessOneNpcMaker, this);
	}

	bool ProcessOneNpcMakerEx() {
		return invoke(CNpcMakerDB, ProcessOneNpcMakerEx, this);
	}

	bool AddTimer(int delay, int id) {
		return invoke(CNpcMakerDB, AddTimer, this, delay, id);
	}
	
	void TimerExpired(int id) {
		return invoke(CNpcMakerDB, TimerExpired, this, id);
	}

	static void TimerExpiredHook(CNpcMakerDB* This, int id);
};

 

NpcSpeedLoad.cpp


#include "StdAfx.h"
#include "NpcSpeedLoad.h"
#include "Utils.h"

void CNpcSpeedLoad::Initialize() {
	//define hooks
	//hook vtable CNpcMakerDB::TimerExpired
	WriteQWORD(0x6B8E80, uintptr_t(CNpcMakerDB::TimerExpiredHook));
	//CNpc::EnterWorld -> AddTimer
	WriteCall(0x4D1BBB, CNpcEx::EnterWorld__AddTimer);
}

void CNpcMakerDB::TimerExpiredHook(CNpcMakerDB* This, int id) {
	try {
		if(id == 1) {
			bool result = true;
			for(int i = 0 ; i < 256 && (result = This->ProcessOneNpcMaker()) ; i++);
			if(!result) {
				((int*) This)[180] = 0;//boolean tell if loading CNpcMaker
				g_Log.Add(LogBlue, "ProcessOneNpcMaker processing finish!");
				This->AddTimer(100, 2);
			} else
				This->AddTimer(100, 1);
		} else if(id == 2) {
			bool result = true;
			for(int i = 0 ; i < 256 && (result = This->ProcessOneNpcMakerEx()) ; i++);
			if(result)
				This->AddTimer(100, 2);
			else
				g_Log.Add(LogBlue, "ProcessOneNpcMakerEx processing finish!");
		}
	} catch(...) {
		g_Log.Add(LogError, L"%s error", __FUNCTIONW__);
	}
}

 

Edited by gattsuicu
  • Thanks 1
  • 1 month later...
  • 6 months later...
Posted (edited)

Hi! good guide, but.. i have a question.

 

how to add this? 

 

in first part i create the NpcSpeedLoad.h and copy the content...

 

in 2th part i create the NpcSpeedLoad.h and .cpp and copy the content... but.

 

i have a quiestion about: 

"invoke CNpcSpeedLoad::Initialize() in dllmain"

 

i added CNpcSpeedLoad::Initialize() 
in a dllmain.h (in IlExt)

 

but the second part say same invoke CNpcSpeedLoad::Initialize() in dllmain but... in a NPCExt doesn't have a dllmain.h

Edited by katia666
  • 1 year later...
Posted

On Npc.cpp add

 

#include "NpcSpeedLoad.h" 

and CNpcSpeedLoad::Initialize(); under

 

        CSharedFactory::Init();
        CNPC::ExtInit();
        CNPCEventFactory::Init();
        CPostLoad::Init();
        CBaseAction::Init();
        CTimer::Init();
        CScriptAccessible::Init();

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...