PDA

View Full Version : |Source| OffSet liberar limite de wings 100 MuEmu



djagripnos
05/03/2018, 07:43 AM
GameServer


#define ([Only registered and activated users can see links]) MAX_CUSTOM_WING 100

Procurar no Item.cpp


__declspec(naked) void WingMakePreviewCharSet() // OK
{
static DWORD WingMakePreviewCharSetAddress1 = 0x004F71DE;
static DWORD WingMakePreviewCharSetAddress2 = 0x004F717D;

_asm
{
Mov Ecx,Dword Ptr Ss:[Ebp+0x0C]
Movzx Edx,Byte Ptr Ds:[Ecx+0x10]
Sar Edx,0x01
And Edx,0xFF
Test Edx,Edx
Je EXIT
Mov Eax,Dword Ptr Ss:[Ebp+0x0C]
Movzx Ecx,Byte Ptr Ds:[Eax+0x10]
Sar Ecx,0x01
And Ecx,0xFF
Sub Ecx,0x01
Push Ecx
Lea Ecx,gCustomWing
Call [CCustomWing::CheckCustomWing]
Test Eax,Eax
Je EXIT
Mov Edx,Dword Ptr Ss:[Ebp+0x0C]
Movzx Eax,Byte Ptr Ds:[Edx+0x10]
Sar Eax,0x01
And Eax,0xFF
Sub Eax,0x01
Push Eax
Lea Ecx,gCustomWing
Call [CCustomWing::GetCustomWingItem]
Add Eax,ITEM_BASE_MODEL
Mov Ecx,Dword Ptr Ss:[Ebp-0x08]
Mov Word Ptr Ds:[Ecx+0x1C0],Ax
Jmp [WingMakePreviewCharSetAddress1]
EXIT:
Mov Eax,Dword Ptr Ss:[Ebp-0x04]
And Eax,0xFF
Jmp [WingMakePreviewCharSetAddress2]
}
}





CustomWing.h



// CustomWing.h: interface for the CCustomWing class.
//
//////////////////////////////////////////////////////////////////////

#pragma once

#define ([Only registered and activated users can see links]) MAX_CUSTOM_WING 100

struct CUSTOM_WING_INFO
{
int Index;
int ItemIndex;
int DefenseConstA;
int IncDamageConstA;
int IncDamageConstB;
int DecDamageConstA;
int DecDamageConstB;
int OptionIndex1;
int OptionValue1;
int OptionIndex2;
int OptionValue2;
int OptionIndex3;
int OptionValue3;
int NewOptionIndex1;
int NewOptionValue1;
int NewOptionIndex2;
int NewOptionValue2;
int NewOptionIndex3;
int NewOptionValue3;
int NewOptionIndex4;
int NewOptionValue4;
int ModelType;
char ModelName[32];
};

class CCustomWing
{
public:
CCustomWing();
virtual ~CCustomWing();
void Init();
void Load(char* path);
void SetInfo(CUSTOM_WING_INFO info);
CUSTOM_WING_INFO* GetInfo(int index);
CUSTOM_WING_INFO* GetInfoByItem(int ItemIndex);
bool CheckCustomWing(int index);
bool CheckCustomWingByItem(int ItemIndex);
int GetCustomWingIndex(int ItemIndex);
int GetCustomWingDefense(int ItemIndex,int ItemLevel);
int GetCustomWingIncDamage(int ItemIndex,int ItemLevel);
int GetCustomWingDecDamage(int ItemIndex,int ItemLevel);
int GetCustomWingOptionIndex(int ItemIndex,int OptionNumber);
int GetCustomWingOptionValue(int ItemIndex,int OptionNumber);
int GetCustomWingNewOptionIndex(int ItemIndex,int OptionNumber);
int GetCustomWingNewOptionValue(int ItemIndex,int OptionNumber);
public:
CUSTOM_WING_INFO m_CustomWingInfo[MAX_CUSTOM_WING];
};

extern CCustomWing gCustomWing;

CustomWing.cpp


// CustomWing.cpp: implementation of the CCustomWing class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CustomWing.h"
#include "MemScript.h"
#include "Util.h"

