• Welcome to Valhalla Legends Archive.
 

Request for information/research: SID_CHATEVENT 0x0F

Started by Archn, May 06, 2008, 08:28 PM

Previous topic - Next topic

Archn

Hi.  I am trying to get color to display when I receive SID_CHATEVENT..

I understand that certain events display certain colors when you receive them.

Here is the code I have, with help from Leo-X.


void Chat::WriteChat(const char szData[], ... )
{
BYTE Event=0x13;
BYTE Flags=0x00;
BYTE Ping=0x2F;
const char szUser[]="Game On";
char *szText = NewString( 4096 );
va_list arguments;
va_start( arguments, szData );
vsprintf_s( szText, 4096, szData, arguments );
va_end( arguments );

int iUserLen = (int)strlen( szUser ) + 1;
int iTextLen = (int)strlen( szText ) + 1;
int iLen = iUserLen + iTextLen + 24;
unsigned char* szBuffer = new unsigned char[iLen];

DWORD dwPos = 0;

szBuffer[dwPos++] = 0xFF;
szBuffer[dwPos++] = 0x0F; //SID_CHATEVENT
szBuffer[dwPos++] = 0x00 + iLen;
szBuffer[dwPos++] = 0x00 + ( iLen >> 8 );

szBuffer[dwPos++] = 0x00 + Event;
szBuffer[dwPos++] = 0x00;
szBuffer[dwPos++] = 0x00;
szBuffer[dwPos++] = 0x00;

szBuffer[dwPos++] = 0x00 + Flags;
szBuffer[dwPos++] = 0x00;
szBuffer[dwPos++] = 0x00;
szBuffer[dwPos++] = 0x00;

szBuffer[dwPos++] = 0x00 + Ping;
szBuffer[dwPos++] = 0x00;
szBuffer[dwPos++] = 0x00;
szBuffer[dwPos++] = 0x00;

szBuffer[dwPos++] = 0x00 + 0x0D;
szBuffer[dwPos++] = 0x00 + 0xF0;
szBuffer[dwPos++] = 0x00 + 0xAD;
szBuffer[dwPos++] = 0x00 + 0xBA;

szBuffer[dwPos++] = 0x00 + 0x0D;
szBuffer[dwPos++] = 0x00 + 0xF0;
szBuffer[dwPos++] = 0x00 + 0xAD;
szBuffer[dwPos++] = 0x00 + 0xBA;

if( stricmp( szUser, "" ) != 0 && szUser != NULL )
{
for( int i = 0; i < iUserLen; i++ )
{
szBuffer[dwPos++] = szUser[i];
}
}

if( stricmp( szText, "" ) != 0 && szText != NULL )
{
for( int i = 0; i < iTextLen; i++ )
{
szBuffer[dwPos++] = szText[i];
}
}

RecvPacket( (void*) szBuffer, dwPos );

delete[] szBuffer;
DeleteString( szText );
}


And the Events are:


    [0x01] EID_SHOWUSER: User in channel
    [0x02] EID_JOIN: User joined channel
    [0x03] EID_LEAVE: User left channel
    [0x04] EID_WHISPER: Recieved whisper
    [0x05] EID_TALK: Chat text
    [0x06] EID_BROADCAST: Server broadcast
    [0x07] EID_CHANNEL: Channel information
    [0x09] EID_USERFLAGS: Flags update
    [0x0A] EID_WHISPERSENT: Sent whisper
    [0x0D] EID_CHANNELFULL: Channel full
    [0x0E] EID_CHANNELDOESNOTEXIST: Channel doesn't exist
    [0x0F] EID_CHANNELRESTRICTED: Channel is restricted
    [0x12] EID_INFO: Information
    [0x13] EID_ERROR: Error message
    [0x17] EID_EMOTE: Emote


Now the line that says Event=0x13 controls the color.. Like 13 would be red. And 12 is a light blue.  Now I want to be able to do something more than just WriteChat("Hi there");

