- Joined
- Oct 29, 2007
- Messages
- 1,290
- Reaction score
- 1,310
BOOL cBundles::DrawNumber(int pObj) // -> 005146C0
{
int pObject = *(WORD*)pObj; // -> Here I make a: 'pointer' to: Inventory Class Method.
// ----
switch(pObject)
{
case ItemId(12,30):
return TRUE;
break;
case ItemId(12,31):
return TRUE;
break;
case ItemId(12,150):
return TRUE;
break;
case ItemId(12,151):
return TRUE;
break;
case ItemId(12,152):
return TRUE;
break;
case ItemId(12,153):
return TRUE;
break;
case ItemId(12,154):
return TRUE;
break;
case ItemId(12,155):
return TRUE;
break;
case ItemId(12,156):
return TRUE;
break;
default:
return pDrawNumber(pObj) >= 2;
break;
}
}
void cBundles::InitDrawNumber()
{
gToolKit.SetOp((LPVOID)0x0050D089,this->DrawNumber,ASM::CALL);
gToolKit.SetOp((LPVOID)0x007347CE,this->DrawNumber,ASM::CALL);
gToolKit.SetOp((LPVOID)0x007777DF,this->DrawNumber,ASM::CALL);
}
void cBundles::Load()
{
this->InitDrawNumber();
}
#ifndef __BUNDLES_H__
#define __BUNDLES_H__
#define ItemId(x, y) ((x * 512) + y)
#define pDrawNumber ((bool(__cdecl*)(int pObj))0x005146C0)
class cBundles
{
public:
void Load();
void InitDrawNumber();
static BOOL DrawNumber(int pObj);
};
extern cBundles gBundles;
#endif
amzing idea to make it . i like your projectgood luckk
and i have little question , how u choose the number that draw ? that something at main offsets ?
Good. 1.04E offsets?
Take it easy "god" ....I'm thinking that you can on easy way research them by yourself... and exists 1 button to give me the: "Thanks".
Take it easy "god" ....
//----- (004E1230) --------------------------------------------------------
bool __cdecl sub_4E1230(int *a1)
{
return sub_4E1250(*(_WORD *)a1, 0) != -1;
}
Offsets Calls:
[COLOR=#ff0000]0x004E0728
0x004E0B4B
0x0058E629
0x005C405E
0x005C865F
0x007DCD14
0x00865F75[/COLOR]
- first of all, BOOL - integer microsoft type, bool - C++ byte type, u have prototype of original function with bool (byte) and in same time use for hook BOOL (int), its mistake what mean that u dont know what wait application in resultBOOL cBundles:rawNumber(int pObj)
- ur income argument is pointer type, not int, this function looks like: bool IsJewelBundle(ItemObject* item), ur code work without crash only bcz main.exe builded for x32 system and pointer size is 4 bytes (like integer), but in x64 system its be 8 bytesBOOL cBundles:rawNumber(int pObj)
- dont know what u mean with ur own pointer idea, also and with "class method", but its just class object which have first element like unsigned short (int16), for what u place int16 in int32 too i cant understand, maybe byte-racism?int pObject = *(WORD*)pObj; // -> Here I make a: 'pointer' to: Inventory Class Method.
class ItemObject {
public:
ItemObject() {} // method
virtual ~ItemObject() {} // too method
void Initialize() {} // too method
private:
short _index; // local variable
public:
short Index; // public variable
};
return pDrawNumber(pObj) >= 2;
- boolean type its only 1 or 0, true or false, how u get value >= 2 if u use boolean which will return to u only 1 as maximum?...#define pDrawNumber ((bool(__cdecl*)(int pObj))0x005146C0)
bool IsJewelBundle(ItemObject* item) {
if (item == nullptr) {
return false;
}
if (item->Index >= ITEM_INDEX(12, 30) && item->Index <= ITEM_INDEX(12, 31) ||
item->Index >= ITEM_INDEX(12, 150) && item->Index <= ITEM_INDEX(12, 156)) {
return true;
}
return false;
// or call to original function if u catch not all code
// like: return ((bool (__cdecl*) (ItemObject*)) 0x5146C0) (item);
}
U like code in darkness, without flashlight.
- first of all, BOOL - integer microsoft type, bool - C++ byte type, u have prototype of original function with bool (byte) and in same time use for hook BOOL (int), its mistake what mean that u dont know what wait application in result
- ur income argument is pointer type, not int, this function looks like: bool IsJewelBundle(ItemObject* item), ur code work without crash only bcz main.exe builded for x32 system and pointer size is 4 bytes (like integer), but in x64 system its be 8 bytes
- dont know what u mean with ur own pointer idea, also and with "class method", but its just class object which have first element like unsigned short (int16), for what u place int16 in int32 too i cant understand, maybe byte-racism?
Method - its function inside class or structure object, so u get 'ur own pointer' not to method, u get 'ur own pointer' to variable.
Code:class ItemObject { public: ItemObject() {} // method virtual ~ItemObject() {} // too method void Initialize() {} // too method private: short _index; // local variable public: short Index; // public variable };
- boolean type its only 1 or 0, true or false, how u get value >= 2 if u use boolean which will return to u only 1 as maximum?...
----
in final u can improve ur code to like this:
Code:bool IsJewelBundle(ItemObject* item) { if (item == nullptr) { return false; } if (item->Index >= ITEM_INDEX(12, 30) && item->Index <= ITEM_INDEX(12, 31) || item->Index >= ITEM_INDEX(12, 150) && item->Index <= ITEM_INDEX(12, 156)) { return true; } return false; // or call to original function if u catch not all code // like: return ((bool (__cdecl*) (ItemObject*)) 0x5146C0) (item); }
of course only if u sure that need use bool :laugh:
P.S.: if u code all in this trash style i not recommend to sell anything, ur skill while small for it.
If you are able to do it in a better way. Welcome.
//
// import
//
auto GLStateFreeze = ((void (__cdecl*) (bool)) 0x651C12);
auto GLStateRestore = ((void (__cdecl*) ()) 0x651B98);
auto DrawNumber = ((float (__cdecl*) (float, float, int, float)) 0x7B35FA);
auto DisplayItemStack = ((void (__cdecl*) (MUItemObject*, float, float, float, float, float)) 0x607680);
auto g_ResolutionWidth = *(int*)0x13E7014;
auto g_ResolutionHeight = *(int*)0x13E7018;
#define ITEM_INDEX(x, y) (x * 512 + y)
//
// our provider for original function
//
void OnDisplayItemStack(MUItemObject* item, float x, float y, float width, float height, float scale) {
if (item == nullptr) {
return;
}
GLStateFreeze(true);
glColor3f(1.0f, 1.0f, 1.0f);
//
float swp = 1024.0f / g_ResolutionWidth;
float shp = 768.0f / g_ResolutionHeight;
float rel_x = (x + width) - swp * 5.0f;
float rel_y = y + shp * 1.0f;
//
if (item->index == ITEM_INDEX(12, 288)) { // elemental rune
glColor3f(0.576f, 0.439f, 0.859f);
DrawNumber(rel_x, rel_y, 50, scale);
}
else if (item->index == ITEM_INDEX(14, 343)) { // archangel's hammer
glColor3f(0.0f, 0.75f, 1.0f);
DrawNumber(rel_x, rel_y, 70, scale);
}
else if (item->index == ITEM_INDEX(14, 352)) { // ruud box
glColor3f(0.824f, 0.412f, 0.118f);
DrawNumber(rel_x, rel_y, 1250, scale);
}
else if (item->index == ITEM_INDEX(8, 92)) { // gru hill armor
glColor3f(0.863f, 0.078f, 0.235f);
DrawNumber(rel_x, rel_y, (item->general_info >> 3) & 0xF, scale);
}
//
glColor3f(1.0f, 1.0f, 1.0f);
GLStateRestore();
DisplayItemStack(item, x, y, width, height, scale);
}
//
// hook
//
Patcher::At(0x9615DE)->Replace(OnDisplayItemStack);
Patcher::At(0x9EAC84)->Replace(OnDisplayItemStack);
Code:// // import // auto GLStateFreeze = ((void (__cdecl*) (bool)) 0x651C12); auto GLStateRestore = ((void (__cdecl*) ()) 0x651B98); auto DrawNumber = ((float (__cdecl*) (float, float, int, float)) 0x7B35FA); auto DisplayItemStack = ((void (__cdecl*) (MUItemObject*, float, float, float, float, float)) 0x607680); auto g_ResolutionWidth = *(int*)0x13E7014; auto g_ResolutionHeight = *(int*)0x13E7018; #define ITEM_INDEX(x, y) (x * 512 + y) // // our provider for original function // void OnDisplayItemStack(MUItemObject* item, float x, float y, float width, float height, float scale) { if (item == nullptr) { return; } GLStateFreeze(true); glColor3f(1.0f, 1.0f, 1.0f); // float swp = 1024.0f / g_ResolutionWidth; float shp = 768.0f / g_ResolutionHeight; float rel_x = (x + width) - swp * 5.0f; float rel_y = y + shp * 1.0f; // if (item->index == ITEM_INDEX(12, 288)) { // elemental rune glColor3f(0.576f, 0.439f, 0.859f); DrawNumber(rel_x, rel_y, 50, scale); } else if (item->index == ITEM_INDEX(14, 343)) { // archangel's hammer glColor3f(0.0f, 0.75f, 1.0f); DrawNumber(rel_x, rel_y, 70, scale); } else if (item->index == ITEM_INDEX(14, 352)) { // ruud box glColor3f(0.824f, 0.412f, 0.118f); DrawNumber(rel_x, rel_y, 1250, scale); } else if (item->index == ITEM_INDEX(8, 92)) { // gru hill armor glColor3f(0.863f, 0.078f, 0.235f); DrawNumber(rel_x, rel_y, (item->general_info >> 3) & 0xF, scale); } // glColor3f(1.0f, 1.0f, 1.0f); GLStateRestore(); DisplayItemStack(item, x, y, width, height, scale); } // // hook // Patcher::At(0x9615DE)->Replace(OnDisplayItemStack); Patcher::At(0x9EAC84)->Replace(OnDisplayItemStack);
#define oDrawColorB_Buff 0x007347EE
#define oDrawColorG_Buff 0x007347F3
#define oDrawColorR_Buff 0x007347F8
void cBundles::DrawColors(int iColor)
{
if(iColor == eNormalNumber)
{
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+4),0x3F);
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+3),0x33);
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+2),0x33);
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+1),0x33);
// ----
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+4),0x3F);
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+3),0x66);
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+2),0x66);
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+1),0x66);
// ----
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+4),0x3F);
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+3),0x80);
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+2),0x00);
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+1),0x00);
}
else if(iColor == eRedNumber)
{
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+4),0x3F);
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+3),0x80);
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+2),0x00);
gToolKit.SetByte((PVOID)(oDrawColorR_Buff+1),0x00);
// ----
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+4),0x00);
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+3),0x00);
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+2),0x00);
gToolKit.SetByte((PVOID)(oDrawColorG_Buff+1),0x00);
// ----
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+4),0x00);
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+3),0x00);
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+2),0x00);
gToolKit.SetByte((PVOID)(oDrawColorB_Buff+1),0x00);
}
}
ON DrawNumber proc:
case ItemId(12,151):
gBundles.DrawColors(eRedNumber);
return TRUE;
break;
U are strange, why u so love ugly byte patching, its like creating of Frankenstein, u can in one function setup size of sprite, position of sprite, color of sprite, value of sprite (example value of jewels is: <item level> * 10), for make this simple thing not need many methods, classes, or patches, its only one function...Sincerelly is not difficult if you understand how to make something like this:
U are strange, why u so love ugly byte patching, its like creating of Frankenstein, u can in one function setup size of sprite, position of sprite, color of sprite, value of sprite (example value of jewels is: <item level> * 10), for make this simple thing not need many methods, classes, or patches, its only one function...