CCustomWing gCustomWing;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCustomWing::CCustomWing() // OK
{
this->Init();
}

CCustomWing::~CCustomWing() // OK
{

}

void CCustomWing::Init() // OK
{
for(int n=0;n < MAX_CUSTOM_WING;n++)
{
this->m_CustomWingInfo[n].Index = -1;
}
}

void CCustomWing::Load(char* path) // OK
{
CMemScript* lpMemScript = new CMemScript;

if(lpMemScript == 0)
{
ErrorMessageBox(MEM_SCRIPT_ALLOC_ERROR,path);
return;
}

if(lpMemScript->SetBuffer(path) == 0)
{
ErrorMessageBox(lpMemScript->GetLastError());
delete lpMemScript;
return;
}

this->Init();

try
{
while(true)
{
if(lpMemScript->GetToken() == TOKEN_END)
{
break;
}

if(strcmp("end",lpMemScript->GetString()) == 0)
{
break;
}

CUSTOM_WING_INFO info;

memset(&info,0,sizeof(info));

info.Index = lpMemScript->GetNumber();

info.ItemIndex = lpMemScript->GetAsNumber();

info.DefenseConstA = lpMemScript->GetAsNumber();

info.IncDamageConstA = lpMemScript->GetAsNumber();

info.IncDamageConstB = lpMemScript->GetAsNumber();

info.DecDamageConstA = lpMemScript->GetAsNumber();

info.DecDamageConstB = lpMemScript->GetAsNumber();

info.OptionIndex1 = lpMemScript->GetAsNumber();

info.OptionValue1 = lpMemScript->GetAsNumber();

info.OptionIndex2 = lpMemScript->GetAsNumber();

info.OptionValue2 = lpMemScript->GetAsNumber();

info.OptionIndex3 = lpMemScript->GetAsNumber();

info.OptionValue3 = lpMemScript->GetAsNumber();

info.NewOptionIndex1 = lpMemScript->GetAsNumber();

info.NewOptionValue1 = lpMemScript->GetAsNumber();

info.NewOptionIndex2 = lpMemScript->GetAsNumber();

info.NewOptionValue2 = lpMemScript->GetAsNumber();

info.NewOptionIndex3 = lpMemScript->GetAsNumber();

info.NewOptionValue3 = lpMemScript->GetAsNumber();

info.NewOptionIndex4 = lpMemScript->GetAsNumber();

info.NewOptionValue4 = lpMemScript->GetAsNumber();

info.ModelType = lpMemScript->GetAsNumber();

strcpy_s(info.ModelName,lpMemScript->GetAsString());

this->SetInfo(info);
}
}
catch(...)
{
ErrorMessageBox(lpMemScript->GetLastError());
}

delete lpMemScript;
}

void CCustomWing::SetInfo(CUSTOM_WING_INFO info) // OK
{
if(info.Index < 0 || info.Index >= MAX_CUSTOM_WING)
{
return;
}

this->m_CustomWingInfo[info.Index] = info;
}

CUSTOM_WING_INFO* CCustomWing::GetInfo(int index) // OK
{
if(index < 0 || index >= MAX_CUSTOM_WING)
{
return 0;
}

if(this->m_CustomWingInfo[index].Index != index)
{
return 0;
}

return &this->m_CustomWingInfo[index];
}

CUSTOM_WING_INFO* CCustomWing::GetInfoByItem(int ItemIndex) // OK
{
for(int n=0;n < MAX_CUSTOM_WING;n++)
{
CUSTOM_WING_INFO* lpInfo = this->GetInfo(n);

if(lpInfo == 0)
{
continue;
}

if(lpInfo->ItemIndex == ItemIndex)
{
return lpInfo;
}
}

return 0;
}

bool CCustomWing::CheckCustomWing(int index) // OK
{
if(this->GetInfo(index) != 0)
{
return 1;
}

return 0;
}

bool CCustomWing::CheckCustomWingByItem(int ItemIndex) // OK
{
if(this->GetInfoByItem(ItemIndex) != 0)
{
return 1;
}

return 0;
}

int CCustomWing::GetCustomWingIndex(int ItemIndex) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

return lpInfo->Index;
}

