PDA

View Full Version : |Source| Fix Agility Bug for 97d99i



djagripnos
03/01/2018, 07:27 PM
//Struct
struct PMSG_CHARINFOMAIN
{
PBMSG_HEAD h;
BYTE Code;
BYTE Class;
WORD Dexterity;
WORD AttackSpeed;
WORD MagicSpeed;
};




//Functions.cpp
#include "StdAfx.h"

Functions func;

BOOL Functions::gObjSetCharacterEx(LPBYTE lpdata, int aIndex)
{
BOOL retornar = gObjSetCharacter(lpdata,aIndex);

if(retornar == TRUE)
{
PMSG_CHARINFOMAIN Result;

Result.h.c = 0xC1;
Result.h.size = sizeof(Result);
Result.h.head = 0xFE;
Result.Code = 0x07;
Result.Class = gObj[aIndex].Class;
Result.Dexterity = (WORD)(gObj[aIndex].Dexterity);
Result.AttackSpeed = (WORD)(gObj[aIndex].m_AttackSpeed);
Result.MagicSpeed = (WORD)(gObj[aIndex].m_MagicSpeed);

DataSend(aIndex, (LPBYTE)(&Result), Result.h.size);
}

return retornar;
}

void Functions::gObjCalCharacterEx(int aIndex)
{
gObjCalCharacter(aIndex);

PMSG_CHARINFOMAIN Result;

Result.h.c = 0xC1;
Result.h.size = sizeof(Result);
Result.h.head = 0xFE;
Result.Code = 0x07;
Result.Class = gObj[aIndex].Class;
Result.Dexterity = (WORD)(gObj[aIndex].Dexterity);
Result.AttackSpeed = (WORD)(gObj[aIndex].m_AttackSpeed);
Result.MagicSpeed = (WORD)(gObj[aIndex].m_MagicSpeed);

DataSend(aIndex, (LPBYTE)(&Result), Result.h.size);
}





//Functions.h:
#pragma once

class Functions
{
public:
static BOOL gObjSetCharacterEx(LPBYTE lpdata, int aIndex);
static void gObjCalCharacterEx(int aIndex);
};

extern Functions func;




//Defines:
#define gObjSetCharacter ((bool(*)(LPBYTE lpdata, int aIndex)) 0x0045C370)
#define gObjCalCharacter ((void(*)(int aIndex)) 0x00451DE0)




//Hooks:

func.HookThis((DWORD)&Functions::gObjSetCharacterEx,0x004026CB);
func.HookThis((DWORD)&Functions::gObjCalCharacterEx,0x004015AF);



CLIENT




//Struct
-------------------------------
struct PMSG_CHARINFOMAIN
{
PBMSG_HEAD h;
BYTE Code;
BYTE Class;
WORD Dexterity;
WORD AttackSpeed;
WORD MagicSpeed;
};




//Naked.h
-------------------------------
#pragma once

DWORD nProtocolCoreBack = 0x4384FB;
LPBYTE nProtocolCoreData = nullptr;

void __declspec(naked) nProtocolCore()
{
__asm MOV nProtocolCoreData, EBP;

ProtocolCore(nProtocolCoreData);

__asm MOV EDX, DWORD PTR DS : [0x8311134];
__asm JMP nProtocolCoreBack;
}




//Protocol.cpp
#include "StdAfx.h"

BYTE PlayerClass = 0;
WORD PlayerDexterity = 0;
WORD PlayerASpeed = 0;
WORD PlayerMSpeed = 0;

void ProtocolCore(LPBYTE aRecv)
{
if (aRecv[0] == 0xC1 || aRecv[0] == 0xC3)
{
switch (aRecv[2])
{
case 0xF3:
{
switch(aRecv[3])
{
case 0x03:
{
ApplyDexterityFix();
}
break;
}
}
break;
case 0xFE:
{
switch(aRecv[3])
{
case 0x07:
{
PMSG_CHARINFOMAIN* Info = (PMSG_CHARINFOMAIN*)(aRecv);

PlayerClass = Info->Class;
PlayerDexterity = Info->Dexterity;
PlayerASpeed = Info->AttackSpeed;
PlayerMSpeed = Info->MagicSpeed;

ApplyDexterityFix();
}
break;
}
}
break;
}
}
}

