Jump to content

PTS C4/Interlude Npc Speed Load (Vanganth Based)


Recommended Posts

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
Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...

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
Link to comment
Share on other sites

  • 1 year later...

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();

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...