Jump to content

Pencil - Color Chat System


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

Spoiler

243551xSBlrQT.jpg

 

Heyhoo újra :D

Equipable pencil item to make your chat colorful.

 

Client side we only gonna work in the UserInterface:

Open packet.h
Search:

 

typedef struct packet_chatting
{
    BYTE    header;
    WORD    size;
    BYTE    type;
    DWORD    dwVID;
    BYTE    bEmpire;
} TPacketGCChat;

Replace:

 

typedef struct packet_chatting
{
    BYTE    header;
    WORD    size;
    BYTE    type;
    DWORD    dwVID;
    BYTE    bEmpire;
    BYTE    TypingColor;
} TPacketGCChat;

Open PythonNetworkStreamPhaseGame.cpp and search for RecvChatPacket function.
In this func. search for

TPacketGCChat kChat;
    TPacketGCChat kChat;
    char buf[1024 + 1];
    char line[1024 + 1];

Add after:

string colored_p;
string colored_buf;

Go down till

_snprintf(line, sizeof(line), "%s", p);

Add it before:

                    switch (kChat.TypingColor)
                    {
                    case 1:
                        colored_p = "|cff00ffff" + string(p) + "|r";
                        colored_buf = "|cff00ffff" + string(buf) + "|r";
                        break;
                    case 2:
                        colored_p = "|cffff0000" + string(p) + "|r";
                        colored_buf = "|cffff0000" + string(buf) + "|r";
                        break;
                    case 3:
                        colored_p = "|cffADFF2F" + string(p) + "|r";
                        colored_buf = "|cffADFF2F" + string(buf) + "|r";
                        break;
                    case 4:
                        colored_p = "|cffFF4500" + string(p) + "|r";
                        colored_buf = "|cffFF4500" + string(buf) + "|r";
                        break;
                    case 5:
                        colored_p = "|cffC67171" + string(p) + "|r";
                        colored_buf = "|cffC67171" + string(buf) + "|r";
                        break;
                    default:
                        colored_p = string(p);
                        colored_buf = string(buf);
                        break;
                    }

Modify the mentioned line from

 

_snprintf(line, sizeof(line), "%s", p);


to

 

_snprintf(line, sizeof(line), "%s", colored_p.c_str());

Find in this func

 

        if (pkInstChatter->IsPC())
            CPythonChat::Instance().AppendChat(kChat.type, buf);

 


Modify the line

 

 

to

 

 

CPythonChat::Instance().AppendChat(kChat.type, colored_buf.c_str());

Compile client binary.

We have to add a new item subtype to the dump_proto.
In ItemCSVReader.cpp search for get_Item_SubType_Value func. and modify arSub16 array:

 

string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_SPECIAL_MOUNT_RIDE", "UNIQUE_COLOR", "UNIQUE_5",
                    "UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};

Compile.

Server side:
game directory:

Open packet.h 
Search for

 

typedef struct packet_chat    // 가변 패킷
{
    BYTE    header;
    WORD    size;
    BYTE    type;
    DWORD    id;
    BYTE    bEmpire;
} TPacketGCChat;

Modify like:

 

typedef struct packet_chat    // 가변 패킷
{
    BYTE    header;
    WORD    size;
    BYTE    type;
    DWORD    id;
    BYTE    bEmpire;
    BYTE    TypingColor;
} TPacketGCChat;

Open input_main.cpp and search for Chat func.
Find the

 

pack_chat.header = HEADER_GC_CHAT;
    pack_chat.size = sizeof(TPacketGCChat) + len;
    pack_chat.type = pinfo->type;
    pack_chat.id = ch->GetVID();

part and modify like:

 

pack_chat.header = HEADER_GC_CHAT;
    pack_chat.size = sizeof(TPacketGCChat) + len;
    pack_chat.type = pinfo->type;
    pack_chat.id = ch->GetVID();
    pack_chat.TypingColor = ch->GetTypingColor();

Open char.h and search for

 

bool            m_bWalking;

Add before:

 

BYTE            TypingColor;

Search:

 

bool            IsStateMove() const            { return IsState((CState&)m_stateMove); }

Add before:

BYTE            GetTypingColor()            { return TypingColor; }
BYTE            SetTypingColor(BYTE _c)        { TypingColor = _c; }