I'd like to do something like WriteChat("ÿc1Hi ÿc2there");

What chat event allows color and would not display something like <On> before every message I send like

<On> Hi there

I think it said On for some weird reason.. maybe based on the ping?  When I did emote, it was in gray with *'s around it but it still said On in front.

Or is color completely blocked from this packet?

I guess the bottom line is, is it possible to use a colorcode?  I think when I tried on on 0x12, it made the text not display at all.

If you can help I appreciate it.. P.S. this is my first post to vL.

If anyone wants to help me on a cool project let me know.

Barabajagal

Oooookay.... If you're writing a bot yourself, you have to do the color code system yourself, too. The ÿc system is a proprietary syntax started in D2 profiles and implemented in many bots; it's not some form of prewritten standard. If you want color codes, you have to write color codes.

Archn

Quote from: Andy on May 06, 2008, 08:51 PM
Oooookay.... If you're writing a bot yourself, you have to do the color code system yourself, too. The ÿc system is a proprietary syntax started in D2 profiles and implemented in many bots; it's not some form of prewritten standard. If you want color codes, you have to write color codes.

I'm sorry I must have completely forgot my manners.

I am writing a program that works within the D2 window itself which runs interaction between the client and the user.

I.E. I write /joke into the console and it writes "Why did the chicken cross the road".. etc...

And I am talking about BNCS not D2GS, so can I use the color codes here?  And what Chat Event would work best for this?

Barabajagal

Color codes don't exist in chat, as far as I know. The best way to do what you're trying to do, in my opinion, would be to make a proxy that the game client connects to, which filters any outgoing commands and replaces them with outgoing messages.


Archn

Sorry if this was the wrong forum.  :-[  What is the correct place for this?  I just wanted some help with 0x0F as far as if  it could interpret color codes.

There actually is a proxy already in place, and that's why the interaction is already successful (I have successfully created a working bugfree hangman game from the D2 client itself).  But the proxy itself only filters the packets.  So I was just asking since obviously there is color in the chat portion itself, like Red, Green, Light Blue, White, etc. But that for the most part you can only have 1 color per line of text, if there would be a way to have multiple colors.  Like in 0x05 (EID_TALK), it will display white with yellow brackets, on the same line.

So I'm guessing there's not a way to change that without actually patching the D2 client itself?  While keeping in mind that there is a proxy which filters packets.

I can spoof any packets I want, I just can't figure out a way to spoof a packet that writes to the chat screen with multiple color codes.  But if color codes don't exist, and the client itself only understands the color based on the EventId, then color is a waste of my time, I guess.  It's just I'm working on this game called "Rush Hour" (If you google Rush Hour Game, you'll see the game I'm talking about), and it would be much easier to identify the cars, if I could have them in color.  The straight 1 color part of it looks great so far.  I have everything except the park_movecar(int car,int direction) part written.

Camel

Quote from: Andy on May 07, 2008, 12:57 AM
Color codes don't exist in chat, as far as I know. The best way to do what you're trying to do, in my opinion, would be to make a proxy that the game client connects to, which filters any outgoing commands and replaces them with outgoing messages.

That's not exactly accurate. D2's text boxes recognize those character combinations as color codes, and implicitly handle the color changes.

The bytes that D2 uses for the color codes are not the ones you used to be able to use in chat (and can still use in profiles). The UTF8 decoder was broken, and would convert that to the color codes.

If you're doing a man-in-the-middle type thing between D2 and the BNCS server, there's no reason you can't send the color codes to D2, but you won't be able to send colors that other D2 clients can see. Firstly, because the UTF8 decoder has been fixed, and secondly, because the actual byte values that you really want to use will result in a swift disconnect from battle.net.

brew

Quote from: Archn on May 06, 2008, 08:28 PM

if( stricmp( szUser, "" ) != 0 && szUser != NULL )

No offense, but daaaaaaamn... that must be hurting.
hint: try "if (szUser[0]) {"
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P