Code:
#include <windows.h>
#include <stdio.h>
#include "..\..\include\era.h"
#include "..\..\include\heroes.h"
#include "..\..\include\patcher_x86_commented.hpp"
void InitWoGSpecials()
{
if (*(int *)(*(int*)0x69CCFC + 4)!=-1)
{
HERO* currhero = (HERO*)GetHeroRecord(*(int *)(*(int*)0x69CCFC + 4));
*(int*)0x27F9970 = (int)currhero;
ErmV[998] = currhero->x;
ErmV[999] = currhero->y;
ErmV[1000] = currhero->l;
ErmF[1000]= !CALL_1(int, __thiscall, 0x4BAA60, *(int*)0x69CCFC);
}
}
void PrintString(char* str)
{
char buf[1024];
sprintf(buf,"IF:L^{~green}%s{~}^;",str);
ExecErmCmd(buf);
/*sprintf(buf,"IF:L^%s^;",str);
EventParams[1] = str*/
}
void __stdcall OnChat(PEvent e)
{
if(EventParams[0] == 1)
{
EventParams[2] = 1;
char *buf=(char*)malloc(32+strlen((const char*)EventParams[1]));
sprintf(buf,"IF:L^{~%s}%s{~}^;\0","lime",EventParams[1]);
ExecErmCmd(buf);
free(buf);
char str[256];
if(!stricmp((const char*)EventParams[1],"/showfps"))
{
*(int*)((*(int*)0x6992B8)+0x3C) = !*(int*)((*(int*)0x6992B8)+0x3C);
PrintString("FPS switched off");
}
if(!stricmp((const char*)EventParams[1],"/leveldebugger"))
{
*(int*)0x698A18 = !*(int*)0x698A18;
PrintString(*(int*)0x698A18?"Level debugger switched on":"Level debugger switched off");
}
if(!stricmp((const char*)EventParams[1],"/heroid"))
{
int id = *(int *)(*(int*)0x69CCFC + 4);
if (id!=-1)
{
sprintf(str,"%s: id %i, struct at 0x%08X",
((HERO*)GetHeroRecord(id))->Name,
id,
GetHeroRecord(id)
);
}
else
{
strcpy(str,"Hero not selected");
}
PrintString(str);
}
if(!strnicmp((const char*)EventParams[1],"/execerm",strlen("/execerm")))
{
InitWoGSpecials();
ExecErmCmd((char*)(strlen("/execerm")+1+EventParams[1]));
PrintString("Executed");
}
if(!strnicmp((const char*)EventParams[1],"!!",strlen("!!")))
{
InitWoGSpecials();
ExecErmCmd((char*)(strlen("!!")+EventParams[1]));
PrintString("Executed");
}
//ExecErmCmd(str);
//MessageBoxA(0,(LPCSTR)(EventParams[1]),(LPCSTR)str,0);
}
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
ConnectEra();
RegisterHandler(OnChat, "OnChat");
}
return TRUE;
}