Jump to content
Sanchez

[C++]Chat coloring with Game

Recommended Posts

Hi everyone,
 
In this thread I will show you how to change the color of the chat messages without any client modification. I will use the 2 new ring slots in this example.
 
First of all, the color codes:
 
RED: |cFFFF0000|H|h
GREEN: |cFF00FF00|H|h
BLUE: |cFF0080FF|H|h
YELLOW: |cFFFFFF00|H|h

Open game/unique_item.h and add these:

TEXT_COLOR_RED = ID_OF_THE_ITEM,
TEXT_COLOR_GREEN = ID_OF_THE_ITEM,
TEXT_COLOR_BLUE = ID_OF_THE_ITEM,
TEXT_COLOR_YELLOW = ID_OF_THE_ITEM,

Open game/input_main.cpp and search for this:

const TPacketCGChat* pinfo = reinterpret_cast<const TPacketCGChat*>(data);

Replace with this:

int len;
const TPacketCGChat* pinfo = reinterpret_cast<const TPacketCGChat*>(data);

Remove this:

int len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s", ch->GetName(), buf);

Search for this:

if (CHAT_TYPE_SHOUT == pinfo->type)

Add this over that:

if (ch->IsEquipNewRingItem(TEXT_COLOR_RED))
{
	// RED
	len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s %s", ch->GetName(), "|cFFFF0000|H|h", buf);
}
else if (ch->IsEquipNewRingItem(TEXT_COLOR_GREEN))
{
	// GREEN
	len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s %s", ch->GetName(), "|cFF00FF00|H|h", buf);
}
else if (ch->IsEquipNewRingItem(TEXT_COLOR_BLUE))
{
	// BLUE
	len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s %s", ch->GetName(), "|cFF0080FF|H|h", buf);
}
else if (ch->IsEquipNewRingItem(TEXT_COLOR_YELLOW))
{
	// YELLOW
	len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s %s", ch->GetName(), "|cFFFFFF00|H|h", buf);
}
else
{
	// DEFAULT COLOR
	len = snprintf(chatbuf, sizeof(chatbuf), "%s : %s", ch->GetName(), buf);
}

Open game/char.cpp and add this event:

bool CHARACTER::IsEquipNewRingItem(DWORD dwItemVnum) const
{
	{
		LPITEM u = GetWear(WEAR_RING1);

		if (u && u->GetVnum() == dwItemVnum)
		{
			return true;
		}
	}

	{
		LPITEM u = GetWear(WEAR_RING2);

		if (u && u->GetVnum() == dwItemVnum)
		{
			return true;
		}
	}

	return false;
}

Open game/char.h and search for this:

bool			IsEquipUniqueGroup(DWORD dwGroupVnum) const;

Add this under that:

bool			IsEquipNewRingItem(DWORD dwItemVnum) const;

And now how it looks in the game:
 

a1_2014_2_8_9wtbvwo1pq.jpg




If you have any question or suggestion, please just reply to this topic.
 
Kind Regards,
Sanchez

  • Love 21

Share this post


Link to post

cool, I remember they had this in Metin2US before using the same color code system and it was removed because people didn't want to only use it to sell and buy items. I've been looking for this modification for such a long time.

  • Love 1

Share this post


Link to post

cool, I remember they had this in Metin2US before using the same color code system and it was removed because people didn't want to only use it to sell and buy items. I've been looking for this modification for such a long time.

 

UndergroundMt2 used the same system but with python code.

You can append the same color codes over python.

 

@Topic: Not bad

  • Love 1

Share this post


Link to post

Hi, how active these two boxes? I have the inventorywindow with activated cells but not activated, that flag used to place rings in box?

Share this post


Link to post

You have to add the new slots to the inventorywindow.py:

				## Equipment Slot
				{
					"name" : "Equipment_Base",
					"type" : "image",

					"x" : 10,
					"y" : 33,

					"image" : "d:/ymir work/ui/equipment_bg_with_ring.tga",

					"children" :
					(

						{
							"name" : "EquipmentSlot",
							"type" : "slot",

							"x" : 3,
							"y" : 3,

							"width" : 150,
							"height" : 182,

							"slot" : (
										{"index":EQUIPMENT_START_INDEX+0, "x":39, "y":37, "width":32, "height":64},
										{"index":EQUIPMENT_START_INDEX+1, "x":39, "y":2, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+2, "x":39, "y":145, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+3, "x":75, "y":67, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+4, "x":3, "y":3, "width":32, "height":96},
										{"index":EQUIPMENT_START_INDEX+5, "x":114, "y":67, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+6, "x":114, "y":35, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+7, "x":2, "y":145, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+8, "x":75, "y":145, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+9, "x":114, "y":2, "width":32, "height":32},
										{"index":EQUIPMENT_START_INDEX+10, "x":75, "y":35, "width":32, "height":32},
										## »ő ąÝÁö1
										{"index":item.EQUIPMENT_RING1, "x":2, "y":106, "width":32, "height":32},
										## »ő ąÝÁö2
										{"index":item.EQUIPMENT_RING2, "x":75, "y":106, "width":32, "height":32},
										## »ő ş§Ć®
										{"index":item.EQUIPMENT_BELT, "x":39, "y":106, "width":32, "height":32},
									),
						},
  • Love 1

Share this post


Link to post

Yes, If I have the file with the selected check boxes and tga is correct but are not activate

 

on the subject of flags? Should the value of item selected go to the box? or do I need a special type, flag or antflag?

Share this post


Link to post
I Could not use without glass? would be better without her having to use the glass, no?
 
glass = item vnum 39035

Share this post


Link to post

Sure you can use without glass, just deactivate in input_main.cpp. Search for ITEM_PRISM and you will see the function.

Share this post


Link to post

For me it doesn't work, just edited the same function.

bool CHARACTER::IsEquipNewRingItem(DWORD dwItemVnum) const
{
    {
        LPITEM u = GetWear(WEAR_RING1);
 
        if (u && u->GetVnum() == dwItemVnum)
        {
            return true;
        }
    }
 
    return false;
}

Share this post


Link to post

Can anyone Post what i have to do in item_proto.txt

 

I try this

 

90014    Gelber Stift    ITEM_RING    NONE    1    NONE    NONE    NONE        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    0    0    0    0    0    0    0    0

 

but if i use my Item it goes in the Right Slot but my Chat is still normal

Share this post


Link to post

is it possible to make it like, if my name starts with "[Dev]"iRemain to color what I'm typing with red?

Share this post


Link to post

Can anyone Post what i have to do in item_proto.txt

 

I try this

 

 

 
90014    Gelber Stift    ITEM_RING    NONE    1    NONE    NONE    NONE        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    0    0    0    0    0    0    0    0

 

 

but if i use my Item it goes in the Right Slot but my Chat is still normal

​Same..

Share this post


Link to post

how to make whisper coloring ?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.