void ApplyDexterityFix()
{
switch (PlayerClass)
{
case 0:
{
if (PlayerMSpeed >= 455 && PlayerMSpeed <= 479)
{
*eMainSpeedFrame2 = 0.0024700f;
}
else if (PlayerMSpeed >= 605 && PlayerMSpeed <= 636)
{
*eMainSpeedFrame2 = 0.0019000f;
}
else if (PlayerMSpeed >= 637 && PlayerMSpeed <= 668)
{
*eMainSpeedFrame2 = 0.0018000f;
}
else if (PlayerMSpeed >= 669 && PlayerMSpeed <= 688)
{
*eMainSpeedFrame2 = 0.0017000f;
}
else if (PlayerMSpeed >= 855 && PlayerMSpeed <= 1040)
{
*eMainSpeedFrame2 = 0.0016300f;
}
else if (PlayerMSpeed >= 1041 && PlayerMSpeed <= 1104)
{
*eMainSpeedFrame2 = 0.0015500f;
}
else if (PlayerMSpeed >= 1301 && PlayerMSpeed <= 1500)
{
*eMainSpeedFrame2 = 0.0017500f;
}
else if (PlayerMSpeed >= 1501 && PlayerMSpeed <= 1524)
{
*eMainSpeedFrame2 = 0.0015000f;
}
else if (PlayerMSpeed >= 1525 && PlayerMSpeed <= 1800)
{
*eMainSpeedFrame2 = 0.0014500f;
}
else if (PlayerMSpeed >= 1801 && PlayerMSpeed <= 1999)
{
*eMainSpeedFrame2 = 0.0013000f;
}
else if (PlayerMSpeed >= 2000 && PlayerMSpeed <= 2167)
{
*eMainSpeedFrame2 = 0.0012500f;
}
else if (PlayerMSpeed >= 2168 && PlayerMSpeed <= 2354)
{
*eMainSpeedFrame2 = 0.0011500f;
}
else if (PlayerMSpeed >= 2855 && PlayerMSpeed <= 3011)
{
*eMainSpeedFrame2 = 0.0009000f;
}
else if (PlayerMSpeed >= 3011)
{
*eMainSpeedFrame2 = 0.0008100f;

}
else
{
*eMainSpeedFrame2 = 0.0020000f;
}
}
break;
case 1:
{
*eMainSpeedFrame1 = 0.0040000f;
*eMainSpeedFrame2 = 0.0020000f;
}
break;
case 2:
{
if (PlayerASpeed >= 509 && PlayerASpeed <= 549)
{
*eMainSpeedFrame1 = 0.0026000f;
}
else if (PlayerASpeed >= 550 && PlayerASpeed <= 750)
{
*eMainSpeedFrame1 = 0.0017000f;
}
else
{
*eMainSpeedFrame1 = 0.0040000f;
}
}
break;
case 3:
{
if (PlayerMSpeed >= 455 && PlayerMSpeed <= 479)
{
*eMainSpeedFrame2 = 0.0024700f;
}
else if (PlayerMSpeed >= 605 && PlayerMSpeed <= 636)
{
*eMainSpeedFrame2 = 0.0019000f;
}
else if (PlayerMSpeed >= 637 && PlayerMSpeed <= 668)
{
*eMainSpeedFrame2 = 0.0018000f;
}
else if (PlayerMSpeed >= 669 && PlayerMSpeed <= 688)
{
*eMainSpeedFrame2 = 0.0017000f;
}
else if (PlayerMSpeed >= 855 && PlayerMSpeed <= 1040)
{
*eMainSpeedFrame2 = 0.0016300f;
}
else if (PlayerMSpeed >= 1041 && PlayerMSpeed <= 1104)
{
*eMainSpeedFrame2 = 0.0015500f;
}
else if (PlayerMSpeed >= 1301 && PlayerMSpeed <= 1500)
{
*eMainSpeedFrame2 = 0.0017500f;
}
else if (PlayerMSpeed >= 1501 && PlayerMSpeed <= 1524)
{
*eMainSpeedFrame2 = 0.0015000f;
}
else if (PlayerMSpeed >= 1525 && PlayerMSpeed <= 1800)
{
*eMainSpeedFrame2 = 0.0014500f;
}
else if (PlayerMSpeed >= 1801 && PlayerMSpeed <= 1999)
{
*eMainSpeedFrame2 = 0.0013000f;
}
else if (PlayerMSpeed >= 2000 && PlayerMSpeed <= 2167)
{
*eMainSpeedFrame2 = 0.0012500f;
}
else if (PlayerMSpeed >= 2168 && PlayerMSpeed <= 2354)
{
*eMainSpeedFrame2 = 0.0011500f;
}
else if (PlayerMSpeed >= 2855 && PlayerMSpeed <= 3011)
{
*eMainSpeedFrame2 = 0.0009000f;
}
else if (PlayerMSpeed >= 3011)
{
*eMainSpeedFrame2 = 0.0008100f;
}
else
{
*eMainSpeedFrame2 = 0.0020000f;
}
}
break;
}
}




//Protocol.h
#pragma once

void ProtocolCore(LPBYTE aRecv);
void ApplyDexterityFix();




//Defines:
#define eMainSpeedFrame1 (float*)(0x54D4BC)
#define eMainSpeedFrame2 (float*)(0x54D8CC)




//Hook
HookOffset((DWORD)&nProtocolCore,0x4384F5,0xE9);

Malyk
03/01/2018, 09:42 PM
Nesse caso que eu não tenho uma Source do Main, como eu faço? tem que criar uma DLL e da Hook?

- Será que alguém com experiencia não poderia fazer um video nem que seja só explicando pra eu dá meus pequenos passos?

Maykon
04/01/2018, 12:32 AM
Créditos: Maykon & Getulio