Open char.cpp, search for Initialize func.
Put it before:

 

TypingColor = 0;

Open item.cpp and search for EquipTo func.
You'll see this at the beginning:

 

if (!ch)
{
    sys_err("EquipTo: nil character");
    return false;
}

Add after:

 

if(GetType() == ITEM_UNIQUE && GetSubType() == UNIQUE_COLOR)
    ch->SetTypingColor(GetValue(1));

Find the Unequip func.
Search for this part:

 

if (this != m_pOwner->GetWear(GetCell() - INVENTORY_MAX_NUM))
{
    sys_err("m_pOwner->GetWear() != this");
    return false;
}


Add after:

 

if(GetType() == ITEM_UNIQUE && GetSubType() == UNIQUE_COLOR)
    m_pOwner->SetTypingColor(0);

common/item_length.h:


Search for

 

enum EUniqueSubTypes
{
    UNIQUE_NONE,
    UNIQUE_BOOK,
    UNIQUE_SPECIAL_RIDE,
    UNIQUE_SPECIAL_MOUNT_RIDE,
};

Modify like

 

enum EUniqueSubTypes
{
    UNIQUE_NONE,
    UNIQUE_BOOK,
    UNIQUE_SPECIAL_RIDE,
    UNIQUE_SPECIAL_MOUNT_RIDE,
    UNIQUE_COLOR,
};

Compile game.

DB:
open ProtoReader.cpp and search for get_Item_SubType_Value func.
Modify arSub16 array like

 

static string arSub16[] = { "UNIQUE_NONE", "UNIQUE_BOOK", "UNIQUE_SPECIAL_RIDE", "UNIQUE_SPECIAL_MOUNT_RIDE", "UNIQUE_COLOR", "UNIQUE_5",
                    "UNIQUE_6", "UNIQUE_7", "UNIQUE_8", "UNIQUE_9", "USE_SPECIAL"};

Compile.

 

 

 

 

 

 

 

 

item_proto:

 

20111    pencil_cyan    ITEM_UNIQUE    UNIQUE_COLOR    1    ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP    LOG    WEAR_SHIELD        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    1    0    0    0    0    0    0    0
20112    pencil_cyan    ITEM_UNIQUE    UNIQUE_COLOR    1    ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP    LOG    WEAR_SHIELD        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    2    0    0    0    0    0    0    0
20113    pencil_cyan    ITEM_UNIQUE    UNIQUE_COLOR    1    ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP    LOG    WEAR_SHIELD        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    3    0    0    0    0    0    0    0
20114    pencil_cyan    ITEM_UNIQUE    UNIQUE_COLOR    1    ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP    LOG    WEAR_SHIELD        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    4    0    0    0    0    0    0    0
20115    pencil_cyan    ITEM_UNIQUE    UNIQUE_COLOR    1    ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP    LOG    WEAR_SHIELD        0    0    0    0    0    LIMIT_NONE    0    LIMIT_NONE    0    APPLY_NONE    0    APPLY_NONE    0    APPLY_NONE    0    0    5    0    0    0    0    0    0    0

item_names:

 

20111    Ceruza
20112    Ceruza
20113    Ceruza
20114    Ceruza
20115    Ceruza

item_list:

 

20111    ETC    icon/item/color_cyan.tga
20112    ETC    icon/item/color_red.tga
20113    ETC    icon/item/color_green.tga
20114    ETC    icon/item/color_orange.tga
20115    ETC    icon/item/color_brown.tga

Icons are attached.

  • Metin2 Dev 5
  • Sad 2
  • Confused 1
  • Love 2

WRnRW3H.gif

Link to comment
Share on other sites

  • 4 months later...
  • Gold

I don't know how to code it but I have better idea. I think it could be made only by python side.

Make a new button in the chat window which will contain the first letter of the color and you can change it by clicking on it like changing chat type from normal to guild etc.

Chat types: Normal | Group | Guild | Call

and next to it will be a button with the first letter of the color name:

R | G | B | C | M | Y | K - Red, Green, Blue, Cyan, Magenta, Yellow, Black

I'll be always helpful! 👊 

Link to comment
Share on other sites

Announcements



×
×
  • 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.