[Guide] Change glow color

DarkMaster

Administrator
Staff member
Joined
Apr 8, 2008
Messages
2,463
Reaction score
11,146
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++:
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]
};
in this variable glow function returns the result color, there are 30(2 equal blues o_O) 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 :D


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;
};
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

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);
}
The Glow Colors dll reads from "glow.gld".
Format of *.gld files:
File header:
Code:
struct GLOW
{
	DWORD signature;	// = 0x574F4C47
	BYTE bType;	// represents max items, 0 - 32, else - 512
};
Further, to the end of file, follows items glow info:
Code:
struct ITEM
{
	USHORT usItemId; // item id
	FRGB fClr;	// glow color
};
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
glowedom8.jpg


default glow
unglowedkq5.jpg



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 :D

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
 

Attachments

  • glow_dll.rar
    28.6 KB · Views: 60
  • GlowEditor.rar
    265.7 KB · Views: 65

ReaL

New Member
Joined
Apr 13, 2008
Messages
1,244
Reaction score
656
10/10
The guide is too long, but usualy it can be made for 30 min ;)
Don't be afraid of the Guide's lenght ^^
 

MACTEP

New Member
Joined
Jul 23, 2008
Messages
3
Reaction score
0
Човек това сигурно е много полезно, но немога да разбера. Смисъм такъв, че ако беше написано на Български щях, но на Английски никога. Едва ли ти се занимава, но така както е нищо няма да мога да направя ... :sweat:
 

Lesh0

Active Member
Joined
Apr 22, 2008
Messages
705
Reaction score
89
еми доста играчка си е
 
Last edited:

RhysFox

New Member
Joined
Jun 30, 2008
Messages
918
Reaction score
299
Днес ще променяме светещия цвят в мain.exe. Нашата главна цел е да променим цвета с който светят предметите от +7 до +13.

1. Ще започнем от теорията.

В main.exe има функция която контролира светещия цвят за повечето предмети и някой чудовища. На пример, за крилата, динорант-модел, коня на лорда-модел и за още някои предмети тази функция не се използва, но аз се чудех как мога да променя светещия цвят на предметите, не да правя блестене на предмети които нямат този атрибут ;) Може би ще го откриете.

Първоначалния модел на тази функция е в 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]
};
В тази променлива функция се връща резултатния свят, има 30(2 равни сини o_O) обикновенните светещи цветове, но на кой му пука? Ние ще направим някакви цветове.

uk1 & uk2 - обикновенно това са два потока, които коннтролират светещите цветове, но ние няма да ги ползваме.

bUkn - помните ли двата балрога, сребърния и червения? Тази променлива се изпозлва само да определи неговия цвят и бяскавина =) сребъред или червен.

Ако сте се досетили, трябва да закачим тази финкция и да върнем цветът който искаме.

Аз ще попитам как да намерим истиснското ИД на предмета, защото във функцията ние имаме ИД-то на обекта. Лесно е, всички предмети са преместени в боен ред от обекти от някаква стойност. ИД-тата на предметите остават същите както в item.bmd и в item.txt (ItemId = ItemType*MaxItemsInType+ItemIndex)

Така, ако имаме ИД-то на обекта и призвание на предметите в боен ред от обекти, ние можем просто да контролираме ИД-то на предмета.
ItemId = ObjectId - Offset;

На пример. нека намерим предмета с ObjectId=0x293 and Offset=0x285, с 512 максимални предмети от вида:

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)

Ако погледмете в items.txt or .bmd, ще видите, че предмета е Lightninh Sword. По късно ще кажа как да откриете "контраста" =)
Със тези знания Вие можете да правите собствени DLL и да променяте светещите цветове сами, но аз направих DLL което е съвместимо за хора които не могат да си направят собствено.

2. DLL

Тука ще опиша алгоритъма за DLL-то.

Това ДЛЛ поддържа 32 & 512 MaxItems, затова най-добрия начин за длл, което ще е съвместимо с всички, е паметно разпределение за всички предмети.

Code:
struct ITEM
{
    BYTE bChng; //ще кажа по късно
    float r, g, b;
};
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

За maxitemindex = 512 няма да се използва много памет, но този метод ни позволява да адресираме, така че е по бързо отколкото да търси предмета в списъка по неговото ИД; а и плюс това този метод ще ни помогне по-късно =)

Запомнете че ITEM::bChng? ще маркираме всички променените предмети (искам да кажа бяскания).
Ако предмета е променен връщаме нашият цвят, ако не - ще върнем обикновенната функция за бласкане.
Ето нашите нови 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);
}
Glow Colors dll чете то "glow.gld".
Формат на *.gld files:
File header:

Code:
struct GLOW
{
    DWORD signature;    // = 0x574F4C47
    BYTE bType;    // represents max items, 0 - 32, else - 512
};

Further, to the end of file, follows items glow info:
Code:

struct ITEM
{
    USHORT usItemId; // item id
    FRGB fClr;    // glow color
};
Така сме закачили функцията за бляскане, сега можем да накраме main.exe да използва нашите цветове.

3. Glow Editor Tool.
http://img91.imageshack.us/img91/7492/programnd8.jpg

Glow Editor Ви позволява да:
-Променяте цвет на бласкане на предметите които искате. След като използва Microsoft Jet(.MDB) database ще ви трябва да робавяте/махате предмети. Просто е с MS Access.
-Load и Save *.gld файлове for 32 and 512 maxitems версии на main.exe
-Patch DLL за Вашото main.exe, защото функицията призванието, и контраста за различни.
-Споделената памет на ДЛЛ-то, използваща File Mapping, + direct addressing( помните ли? ) Позволява на Glow Editor-а да променя цветовете дирекно в играта.

4. DLL Patch.

Призванието на Glow function и контраста на предметите са разчилни, затова тряжва да променим стойностите.
Ще ви кажа как да ги намерите използвайки ollydbg, но при едно условие - main.exe трябва да е unpacked.

1. Launch main.exe в ollydbg.

2. Десен Бутон -> Search for -> all referenced text strings.
http://img262.imageshack.us/img262/3...archalluz4.jpg

3. В излезналия прозорец Десен Бутон -> search for text
http://img214.imageshack.us/img214/1...rchtextzi1.jpg

4. Напишете "sword"; Uncheck "Case sensitive" и проверете "Entire scope"
http://img262.imageshack.us/img262/4...chswordlu8.jpg

5. Потърсете "Sword" както ан картинката използвайки CTR+L(search next)
http://img187.imageshack.us/img187/6563/03swordvx8.jpg

6. Когато го намерите, двоен клик или натиснете ENTER върху него, и в main window трябва да видите нещо като на картинакта, ордолу под "Sword" трябва да е "Data\Item" или може би само "Item".
http://img186.imageshack.us/img186/9215/04foundnr6.jpg

7. Над присоваването на функцията първо натиснете command pushes в stack ObjectId. Предмете написаи от групата Swords(Type = 0), така че когато стартирате main.exe-то пуска моделтите или текстурите за мечове то прибавя ИД-то на итема Offset-а от началото на уръжията от тип мечовете, и ако мечовете са първи тип предмети, този offset е Offset-а на предметите на бойна редица от обекти.
http://img214.imageshack.us/img214/1222/05offsetyq2.jpg

8. Нека намерим функцията за баляскане. Десен Бутон ->search for -> all constants
http://img262.imageshack.us/img262/7...llconstbh3.jpg

9. Ще търсим за ObjectId of the Lightning Sword(помните ли как да приканвате itemid or object id?)
ObjectId = Offset(стойността която сте намерили) + ItemdId(0*512+14 = 14(0x0E))
for Offset = 0x285, ObjectId = 0x293
http://img187.imageshack.us/img187/4...ngswordsl3.jpg

10. В показалия се прозорец намерете две Compare Commands
http://img214.imageshack.us/img214/2...onstantma9.jpg

11. Double-click или ENTER на пръвата команда, и Вие ще бъдете изпратени до нея.
http://img262.imageshack.us/img262/7...toconstgq7.jpg

12. Това е нашата glow proc, scroll up и намерете началото й.
http://img214.imageshack.us/img214/4...lowprocsv7.jpg

13. Дайте на първата команда, след това Десен Бутон -> Go to, и ще видите две повиквания за glow function
http://img262.imageshack.us/img262/5467/11callskr8.jpg

Ако нямате "CALL from X", давате Десен Бутон -> Analyse-> Analyse code, и опитайте отново 13-та стъпка.
http://img214.imageshack.us/img214/2...analysedz0.jpg

Сега с Offset and 2 func Calls можете да пачнете DLL =)

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

Може би по-късно ще ги прибавя към Едитора

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

За да създадете glow.gld, просто отворете tool после File->Save а то ще го направи .gld вместо вас
Това не е тествано с 32 MaxItems, но би трябвало да работи.


Е надявам се да съм ви помогнал (на тези който не разбират английски). Пак заповядайте. Между другото в английската версия има грешки и не можах да преведа точно както трябва затова си позволих да заместя в превода с някой думи ::(:.
 
  • Like
Reactions: G0dLiK3 and PaskaL

Ex74

New Member
Joined
Aug 24, 2008
Messages
14
Reaction score
0
хубаво, само трябва да оправиш някои линкове
 

RhysFox

New Member
Joined
Jun 30, 2008
Messages
918
Reaction score
299
хубаво, само трябва да оправиш някои линкове

Обръшай се към DarkMaster. Аз само съм го превел !
 

G0dLiK3

Active Member
Joined
Jun 28, 2008
Messages
623
Reaction score
108
леле тва е голяма играчка :d