int CCustomWing::GetCustomWingDefense(int ItemIndex,int ItemLevel) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

return (lpInfo->DefenseConstA*ItemLevel);
}

int CCustomWing::GetCustomWingIncDamage(int ItemIndex,int ItemLevel) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 100;
}

return (lpInfo->IncDamageConstA+(ItemLevel*lpInfo->IncDamageConstB));
}

int CCustomWing::GetCustomWingDecDamage(int ItemIndex,int ItemLevel) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 100;
}

return (lpInfo->DecDamageConstA-(ItemLevel*lpInfo->DecDamageConstB));
}

int CCustomWing::GetCustomWingOptionIndex(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->OptionIndex1;
case 1:
return lpInfo->OptionIndex2;
case 2:
return lpInfo->OptionIndex3;
}

return 0;
}

int CCustomWing::GetCustomWingOptionValue(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->OptionValue1;
case 1:
return lpInfo->OptionValue2;
case 2:
return lpInfo->OptionValue3;
}

return 0;
}

int CCustomWing::GetCustomWingNewOptionIndex(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->NewOptionIndex1;
case 1:
return lpInfo->NewOptionIndex2;
case 2:
return lpInfo->NewOptionIndex3;
case 3:
return lpInfo->NewOptionIndex4;
}

return 0;
}

int CCustomWing::GetCustomWingNewOptionValue(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->NewOptionValue1;
case 1:
return lpInfo->NewOptionValue2;
case 2:
return lpInfo->NewOptionValue3;
case 3:
return lpInfo->NewOptionValue4;
}

return 0;
}


Main

CustomWing.cpp


// CustomWing.cpp: implementation of the CCustomWing class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CustomWing.h"

CCustomWing gCustomWing;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCustomWing::CCustomWing() // OK
{
this->Init();
}

CCustomWing::~CCustomWing() // OK
{

}

void CCustomWing::Init() // OK
{
for(int n=0;n < MAX_CUSTOM_WING;n++)
{
this->m_CustomWingInfo[n].Index = -1;
}
}

void CCustomWing::Load(CUSTOM_WING_INFO* info) // OK
{
for(int n=0;n < MAX_CUSTOM_WING;n++)
{
this->SetInfo(info[n]);
}
}

void CCustomWing::SetInfo(CUSTOM_WING_INFO info) // OK
{
if(info.Index < 0 || info.Index >= MAX_CUSTOM_WING)
{
return;
}

this->m_CustomWingInfo[info.Index] = info;
}

CUSTOM_WING_INFO* CCustomWing::GetInfo(int index) // OK
{
if(index < 0 || index >= MAX_CUSTOM_WING)
{
return 0;
}

if(this->m_CustomWingInfo[index].Index != index)
{
return 0;
}

return &this->m_CustomWingInfo[index];
}

CUSTOM_WING_INFO* CCustomWing::GetInfoByItem(int ItemIndex) // OK
{
for(int n=0;n < MAX_CUSTOM_WING;n++)
{
CUSTOM_WING_INFO* lpInfo = this->GetInfo(n);

if(lpInfo == 0)
{
continue;
}

if(lpInfo->ItemIndex == ItemIndex)
{
return lpInfo;
}
}

return 0;
}

BOOL CCustomWing::CheckCustomWing(int index) // OK
{
if(this->GetInfo(index) != 0)
{
return 1;
}

return 0;
}

BOOL CCustomWing::CheckCustomWingByItem(int ItemIndex) // OK
{
if(this->GetInfoByItem(ItemIndex) != 0)
{
return 1;
}

return 0;
}

BOOL CCustomWing::CheckCustomWingByModelType(int ItemIndex,int ModelType) // OK
{
for(int n=0;n < MAX_CUSTOM_WING;n++)
{
CUSTOM_WING_INFO* lpInfo = this->GetInfo(n);

if(lpInfo == 0)
{
continue;
}

if(lpInfo->ItemIndex == ItemIndex && lpInfo->ModelType == ModelType)
{
return 1;
}
}

return 0;
}

int CCustomWing::GetCustomWingItem(int index) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfo(index);

if(lpInfo == 0)
{
return 0;
}

return lpInfo->ItemIndex;
}

