Thread: [474] In-depth look at the 474 protocol.

Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1 [474] In-depth look at the 474 protocol. 
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Hi, I'm TheChosenOne (not my real name ofcourse ).
    I've been part of Rune-Server since April 2009 (on my old account with the same name) and would like to put my efforts in this thread (and hopefully have it grow as we gain knowledge).
    I'd like to help those who make a server based on the 474 protocol.
    I'll list all (of which I know the meaning) packets and how to use them, both ClientSided and ServerSided.
    The reason you should read this informative thread is because you can't master a server without mastering the packets. The packets are key to good communication between client and server.
    This thread is dedicated to all the 474 server coders.

    UPDATES:
    Added server to client packet 255 (set vertical scrollbar position), 225 (SendPlayerOption), 114 (SetInterfaceComponentColour). Special thanks to ChrisTheCook.
    Added server to client packet 54: Write to random.dat file
    Added server to client packet 32: Update ClanChat Participant
    Added server to client packet 76: Offset Interface Item
    Pruned the update list (third time since original thread).

    Thanks go to: Vigan20, Jackasaur!, Digistr, Jarba, Vastico, Xaves, Arian Rock, ChrisTheCook, Scu11
    My informative threads:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     


  2. #2  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    First I'd like to lecture you on the packetStream/Stream, it's method and sending 'numerical' data in general.

    Underneath I'll list a table of certain primitive datatypes and relevant information about them.

    Code:
    Datatype	Also known as		size (bytes)
    byte		/			1
    short		word			2
    integer		dword (double word)	4
    double		/			8
    long		qword (quadripple word)	8
    In java these primitive datatypes are signed (meaning they can be positive or negative).
    This is different from unsigned datatypes (who can only exist 'virtualy', more on this later).
    A primitive number is negative if the first bit (it's important to understand this when I talk about reading 'unsigned datatypes') is set to 1.

    For example:
    A signed short (as seen in java) ranges from 2 ^ (2 * 8 – 1) to -(2 ^ (2 * 8 – 1)) - 1.
    This is 32767 to -32768.
    An unsigned short would not use the first bit to tell it's a negative number, making the range going from 0 to 2^(2 * 8) – 1, being 0 to 65535.
    In java, a short isn't able to hold that value. The solution is: using the next larger dataType.
    So if you were to read an unsigned short, put it in an integer and only look at the last 2 bytes (the size of the original datatype). The latter thing can be done by anding (bitwise and operator).
    I won't give you much details about it:
    The anding can be done with the bitwise and operator, the ampersand (&).
    If you have a number and would only like to have the last 2 bytes you would do something like this:
    int unsigned = signed & 0xFFFF;
    0xFFFF is a hexidecimal number, in this case it'll get the last 4 nibbles (2 bytes) of the original number.

    If I talk about unsigned datatypes you'll see that I use the prefix U.
    If you see S I explitely mean signed (even though it's standard).

    Back to other basic lectures before we delve into the packets: The order of sending data.
    Every piece of data you send is a byte (you can't just send 1 bit). Since a byte is atomic, you can only send it through in 1 way: as a byte. It bits can only be written in the order set by the byte (which create the value of the byte).
    When we have a datatype that consists of more than 1 byte (2 for example), we can choose which byte to send first. The receiver should know the order of the bytes to be able to reconstruct the correct value (protocol).

    There are 2 basic orders: big endian (BE) and little endian (LE).
    Big endian would be the normal situation, where higher (of which the bits would be valued more) bytes come first.
    Little endian is the reverse (byte wise, not bitwise) of big endian.
    For example: Say there's a number (long: 8 bytes) represented by the following letters:
    A B C D E F G H
    The big endian (“big end comes first”) way to send them would be: A, B, C, D, E, F, G, H.
    The little endian (“little end comes first”) way would be: H, G, F, E, D, C, B, A.

    There are other ways combinations but I'll just put up a table with the methods how to write/read.
    If someone has a question about any of these, please ask and I'll add an explenation underneath the table.
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Code:
    READ						WRITE
    byte Get(), getByte()				put(byte)
    
    void get(byte[])				put(byte[])
    
    int getUByte(),getUnsignedByte()		put(int)
    
    short getShort(), int readSWordeBE()		putShort(int)
    
    int getUnsignedShort()				putShort(int)
    
    int getInt(), int readDWord()			putInt(int)
    
    long getLong()					putLong(long)
    
    byte getByteC(), int readByteCInteger(),	putByteC(int), putByteC(byte)
    byte readSByteC()
    
    byte getByteS(), 				putByteS(byte)
    
    short getLEShortA()				putLEShortA(int)
    
    short getLEShort()				putLEShort(int)
    
    int getInt1(), int readInt1()			putInt1(int)
    
    int getLEInt()					putLEInt(int)
    
    int getInt2()					putInt2(int)
    
    int getTriByte(), int readTriBytes()		putTriByte(int)
    
    byte getByteA()					putByteA(int), putByteA(byte)
    
    String getRS2String()				putRS2String(String)
    
    String getString()				putString(String)	
    
    short getShortA()				putShortA(int)
    
    void getReverse(byte[], int, int)		putReverse(byte, int, int)
    
    void getReverseA(byte[], int, int)		putReverseA(byte[], int, int)
    
    void get(byte[], int, int)			put(byte, int, int)
    
    int getSmart()					putSmart(int)
    
    int getSignedSmart()				putSignedSmart(int)
    This table is not complete, these methods may also have other names. I strongly suggest that you use the same method names for your client and your server as it makes everything easier.

    This ends the basics. Don't hesitate to post if you've got a question about any of this. Maybe I'll add it to this thread to help the rest who have the same question.
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Now it's on our way to the packets.
    Remember this is only for the 474 protocol. The protocol of other revisions has other packetnumber and the data is most likely sent differently. Some packets may or may not exist.

    Knowing packet sizes is important. If you don't know them, packetdata can get screwed up. I've had this problem where 2 packets were being sent from the client to my server and the last one was not received. It was until closer inspection that I found out the packetsize of the packet being sent before it had an unspecified size, meaning the server would look howmany bytes there were left on the stream. In my case (it was always the case with those packets) the packet I was interested in was behind the first packet on the stream. But since the first one was unspecified, the size being taken by the packet included the size of the second packet plus the size of the opCode. To prevent this problem from happening to you I'm going to list (and update as we find out more) the packetsizes of the packets sent from the client to the server (incomming packets). -1 means the packetSize is variable in length, -3 means unknown resulting in the server counting howmany bytes are left on the stream (might not always be correct).

    Code:
    //0----1----2----3----4----5----6----7----8----9
     -3,   8,  -3,   6,  -3,  -3,  -3,  -3,  -3,  -3, // 0
     -3,  -1,  -3,  12,  -3,  -3,  -3,  -3,  -3,  -3, // 1
     -3,   2,  8,  -3,  -3,  -3,  -3,  13,  -3,   6, // 2
     -3,  -3,  -3,  -3,   1,   8,  -3,   6,  -3,  -3, // 3
     -3,  -3,  -3,  -3,  -3,  -3,  -1,   2,  -3,  -3, // 4
     -3,  -3,  -1,  -3,  -3,  -3,  -3,  -3,  -3,  -1, // 5
     -3,  -3,  -3,  -3,  -3,   6,  -3,  -3,  -3,  -3, // 6
      6,   8,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3, // 7
     -3,  -3,   8,  -3,  -3,  -3,  -3,   6,  -1,   8, // 8
     -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3, // 9
     -3,  -3,  -3,  -3,  -3,   6,  -3,   8,  -3,  -3, // 10
     -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3, // 11
     -3,  -1,   8,  -3,   8,  -3,  -3,  -3,  -3,  -3, // 12
     -3,   8,  -3,  -3,  14,  -3,  -3,  -3,  -3,  -3, // 13
     -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  -1, // 14
      4,   0,   8,  -3,   6,  -3,   6,   8,  -3,  -3, // 15
      2,  -3,  -3,  8,  -3,  -3,   9,   4,  -3,   4, // 16
     -3,  -3,  -3,  -1,  -3,  -3,   0,  -3,   2,  -3, // 17
     -3,  -3,  -3,  -3,  -3,  -3,   0,  -3,  -3,  -3, // 18
     12,  -3,   6,  -3,  -3,  -3,   2,  -3,  -3,  -3, // 19
     -3,  -3,  -1,  -3,  10,  12,  16,  -3,  14,  -3, // 20
     -3,  -3,  -3,  -3,  -3,   4,  -3,  -3,  -3,  -3, // 21
     -3,  -3,  -3,  -3,  -3,  -3,   2,  -3,  -3,  -3, // 22
     -3,  -3,  -3,  -3,   6,  -3,   0,  -3,  14,  -3, // 23
     -3,   8,  -3,  -3,  -3,  -3,  -3,  -3,  -3,  4, // 24
     9,   3,  -1,  -3,  -3,  -3                      // 25
    Packets can be split up in 2 groups:
    Packets from client to server (processed by 'packethandlers')
    Packets from server to client (sent by 'actionsender' (Hyperion))

    I'll first list all packetnumbers of packets which can be processed by packethandlers (without an explenation) followed by the packetnumbers of packets which can be sent to the client.
    The green numbers are the packetnumber of which there is an explenation somewhere below (so search for the number). The red ones obviously mean the opposite. Orange ones are packets that aren't complete and need updating.
    I encourage you to report any numbers you know with their purpose and if possible a description on how to use them (as it's very hard to figure them out on my own, there's no need to reinvent the wheel). This goes for packets in both directions. If you have sugestions or correction, please leave a post or message me.

    Packetnumbers Client to Server:
    1, 3, 4, 8, 11, 13, 21, 22, 24, 27, 29, 31, 34, 35, 37, 41, 46, 47, 52, 55, 56, 59, 64, 65, 70, 71, 78, 82, 84, 87, 88, 89, 96, 102, 105, 107, 116, 121, 122, 124, 125, 131, 134, 141, 145, 149, 150, 151, 152, 154, 156, 157, 160, 163, 166, 167, 169, 171, 174, 175, 176, 178, 185, 186, 190, 192, 196, 198, 202, 203, 204, 205, 206, 208, 211, 214, 215, 226, 230, 234, 236, 238, 241, 242, 244, 247, 249, 250, 251, 252, 254

    Packetnumbers Server to Client:
    4, 5, 7, 10, 15, 17, 18, 22, 28, 30, 32, 33, 35, 36, 38, 42, 44, 48, 49, 54, 55, 56, 57, 61, 66, 71, 76, 82, 84, 86, 100, 107, 114, 117, 119, 121, 127, 128, 133, 138, 146, 150, 153, 156, 158, 163, 166, 167, 168, 169, 173, 174, 175, 178, 179, 184, 187, 188, 191, 196, 200, 205, 207, 209, 220, 225, 230, 231, 236, 237, 238, 241, 243, 249, 251, 253, 255

    Now here we go with the real deal.
    Last edited by TheChosenOne; 06-26-2013 at 12:58 AM.
    Reply With Quote  
     

  7. Thankful users:


  8. #5  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    PACKETS: CLIENT TO SERVER:

    Name: Remove Ignore
    Number: 1
    Purpose: Signals the player wants to remove an ignore.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: Fourth interface option
    Number: 3
    Purpose: This is triggered when a fourth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: ObjectOptionPacket4 //pickpocket trapdoor
    Number: 4
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Minimap WalkingPacket
    Number: 11
    Purpose: Sends walking data to the server.
    Data Sent: size, firstX, firstY, running, waitpointdata
    How to receive:
    Code:
    int size = packet.getLength();
    if(packet.getOpcode() == 11)
        size -= 14;
    final int steps = (size - 5) / 2;
    final int[][] path = new int[steps][2];
    for (int i = 0; i < steps; i++) {
        path[i][0] = packet.getByte();
        path[i][1] = packet.getByteS();
    }
    final int firstX = packet.getShortA();
    final int firstY = packet.getLEShort();
    final boolean runSteps = packet.getByteC() == 1;
    Remarks: The minimap packet is 14 bytes longer than the other 2 walkingpackets (46 and 59).
    If anyone can tell me why this is, please tell.
    The “How to receive” is the same with 46 and 59 and can be combined to be handled as 1 packet.
    -------------------------------------------------------------------

    Name: Use Item On NPC
    Number: 13
    Purpose: Indicates the player has clicked to use an item on an NPC.
    Data Sent: npcIndex, parentUID, itemSlot, itemId.
    How to receive:
    Code:
    int npcIndex = packet.getLEShort() & 0xFFFF;
    int parentUID = packet.getLEInt();
    int itemSlot = packet.getLEShort() & 0xFFFF;
    int itemId = packet.getShortA() & 0xFFFF;
    Remarks: Same as before, this doesn't indicate the player is close enough.
    -------------------------------------------------------------------

    Name: Interact With NPC
    Number: 21
    Purpose: Indicates a specific type of interaction from player to npc.
    Data Sent: npcIndex.
    How to receive:
    Code:
    int npcIndex = packet.getShort() & 0xFFFF;
    Remarks: Actions include: Talk To, Bait, Fish, Banish, Pet.
    -------------------------------------------------------------------

    Name: Kick clanChat participant
    Number: 22
    Purpose: Indicates a friend of the clanChat owner attempts to kick a fellow clanChatParticipant (non-owner).
    Data Sent: kickParticipantLong.
    How to receive:
    Code:
    long kickParticipantLong = packet.getLong();
    Remarks: Any friend of the clanChat owner has the option available.
    -------------------------------------------------------------------

    Name: Sixth Interface Option
    Number: 29
    Purpose: Tells the server a sixth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: ObjectOptionPacket3 //cut trees, open door, climb up stairs (if only option), forfeit trapdoor (duel area), mine //Looks like PRIME option
    Number: 31
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Client focus
    Number: 34
    Purpose: Tells the server the clients focus has changed.
    Data Sent: focus
    How to receive:
    Code:
    int focus = packet.get();
    Remarks: Focus will be 0 if the client loses focus, it will be 1 when it has gained focus.
    -------------------------------------------------------------------

    Name: Use Magic On Player
    Number: 35
    Purpose: Indicates the player wants to use a spell on another player.
    Data Sent: spellId, playerIndex, unknown.
    How to receive:
    Code:
    int spellBookId = packet.getShort() & 0xFFFF;
    int spellId = packet.getShort() & 0xFFFF;
    int playerIndex = packet.getLEShortA() & 0xFFFF;
    int unknown = packet.getLEShortA() & 0xFFFF;
    Remarks: This is not the attackButton. It's singlecasting on players (pvp and nonpvp spells).
    The spellId is actualy the childId within the current spellBook (spellBookId (parentId of the childId)).
    -------------------------------------------------------------------

    Name: Third interface option
    Number: 37
    Purpose: This is triggered when one a third interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: World WalkingPacket (Normal WalkingPacket) (Need specifications)
    Number: 46
    Purpose: Sends walking data to the server.
    Data Sent: size, firstX, firstY, running, waitpointdata
    How to receive:
    Code:
    int size = packet.getLength();
    if(packet.getOpcode() == 11)
        size -= 14;
    final int steps = (size - 5) / 2;
    final int[][] path = new int[steps][2];
    for (int i = 0; i < steps; i++) {
        path[i][0] = packet.getByte();
        path[i][1] = packet.getByteS();
    }
    final int firstX = packet.getShortA();
    final int firstY = packet.getLEShort();
    final boolean runSteps = packet.getByteC() == 1;
    Remarks: This walkingpacket is sent when you click “Walk here” in the 3D-world.
    The “How to receive” is the same with 11 and 59 and can be combined to be handled as 1 packet.
    -------------------------------------------------------------------

    Name: Examine Item.
    Number: 47
    Purpose: Triggered when the player examines an item.
    Data Sent: itemId.
    How to receive:
    Code:
    int itemId = packet.getLEShortA() & 0xFFFF;
    Remarks: The examination of the object should be sent. This packet is only triggered when the stackCount is less than 100 000.
    -------------------------------------------------------------------

    Name: ChatPacket
    Number: 52
    Purpose: Triggered when a player says something in public chat (excluding commands).
    Data Sent: ChatEffect, Colour, Size, ChatData
    How to receive:
    Code:
    int effects = packet.getByte() & 0xFF;
    int colour = packet.getByte() & 0xFF;
    int size = packet.getLength() - 2;
    byte[] rawChatData = new byte[size];
    packet.get(rawChatData);
    if(player.getChatMessageQueue().size() >= CHAT_QUEUE_SIZE) {
    	return;
    }
    String unpacked = TextUtils.textUnpack(rawChatData, size);
    unpacked = TextUtils.filterText(unpacked);
    unpacked = TextUtils.optimizeText(unpacked);
    byte[] packed = new byte[size];
    TextUtils.textPack(packed, unpacked);
    player.getChatMessageQueue().add(new ChatMessage(effects, colour, packed));
    Remarks: None.
    -------------------------------------------------------------------

    Name: Interaction WalkingPacket
    Number: 59
    Purpose: Sends walking data to the server.
    Data Sent: size, firstX, firstY, running, waitpointdata
    How to receive:
    Code:
    int size = packet.getLength();
    if(packet.getOpcode() == 11)
        size -= 14;
    final int steps = (size - 5) / 2;
    final int[][] path = new int[steps][2];
    for (int i = 0; i < steps; i++) {
        path[i][0] = packet.getByte();
        path[i][1] = packet.getByteS();
    }
    final int firstX = packet.getShortA();
    final int firstY = packet.getLEShort();
    final boolean runSteps = packet.getByteC() == 1;
    Remarks: This walkingpacket is sent when you interact with an entity (player or npc) or an object.
    The “How to receive” is the same with 11 and 46 and can be combined to be handled as 1 packet.
    -------------------------------------------------------------------

    Name: Ninth Interface Option
    Number: 65
    Purpose: Tells the server a ninth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Fifth interface option
    Number: 70
    Purpose: This is triggered when a fifth interface option is clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Drop Item
    Number: 71
    Purpose: Tells the server the player want to have an item dropped.
    Data Sent: parentUID, droppedItemId, slot
    How to receive:
    Code:
    int parentUID = packet.getLEInt();
    int droppedItemId = packet.getLEShortA();
    int slot = packet.getLEShort();
    Remarks: 'Dropping' includes destroying and dropping pets on the ground to follow you. These must also be handled by this packet.
    -------------------------------------------------------------------

    Name: Enter Text (via long)
    Number: 82
    Purpose: Sends the result of an enter text input.
    Data Sent: textLong
    How to receive:
    Code:
    long textLong = packet.getLong()
    Remarks: The context will have to be determined based on the current open interface.
    The entered text gets converted to a long before being sent. Entered text will be case insensitive.
    -------------------------------------------------------------------

    Name: Second interface option
    Number: 87
    Purpose: This is triggered when a second interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Enter Text (via String)
    Number: 88
    Purpose: Sends the result of an enter text input.
    Data Sent: textLength, text
    How to receive:
    Code:
    int lengthLength = packet.get() - 1;
    String text = packet.getRS2String();
    Remarks: The context will have to be determined based on the current open interface.
    The entered text gets sent as a String. Entered text will be case sensitive.
    -------------------------------------------------------------------

    Name: Primary Item Option
    Number: 89
    Purpose: Indicates the user has clicked the primary (not necessary first) option on an inventoryItem.
    Data Sent: UPDATE
    How to receive:
    Remarks: Uses include: drink, bury, read, ...
    -------------------------------------------------------------------

    Name: Take Item
    Number: 105
    Purpose: Tells the server the player has clicked to pick up an item.
    Data Sent: itemId, itemX, itemY
    How to receive:
    Code:
    int itemId = packet.getShortA();
    int itemX = packet.getLEShort();
    int itemY = packet.getLEShort();
    Remarks: When this packet is received, it's possible the player isn't on the spot yet or that the item has already been claimed by someone else.
    -------------------------------------------------------------------

    Name: Operate equipment
    Number: 107
    Purpose: The players wants to operate equipment (a wielded item).
    Data Sent: itemSlot, parentUID, itemId
    How to receive:
    Code:
    int slot = packet.getShortA();
    int parentUID = packet.getInt();
    int itemId = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Remove Friend
    Number: 122
    Purpose: Signals the player wants to remove a friend.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: WieldPacket
    Number: 124
    Purpose: A player attempts to wear an item.
    Data Sent: itemId, itemSlot, unknown.
    How to receive:
    Code:
    int itemSlot = packet.getLEShortA() & 0xFFFF;
    int itemId = packet.getShort() & 0xFFFF;
    int unknown = packet.getInt2();
    Remarks: /
    -------------------------------------------------------------------

    Name: Add Friend
    Number: 131
    Purpose: Signals the player wants to add a friend.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: Use Item On Object
    Number: 134
    Purpose: Indicates the player has used an item on an object
    Data Sent: objectX, objectY, objectId, inventorySlot, inventoryItemId, unknown.
    How to receive:
    Code:
    int objX = packet.getShortA();
    int slot = packet.getShortA();
    int objID = packet.getLEShort() & 0xFFFF;
    int objY = packet.getLEShortA() & 0xFFFF;
    int unknown = packet.getInt1();
    int itemId = packet.getLEShort() & 0xFFFF;
    Remarks: Uses are such as using flax on a spinning wheel. The packets is sent as soon as the click occurs. The player may not be close enough.
    -------------------------------------------------------------------

    Name: ItemOptionPacket3 //Empty
    Number: 141
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: ObjectOptionPacket2 //Guide patch,
    Number: 145
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: QuietPacket1
    Number: 149
    Purpose: UNKNOWN SO FAR
    Data Sent: UNKNOWN
    How to receive: UNKNOWN
    Remarks: UNKNOWN
    -------------------------------------------------------------------

    Name: POINTLESS PACKET? AT LOGIN
    Number: 150
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Add Ignore
    Number: 152
    Purpose: Signals the player wants to add an ignore.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: Eighth Interface Option
    Number: 154
    Purpose: Tells the server an eighth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Tenth Interface Option
    Number: 156
    Purpose: Tells the server a tenth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Use Magic On NPC
    Number: 157
    Purpose: Indicates the player wants to use a spell on an NPC.
    Data Sent: unknown, spellId, npcIndex.
    How to receive:
    Code:
    int unknown = packet.getShort() & 0xFFFF;
    int spellId = packet.getLEShort() & 0xFFFF;
    int spellBookId = packet.getLEShort() & 0xFFFF;
    int npcIndex = packet.getLEShortA() & 0xFFFF;
    Remarks: The spellId is actualy the childId within the current spellBook (spellBookId (parentId of the childId)).
    -------------------------------------------------------------------

    Name: Trade Or PickPocket NPC
    Number: 160
    Purpose: Indicates the player either tries to trade with the NPC or pickpocket him.
    Data Sent: npcIndex.
    How to receive:
    Code:
    int npcIndex = packet.getLEShort() & 0xFFFF;
    Remarks: This packet is shared by trade and pickpocket. If someone knows an npc with both trade and pickpocket, please tell me.
    -------------------------------------------------------------------

    Name: Join/Leave ClanChat
    Number: 163
    Purpose: The player either wants to join or leave a clanChat.
    Data Sent: clanChatOwnerNameAsLong
    How to receive:
    Code:
    long clanChatOwnerNameAsLong = packet.getLong();
    Remarks: The player wants to leave a clanChat when the long is 0.
    -------------------------------------------------------------------

    Name: SwitchItemPacket
    Number: 166
    Purpose: Indicates an Item has switched slots.
    Data Sent: fromSlot, toSlot, unknown, parentUID
    How to receive:
    Code:
    int toSlot = packet.getLEShortA() & 0xFFFF;
    int unknown = packet.getByteS();
    int parentUID = packet.getInt2();
    int fromSlot = packet.getLEShort() & 0xFFFF;
    Remarks: It's important to have this packet, otherwise client and server could get out of sync. This would be a problem if you have protection built in your server (anti dupe for example).
    -------------------------------------------------------------------

    Name: ClickPacket
    Number: 167
    Purpose: Triggered whenever a player clicks something.
    Data Sent: TODO
    How to receive: TODO
    Remarks: You may very well ignore this one (or handle it as a quietPacket) as it's not likely this is useful information for your server.
    -------------------------------------------------------------------

    Name: ArrowsPressedPacket
    Number: 169
    Purpose: Triggered when the arrowKeys are used (camera rotation in the normal case).
    Data Sent: cameraUpDownRotation, cameraLeftRightRotation.
    How to receive:
    Code:
    int cameraUpDownRotation = packet.getLEShort() & 0xFFFF;
    int cameraLeftRightRotation = packet.getLEShort() & 0xFFFF;
    Remarks: You may very well ignore this one (or handle it as a quietPacket).
    CameraLeftRightRotation lies in the range: 0 – 2047 (2048 would be a full rotation).
    CameraUpDownRotation lies in the range: 128 – 383.
    -------------------------------------------------------------------

    Name: ObjectOptionPacket5 //climb down stairs (if climb and climbup)
    Number: 174
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: SIGNAL LOGGED IN
    Number: 176
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Examine NPC
    Number: 178
    Purpose: Triggered when the player examines an NPC.
    Data Sent: npcType.
    How to receive:
    Code:
    int npcType = packet.getShortA();
    Remarks: The examination of the NPC should be sent.
    -------------------------------------------------------------------

    Name: PingPacket This is not a pingpacket, needs to be updated.
    Number: 186
    Purpose: To ping the server.
    Data Sent: None
    How to receive: /
    Remarks: None yet.
    -------------------------------------------------------------------

    Name: Use Magic On GroundItem
    Number: 190
    Purpose: Indicates the player wants to use a spell on a groundItem.
    Data Sent: itemX, itemY, itemId, spellId, unknown.
    How to receive:
    Code:
    int itemX = packet.getShortA() & 0xFFFF;
    int itemId = packet.getShortA() & 0xFFFF;
    int itemY = packet.getLEShort() & 0xFFFF;
    int spellId = packet.getLEShort() & 0xFFFF;
    int spellBookId = packet.getLEShort() & 0xFFFF;
    int unknown = packet.getShortA() & 0xFFFF;
    Remarks: Foremost use is Telegrab.
    -------------------------------------------------------------------

    Name: Seventh Interface Option
    Number: 192
    Purpose: Tells the server a seventh interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Attack NPC
    Number: 196
    Purpose: Indicates the player has clicked the attack option on an NPC.
    Data Sent: npcIndex.
    How to receive:
    Code:
    int npcIndex = packet.getLEShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: CommandPacket
    Number: 202
    Purpose: Sends a command to the server.
    Data Sent: The commandString
    How to receive:
    Code:
    String commandString = packet.getRS2String();
    Remarks: None
    -------------------------------------------------------------------

    Name: ObjectOptionPacket1 //Inspect patch, climb up stairs (if climb and climb down), prospect rock //looks like SECONDARY option
    Number: 203
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Use Item On Player
    Number: 204
    Purpose: An Item has been used on another player.
    Data Sent: itemId, itemSlot, playerIndex, unknown.
    How to receive:
    Code:
    int itemId = packet.getShort() & 0xFFFF;
    int playerIndex = packet.getShortA() & 0xFFFF;
    int unknown = packet.getInt1();
    int itemSlot = packet.getShortA() & 0xFFFF;
    Remarks: Uses include healing other players and giving items to other players.
    -------------------------------------------------------------------

    Name: Use Magic On Object
    Number: 205
    Purpose: A player wants to cast a spell on an object.
    Data Sent: objectId, objectX, objectY, spellId, unknown.
    How to receive:
    Code:
    int objectId = packet.getShortA() & 0xFFFF;
    int objectX = packet.getLEShortA() & 0xFFFF;
    int spellBookId = packet.getLEShort() & 0xFFFF;
    int spellId = packet.getLEShort() & 0xFFFF;
    int unknown = packet.getShortA() & 0xFFFF;
    int objectY = packet.getLEShortA() & 0xFFFF;
    Remarks: Foremost use is enchanting obelisks.
    -------------------------------------------------------------------

    Name: Use Item On Item
    Number: 206
    Purpose: An item has been used with another item (both inventory).
    Data Sent: sourceSlot, sourceItemId, targetSlot, targetItemId, unknown1, unknown2
    How to receive:
    Code:
    int sourceSlot = packet.getShort() & 0xFFFF;
    int unknown1 = packet.getInt1();
    int sourceItemId = packet.getLEShortA() & 0xFFFF;
    int targetSlot = packet.getLEShort() & 0xFFFF;
    int unknown2 = packet.getInt1();
    int targetItemId = packet.getLEShortA() & 0xFFFF;
    Remarks: The 2 unknown variable might be used to put the different items into different categories, although this hasn't been proved yet.
    -------------------------------------------------------------------

    Name: Use Item On GroundItem
    Number: 208
    Purpose: The player has used an inventoryItem with a groundItem.
    Data Sent: itemSlot, itemId, groundItemX, groundItemY, groundItemId, parentUID.
    How to receive:
    Code:
    int itemSlot = packet.getShort() & 0xFFFF;
    int groundItemY = packet.getShortA();
    int groundItemId = packet.getLEShort() & 0xFFFF;
    int groundItemX = packet.getLEShortA() & 0xFFFF;
    int parentUID = packet.getInt2();
    Remarks: Uses include firemaking (using tinderbox with logs on the ground).
    ParentUID is the location of the interface in which the selected item's located.
    -------------------------------------------------------------------

    Name: ActionButtons
    Number: 215
    Purpose: Tells the server an actionButton has been activated.
    Data Sent: buttonId
    How to receive:
    Code:
    final int buttonId = packet.getInt();
    Remarks: /
    -------------------------------------------------------------------

    Name: Examine Object
    Number: 226
    Purpose: Triggered when the player examines an object.
    Data Sent: objectId.
    How to receive:
    Code:
    int objectId = packet.getLEShort() & 0xFFFF;
    Remarks: The examination of the object should be sent.
    -------------------------------------------------------------------

    Name: First Interface Option
    Number: 234
    Purpose: Tells the server a first interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: IdlePacket
    Number: 236
    Purpose: Tells the server the mouse and keyboard have been idle for some time.
    Data Sent: None
    How to receive: /
    Remarks: This packet is sent after 90 seconds (1,5 minutes) which equals to 4500 cycles at 50Hz.
    After this initial idlePacket, it is sent again every 10 seconds which equals 500 cycles at 50Hz.
    -------------------------------------------------------------------

    Name: Use Magic On InventoryItem
    Number: 238
    Purpose: Indicates the player wants to use a spell on an inventoryItem.
    Data Sent: itemSlot, itemId, spellId, interfaceId, unknown2
    How to receive:
    Code:
    int interfaceId = packet.getInt2();
    int itemId = packet.getLEShort() & 0xffff;
    int unknown2 = packet.getLEShort() & 0xffff;
    int itemSlot = packet.getShort() & 0xffff;
    int spellBookId = packet.getShort() & 0xFFFF;
    int spellId = packet.getShort() & 0xFFFF;
    Remarks: The spellId is actualy the childId within the current spellBook (spellBookId (parentId of the childId)).
    -------------------------------------------------------------------

    Name: Remove equipment
    Number: 241
    Purpose: Indicates an attempt of the player to remove equipment by clicking it on the equipment interface.
    Data Sent: itemSlot, parentUID, itemId
    How to receive:
    Code:
    int itemSlot = packet.getShort() & 0xFFFF;
    int parentUID = packet.getLEInt();
    int itemId = packet.getLEShortA() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Enter Amount
    Number: 249
    Purpose: Sends the result of an enter amount input.
    Data Sent: input
    How to receive:
    Code:
    int amount = packet.getInt();
    Remarks: The context will have to be determined based on the current open interface.
    -------------------------------------------------------------------

    Name: Change ClanChatFriend Rank
    Number: 250
    Purpose: Requests a change of rank for a (clanChat)friend.
    Data Sent: rank, clanChatFriendNameAsLong
    How to receive:
    Code:
    int rank = packet.getByteC();
    long clanChatFriendNameAsLong = packet.getLong1();
    Remarks: Ranks: Not in clan/Normal Friend (0), Recruit (1), Corporal (2), Sergeant (3), Lieutenant (4), Captain (5), General (6), Channel Owner (7).
    -------------------------------------------------------------------

    Name: chatStatusUpdate
    Number: 251
    Purpose: Sends the public, private and trade chatMode after clicking on one of the possible chat modes at the relevant types.
    Data Sent: publicChatMode, privateChatMode, tradeChatMode.
    How to receive:
    Code:
    int publicChatMode = packet.get();
    int privateChatMode = packet.get();
    int tradeChatMode = packet.get();
    Remarks: This packet gets sent before any of the 4 chatMode packets the only type that doesn't send this packet is the clanChat one. This packet is smaller than any of the chatMode packets (3 vs 6) but it does lack the clanChatMode being sent. If you don't wish to keep track of the clanChatMode, this packet is more usefull than the 4 chatMode packets together.
    Modes: 0 is ON, 1 is FRIENDS, 2 is OFF and 3 is HIDDEN (only for public chat).
    -------------------------------------------------------------------

    Name: Private Message
    Number: 252
    Purpose: Receives a private message from a player.
    Data Sent: toPlayerLong, chatText
    How to receive:
    Code:
    long toPlayerLong = packet.getLong();
    int chatTextSize = (byte) (packet.getLength()-8);
    byte[] chatText = new byte[256];
    packet.get(chatText, 0, chatTextSize);
    Remarks: The private messages needs to be sent back to the sender and sent forward to the receiver.
    -------------------------------------------------------------------
    Reply With Quote  
     

  9. Thankful user:


  10. #6  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    PACKETS: SERVER TO CLIENT:

    Name: Send Minimap State
    Number: 5
    Purpose: Sends the minimap state.
    Data Sent: minimapState
    How to send:
    Code:
    bldr.put((byte) minimapState);
    Remarks: minimapStates:
    0 (all visible, clickable), 1 (all visible, unclickable), 2 (black minimap, unclickable), 3 (black compass, clickable), 4 (black compass, unclickable), 5 (all black, unclickable).
    -------------------------------------------------------------------

    Name: Send GroundItem
    Number: 7
    Purpose: Sends a groundItem to the player.
    Data Sent: unknown, groundItemId, itemCount.
    How to send:
    Code:
    bldr.put((byte) unknown);
    bldr.putShort(groundItemId);
    bldr.putLEShortA(count);
    Remarks: The unknown variable is set to 0 in my server. Be aware that sending the itemCount as a short can result in incorrect stackmodels, for example dropping 65537 coins will result in a stackmodel of 1 coin. I advice sending a value of 65535 when the value is greater than 65535.
    -------------------------------------------------------------------

    Name: SendConfigInt a.k.a. SendConfig2
    Number: 10
    Purpose: Sends settings to the client such as musicVolume, brightness, publicChatStatus, ...
    Data Sent: configId, settingValue
    How to send:
    Code:
    bldr.putLEInt(settingValue);
    bldr.putShort(configId);
    Remarks: I'm not gonna post a list with configId's and settings. SendConfigInt IS used over SendConfigByte when the settingValue takes up more than 1 byte.
    -------------------------------------------------------------------

    Name: updateChatModes
    Number: 15
    Purpose: Updates the chatModes clientSided
    Data Sent: publicChatMode, privateChatMode, tradeChatMode.
    How to send:
    Code:
    bldr.put((byte) publicChatMode);
    bldr.put((byte) privateChatMode);
    bldr.put((byte) tradeChatMode);
    Remarks: Modes: 0 is ON, 1 is FRIENDS, 2 is OFF and 3 is HIDDEN (only for public chat). This method does not update the clanChatMode.
    -------------------------------------------------------------------

    Name: SendInterfacePacket
    Number: 17
    Purpose: Sends a specific interface.
    Data Sent: parentInterfaceId, childId, interfaceId, walkable
    How to send:
    Code:
    bldr.putByteA((byte) (walkable ? 1 : 0));
    bldr.putLEShort(interfaceId);
    bldr.putInt1(parentInterfaceId << 16 | childId);
    Remarks:
    -------------------------------------------------------------------

    Name: Send Remove GroundItem
    Number: 28
    Purpose: Removes a groundItem for a certain player.
    Data Sent: groundItemId, unknown.
    How to send:
    Code:
    sendRegion
    bldr.putShartA(groundItemId);
    bldr.put(unknown);
    Remarks: I use 0 for the unknown variable at the moment.
    -------------------------------------------------------------------

    Name: send Contact ServerStatus
    Number: 30
    Purpose: Sends the contact serverStatus to the client.
    Data Sent: The contact serverStatus.
    How to send:
    Code:
    bldr.put((byte) status);
    Remarks: available statusses: 0 (loading), 1 (connecting), 2 (connected).
    -------------------------------------------------------------------

    Name: Update ClanChat Participant
    Number: 32
    Purpose: Updates (adds or removes) 1 participant to/from the list of clan chat participants.
    Data Sent: participantLong, participantWorld, participantRank
    How to send:
    Add/Update a clanChat participant:
    Code:
    bldr.putLong(participantLong);
    bldr.putShort(participantWorld);
    bldr.put(participantRank);
    Remove participant from clanChat:
    Code:
    participantLong |= 0x8000000000000000L;
    bldr.putLong(participantLong);
    bldr.putShort(participantWorld);
    bldr.put(participant.getRank().toByte());
    Remarks: To remove a participant from the list, you need to add a flag (0x8000000000000000L) to the participantLong (the name of the participant in long format).
    You can combine both add/update and remove by making the flag addition optional:
    Code:
    if(!add)
        participantLong |= 0x8000000000000000L;
    For updating or clearing the whole list, see packet 56: Update ClanChat List
    -------------------------------------------------------------------

    Name: Send Clan Chat Message
    Number: 35
    Purpose: Sends a clan chat message to the client.
    Data Sent: speakerNameLong, clanChatNameLong, messageLength, encryptedMessage, chatId, speakerRight
    How to send:
    Code:
    bldr.putLong(speakerNameLong);
    bldr.put((byte)0);
    bldr.putLong(clanChatNameLong);
    bldr.putShort(messageLength);
    bldr.putTriByte(chatId);
    bldr.put(speakerRight);
    for(byte character : encryptedMessage)
        bldr.put(character);
    Remarks: Type: VARIABLE
    The speakerRight is the the playerRight of the speaker (Player, Mod, Admin, …).
    The 0-byte doesn't have a real meaning, it can be any byte-value, but it is necessary.
    The encryptedMessage is a byte array (byte[]) which can be found in the chatPacket (after the encryption).
    The true side of
    Code:
    if(rawChatData[1] == 0 && rawChatData[2] == 5)
    means the message starts with '/'.
    -------------------------------------------------------------------

    Name: send projectile
    Number: 38
    Purpose: Sends a flying projectile to the server.
    Data Sent: offsetMask, offsetX, offsetY, targetIndex, projectileId, startHeight, endHeight, delay, speed, slope
    How to send:
    Code:
    bldr.put((byte) offsetMask);
    bldr.put((byte) offsetX);
    bldr.put((byte) offsetY);
    bldr.putShort(targetIndex);
    bldr.putShort(projectileId);
    bldr.put(startHeight);
    bldr.put(endHeight);
    bldr.putShort(delay);
    bldr.putShort(speed);
    bldr.put(slope);
    bldr.put((byte) frontOffset);
    Remarks: The region should be sent first.
    OffsetMask is a mask containing the offsets of the projectile.
    OffsetX and offsetY are the offsets to where the projectile should be sent.
    TargetIndex is the index of the target.
    ProjectileId, is the flying projectile's id.
    The heights are as normal: 0 floor, 25 mid, 50 head.
    The delay is the startDelay in number of cycles.
    The speed is the number of cycles the projectile takes to hit the target.
    The slope is the slope at which the projectile should start and end:
    0 is 0 degrees, 64 is 90 degrees (not usefull as it cannot be seen well enough), 32 is 45 degrees.
    frontOffset is an offset towards the target at the start. One tile equals 128.
    -------------------------------------------------------------------

    Name: send RunEnergy
    Number: 42
    Purpose: Sends the runEnergy value.
    Data Sent: runEnergy.
    How to send:
    Code:
    bldr.put((byte) runEnergy);
    Remarks: RunEnergy will have to be updated every time it changes.
    -------------------------------------------------------------------

    Name: send Earthquake data
    Number: 44
    Purpose: Sends data as how an earthquake should shake.
    Data Sent: earthquakeDirection, magnitude, amplitude, fourPiOverPeriod, earthquakeOffset
    How to send:
    Code:
    bldr.put((byte)earthquakeDirection);
    bldr.put((byte)magnitude);
    bldr.put((byte)amplitude);
    bldr.put((byte)fourPiOverPeriod);
    bldr.putShort(quakeOffset);
    Remarks:
    EarthquakeDirection: The direction this data relates to:
    0: X-direction; 1: Z-direction; 2: Y-direction; 3: XY-Angle; 4: Z-Angle
    Magnitude 0 - 255; The magnitude. This is the difference between the average and maximum/minimum earthquakeMagnitude. Because of this, the magnitude is a measure for smoothness of the final earthquake. The lower, the smoother.
    Amplitude 0 - 255; The maximum amplitude of the average wave.
    FourPiOverPeriod 0 - 255; The number which is a result of 4 pi over period.
    EarthquakeOffset 0 - 65535; The offset in the wave, it serves as the time component for the earthquake.
    -------------------------------------------------------------------

    Name: Set Hint Arrow
    Number: 48
    Purpose: Sets a hint arrow above a player, an npc or a location.
    Data Sent: Depending on the situation: npcIndex and hintType, playerIndex and hintType or absX, absY, arrowHeight and hintType
    How to send:
    Player/NPC:
    Code:
    bldr.put((byte)(targetEntity instanceof NPC ? 1 : 10)); //1 for NPC, 10 for Player
    bldr.putShort(npcIndex or playerIndex);
    bldr.putTriByte(0);
    Location:
    Code:
    bldr.put((byte)targetType);
    bldr.putShort(absX);
    bldr.putShort(absY);
    bldr.put((byte)arrowHeight);
    Remarks: This packet has a fixed packetlength of 6 bytes, even when sending an arrow to a Player or NPC. In this case the value of 3 bytes put in the buffer by putTriByte is useless. Yet putting 3 bytes in there is a must to prevent malformed packets.
    TargetType:
    1: NPC
    2: Location: Center
    3: Location: West Side
    4: Location: East Side
    5: Location: South Side
    6: Location: North Side
    10: Player
    -------------------------------------------------------------------

    Name: Send Still GFX
    Number: 49
    Purpose: Sends a GFX to a location.
    Data Sent: offset, gfxId, height, startDelay
    How to send:
    Update ClanChat:
    Code:
    sendRegion
    bldr.put((byte)offset);
    bldr.putShort(gfxId);
    bldr.put((byte) height);
    bldr.putShort(startDelay);
    Remarks: The unit of startDelay is cycles.
    -------------------------------------------------------------------

    Name: Write to random.dat file
    Number: 54
    Purpose: Writes 24 bytes to the random.dat file.
    Data Sent: data[] (24 bytes)
    How to send:
    Code:
    for(int i = 0; i < 24; i++){
         bldr.put(data[i]);
    }
    Remarks: it’s one of the data bytes sent to the client upon login.
    -------------------------------------------------------------------

    Name: Update ClanChat List
    Number: 56
    Purpose: Updates the list of clan chat participants.
    Data Sent: ownerNameLong, clanNameLong, unknownByte, participantCount, participantNameAsLongs[], participantWorlds[], participantRanks[]
    How to send:
    Update ClanChat:
    Code:
    bldr.putLong(ownerNameLong);
    bldr.putLong(clanNameLong);
    bldr.put((byte) unknownByte);
    bldr.put((byte) participantCount);
    for(int i = 0; i < participantCount; i++){
         bldr.put(participantNameAsLongs[i]);
         bldr.putShort(participantWorlds[i]);
         bldr.put(participantRanks[i]);
    }
    Clear ClanChat:
    Code:
    bldr.putLong(0);
    Remarks: Type: VARIABLE_SHORT
    The upper code is for updating the whole clanChatList when active in a clanChat. The lower one is for clearing the whole clanChatList.
    For updating (adding or removing) 1 participant, see packet 32: Update ClanChat Participant
    -------------------------------------------------------------------

    Name: Send Private Message (Sender)
    Number: 57
    Purpose: Sends the sender version of a private message to the sender.
    Data Sent: toPlayerLong, message
    How to send:
    Code:
    bldr.putLong(toPlayerLong);
    bldr.put(message, 0, messageLength);
    Remarks: The message is in byte[] form, as it should've been received by the Client to Server PrivateMessage Packet.
    -------------------------------------------------------------------

    Name: SendMapRegionPacket
    Number: 61
    Purpose: Sends the map region load command.
    Remarks: This is a complicated packet and I won't post it for now.
    -------------------------------------------------------------------

    Name: OffsetInterfaceItem
    Number: 76
    Purpose: Offsets child interfaces on the parent’s interface.
    Data Sent: parentId, childId, xOffset, yOffset
    How to send:
    Code:
    bldr.putLEShort(xOffset);
    bldr.putLEInt(parentId << 16 | childId);
    bldr.putShortA(yOffset);
    Remarks: The offset is in relation to the child’s original position on the parent.
    -------------------------------------------------------------------

    Name: SetInterfaceComponentColour
    Number: 114
    Purpose: To change the colour of an interface component (can be text).
    Data Sent: parentId, childId, colour
    How to send:
    Code:
    bldr.putShort(colour);
    bldr.putInt1(parentId << 16 | childId);
    Remarks:
    The colour is not directly the 3 bytes rgb format.
    Each colour gets only 5 bytes instead of 15 (this way it can be sent as a short).
    The downside is that each value in this short format represents 8 (32 gradients!) in the 3 bytes format.
    To send a value of 255 you would do:
    255 / 8 = 31,875 => 31
    31 in the old format translates to 248 in the new format, which is as close as we can get.
    -------------------------------------------------------------------

    Name: Send Private Message (Receiver)
    Number: 117
    Purpose: Sends the receiver version of a private message to the receiver.
    Data Sent: fromPlayerLong, chatId, fromPlayerRight, message
    How to send:
    Code:
    bldr.putLong(fromPlayerLong);
    bldr.put((byte)0);
    bldr.putInt(chatId);
    bldr.put((byte)fromPlayerRight);
    bldr.put(message, 0, messageLength);
    Remarks: The message is in byte[] form, as it should've been received by the Client to Server PrivateMessage Packet.
    The 0-byte and chatId are part of the 5 bytes (normaly grouped short and triByte) that make up the actual chatId. If you know more about it, please contact me. For now, the 0-byte remains a 0-byte.
    -------------------------------------------------------------------

    Name: SendUpdateItemsPacket
    Number: 119
    Purpose: Sends a packet to update a group of items.
    Data Sent: parentInterfaceId, childId, type, itemCount[], itemId[], itemCount
    How to send:
    Code:
    bldr.putInt(interfaceId << 16 | childId);
    bldr.putShort(type);
    bldr.putShort(items.length);
    for(Item item : items) {
    	if(item != null) {
    		int count = item.getCount();
    		if(count > 254) {
    			bldr.putByteC((byte) 255);
    			bldr.putLEInt(count);
    		} else {
    			bldr.putByteC((byte) count);
    		}
    		bldr.putLEShortA(item.getId() + 1);
    	} else {
    		bldr.putByteC((byte) 0);
    		bldr.putLEShortA(0);
    	}
    }
    Remarks: Type: VARIABLE_SHORT
    -------------------------------------------------------------------

    Name: send AreaSound (TO TEST)
    Number: 121
    Purpose: Sends an areaSound to play.
    Data Sent: The areaSound.
    How to send:
    Code:
    bldr.putLEShortA((byte) areaSound);
    Remarks:
    -------------------------------------------------------------------

    Name: reset Animations
    Number: 138
    Purpose: Resets all animations.
    Remarks: No data is sent. It resets the animation of all players and npc.
    -------------------------------------------------------------------

    Name: NPCUpdatePacket
    Number: 146
    Purpose: Performs a clientsided npcUpdate.
    Remarks: I'M NOT GOING TO HANDLE THIS MATTER HERE. USE THE FORUMS IF YOU NEED HELP.
    -------------------------------------------------------------------

    Name: PlayerUpdatePacket
    Number: 150
    Purpose: Performs a clientsided playerUpdate.
    Remarks: I'M NOT GOING TO HANDLE THIS MATTER HERE. USE THE FORUMS IF YOU NEED HELP.
    -------------------------------------------------------------------

    Name: Send Stop Cinematics
    Number: 156
    Purpose: Stops any cinematics and returns to the normal camera view.
    Data Sent: None.
    How to send: /
    Remarks: Without modifications to the client, earthquakes (which are part of cinematics) don't reset between login. Therefore it's best to send this packet on logout if any earthquake is happening on that moment.
    -------------------------------------------------------------------

    Name: Send Multiple MapPackets
    Number: 163
    Purpose: Signals the start of multiple mapPackets being sent (See: Send Region (packet 168)).
    Data Sent: regionX, regionY
    How to send:
    Code:
    bldr.put((byte)regionX);
    bldr.putByteS((byte)regionY);
    Remarks: After this packet is received, the client expects mapPackets. When multiple mapPackets at the same region are sent, this packet is prefered.
    -------------------------------------------------------------------

    Name: SendLogoutPacket
    Number: 166
    Purpose: Sends the logout packet.
    Data Sent: None.
    How to send: /
    Remarks: /
    -------------------------------------------------------------------

    Name: Turn camera to location
    Number: 167
    Purpose: Rotates the camera to a spatial point.
    Data Sent: localX, localY, height, constantSpeed, variableSpeed.
    How to send:
    Code:
    bldr.put((byte)localX);
    bldr.put((byte)localY);
    bldr.putShort(height);
    bldr.put((byte)constantSpeed);
    bldr.put((byte)variableSpeed);
    Remarks: ConstantSpeed is the constant linear camera movement speed as angular units per cycle.
    In the left-right angle there are 2048 units in 360 degrees. The up-down angle is restricted between 128 and 383.
    The variableSpeed is the variable linear camera movement speed as promile of what's left. Max 99, 100 is instant.
    Return to normal camera with the stopCinematic packet (packet 156).
    -------------------------------------------------------------------

    Name: Send Region
    Number: 168
    Purpose: Updates the region so the next packet that gets sent doesn't need to hand out the relative location of it's subject.
    Data Sent: regionX, regionY.
    How to send:
    Code:
    bldr.put((byte) regionX);
    bldr.putByteA(regionY);
    Remarks: If multiple mapPackets using the same region are to be sent after this packet, Send Multiple MapPackets (packet 163) is prefered.
    -------------------------------------------------------------------

    Name: Send Ignores
    Number: 173
    Purpose: Sends the ignoreList to the client.
    Data Sent: playerNameLongs
    How to send:
    Code:
    for(int i = 0; i < player.getContacts().getIgnoreCount(); i++)
        bldr.putLong(ignores[i]);
    Remarks: Only send existing ignores, don't send the whole list (with empty ones).
    Type: VARIABLE_SHORT
    -------------------------------------------------------------------

    Name: Clear Interface
    Number: 174
    Purpose: Clears an interface clientsided.
    Data Sent: parentId, childId
    How to send:
    Code:
    bldr.putInt(parentId << 16 | (childId & 0xFFFF));
    Remarks: /
    -------------------------------------------------------------------

    Name: Move camera to location
    Number: 179
    Purpose: Gradually moves the camera to a specified location.
    Data Sent: localX, localY, height, constantSpeed, variableSpeed.
    How to send:
    Code:
    bldr.put((byte)localX);
    bldr.put((byte)localY);
    bldr.putShort(height);
    bldr.put((byte)constantSpeed);
    bldr.put((byte)variableSpeed);
    Remarks: ConstantSpeed is the constant linear camera movement speed as positions (128 per square) per cycle.
    The variableSpeed is the variable linear camera movement speed as promile of what's left. Max 99, 100 is instant.
    Return to normal camera with the stopCinematic packet (packet 156).
    -------------------------------------------------------------------

    Name: Show/Hide interface feature
    Number: 184
    Purpose: Hides or unhides certain interface features.
    Data Sent: show, parentId, childId.
    How to send:
    Code:
    bldr.putByteA((byte)(show ? 0 : 1))
    bldr.putInt(parentId << 16 | childId);
    Remarks: This packet can show or hide parts of interfaces. For example, it can show or hide the special attack bar.
    -------------------------------------------------------------------

    Name: Send Skill
    Number: 196
    Purpose: Send the data of 1 skill to the client.
    Data Sent: skillId, skillExp, skillLevel
    How to send:
    Code:
    bldr.put((byte) skillId);
    bldr.putInt2((int) skillExp);
    bldr.put((byte) skillLevel);
    Remarks: Used to update the skills clientsided.
    -------------------------------------------------------------------

    Name: send Friend Status/Add Friend
    Number: 200
    Purpose: Sends a signal telling a friend has come online/gone offline or adds a friend to the friendsList.
    Data Sent: friendLong, world, clanChatRank.
    How to send:
    Code:
    bldr.putLong(friendLong);
    bldr.putShort((byte) world);
    bldr.put((byte) clanChatRank);
    Remarks: When a player goes offline, the world should be set to 0.
    The first time the packet is sent for a friendLong, the person gets added to the friendsList without notifiying the player (as is the case when the player logs in).
    Ranks: Not in clan/Normal Friend (0), Recruit (1), Corporal (2), Sergeant (3), Lieutenant (4), Captain (5), General (6), Channel Owner (7).
    -------------------------------------------------------------------

    Name: Send Server UpdateTime
    Number: 207
    Purpose: Sends the server's time till update.
    Data Sent: The updateTime measured in number of client cycles.
    How to send:
    Code:
    bldr.putLEShort(updateTime);
    Remarks: The unit is number of cycles (600 ms). The timer does not elapse and setting the timer to 0 won't log the player out.
    -------------------------------------------------------------------

    Name: SendMessagePacket
    Number: 209
    Purpose: Sends a message to the player.
    Data Sent: message
    How to send:
    Code:
    bldr.putString(message);
    Remarks: Type: VARIABLE
    -------------------------------------------------------------------

    Name: Send Alter GroundItem Count
    Number: 220
    Purpose: Sends an alternate itemCount to a groundItem for a player.
    Data Sent: groundItemId, oldItemCount, newItemCount, unknown.
    How to send:
    Code:
    sendRegion
    bldr.put((byte) unknown);
    bldr.putShort(groundItemId);
    bldr.putShort(oldItemCount);
    bldr.putShort(newItemCount);
    Remarks: This packets 'prevents' you from removing a groundItem and creating it with a new count. Be aware that sending the itemCount as a short can result in incorrect stackmodels, for example dropping 65537 coins will result in a stackmodel of 1 coin. I advice sending a value of 65535 when the value is greater than 65535.
    -------------------------------------------------------------------

    Name: SendPlayerOption
    Number: 225
    Purpose: Sending click options for players such as: attack, challenge, trade.
    Data Sent: option, slot, onTop
    How to send:
    Code:
    bldr.putByteA(onTop ? 1 : 0);
    bldr.putString(option);
    bldr.putByteC((byte) slot);
    Remarks: Type: VARIABLE
    If the option should be available for players without opening the playerOption menu, onTop should be set to true (sending value 1).
    -------------------------------------------------------------------

    Name: SendStringPacket
    Number: 231
    Purpose: Sends a string to replace text in/on an interface.
    Data Sent: parentInterfaceId, childId, string.
    How to send:
    Code:
    bldr.putInt2(parrentInterfaceId << 16 | childId);
    bldr.putRS2String(string);
    Remarks: Type: VARIABLE_SHORT
    -------------------------------------------------------------------

    Name: Send Ping Packet
    Number: 238
    Purpose: Returns a pingpacket to the client.
    Data Sent: pingId: a unique id, different from the one used before (keep track of your pingId).
    How to send:
    Code:
    bldr.putInt(pingId);
    Remarks: Type: VARIABLE_SHORT
    -------------------------------------------------------------------

    Name: send Sound
    Number: 243
    Purpose: UPDATE
    Data Sent: soundId, volume, delay.
    How to send:
    Code:
    bldr.putShort(soundId);
    bldr.put((byte)volume);
    bldr.putShort(delay);
    Remarks: Delay is sent as the number of cycles before the sound starts.
    -------------------------------------------------------------------

    Name: SendWindowPanePacket
    Number: 251
    Purpose: UPDATE
    Data Sent: window
    How to send:
    Code:
    bldr.putLEShort(window);
    Remarks: Need more specific information about this.
    -------------------------------------------------------------------

    Name: SendConfigByte a.k.a. SendConfig1
    Number: 253
    Purpose: Sends settings to the client such as musicVolume, brightness, publicChatStatus, ...
    Data Sent: configId, settingValue
    How to send:
    Remarks: I'm not gonna post a list with configId's and settings. SendConfigByte CAN be used over SendConfigInt when the settingValue can take up 1 byte.
    -------------------------------------------------------------------

    Name: SetVerticalScrollPanePosition
    Number: 255
    Purpose: Remotely scrolling the scrollPane on an interface.
    Data Sent: parentId, childId, scrollPos
    How to send:
    Code:
    bldr.putLEShortA(scrollPosition);
    bldr.putLEInt(parentId | childId);
    Remarks: The position is not in percent.
    An example of this is to set the position of the bank’s scrollPane: parentId = 12, childId = 91.
    -------------------------------------------------------------------
    Reply With Quote  
     

  11. Thankful user:


  12. #7  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    PACKETS: CLIENT TO SERVER:

    Name: Remove Ignore
    Number: 1
    Purpose: Signals the player wants to remove an ignore.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: Fourth interface option
    Number: 3
    Purpose: This is triggered when a fourth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: ObjectOptionPacket4 //pickpocket trapdoor
    Number: 4
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Minimap WalkingPacket
    Number: 11
    Purpose: Sends walking data to the server.
    Data Sent: size, firstX, firstY, running, waitpointdata
    How to receive:
    Code:
    int size = packet.getLength();
    if(packet.getOpcode() == 11)
        size -= 14;
    final int steps = (size - 5) / 2;
    final int[][] path = new int[steps][2];
    for (int i = 0; i < steps; i++) {
        path[i][0] = packet.getByte();
        path[i][1] = packet.getByteS();
    }
    final int firstX = packet.getShortA();
    final int firstY = packet.getLEShort();
    final boolean runSteps = packet.getByteC() == 1;
    Remarks: The minimap packet is 14 bytes longer than the other 2 walkingpackets (46 and 59).
    If anyone can tell me why this is, please tell.
    The “How to receive” is the same with 46 and 59 and can be combined to be handled as 1 packet.
    -------------------------------------------------------------------

    Name: Use Item On NPC
    Number: 13
    Purpose: Indicates the player has clicked to use an item on an NPC.
    Data Sent: npcIndex, parentUID, itemSlot, itemId.
    How to receive:
    Code:
    int npcIndex = packet.getLEShort() & 0xFFFF;
    int parentUID = packet.getLEInt();
    int itemSlot = packet.getLEShort() & 0xFFFF;
    int itemId = packet.getShortA() & 0xFFFF;
    Remarks: Same as before, this doesn't indicate the player is close enough.
    -------------------------------------------------------------------

    Name: Interact With NPC
    Number: 21
    Purpose: Indicates a specific type of interaction from player to npc.
    Data Sent: npcIndex.
    How to receive:
    Code:
    int npcIndex = packet.getShort() & 0xFFFF;
    Remarks: Actions include: Talk To, Bait, Fish, Banish, Pet.
    -------------------------------------------------------------------

    Name: Kick clanChat participant
    Number: 22
    Purpose: Indicates a friend of the clanChat owner attempts to kick a fellow clanChatParticipant (non-owner).
    Data Sent: kickParticipantLong.
    How to receive:
    Code:
    long kickParticipantLong = packet.getLong();
    Remarks: Any friend of the clanChat owner has the option available.
    -------------------------------------------------------------------

    Name: Sixth Interface Option
    Number: 29
    Purpose: Tells the server a sixth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: ObjectOptionPacket3 //cut trees, open door, climb up stairs (if only option), forfeit trapdoor (duel area), mine //Looks like PRIME option
    Number: 31
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Client focus
    Number: 34
    Purpose: Tells the server the clients focus has changed.
    Data Sent: focus
    How to receive:
    Code:
    int focus = packet.get();
    Remarks: Focus will be 0 if the client loses focus, it will be 1 when it has gained focus.
    -------------------------------------------------------------------

    Name: Use Magic On Player
    Number: 35
    Purpose: Indicates the player wants to use a spell on another player.
    Data Sent: spellId, playerIndex, unknown.
    How to receive:
    Code:
    int spellBookId = packet.getShort() & 0xFFFF;
    int spellId = packet.getShort() & 0xFFFF;
    int playerIndex = packet.getLEShortA() & 0xFFFF;
    int unknown = packet.getLEShortA() & 0xFFFF;
    Remarks: This is not the attackButton. It's singlecasting on players (pvp and nonpvp spells).
    The spellId is actualy the childId within the current spellBook (spellBookId (parentId of the childId)).
    -------------------------------------------------------------------

    Name: Third interface option
    Number: 37
    Purpose: This is triggered when one a third interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: World WalkingPacket (Normal WalkingPacket) (Need specifications)
    Number: 46
    Purpose: Sends walking data to the server.
    Data Sent: size, firstX, firstY, running, waitpointdata
    How to receive:
    Code:
    int size = packet.getLength();
    if(packet.getOpcode() == 11)
        size -= 14;
    final int steps = (size - 5) / 2;
    final int[][] path = new int[steps][2];
    for (int i = 0; i < steps; i++) {
        path[i][0] = packet.getByte();
        path[i][1] = packet.getByteS();
    }
    final int firstX = packet.getShortA();
    final int firstY = packet.getLEShort();
    final boolean runSteps = packet.getByteC() == 1;
    Remarks: This walkingpacket is sent when you click “Walk here” in the 3D-world.
    The “How to receive” is the same with 11 and 59 and can be combined to be handled as 1 packet.
    -------------------------------------------------------------------

    Name: Examine Item.
    Number: 47
    Purpose: Triggered when the player examines an item.
    Data Sent: itemId.
    How to receive:
    Code:
    int itemId = packet.getLEShortA() & 0xFFFF;
    Remarks: The examination of the object should be sent. This packet is only triggered when the stackCount is less than 100 000.
    -------------------------------------------------------------------

    Name: ChatPacket
    Number: 52
    Purpose: Triggered when a player says something in public chat (excluding commands).
    Data Sent: ChatEffect, Colour, Size, ChatData
    How to receive:
    Code:
    int effects = packet.getByte() & 0xFF;
    int colour = packet.getByte() & 0xFF;
    int size = packet.getLength() - 2;
    byte[] rawChatData = new byte[size];
    packet.get(rawChatData);
    if(player.getChatMessageQueue().size() >= CHAT_QUEUE_SIZE) {
    	return;
    }
    String unpacked = TextUtils.textUnpack(rawChatData, size);
    unpacked = TextUtils.filterText(unpacked);
    unpacked = TextUtils.optimizeText(unpacked);
    byte[] packed = new byte[size];
    TextUtils.textPack(packed, unpacked);
    player.getChatMessageQueue().add(new ChatMessage(effects, colour, packed));
    Remarks: None.
    -------------------------------------------------------------------

    Name: Interaction WalkingPacket
    Number: 59
    Purpose: Sends walking data to the server.
    Data Sent: size, firstX, firstY, running, waitpointdata
    How to receive:
    Code:
    int size = packet.getLength();
    if(packet.getOpcode() == 11)
        size -= 14;
    final int steps = (size - 5) / 2;
    final int[][] path = new int[steps][2];
    for (int i = 0; i < steps; i++) {
        path[i][0] = packet.getByte();
        path[i][1] = packet.getByteS();
    }
    final int firstX = packet.getShortA();
    final int firstY = packet.getLEShort();
    final boolean runSteps = packet.getByteC() == 1;
    Remarks: This walkingpacket is sent when you interact with an entity (player or npc) or an object.
    The “How to receive” is the same with 11 and 46 and can be combined to be handled as 1 packet.
    -------------------------------------------------------------------

    Name: Ninth Interface Option
    Number: 65
    Purpose: Tells the server a ninth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Fifth interface option
    Number: 70
    Purpose: This is triggered when a fifth interface option is clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Drop Item
    Number: 71
    Purpose: Tells the server the player want to have an item dropped.
    Data Sent: parentUID, droppedItemId, slot
    How to receive:
    Code:
    int parentUID = packet.getLEInt();
    int droppedItemId = packet.getLEShortA();
    int slot = packet.getLEShort();
    Remarks: 'Dropping' includes destroying and dropping pets on the ground to follow you. These must also be handled by this packet.
    -------------------------------------------------------------------

    Name: Enter Text (via long)
    Number: 82
    Purpose: Sends the result of an enter text input.
    Data Sent: textLong
    How to receive:
    Code:
    long textLong = packet.getLong()
    Remarks: The context will have to be determined based on the current open interface.
    The entered text gets converted to a long before being sent. Entered text will be case insensitive.
    -------------------------------------------------------------------

    Name: Second interface option
    Number: 87
    Purpose: This is triggered when a second interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Enter Text (via String)
    Number: 88
    Purpose: Sends the result of an enter text input.
    Data Sent: textLength, text
    How to receive:
    Code:
    int lengthLength = packet.get() - 1;
    String text = packet.getRS2String();
    Remarks: The context will have to be determined based on the current open interface.
    The entered text gets sent as a String. Entered text will be case sensitive.
    -------------------------------------------------------------------

    Name: Primary Item Option
    Number: 89
    Purpose: Indicates the user has clicked the primary (not necessary first) option on an inventoryItem.
    Data Sent: UPDATE
    How to receive:
    Remarks: Uses include: drink, bury, read, ...
    -------------------------------------------------------------------

    Name: Take Item
    Number: 105
    Purpose: Tells the server the player has clicked to pick up an item.
    Data Sent: itemId, itemX, itemY
    How to receive:
    Code:
    int itemId = packet.getShortA();
    int itemX = packet.getLEShort();
    int itemY = packet.getLEShort();
    Remarks: When this packet is received, it's possible the player isn't on the spot yet or that the item has already been claimed by someone else.
    -------------------------------------------------------------------

    Name: Operate equipment
    Number: 107
    Purpose: The players wants to operate equipment (a wielded item).
    Data Sent: itemSlot, parentUID, itemId
    How to receive:
    Code:
    int slot = packet.getShortA();
    int parentUID = packet.getInt();
    int itemId = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Remove Friend
    Number: 122
    Purpose: Signals the player wants to remove a friend.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: WieldPacket
    Number: 124
    Purpose: A player attempts to wear an item.
    Data Sent: itemId, itemSlot, unknown.
    How to receive:
    Code:
    int itemSlot = packet.getLEShortA() & 0xFFFF;
    int itemId = packet.getShort() & 0xFFFF;
    int unknown = packet.getInt2();
    Remarks: /
    -------------------------------------------------------------------

    Name: Add Friend
    Number: 131
    Purpose: Signals the player wants to add a friend.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: Use Item On Object
    Number: 134
    Purpose: Indicates the player has used an item on an object
    Data Sent: objectX, objectY, objectId, inventorySlot, inventoryItemId, unknown.
    How to receive:
    Code:
    int objX = packet.getShortA();
    int slot = packet.getShortA();
    int objID = packet.getLEShort() & 0xFFFF;
    int objY = packet.getLEShortA() & 0xFFFF;
    int unknown = packet.getInt1();
    int itemId = packet.getLEShort() & 0xFFFF;
    Remarks: Uses are such as using flax on a spinning wheel. The packets is sent as soon as the click occurs. The player may not be close enough.
    -------------------------------------------------------------------

    Name: ItemOptionPacket3 //Empty
    Number: 141
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: ObjectOptionPacket2 //Guide patch,
    Number: 145
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: QuietPacket1
    Number: 149
    Purpose: UNKNOWN SO FAR
    Data Sent: UNKNOWN
    How to receive: UNKNOWN
    Remarks: UNKNOWN
    -------------------------------------------------------------------

    Name: POINTLESS PACKET? AT LOGIN
    Number: 150
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Add Ignore
    Number: 152
    Purpose: Signals the player wants to add an ignore.
    Data Sent: playerNameLong
    How to receive:
    Code:
    long playerLong = packet.getLong();
    Remarks: /
    -------------------------------------------------------------------

    Name: Eighth Interface Option
    Number: 154
    Purpose: Tells the server an eighth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Tenth Interface Option
    Number: 156
    Purpose: Tells the server a tenth interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Use Magic On NPC
    Number: 157
    Purpose: Indicates the player wants to use a spell on an NPC.
    Data Sent: unknown, spellId, npcIndex.
    How to receive:
    Code:
    int unknown = packet.getShort() & 0xFFFF;
    int spellId = packet.getLEShort() & 0xFFFF;
    int spellBookId = packet.getLEShort() & 0xFFFF;
    int npcIndex = packet.getLEShortA() & 0xFFFF;
    Remarks: The spellId is actualy the childId within the current spellBook (spellBookId (parentId of the childId)).
    -------------------------------------------------------------------

    Name: Trade Or PickPocket NPC
    Number: 160
    Purpose: Indicates the player either tries to trade with the NPC or pickpocket him.
    Data Sent: npcIndex.
    How to receive:
    Code:
    int npcIndex = packet.getLEShort() & 0xFFFF;
    Remarks: This packet is shared by trade and pickpocket. If someone knows an npc with both trade and pickpocket, please tell me.
    -------------------------------------------------------------------

    Name: Join/Leave ClanChat
    Number: 163
    Purpose: The player either wants to join or leave a clanChat.
    Data Sent: clanChatOwnerNameAsLong
    How to receive:
    Code:
    long clanChatOwnerNameAsLong = packet.getLong();
    Remarks: The player wants to leave a clanChat when the long is 0.
    -------------------------------------------------------------------

    Name: SwitchItemPacket
    Number: 166
    Purpose: Indicates an Item has switched slots.
    Data Sent: fromSlot, toSlot, unknown, parentUID
    How to receive:
    Code:
    int toSlot = packet.getLEShortA() & 0xFFFF;
    int unknown = packet.getByteS();
    int parentUID = packet.getInt2();
    int fromSlot = packet.getLEShort() & 0xFFFF;
    Remarks: It's important to have this packet, otherwise client and server could get out of sync. This would be a problem if you have protection built in your server (anti dupe for example).
    -------------------------------------------------------------------

    Name: ClickPacket
    Number: 167
    Purpose: Triggered whenever a player clicks something.
    Data Sent: TODO
    How to receive: TODO
    Remarks: You may very well ignore this one (or handle it as a quietPacket) as it's not likely this is useful information for your server.
    -------------------------------------------------------------------

    Name: ArrowsPressedPacket
    Number: 169
    Purpose: Triggered when the arrowKeys are used (camera rotation in the normal case).
    Data Sent: cameraUpDownRotation, cameraLeftRightRotation.
    How to receive:
    Code:
    int cameraUpDownRotation = packet.getLEShort() & 0xFFFF;
    int cameraLeftRightRotation = packet.getLEShort() & 0xFFFF;
    Remarks: You may very well ignore this one (or handle it as a quietPacket).
    CameraLeftRightRotation lies in the range: 0 – 2047 (2048 would be a full rotation).
    CameraUpDownRotation lies in the range: 128 – 383.
    -------------------------------------------------------------------

    Name: ObjectOptionPacket5 //climb down stairs (if climb and climbup)
    Number: 174
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: SIGNAL LOGGED IN
    Number: 176
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Examine NPC
    Number: 178
    Purpose: Triggered when the player examines an NPC.
    Data Sent: npcType.
    How to receive:
    Code:
    int npcType = packet.getShortA();
    Remarks: The examination of the NPC should be sent.
    -------------------------------------------------------------------

    Name: PingPacket This is not a pingpacket, needs to be updated.
    Number: 186
    Purpose: To ping the server.
    Data Sent: None
    How to receive: /
    Remarks: None yet.
    -------------------------------------------------------------------

    Name: Use Magic On GroundItem
    Number: 190
    Purpose: Indicates the player wants to use a spell on a groundItem.
    Data Sent: itemX, itemY, itemId, spellId, unknown.
    How to receive:
    Code:
    int itemX = packet.getShortA() & 0xFFFF;
    int itemId = packet.getShortA() & 0xFFFF;
    int itemY = packet.getLEShort() & 0xFFFF;
    int spellId = packet.getLEShort() & 0xFFFF;
    int spellBookId = packet.getLEShort() & 0xFFFF;
    int unknown = packet.getShortA() & 0xFFFF;
    Remarks: Foremost use is Telegrab.
    -------------------------------------------------------------------

    Name: Seventh Interface Option
    Number: 192
    Purpose: Tells the server a seventh interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Attack NPC
    Number: 196
    Purpose: Indicates the player has clicked the attack option on an NPC.
    Data Sent: npcIndex.
    How to receive:
    Code:
    int npcIndex = packet.getLEShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: CommandPacket
    Number: 202
    Purpose: Sends a command to the server.
    Data Sent: The commandString
    How to receive:
    Code:
    String commandString = packet.getRS2String();
    Remarks: None
    -------------------------------------------------------------------

    Name: ObjectOptionPacket1 //Inspect patch, climb up stairs (if climb and climb down), prospect rock //looks like SECONDARY option
    Number: 203
    Purpose: UPDATE
    Data Sent:
    How to receive:
    Remarks:
    -------------------------------------------------------------------

    Name: Use Item On Player
    Number: 204
    Purpose: An Item has been used on another player.
    Data Sent: itemId, itemSlot, playerIndex, unknown.
    How to receive:
    Code:
    int itemId = packet.getShort() & 0xFFFF;
    int playerIndex = packet.getShortA() & 0xFFFF;
    int unknown = packet.getInt1();
    int itemSlot = packet.getShortA() & 0xFFFF;
    Remarks: Uses include healing other players and giving items to other players.
    -------------------------------------------------------------------

    Name: Use Magic On Object
    Number: 205
    Purpose: A player wants to cast a spell on an object.
    Data Sent: objectId, objectX, objectY, spellId, unknown.
    How to receive:
    Code:
    int objectId = packet.getShortA() & 0xFFFF;
    int objectX = packet.getLEShortA() & 0xFFFF;
    int spellBookId = packet.getLEShort() & 0xFFFF;
    int spellId = packet.getLEShort() & 0xFFFF;
    int unknown = packet.getShortA() & 0xFFFF;
    int objectY = packet.getLEShortA() & 0xFFFF;
    Remarks: Foremost use is enchanting obelisks.
    -------------------------------------------------------------------

    Name: Use Item On Item
    Number: 206
    Purpose: An item has been used with another item (both inventory).
    Data Sent: sourceSlot, sourceItemId, targetSlot, targetItemId, unknown1, unknown2
    How to receive:
    Code:
    int sourceSlot = packet.getShort() & 0xFFFF;
    int unknown1 = packet.getInt1();
    int sourceItemId = packet.getLEShortA() & 0xFFFF;
    int targetSlot = packet.getLEShort() & 0xFFFF;
    int unknown2 = packet.getInt1();
    int targetItemId = packet.getLEShortA() & 0xFFFF;
    Remarks: The 2 unknown variable might be used to put the different items into different categories, although this hasn't been proved yet.
    -------------------------------------------------------------------

    Name: Use Item On GroundItem
    Number: 208
    Purpose: The player has used an inventoryItem with a groundItem.
    Data Sent: itemSlot, itemId, groundItemX, groundItemY, groundItemId, parentUID.
    How to receive:
    Code:
    int itemSlot = packet.getShort() & 0xFFFF;
    int groundItemY = packet.getShortA();
    int groundItemId = packet.getLEShort() & 0xFFFF;
    int groundItemX = packet.getLEShortA() & 0xFFFF;
    int parentUID = packet.getInt2();
    Remarks: Uses include firemaking (using tinderbox with logs on the ground).
    ParentUID is the location of the interface in which the selected item's located.
    -------------------------------------------------------------------

    Name: ActionButtons
    Number: 215
    Purpose: Tells the server an actionButton has been activated.
    Data Sent: buttonId
    How to receive:
    Code:
    final int buttonId = packet.getInt();
    Remarks: /
    -------------------------------------------------------------------

    Name: Examine Object
    Number: 226
    Purpose: Triggered when the player examines an object.
    Data Sent: objectId.
    How to receive:
    Code:
    int objectId = packet.getLEShort() & 0xFFFF;
    Remarks: The examination of the object should be sent.
    -------------------------------------------------------------------

    Name: First Interface Option
    Number: 234
    Purpose: Tells the server a first interface option has been clicked.
    Data Sent: buttonId, itemContainerSlot.
    How to receive:
    Code:
    int buttonId = packet.getInt();
    int itemContainerSlot = packet.getShort() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: IdlePacket
    Number: 236
    Purpose: Tells the server the mouse and keyboard have been idle for some time.
    Data Sent: None
    How to receive: /
    Remarks: This packet is sent after 90 seconds (1,5 minutes) which equals to 4500 cycles at 50Hz.
    After this initial idlePacket, it is sent again every 10 seconds which equals 500 cycles at 50Hz.
    -------------------------------------------------------------------

    Name: Use Magic On InventoryItem
    Number: 238
    Purpose: Indicates the player wants to use a spell on an inventoryItem.
    Data Sent: itemSlot, itemId, spellId, interfaceId, unknown2
    How to receive:
    Code:
    int interfaceId = packet.getInt2();
    int itemId = packet.getLEShort() & 0xffff;
    int unknown2 = packet.getLEShort() & 0xffff;
    int itemSlot = packet.getShort() & 0xffff;
    int spellBookId = packet.getShort() & 0xFFFF;
    int spellId = packet.getShort() & 0xFFFF;
    Remarks: The spellId is actualy the childId within the current spellBook (spellBookId (parentId of the childId)).
    -------------------------------------------------------------------

    Name: Remove equipment
    Number: 241
    Purpose: Indicates an attempt of the player to remove equipment by clicking it on the equipment interface.
    Data Sent: itemSlot, parentUID, itemId
    How to receive:
    Code:
    int itemSlot = packet.getShort() & 0xFFFF;
    int parentUID = packet.getLEInt();
    int itemId = packet.getLEShortA() & 0xFFFF;
    Remarks: /
    -------------------------------------------------------------------

    Name: Enter Amount
    Number: 249
    Purpose: Sends the result of an enter amount input.
    Data Sent: input
    How to receive:
    Code:
    int amount = packet.getInt();
    Remarks: The context will have to be determined based on the current open interface.
    -------------------------------------------------------------------

    Name: Change ClanChatFriend Rank
    Number: 250
    Purpose: Requests a change of rank for a (clanChat)friend.
    Data Sent: rank, clanChatFriendNameAsLong
    How to receive:
    Code:
    int rank = packet.getByteC();
    long clanChatFriendNameAsLong = packet.getLong1();
    Remarks: Ranks: Not in clan/Normal Friend (0), Recruit (1), Corporal (2), Sergeant (3), Lieutenant (4), Captain (5), General (6), Channel Owner (7).
    -------------------------------------------------------------------

    Name: chatStatusUpdate
    Number: 251
    Purpose: Sends the public, private and trade chatMode after clicking on one of the possible chat modes at the relevant types.
    Data Sent: publicChatMode, privateChatMode, tradeChatMode.
    How to receive:
    Code:
    int publicChatMode = packet.get();
    int privateChatMode = packet.get();
    int tradeChatMode = packet.get();
    Remarks: This packet gets sent before any of the 4 chatMode packets the only type that doesn't send this packet is the clanChat one. This packet is smaller than any of the chatMode packets (3 vs 6) but it does lack the clanChatMode being sent. If you don't wish to keep track of the clanChatMode, this packet is more usefull than the 4 chatMode packets together.
    Modes: 0 is ON, 1 is FRIENDS, 2 is OFF and 3 is HIDDEN (only for public chat).
    -------------------------------------------------------------------

    Name: Private Message
    Number: 252
    Purpose: Receives a private message from a player.
    Data Sent: toPlayerLong, chatText
    How to receive:
    Code:
    long toPlayerLong = packet.getLong();
    int chatTextSize = (byte) (packet.getLength()-8);
    byte[] chatText = new byte[256];
    packet.get(chatText, 0, chatTextSize);
    Remarks: The private messages needs to be sent back to the sender and sent forward to the receiver.
    -------------------------------------------------------------------


    As last I'd like to ask you (again) to report any missing packets/packets you know/errors.

    Thanks for reading, I hope this thread grows and becomes valued to 474 coders.
    Reply With Quote  
     

  13. #8  
    Registered Member
    thim slug's Avatar
    Join Date
    Nov 2010
    Age
    23
    Posts
    4,142
    Thanks given
    1,079
    Thanks received
    1,090
    Rep Power
    5000
    Nice job a lot of information there, haven't read through it but, one thing: "The packets are key to good communication between client and server.". They're not really the key to good communication between client and server though are they lol, they are communication between server and client.
    Reply With Quote  
     

  14. #9  
    Registered Member
    TheChosenOne's Avatar
    Join Date
    Jan 2013
    Posts
    976
    Thanks given
    47
    Thanks received
    160
    Rep Power
    366
    Quote Originally Posted by Leopold Butters Stotch View Post
    Nice job a lot of information there, haven't read through it but, one thing: "The packets are key to good communication between client and server.". They're not really the key to good communication between client and server though are they lol, they are communication between server and client.
    Works both ways .
    Reply With Quote  
     

  15. Thankful user:


  16. #10  
    Registered Member
    Join Date
    Aug 2008
    Posts
    2,420
    Thanks given
    721
    Thanks received
    595
    Rep Power
    1233
    Soo... You just reposted [Only registered and activated users can see links. ]?
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [PI] Dialogues In Depth Guide for the Beginner
    By ItsGoml in forum Tutorials
    Replies: 57
    Last Post: 08-15-2013, 10:23 PM
  2. [474] In-depth analysis of the 474 protocol.
    By Its paris in forum Informative Threads
    Replies: 204
    Last Post: 05-20-2013, 07:05 PM
  3. Replies: 0
    Last Post: 02-17-2012, 08:18 AM
  4. Replacing characters in the 474 server
    By Avalanche in forum Tutorials
    Replies: 10
    Last Post: 07-31-2008, 11:59 PM
  5. A closer look at the if... Statement
    By Jay Dawg in forum Tutorials
    Replies: 0
    Last Post: 05-31-2008, 12:09 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •