- Joined
- Apr 8, 2008
- Messages
- 2,465
- Reaction score
- 11,169
Today we will edit glow color in main.exe. The main target is changing items glow(+7 - +13).
1. We will start from theory.
There is a function in main.exe that calcs glow color for most of items +7 - +13, and some mobs. For example, for wings, dinorant-model, darkhorse-model and for some other items this function isn't called, but i was wandering how to change glow color, not in making glow items that doesn't have this attribute May be u'll find it out.
The prototype of this function in c++:
dwItemId - objectId or index, each object is loaded in a big array of objects, and each object has it's unique index =)
cl - it's a float RGB struct
in this variable glow function returns the result color, there are 30(2 equal blues ) default glow colors, but who cares? we will make any color
uk1 & uk2 - actually these two are floats, and they are used to calc glow color, but we won't use them
bUkn - do u remember 2 kind of balrogs, silver and red? this variable is used only to determine his glow and his bill glow =) silver or red.
If you've already guessed, we have to hook this function and return the color we want.
But u'll ask how to find out the real item's Id, because in function we have object's Id. It's simple, all items are displaced in array of objects on some value. Items Ids remain the same as in item.bmd and in item.txt(itemId = ItemType*MaxItemsInType+ItemIndex)
So if we have ObjectId and Offset of items in array of objects, we can simply calc item's id:
ItemId = ObjectId - Offset;
For Example, let's find the item with ObjectId=0x293 and Offset=0x285, with 512 max items in type:
ItemId = ObjectId - Offset = 0x293 - 0x285 = 0x0E(14)
ItemType = ItemId / MaxItems = 14 / 512 = 0 (integer division)
ItemIndex = ItemId % MaxItems = 14 % 512 = 14 (remainder of the integer division)
if you'll take a look in items.txt or .bmd,
you'll find that item with Type = 0 and Index = 14 is Lightning Sword
Later i'll tell you how to find the "Offset" =)
With these knowledges you can make your own DLL and change glow colors by yourselves, but I made a DLL that will be compatible for people who won't be able to make their own.
2. DLL
Here i'll describe the algorithm of the dll.
This dll supports 32 & 512 MaxItems.
So the best way for a dll, that will be compatible for all, is memory allocation for all the items -
sizeof(ITEM) = 3*4 + 1 = 13 bytes
maxtypes = 16
memory = sizeof(ITEM)*maxtypes*maxitemindex = 208*maxitemindex
if maxitemindex = 32, then memory = 208*32 = 6 656 bytes ~ 6,5 kb
if maxitemindex = 512, then memory = 208*512 = 106 496 bytes = 104 kb
For maxitemindex = 512 a lot of memory won't be used at all, but this method allows us to use direct addressing, so it is faster then if we had to find the item in the list of items by it's id; and also this method will help us later =)
remember ITEM::bChng? we will mark all changed items(i mean glow).
If item is changed we return our color, if not - we call default glow function.
Here is our new Glow Proc
The Glow Colors dll reads from "glow.gld".
Format of *.gld files:
File header:
Further, to the end of file, follows items glow info:
So we've hooked glow function, we can now force main.exe to use our colors.
3. Glow Editor Tool.
404 Not Found
Glow Editor allows you:
-Edit glow color of the items u want,
since it uses Microsoft Jet(.MDB) database u'll be able to add or remove items, it's simple with MS Access.
-Load and Save *.gld files for 32 and 512 maxitems versions of main.exe
-Patch DLL for you main.exe, because function calls and items offset are different
-DLL's shared memory, using File Mapping, + direct addressing( remember? ) allows Glow Editor change colors directly in game.
4. DLL Patch.
Glow function calls and items offset are different in different mains, so we have to change these values.
I'll tell you how to find them using ollydbg, but with 1 condition - main.exe must be unpacked.
1. Launch main.exe in ollydbg.
2. Right Button(RB)-> Search for -> all referenced text strings.
http://img262.imageshack.us/img262/3...archalluz4.jpg
3. In the appeared window RB -> search for text
http://img214.imageshack.us/img214/1...rchtextzi1.jpg
4. Type "sword"; Uncheck "Case sensitive" and Check "Entire scope"
http://img262.imageshack.us/img262/4...chswordlu8.jpg
5. Search "Sword" like on the picture using CTR+L(search next)
404 Not Found
6. When you'll find it, double-click or press ENTER on it, and in the main window u should see smth like
on the picture, the srtring below "Sword" must be "Data\Item" or may be just "Item".
http://img186.imageshack.us/img186/9215/04foundnr6.jpg
7. Above the function call first push command pushes in stack ObjectId. Items types begin from Swords(Type = 0),
so when main.exe loads models or textures for swords it adds to the item's id the Offset of beginning sword's type section, and if sword's type is the first type of items,
this offset is the Offset of items in array of objects
http://img214.imageshack.us/img214/1222/05offsetyq2.jpg
8. Let's find glow function calls. RB ->search for -> all constants
http://img262.imageshack.us/img262/7...llconstbh3.jpg
9. We will search for ObjectId of the Lightning Sword(remember how to calc itemid or object id?)
ObjectId = Offset(value that you have found) + ItemdId(0*512+14 = 14(0x0E))
for Offset = 0x285, ObjectId = 0x293
http://img187.imageshack.us/img187/4...ngswordsl3.jpg
10. In the appeared window find 2 Compare Commands
http://img214.imageshack.us/img214/2...onstantma9.jpg
11. Double-click or ENTER on the FIRST command, and you'll be redirected to it
http://img262.imageshack.us/img262/7...toconstgq7.jpg
12. This is our glow proc, scroll up and find the beginning of it
http://img214.imageshack.us/img214/4...lowprocsv7.jpg
13. Select first command, then RB -> Go to, and you will see 2 calls for glow function
http://img262.imageshack.us/img262/5467/11callskr8.jpg
if u don't have "CALL from X", then RB -> Analyse-> Analyse code, and trye again step 13
http://img214.imageshack.us/img214/2...analysedz0.jpg
now with Offset and 2 func Calls you can patch DLL =)
glowed items
default glow
Default Glows [id - R, G, B preview]:
00 - 1.00, 0.50, 0.00 http://img151.imageshack.us/img151/8288/00ax5.jpg
01 - 1.00, 0.20, 0.00 http://img151.imageshack.us/img151/1716/01md4.jpg
02 - 0.00, 0.50, 1.00 http://img151.imageshack.us/img151/693/02go6.jpg
03 - 0.00, 0.50, 1.00 http://img151.imageshack.us/img151/693/02go6.jpg
04 - 0.00, 0.80, 0.40 http://img81.imageshack.us/img81/9130/04dh0.jpg
05 - 1.00, 1.00, 1.00 http://img81.imageshack.us/img81/2693/05oo4.jpg
06 - 0.60, 0.20, 0.40 http://img86.imageshack.us/img86/7563/06yh3.jpg
07 - 0.90, 0.80, 1.00 http://img208.imageshack.us/img208/3373/07yp5.jpg
08 - 0.80, 0.80, 1.00 http://img205.imageshack.us/img205/9941/08ut2.jpg
09 - 0.50, 0.50, 0.80 http://img404.imageshack.us/img404/8607/09kd8.jpg
10 - 0.75, 0.65, 0.50 http://img187.imageshack.us/img187/9000/10wz6.jpg
11 - 0.35, 0.35, 0.60 http://img185.imageshack.us/img185/7017/11nl3.jpg
12 - 0.47, 0.67, 0.30 http://img205.imageshack.us/img205/7330/12hk1.jpg
13 - 0.00, 0.30, 0.60 http://img262.imageshack.us/img262/7458/13yo5.jpg
14 - 0.65, 0.65, 0.55 http://img404.imageshack.us/img404/1964/14us2.jpg
15 - 0.20, 0.30, 0.60 http://img214.imageshack.us/img214/3042/15io4.jpg
16 - 0.80, 0.46, 0.25 http://img208.imageshack.us/img208/3078/16vn6.jpg
17 - 0.65, 0.45, 0.30 http://img205.imageshack.us/img205/1149/17he8.jpg
18 - 0.50, 0.40, 0.30 http://img404.imageshack.us/img404/2445/18ps6.jpg
19 - 0.37, 0.37, 1.00 http://img187.imageshack.us/img187/7092/19lo3.jpg
20 - 0.30, 0.70, 0.30 http://img185.imageshack.us/img185/3805/20yd3.jpg
21 - 0.50, 0.40, 1.00 http://img205.imageshack.us/img205/9804/21ho9.jpg
22 - 0.45, 0.45, 0.23 http://img214.imageshack.us/img214/4053/22sa3.jpg
23 - 0.30, 0.30, 0.45 http://img208.imageshack.us/img208/489/23my8.jpg
24 - 0.60, 0.50, 0.20 http://img205.imageshack.us/img205/8799/24xf5.jpg
25 - 0.60, 0.60, 0.60 http://img404.imageshack.us/img404/8000/25xd5.jpg
26 - 0.30, 0.70, 0.30 http://img187.imageshack.us/img187/2576/26xd7.jpg
27 - 0.50, 0.60, 0.70 http://img185.imageshack.us/img185/9435/27oh0.jpg
28 - 0.45, 0.45, 0.23 http://img214.imageshack.us/img214/7489/28nx7.jpg
29 - 0.45, 0.45, 0.45 forgot to make screen
may be later i will add them to the glow editor
Glow.dll goes to MuOnline client's folder
Glow.gld goes to MuOnline client's Data\ folder
Don't forget to hook DLL in main.exe
to create glow.gld, just open the tool then File->Save it will create .gld for you
not tested with 32 max items, but should work
Credits:
1. Hybrid
2 .Fiuz
1. We will start from theory.
There is a function in main.exe that calcs glow color for most of items +7 - +13, and some mobs. For example, for wings, dinorant-model, darkhorse-model and for some other items this function isn't called, but i was wandering how to change glow color, not in making glow items that doesn't have this attribute May be u'll find it out.
The prototype of this function in c++:
Code:
void __cdecl Glow(DWORD dwItemId, DWORD uk1, DWORD uk2, FRGB& cl, BYTE bUkn);
dwItemId - objectId or index, each object is loaded in a big array of objects, and each object has it's unique index =)
cl - it's a float RGB struct
Code:
struct FRGB
{
float r, g, b; // range of each color [0, 1]
};
uk1 & uk2 - actually these two are floats, and they are used to calc glow color, but we won't use them
bUkn - do u remember 2 kind of balrogs, silver and red? this variable is used only to determine his glow and his bill glow =) silver or red.
If you've already guessed, we have to hook this function and return the color we want.
But u'll ask how to find out the real item's Id, because in function we have object's Id. It's simple, all items are displaced in array of objects on some value. Items Ids remain the same as in item.bmd and in item.txt(itemId = ItemType*MaxItemsInType+ItemIndex)
So if we have ObjectId and Offset of items in array of objects, we can simply calc item's id:
ItemId = ObjectId - Offset;
For Example, let's find the item with ObjectId=0x293 and Offset=0x285, with 512 max items in type:
ItemId = ObjectId - Offset = 0x293 - 0x285 = 0x0E(14)
ItemType = ItemId / MaxItems = 14 / 512 = 0 (integer division)
ItemIndex = ItemId % MaxItems = 14 % 512 = 14 (remainder of the integer division)
if you'll take a look in items.txt or .bmd,
you'll find that item with Type = 0 and Index = 14 is Lightning Sword
Later i'll tell you how to find the "Offset" =)
With these knowledges you can make your own DLL and change glow colors by yourselves, but I made a DLL that will be compatible for people who won't be able to make their own.
2. DLL
Here i'll describe the algorithm of the dll.
This dll supports 32 & 512 MaxItems.
So the best way for a dll, that will be compatible for all, is memory allocation for all the items -
Code:
struct ITEM
{
BYTE bChng; // i'll tell later
float r, g, b;
};
maxtypes = 16
memory = sizeof(ITEM)*maxtypes*maxitemindex = 208*maxitemindex
if maxitemindex = 32, then memory = 208*32 = 6 656 bytes ~ 6,5 kb
if maxitemindex = 512, then memory = 208*512 = 106 496 bytes = 104 kb
For maxitemindex = 512 a lot of memory won't be used at all, but this method allows us to use direct addressing, so it is faster then if we had to find the item in the list of items by it's id; and also this method will help us later =)
remember ITEM::bChng? we will mark all changed items(i mean glow).
If item is changed we return our color, if not - we call default glow function.
Here is our new Glow Proc
Code:
void Glow(DWORD dwItemId, DWORD uk1, DWORD uk2, FRGB& fClr, BYTE bUkn)
{
int id = dwItemId - g_dwOffset; // calc item id
// if our object is an item and this item should use our glow and it's not a silver balrog :D
// then we return our color
// else call the default function
if( id >=0 && id < g_MaxItems*16 && Glows[id].bIsChanged && !bUkn)
fClr = Glows[id].fClr;
else
fnOldGlow(dwItemId, uk1, uk2, fClr, bUkn);
}
Format of *.gld files:
File header:
Code:
struct GLOW
{
DWORD signature; // = 0x574F4C47
BYTE bType; // represents max items, 0 - 32, else - 512
};
Code:
struct ITEM
{
USHORT usItemId; // item id
FRGB fClr; // glow color
};
3. Glow Editor Tool.
404 Not Found
Glow Editor allows you:
-Edit glow color of the items u want,
since it uses Microsoft Jet(.MDB) database u'll be able to add or remove items, it's simple with MS Access.
-Load and Save *.gld files for 32 and 512 maxitems versions of main.exe
-Patch DLL for you main.exe, because function calls and items offset are different
-DLL's shared memory, using File Mapping, + direct addressing( remember? ) allows Glow Editor change colors directly in game.
4. DLL Patch.
Glow function calls and items offset are different in different mains, so we have to change these values.
I'll tell you how to find them using ollydbg, but with 1 condition - main.exe must be unpacked.
1. Launch main.exe in ollydbg.
2. Right Button(RB)-> Search for -> all referenced text strings.
http://img262.imageshack.us/img262/3...archalluz4.jpg
3. In the appeared window RB -> search for text
http://img214.imageshack.us/img214/1...rchtextzi1.jpg
4. Type "sword"; Uncheck "Case sensitive" and Check "Entire scope"
http://img262.imageshack.us/img262/4...chswordlu8.jpg
5. Search "Sword" like on the picture using CTR+L(search next)
404 Not Found
6. When you'll find it, double-click or press ENTER on it, and in the main window u should see smth like
on the picture, the srtring below "Sword" must be "Data\Item" or may be just "Item".
http://img186.imageshack.us/img186/9215/04foundnr6.jpg
7. Above the function call first push command pushes in stack ObjectId. Items types begin from Swords(Type = 0),
so when main.exe loads models or textures for swords it adds to the item's id the Offset of beginning sword's type section, and if sword's type is the first type of items,
this offset is the Offset of items in array of objects
http://img214.imageshack.us/img214/1222/05offsetyq2.jpg
8. Let's find glow function calls. RB ->search for -> all constants
http://img262.imageshack.us/img262/7...llconstbh3.jpg
9. We will search for ObjectId of the Lightning Sword(remember how to calc itemid or object id?)
ObjectId = Offset(value that you have found) + ItemdId(0*512+14 = 14(0x0E))
for Offset = 0x285, ObjectId = 0x293
http://img187.imageshack.us/img187/4...ngswordsl3.jpg
10. In the appeared window find 2 Compare Commands
http://img214.imageshack.us/img214/2...onstantma9.jpg
11. Double-click or ENTER on the FIRST command, and you'll be redirected to it
http://img262.imageshack.us/img262/7...toconstgq7.jpg
12. This is our glow proc, scroll up and find the beginning of it
http://img214.imageshack.us/img214/4...lowprocsv7.jpg
13. Select first command, then RB -> Go to, and you will see 2 calls for glow function
http://img262.imageshack.us/img262/5467/11callskr8.jpg
if u don't have "CALL from X", then RB -> Analyse-> Analyse code, and trye again step 13
http://img214.imageshack.us/img214/2...analysedz0.jpg
now with Offset and 2 func Calls you can patch DLL =)
glowed items
default glow
Default Glows [id - R, G, B preview]:
00 - 1.00, 0.50, 0.00 http://img151.imageshack.us/img151/8288/00ax5.jpg
01 - 1.00, 0.20, 0.00 http://img151.imageshack.us/img151/1716/01md4.jpg
02 - 0.00, 0.50, 1.00 http://img151.imageshack.us/img151/693/02go6.jpg
03 - 0.00, 0.50, 1.00 http://img151.imageshack.us/img151/693/02go6.jpg
04 - 0.00, 0.80, 0.40 http://img81.imageshack.us/img81/9130/04dh0.jpg
05 - 1.00, 1.00, 1.00 http://img81.imageshack.us/img81/2693/05oo4.jpg
06 - 0.60, 0.20, 0.40 http://img86.imageshack.us/img86/7563/06yh3.jpg
07 - 0.90, 0.80, 1.00 http://img208.imageshack.us/img208/3373/07yp5.jpg
08 - 0.80, 0.80, 1.00 http://img205.imageshack.us/img205/9941/08ut2.jpg
09 - 0.50, 0.50, 0.80 http://img404.imageshack.us/img404/8607/09kd8.jpg
10 - 0.75, 0.65, 0.50 http://img187.imageshack.us/img187/9000/10wz6.jpg
11 - 0.35, 0.35, 0.60 http://img185.imageshack.us/img185/7017/11nl3.jpg
12 - 0.47, 0.67, 0.30 http://img205.imageshack.us/img205/7330/12hk1.jpg
13 - 0.00, 0.30, 0.60 http://img262.imageshack.us/img262/7458/13yo5.jpg
14 - 0.65, 0.65, 0.55 http://img404.imageshack.us/img404/1964/14us2.jpg
15 - 0.20, 0.30, 0.60 http://img214.imageshack.us/img214/3042/15io4.jpg
16 - 0.80, 0.46, 0.25 http://img208.imageshack.us/img208/3078/16vn6.jpg
17 - 0.65, 0.45, 0.30 http://img205.imageshack.us/img205/1149/17he8.jpg
18 - 0.50, 0.40, 0.30 http://img404.imageshack.us/img404/2445/18ps6.jpg
19 - 0.37, 0.37, 1.00 http://img187.imageshack.us/img187/7092/19lo3.jpg
20 - 0.30, 0.70, 0.30 http://img185.imageshack.us/img185/3805/20yd3.jpg
21 - 0.50, 0.40, 1.00 http://img205.imageshack.us/img205/9804/21ho9.jpg
22 - 0.45, 0.45, 0.23 http://img214.imageshack.us/img214/4053/22sa3.jpg
23 - 0.30, 0.30, 0.45 http://img208.imageshack.us/img208/489/23my8.jpg
24 - 0.60, 0.50, 0.20 http://img205.imageshack.us/img205/8799/24xf5.jpg
25 - 0.60, 0.60, 0.60 http://img404.imageshack.us/img404/8000/25xd5.jpg
26 - 0.30, 0.70, 0.30 http://img187.imageshack.us/img187/2576/26xd7.jpg
27 - 0.50, 0.60, 0.70 http://img185.imageshack.us/img185/9435/27oh0.jpg
28 - 0.45, 0.45, 0.23 http://img214.imageshack.us/img214/7489/28nx7.jpg
29 - 0.45, 0.45, 0.45 forgot to make screen
may be later i will add them to the glow editor
Glow.dll goes to MuOnline client's folder
Glow.gld goes to MuOnline client's Data\ folder
Don't forget to hook DLL in main.exe
to create glow.gld, just open the tool then File->Save it will create .gld for you
not tested with 32 max items, but should work
Credits:
1. Hybrid
2 .Fiuz