int CCustomWing::GetCustomWingIndex(int ItemIndex) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

return lpInfo->Index;
}

int CCustomWing::GetCustomWingDefense(int ItemIndex,int ItemLevel) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

return (lpInfo->DefenseConstA*ItemLevel);
}

int CCustomWing::GetCustomWingIncDamage(int ItemIndex,int ItemLevel) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

return ((lpInfo->IncDamageConstA+(ItemLevel*lpInfo->IncDamageConstB))-100);
}

int CCustomWing::GetCustomWingDecDamage(int ItemIndex,int ItemLevel) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

return (100-(lpInfo->DecDamageConstA-(ItemLevel*lpInfo->DecDamageConstB)));
}

int CCustomWing::GetCustomWingOptionIndex(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->OptionIndex1;
case 1:
return lpInfo->OptionIndex2;
case 2:
return lpInfo->OptionIndex3;
}

return 0;
}

int CCustomWing::GetCustomWingOptionValue(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->OptionValue1;
case 1:
return lpInfo->OptionValue2;
case 2:
return lpInfo->OptionValue3;
}

return 0;
}

int CCustomWing::GetCustomWingNewOptionIndex(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->NewOptionIndex1;
case 1:
return lpInfo->NewOptionIndex2;
case 2:
return lpInfo->NewOptionIndex3;
case 3:
return lpInfo->NewOptionIndex4;
}

return 0;
}

int CCustomWing::GetCustomWingNewOptionValue(int ItemIndex,int OptionNumber) // OK
{
CUSTOM_WING_INFO* lpInfo = this->GetInfoByItem(ItemIndex);

if(lpInfo == 0)
{
return 0;
}

switch(OptionNumber)
{
case 0:
return lpInfo->NewOptionValue1;
case 1:
return lpInfo->NewOptionValue2;
case 2:
return lpInfo->NewOptionValue3;
case 3:
return lpInfo->NewOptionValue4;
}

return 0;
}

CustomWing.h


// CustomWing.h: interface for the CCustomWing class.
//
//////////////////////////////////////////////////////////////////////

#pragma once

struct CUSTOM_WING_INFO
{
int Index;
int ItemIndex;
int DefenseConstA;
int IncDamageConstA;
int IncDamageConstB;
int DecDamageConstA;
int DecDamageConstB;
int OptionIndex1;
int OptionValue1;
int OptionIndex2;
int OptionValue2;
int OptionIndex3;
int OptionValue3;
int NewOptionIndex1;
int NewOptionValue1;
int NewOptionIndex2;
int NewOptionValue2;
int NewOptionIndex3;
int NewOptionValue3;
int NewOptionIndex4;
int NewOptionValue4;
int ModelType;
char ModelName[32];
};

class CCustomWing
{
public:
CCustomWing();
virtual ~CCustomWing();
void Init();
void Load(CUSTOM_WING_INFO* info);
void SetInfo(CUSTOM_WING_INFO info);
CUSTOM_WING_INFO* GetInfo(int index);
CUSTOM_WING_INFO* GetInfoByItem(int ItemIndex);
BOOL CheckCustomWing(int index);
BOOL CheckCustomWingByItem(int ItemIndex);
BOOL CheckCustomWingByModelType(int ItemIndex,int ModelType);
int GetCustomWingItem(int index);
int GetCustomWingIndex(int ItemIndex);
int GetCustomWingDefense(int ItemIndex,int ItemLevel);
int GetCustomWingIncDamage(int ItemIndex,int ItemLevel);
int GetCustomWingDecDamage(int ItemIndex,int ItemLevel);
int GetCustomWingOptionIndex(int ItemIndex,int OptionNumber);
int GetCustomWingOptionValue(int ItemIndex,int OptionNumber);
int GetCustomWingNewOptionIndex(int ItemIndex,int OptionNumber);
int GetCustomWingNewOptionValue(int ItemIndex,int OptionNumber);
public:
CUSTOM_WING_INFO m_CustomWingInfo[MAX_CUSTOM_WING];
};

extern CCustomWing gCustomWing;

Credits
Louis

louis
05/03/2018, 09:54 AM
Só faltou o offset kkk