I was able to fix the HPBar problem by chaging Life and MaxLife from int to float, since GS uses it as float:
GS - User.CPP
Code:
//Custom HPBar mod:
struct PMSG_ATTACKRESULT
{
PBMSG_HEAD h; // C1:DC
BYTE NumberH; // 3
BYTE NumberL; // 4
BYTE DamageH; // 5
BYTE DamageL; // 6
BYTE DamageType; // 7
BYTE btShieldDamageH; // 8
BYTE btShieldDamageL; // 9
float Life; //A
float MaxLife; //E
};
Main.dll - mob_hp_bar.cpp
Code:
void CMob_HPBar::Draw()
{
if (this->MaxHP == 0) return;
int pHP = (int)((this->HP * 100) / this->MaxHP);
if (pHP)
{
MU_DrawGUI(NEWUI_BAR_SWITCH01, (MAX_WIDTH / 2) - 80, 20, 160, 18);
MU_DrawColorButton(NEWUI_BAR_SWITCH02, (MAX_WIDTH / 2) - 75, 25, (150 * pHP) / 100, 8, 0, 0, MU_CreateColor(255, 0, 0, 130));
}
else
{
this->isDraw = false;
}
}
void CMob_HPBar::SetupMob(float Life, float MaxLife, WORD index)
{
if (Life > MaxLife)
{
this->isDraw = false; //something is wrong ^.^
}
this->HP = Life;
this->MaxHP = MaxLife;
this->aIndex = index;
this->isDraw = TRUE;
}
Main.dll - mob_hp_bar.h
Code:
class CMob_HPBar
{
private:
float HP;
float MaxHP;
public:
BOOL isDraw;
WORD aIndex;
CMob_HPBar();
virtual ~CMob_HPBar();
void SetupMob(float Life, float MaxLife, WORD index);
void Draw();
};
I've added the PMSG_ATTACKRESULT on Protocol.cpp, to a better reading:
Code:
#include "StdAfx.h"
#include "Protocol.h"
#include "game_char.h"
#include "mob_hp_bar.h"
#include "mu_utils.h"
pMU_ProtocolCoreEx MU_ProtocolCoreEx;
BYTE PROTOCOLCORE_COPY_LEN = 7;
struct PBMSG_HEAD // Packet - Byte Type
{
public:
void set ( LPBYTE lpBuf, BYTE head, BYTE size) // line : 18
{
lpBuf[0] = 0xC1;
lpBuf[1] = size;
lpBuf[2] = head;
}; // line : 22
void setE ( LPBYTE lpBuf, BYTE head, BYTE size) // line : 25
{
lpBuf[0] = 0xC3;
lpBuf[1] = size;
lpBuf[2] = head;
}; // line : 29
BYTE c;
BYTE size;
BYTE headcode;
};
struct PMSG_ATTACKRESULT
{
PBMSG_HEAD h; // C1:DC
BYTE NumberH; // 3
BYTE NumberL; // 4
BYTE DamageH; // 5
BYTE DamageL; // 6
BYTE DamageType; // 7
BYTE btShieldDamageH; // 8
BYTE btShieldDamageL; // 9
float Life; //A
float MaxLife; //E
};
int __cdecl cMU_ProtocolCore(int index, PBYTE lpMsg, int len, int flags)
{
switch (index)
{
case MU_DAMAGE: //Damage
{
PMSG_ATTACKRESULT * lpAttack = (PMSG_ATTACKRESULT *) lpMsg;
WORD tIndex = ((lpAttack->NumberH << 8) + lpAttack->NumberL) & 0x7FFF;
if (tIndex == *GameIndex) {break;}
if (lpMsg[1] > 10)
{
float Life, MaxLife;
memcpy(&Life, &lpAttack->Life, sizeof(float));
memcpy(&MaxLife, &lpAttack->MaxLife, sizeof(float));
Mob_HP_Bar.SetupMob(Life, MaxLife, tIndex);
break;
}
break;
}
case 0x14: //Destroy viewport chars
{
for (unsigned int i=0; i<lpMsg[3]; ++i)
{
WORD tIndex = (lpMsg[4 + (i*2)] << 8) + lpMsg[5 + (i*2)];
if (tIndex == Mob_HP_Bar.aIndex)
{
Mob_HP_Bar.isDraw = false;
break;
}
}
break;
}
case 0x17: //Killed object
{
WORD tIndex = (lpMsg[3] << 8) + lpMsg[4];
if ((tIndex == Mob_HP_Bar.aIndex) || (tIndex == *GameIndex))
{
Mob_HP_Bar.isDraw = false;
}
break;
}
case 0x1C: //Teleport
{
if (lpMsg[5] == 1)
{
Mob_HP_Bar.isDraw = false;
}
break;
}
case 0xF3:
{
switch(lpMsg[3])
{
case 0x03: //Character selected (join map)
{
Mob_HP_Bar.isDraw = false;
break;
}
case 0x04: //Respawn
{
Mob_HP_Bar.isDraw = false;
break;
}
}
break;
}
}
return MU_ProtocolCoreEx(index, lpMsg, len, flags);
}
void InitProtocol()
{
MU_ProtocolCoreEx = (pMU_ProtocolCoreEx)HookFunction((LPVOID)MU_PROTOCOL_CORE, cMU_ProtocolCore, PROTOCOLCORE_COPY_LEN);
}
EDIT:
I've noticed also there is no Damage Info on client side, this is because the GCDamageSend function was hooked and after it, it just finish, didnt continue what GCDamageSend should do.
Dont know if there is a solution for this, but i've done as follows:
Declare the original GCDamageSend function on Prodef.h:
Code:
#define lpGCDamageSend ((void(*)(int aIndex, int TargetIndex, int AttackDamage, int MSBFlag, int MSBDamage, int iShieldDamage)) 0x00455CB0)
And just call this function at the end of our new function - User.cpp
Code:
lpGCDamageSend(aIndex, TargetIndex, AttackDamage, MSBFlag, MSBDamage, iShieldDamage);
Now my request:
1 - Some one knows the offsets for current selected monsters? Then we can improve the HPMobar to show only selected mobs.
2 - How to get rid of this fog on Cash Shop?
