### Get Player List (Static) Source: https://github.com/jonyrlima/tfg/blob/main/scripts/custom-tfg/t_personalmessage.txt This function appears to pre-populate player list tags, potentially for testing or a fixed display. It sets a maximum of 50 players and a corresponding count. ```script [FUNCTION list_getplayers_list] // Function I used to list page system for x 1 50 try ctag.list_p>=01 end ctag.list_numplayers=50 ``` -------------------------------- ### Ultima Online Action Codes Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm This section lists various action codes and special byte values used in Ultima Online packets. Examples include '0x58 (X) - Open Door', 'BYTE null termination (0x00)', and '0xc7 - action'. It also mentions specific action strings like 'bow' and 'salute' which are associated with null-terminated strings within action data. ```C++ #define ACTION_OPEN_DOOR 0x58 #define NULL_TERMINATOR 0x00 #define ACTION_CODE 0xc7 // Example usage within packet processing: // if (packet.actionCode == ACTION_CODE) { // char* actionString = (char*)(packet.data + offset); // if (strcmp(actionString, "bow") == 0) { /* handle bow */ } // else if (strcmp(actionString, "salute") == 0) { /* handle salute */ } // } ``` -------------------------------- ### City Invasion Event Configuration and Functions (SCP) Source: https://context7.com/jonyrlima/tfg/llms.txt Configures and manages a city invasion event. It defines parameters like monster count, announcement location, and special loot. Includes functions to start and stop the invasion, spawning announcement and control items, and broadcasting messages to players. Uses SCP scripting language. ```scp // City invasion configuration [DEFNAME city_invasion_settings] CITY_INVASION_MONSTERS_COUNT 120 CITY_INVASION_NAME INVASAO HALLOWEEN CITY_INVASION_ANNOUNCEMENT_LOCATION 2320,1209 CITY_INVASION_REMOVAL_RANGE 120 CITY_INVASION_RANDOM_LOCATION 1 // 1 = random, 0 = spawn locations CITY_INVASION_RADIUS 70 // Radius for random locations CITY_INVASION_COLORS {080e 1 0bb2 1} // Color variants CITY_INVASION_SPECIAL_LOOT {i_halloween_2019_ticket 1 0 99} CITY_INVASION_SPECIAL_LOOT_STRONG {i_halloween_2019_ticket 1 0 10} // Start invasion function [FUNCTION f_start_city_invasion] IF () f_stop_city_invasion // Stop existing invasion ENDIF LOCAL.CITY_INVASION_ANNOUNCEMENT_LOCATION IF ( >= 2) LOCAL.CITY_INVASION_ANNOUNCEMENT_LOCATION ENDIF FORINSTANCES i_control_city_invasion REMOVE ENDFOR serv.newitem i_city_invasion_announcement NEW.P NEW.UPDATE serv.newitem i_control_city_invasion NEW.P NEW.MOVE N NEW.ATTR 090 NEW.TAG.NO_PVP 1 NEW.UPDATEX VAR.CITY_INVASION_CONTROL = SERV.B @70 [] Comecou !!! A invasao esta acontecendo em () ! Corra ! RETURN 1 // Stop invasion function [FUNCTION f_stop_city_invasion] FORINSTANCES i_city_invasion_announcement REMOVE ENDFOR FORINSTANCES i_control_city_invasion REMOVE ENDFOR VAR.CITY_INVASION_CONTROL SERV.B @70 [] Evento encerrado ! Obrigado aos que participaram ! ``` -------------------------------- ### C++ Traditional Type Casting Example Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/language/typecast.html Demonstrates traditional C++ type casting for basic data types like double to int using C-style and functional cast notations. This method is suitable for fundamental types but can be unsafe when applied indiscriminately to classes. ```C++ int i; double d; i = (int) d; // or i = int (d); ``` -------------------------------- ### 0xCA: Get User Server Ping Packet Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Similar to 0xC9, this packet requests ping information from the server for a specific user context. ```APIDOC ## 0xCA: Get User Server Ping Packet ### Description This packet is similar to the 0xC9 packet and is used to measure network ping to the server, potentially in a user-specific context. The client sends its tick count, and the server responds with its own tick count. ### Method Bi-directional (Client to Server, Server replies) ### Endpoint N/A ### Parameters #### Body - **cmd** (BYTE) - Command byte - **sequence** (BYTE) - Sequence number, starts at 1 and wraps around at 255. - **tickcount** (BYTE[4]) - The client's current tick count. ### Request Example ```json { "cmd": "CA", "sequence": "01", "tickcount": "00000000" } ``` ### Response #### Success Response (N/A) N/A (Server replies with a similar packet) #### Response Example ```json { "cmd": "CA", "sequence": "01", "tickcount": "12345678" // Server's tick count } ``` ``` -------------------------------- ### Client/Server State and Configuration Subcommands Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Subcommands for client and server status updates, configuration, and interaction. ```APIDOC ## Client/Server State and Configuration Subcommands ### Subsubcommand 6: Party Can Loot Me? **Note:** Client message **Structure:** - BYTE canloot (0=no, 1=yes) ### Subcommand 8: Set cursor hue / Set MAP **Note:** Server Message **Structure:** - BYTE hue (0 = Felucca, unhued / BRITANNIA map. 1 = Trammel, hued gold / BRITANNIA map, 2 = (switch to) ILSHENAR map) ### Subcommand 0x0b: Client Language **Note:** Client Message, send once at login **Structure:** - BYTE[3] language (ENU, for English) ### Subcommand 0x0c: Closed Status Gump **Note:** Server Message **Structure:** - BYTE[4] id (character id) ### Subcommand 0x13: Request popup menu **Note:** Client Message **Structure:** - BYTE[4] id (character id) ### Subcommand 0x15: Popup Entry Selection **Structure:** - BYTE[4] Character ID - BYTE[2] Entry Tag for line selected provided in subcommand 0x14 ``` -------------------------------- ### 0xC9: Get Area Server Ping Packet Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Client sends this packet with its tick count to request ping information from the server. The server replies with the same packet ID and its tick count. ```APIDOC ## 0xC9: Get Area Server Ping Packet ### Description This packet is used to measure the network ping to the server. The client sends its current tick count, and the server responds with its own tick count. By comparing these values over several packets, the client can estimate the ping. ### Method Bi-directional (Client to Server, Server replies) ### Endpoint N/A ### Parameters #### Body - **cmd** (BYTE) - Command byte - **sequence** (BYTE) - Sequence number, starts at 1 and wraps around at 255. - **tickcount** (BYTE[4]) - The client's current tick count. ### Request Example ```json { "cmd": "C9", "sequence": "01", "tickcount": "00000000" } ``` ### Response #### Success Response (N/A) N/A (Server replies with a similar packet) #### Response Example ```json { "cmd": "C9", "sequence": "01", "tickcount": "12345678" // Server's tick count } ``` ``` -------------------------------- ### Bring Up House/Boat Placement View Packet (0x9A) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Packet to initiate the placement view for houses or boats. ```APIDOC ## BRING UP HOUSE/BOAT PLACEMENT VIEW PACKET (0x9A) ### Description Packet to initiate the placement view for houses or boats. Can be sent by server (0x01) or client (0x00). ### Method N/A (Packet structure) ### Endpoint N/A (Packet structure) ### Parameters #### Packet Fields - **cmd** (BYTE) - Command identifier - **request** (BYTE) - Request type (0x01 from server, 0x00 from client) - **ID of deed** (BYTE[4]) - ID of the deed for placement - **unknown** (BYTE[12]) - Unknown field (all 0) - **multi model** (BYTE[2]) - Multi-use item model (e.g., 0x4000) - **unknown** (BYTE[6]) - Unknown field (all 0) ``` -------------------------------- ### Player Configuration Commands Source: https://context7.com/jonyrlima/tfg/llms.txt Bash commands that allow players to configure various game settings, such as gate options, titles, robe appearance, and access to special shops. These commands personalize the player's experience. ```bash # Configuration commands .gateconf # Toggle gate configuration .gateoptions # Configure gate entry options .titulo # Change title display on paperdoll .toggle_special_robe_gump # Toggle special robe selection gump .vipshop # Open VIP shop menu .epshop # Trade event points for rewards ``` -------------------------------- ### Java SHA-256 Hashing Utility Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/uokr/uokr_encryption_POF.txt This function computes the SHA-256 hash of a given byte array. It utilizes the Java MessageDigest API and throws a NoSuchAlgorithmException if the algorithm is not available. ```java public static byte[] sha256(byte[] in) throws NoSuchAlgorithmException { MessageDigest digest = MessageDigest.getInstance("sha-256"); return digest.digest(in); } ``` -------------------------------- ### Player Information Commands Source: https://context7.com/jonyrlima/tfg/llms.txt A collection of bash commands providing players with information about game mechanics, player status, and server status. These commands are essential for players to track their progress and understand game dynamics. ```bash # Information commands .paragons # Show paragon spawn times and locations .myrank # Show PvP and PvM ranking .myeventpoints # Show event points earned .where # Show current coordinates .stats # Show fame, karma, and kills .statsfix # Refresh status display .online # Show number of players online .lista # List all players online ``` -------------------------------- ### 0xBF sub 0x14 (Server -> Client): KR Context Menu Display Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/uokr/uokr_packets.txt Displays the KR Context Menu. It includes an unk1 field, character serial, entry count, and iterated entries with cliloc ID, entry ID, and flags. ```APIDOC ## 0xBF sub 0x14 (Server -> Client): KR Context Menu Display ### Description Displays the KR Context Menu. This packet contains information about menu entries, including localized strings and entry-specific IDs. ### Method Server -> Client ### Endpoint N/A (Packet based) ### Parameters #### Packet Fields - **unk1** (byte[2]) - Unknown field, always 0x0002. - **char serial** (byte[4]) - The serial number of the character associated with the menu. - **entry count** (byte[1]) - The number of context menu entries. - **Entries** (foreach entry): - **cliloc id** (byte[4]) - Localized string ID from LocalizedStrings.uop. - **entry id** (byte[2]) - The ID of the context menu entry. - **flags** (byte[2]) - Flags associated with the entry. ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Java Hexadecimal String Parsing Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/uokr/uokr_encryption_POF.txt This utility function parses a space-separated hexadecimal string into a byte array. Each part of the string is converted from its hexadecimal representation to a byte, ensuring values are within the 0-255 range. ```java public static byte[] parseHex(String str) { String[] parts = str.split(" "); byte[] res = new byte[parts.length]; for (int i = 0; i < parts.length; ++i) { res[i] = (byte) (Integer.valueOf(parts[i], 16) & 0xFF); } return res; } ``` -------------------------------- ### Set Minimum CMake Version and Include Modules (CMake) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/src/CMakeLists.txt Sets the minimum required CMake version to 3.0.0 and includes necessary CMake modules ('CMakeSources.cmake' and 'CMakeGitStatus.cmake'). These are fundamental setup steps for the build configuration. ```cmake CMAKE_MINIMUM_REQUIRED (VERSION 3.0.0) INCLUDE ("CMakeSources.cmake") INCLUDE ("CMakeGitStatus.cmake") ``` -------------------------------- ### Connect to Game Server Packet (0x90) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Packet used to establish a connection to the game server. ```APIDOC ## CONNECT TO GAME SERVER PACKET (0x90) ### Description Packet used to establish a connection to the game server. ### Method N/A (Packet structure) ### Endpoint N/A (Packet structure) ### Parameters #### Packet Fields - **cmd** (BYTE) - Command identifier - **gameServer IP** (BYTE[4]) - Game server IP address - **gameServer port** (BYTE[2]) - Game server port - **new key** (BYTE[4]) - New connection key ``` -------------------------------- ### C++ typeid Operator for Type Identification Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/language/typecast.html Shows how to use the typeid operator to obtain runtime type information. It returns a reference to a type_info object, which can be used for comparisons or to get the type name via the name() method. ```cpp #include #include class CDummy { }; int main () { CDummy* a = new CDummy; CDummy* b = new CDummy; if (typeid(a) != typeid(b)) { std::cout << "a and b are of different types:\n"; std::cout << "a is: " << typeid(a).name() << '\n'; std::cout << "b is: " << typeid(b).name() << '\n'; } return 0; } ``` -------------------------------- ### Player Combat and Action Commands Source: https://context7.com/jonyrlima/tfg/llms.txt Bash commands related to combat and player actions, including unequipping items, toggling battle message details, checking warmode, and viewing PvM damage. These commands provide tactical advantages and information. ```bash # Combat and action commands .strip # Remove all clothes .armorunequip # Remove all armor .detail # Toggle battle message details .war_status # Check warmode status .mypvmdamage # Check PvM event damage ``` -------------------------------- ### Java AES/CFB Decryption Implementation Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/uokr/uokr_encryption_POF.txt This main method demonstrates AES decryption in CFB mode. It includes generating cryptographic keys, deriving a shared secret, and decrypting a provided ciphertext using the calculated key and initialization vector. ```java public static void main(String[] args) throws Exception { Formatter f = new Formatter(System.out); /** * The following values are chosen by the server and may differ. */ BigInteger g = BigInteger.valueOf(3); BigInteger p1 = new BigInteger( new byte[] { 0x00, (byte) 0xF6, 0x19, 0x45, (byte) 0xEA, (byte) 0x54, (byte) 0x89, (byte) 0xB0, (byte) 0xB6, (byte) 0xF6, (byte) 0x2E, (byte) 0x24, (byte) 0xD4, (byte) 0x6D, (byte) 0xE5, (byte) 0x12, (byte) 0x9B }); BigInteger privateKey = new BigInteger(new byte[] { 0x02, (byte) 0xB3, (byte) 0x43, (byte) 0x65, (byte) 0x0B, (byte) 0x45, (byte) 0xD4, (byte) 0xAA }); @SuppressWarnings("unused") BigInteger publicKey = g.modPow(privateKey, p1); /* * Here you would send 0xE3 with (BEREncode(g), BEREncode(p1), * publicKey.toByteArray(), 0x20, IV) to the client */ /* * Here we continue after receiving 0xE4 from the client. */ BigInteger otherPublic = new BigInteger(rawOtherPublic); // Calculate the shared session secret BigInteger realKey = otherPublic.modPow(privateKey, p1); byte[] rawRealKey = realKey.toByteArray(); System.out.print("DYNAMIC SECRET: "); for (byte b : rawRealKey) { f.format("%02X ", b); } System.out.println('\n'); System.out .println("-------------------------------------------------------------------------------"); // The following values are harcoded in the client BigInteger staticPublicKey = new BigInteger( parseHex("72 0E EF C3 38 13 27 5A 18 F8 AB 8A 24 68 CE 62")); BigInteger staticPrivateKey = new BigInteger( parseHex("00 00 00 00 00 00 00 00 02 B3 43 65 0B 45 D4 AA")); BigInteger p2 = new BigInteger( parseHex("00 c7 77 96 c9 ea 6a 9e 9f 71 a7 27 19 d6 77 80 43")); // This could also be included as a constant as the value is always the same. BigInteger staticSecret = staticPublicKey.modPow(staticPrivateKey, p2); System.out.print("STATIC SECRET: "); for (byte b : staticSecret.toByteArray()) { f.format("%02X ", b); } System.out.println('\n'); System.out .println("-------------------------------------------------------------------------------"); // Compute AES Key from staticSecret|dynamicSecret byte[] sha256Input = new byte[32]; byte[] rawStaticSecret = staticSecret.toByteArray(); System.arraycopy(rawStaticSecret, rawStaticSecret.length - 0x10, sha256Input, 0, 0x10); System.arraycopy(rawRealKey, rawRealKey.length - 0x10, sha256Input, 0x10, 0x10); SecretKeySpec key = new SecretKeySpec(sha256(sha256Input), "AES"); IvParameterSpec ivParam = new IvParameterSpec(rawIv); Cipher c = Cipher.getInstance("AES/CFB/NoPadding"); c.init(Cipher.DECRYPT_MODE, key, ivParam); // Decode the value sent by the client byte[] plain = c.update(ciphertext); for (byte b : plain) { f.format("%02X ", b); } System.out.println('\n'); } ``` -------------------------------- ### Player Utility Commands Source: https://context7.com/jonyrlima/tfg/llms.txt A set of bash commands offering utility functions for players, including buffer status, door manipulation, bank operations, and spell information. These commands streamline common in-game tasks. ```bash # Utility commands .buffer # Show mining, fishing, lumber buffers .open_door # Open and close doors banker cheque 5000 # Create a check for 5000 gold bank balance # Show total money in bank .spells # Show spell information .zerarkills # Zero kills (can use once per character) ``` -------------------------------- ### Player Quick Use Commands Source: https://context7.com/jonyrlima/tfg/llms.txt A set of bash commands designed for quick item usage from the backpack, including bandages, potions, and scrolls for spells like flamestrike and chain lightning. These commands streamline combat and healing actions. ```bash # Quick use commands (items must be in backpack) .bandage # Use bandages with free targeting .totalmana # Drink total mana potion .gheal # Drink greater heal potion .refresh # Drink total refresh potion .gcure # Drink greater cure potion .lifeboost # Drink life boost potion .manaboost # Drink mana boost potion .refilling # Drink refilling potion .inv # Drink invisibility potion .fs # Use flamestrike scroll with free targeting .cl # Use chain lightning scroll with free targeting ``` -------------------------------- ### UO:KR E4 Packet Structure Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/uokr/uokr_encryption.txt Defines the structure of the 0xE4 packet used in UO:KR network communication. This packet primarily contains the public key, which is part of the key exchange or cryptographic setup process between the client and server. ```text byte[1] packet cmd (0xe4) byte[2] packet length byte[4] length public key byte[length public key] public key ``` -------------------------------- ### Player Runebook Commands Source: https://context7.com/jonyrlima/tfg/llms.txt Bash commands for managing runebooks, including recalling and gating to specific locations, and setting primary runebooks for quick access. These commands enhance player mobility and navigation. ```bash # Runebook commands .recall 1,5 # Recall using page 1, position 5 of runebook .gate 2,3 # Gate using page 2, position 3 of runebook .recall set # Set primary runebook for quick recall .gate set # Set primary runebook for quick gate ``` -------------------------------- ### Quest Properties and Commands Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/Revisions.txt Defines properties and commands for managing quests within the game. These can be accessed and modified via scripts to control quest flow and player interaction. Includes properties like NAME, OBJECTIVE, PRIZE, and commands like START, FINISH, CANCEL. ```lua COMPLETE FAILED NAME OBJECTIVE OBJECTIVE.x.* PRIZE PRIZE.x.* RESIGN SOURCE SOURCE.* STATUS TEXT TIMELEFT TIMELIMIT UNCOMPLETE CANCEL FINISH START ``` -------------------------------- ### Create Character Packet (0x00) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Details the structure of the packet used to create a new character, including character name, password, stats, and initial skills. ```APIDOC ## Create Character Packet (0x00) ### Description This packet is used to create a new character in the game. It includes all necessary information for character initialization, such as name, appearance, and starting stats. ### Method N/A (Packet Structure) ### Endpoint N/A (Packet Structure) ### Parameters #### Packet Structure - **cmd** (BYTE) - Packet identifier (0x00) - **pattern1** (BYTE[4]) - Fixed pattern (0xedededed) - **pattern2** (BYTE[4]) - Fixed pattern (0xffffffff) - **pattern3** (BYTE) - Fixed pattern (0x00 or 0xFF for Krrios' client) - **char name** (BYTE[30]) - The desired name for the character. - **char password** (BYTE[30]) - The password for the character. - **sex** (BYTE) - 0 for male, 1 for female. - **str** (BYTE) - Strength attribute (10-45, sum with dex and int = 65). - **dex** (BYTE) - Dexterity attribute (10-45, sum with str and int = 65). - **int** (BYTE) - Intelligence attribute (10-45, sum with str and dex = 65). - **skill1** (BYTE) - First skill identifier (0-45). - **skill1value** (BYTE) - Value for the first skill (0-50, sum with other skill values = 100). - **skill2** (BYTE) - Second skill identifier (0-45). - **skill2value** (BYTE) - Value for the second skill (0-50, sum with other skill values = 100). - **skill3** (BYTE) - Third skill identifier (0-45). - **skill3value** (BYTE) - Value for the third skill (0-50, sum with other skill values = 100). - **skinColor** (BYTE[2]) - Skin color (0x3EA to 0x422, exclusive). - **hairStyle** (BYTE[2]) - Hair style identifier (0x203B to 0x204A, exclusive, excluding 0x203D to 0x2044). - **hairColor** (BYTE[2]) - Hair color (0x44E to 0x4AD, exclusive). - **facial hair** (BYTE[2]) - Facial hair style identifier (0x203E to 0x204D). - **facial hair color** (BYTE[2]) - Facial hair color (0x44E to 0x4AD, exclusive). - **location** (BYTE[2]) - Starting location identifier. - **unknown1** (BYTE[2]) - Reserved for future use. - **slot** (BYTE[2]) - Character slot identifier. - **clientIP** (BYTE[4]) - The IP address of the client. - **shirt color** (BYTE[2]) - Shirt color. - **pants color** (BYTE[2]) - Pants color. ### Notes - Str, Dex, and Int must sum to 65. - Str, Dex, and Int must be between 10 and 45, inclusive. - Skill identifiers must be unique and between 0 and 45. - Skill values must sum to 100 and be between 0 and 50, inclusive. - Color and style ranges are specified for appearance customization. ``` -------------------------------- ### Construct OPLInfo Packet Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/new_tooltips_info.txt This C# constructor initializes an `OPLInfo` packet, inheriting from a `Packet` base class. It writes the entity's serial and hash values to the stream. The constructor specifies a packet type (0xDC) and an initial capacity (9). ```csharp public OPLInfo( ObjectPropertyList list ) : base( 0xDC, 9 ) { m_Stream.Write( (int) list.Entity.Serial ); m_Stream.Write( (int) list.Hash ); } ``` -------------------------------- ### Packet Type 0x74: Open Buy Window Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Opens a buy window for a vendor, displaying items for sale. ```APIDOC ## Packet Type 0x74: Open Buy Window ### Description Opens a buy window for a vendor, displaying items available for purchase. ### Method N/A (Packet Structure) ### Endpoint N/A (Packet Structure) #### Parameters * **cmd** (BYTE) - Command identifier for this packet. * **blockSize** (BYTE[2]) - Size of the packet excluding the initial command byte. * **vendorID** (BYTE[4]) - The vendor's unique identifier, combined with 0x40000000. * **# of items** (BYTE) - The total number of items available in the window. For each item: * **price** (BYTE[4]) - The price of the item. * **length of text description** (BYTE) - The length of the item's description string. * **item description** (BYTE[length of text description]) - The null-terminated description of the item. ### Request Example ```json { "cmd": "byte", "blockSize": "bytes", "vendorID": "bytes", "numItems": "byte", "items": [ { "price": "bytes", "descriptionLength": "byte", "description": "string" } ] } ``` ### Response Example (Not Specified) ### Note This packet is typically preceded by a 'describe contents' packet (0x3c) and an 'open container' packet (0x24?). ``` -------------------------------- ### C++ Unsafe Class Type Casting Example Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/language/typecast.html Illustrates an unsafe type cast in C++ where a pointer to a CDummy object is cast to a CAddition pointer, leading to potential runtime errors or unexpected behavior when accessing members of the wrong class. This highlights the need for safer casting mechanisms. ```C++ #include class CDummy { int i; }; class CAddition { int x,y; public: CAddition (int a, int b) { x=a; y=b; } int result() { return x+y;} }; int main () { CDummy d; CAddition * padd; padd = (CAddition*) &d; cout << padd->result(); return 0; } ``` -------------------------------- ### Ultima Online Combat Ability Names Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm This lists various combat-related ability names found in the game data. These are likely used in packet payloads or game logic to identify specific player actions or spells. Examples include 'Incognito', 'Reflection', 'Mind Blast', 'Paralyze', 'Poison Field', and many others up to 'Summon Water Elemental'. ```text "35" - Incognito "36" - Reflection "37" - Mind Blast "38" - Paralyze "39" - Poison Field "40" - Summon Creature "41" - Dispel "42" - Energy Bolt "43" - Explosion "44" - Invisibility "45" - Mark "46" - Mass Curse "47" - Paralyze Field "48" - Reveal "49" - Chain Lightning "50" - Energy Field "51" - Flame Strike "52" - Gate "53" - Mana Vampire "54" - Mass Dispel "55" - Meteor Shower "56" - Polymorph "57" - Earthquake "58" - Energy Vortex "59" - Ressurection "60" - Summon Air Elemental "61" - Summon Daemon "62" - Summon Earth Elemental "63" - Summon Fire Elemental "64" - Summon Water Elemental ``` -------------------------------- ### Client to Server: Initial Login Packet Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/supported_packets.htm Handles the initial login process to the login server. Requires username and password. ```Java sendInitialLogin(String username, String password) ``` -------------------------------- ### Get Player List (Server Side) Source: https://github.com/jonyrlima/tfg/blob/main/scripts/custom-tfg/t_personalmessage.txt This server-side function is called for each client to populate the player list. It checks visibility settings (staff listing and private mode) and adds the player's UID to a temporary tag if they should be listed. It increments a counter for the total number of players to be listed. ```script [FUNCTION list_getplayers] // List players in CTAGs on the caller IF !() if ( > ) || (() && !()) return else src.ctag0.list_numplayers += 1 try src.ctag.list_p)>= endif ELSE if () && !() return else src.ctag0.list_numplayers += 1 try src.ctag.list_p)>= endif ENDIF ``` -------------------------------- ### 0xF1 (Client -> Server): MOVEMENT SYNC (maybe) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/uokr/uokr_packets.txt A packet, possibly for movement synchronization, sent automatically by the client once per minute. Contains unknown fields. ```APIDOC ## 0xF1 (Client -> Server): MOVEMENT SYNC (maybe) ### Description This packet is potentially used for movement synchronization and is sent automatically by the client every minute. It contains unknown data fields. ### Method Client -> Server ### Endpoint N/A (Packet based) ### Parameters #### Packet Fields - **packet cmd** (byte[1]) - The command byte, value is 0xF1. - **unk1** (byte[4]) - An unknown value, observed as 0x00000122. - **unk2** (byte[4]) - An unknown value. ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### 0xD7 Packet - Fight Book/System Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm This packet is related to the fight book or system, handling player abilities and weapon changes. ```APIDOC ## 0xD7 Packet - Fight Book/System ### Description This packet contains information related to the player's fight book or system, including selected abilities and potential weapon change notifications. ### Method N/A (Packet Structure) ### Endpoint N/A (Packet Structure) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **cmd** (BYTE) - Command byte. - **length** (BYTE[2]) - Length of the packet. - **serial** (BYTE[4]) - Player serial identifier. - **unknown** (BYTE[2]) - Always 0x19. - **unknown** (BYTE[4]) - Always 0. - **selected ability** (BYTE) - The selected ability icon (e.g., 1 for armor ignore, 2 for bleed attack, 13 for whirlwind attack). - **unknown** (BYTE) - Always 7. ### Request Example ```json { "cmd": "0xD7", "length": "...", "serial": "...", "unknown1": "0x19", "unknown2": "0x00000000", "selected_ability": "...", "unknown3": "7" } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ### Notes - When a weapon is changed, ability icons automatically change, but the client does not notify the server. - Fightbook only appears when common AOS is activated via 0xa9. ``` -------------------------------- ### Request Help Packet (0x9E) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Packet used to request help from the system. ```APIDOC ## REQUEST HELP PACKET (0x9E) ### Description Packet used to request help from the system. ### Method N/A (Packet structure) ### Endpoint N/A (Packet structure) ### Parameters #### Packet Fields - **cmd** (BYTE) - Command identifier - **0x00** (BYTE[257]) - Padding or unused bytes ``` -------------------------------- ### Packet Type 0x80: Login Request Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Initiates the login process by sending user credentials. ```APIDOC ## Packet Type 0x80: Login Request ### Description This packet is sent by the client to initiate the login process, providing user credentials. ### Method N/A (Packet Structure) ### Endpoint N/A (Packet Structure) #### Parameters * **cmd** (BYTE) - Command identifier for this packet. * **userid** (BYTE[30]) - The user's username. * **password** (BYTE[30]) - The user's password. * **unknown1** (BYTE) - An unknown field, not typically zero. ### Request Example ```json { "cmd": "byte", "userId": "string (padded to 30 bytes)", "password": "string (padded to 30 bytes)", "unknown1": "byte" } ``` ### Response Example (See 0x82 Packet for Login Denied) ``` -------------------------------- ### 0xD0 Packet Structure for Configuration Files Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Details the 0xD0 packet, used for dynamic length configuration files. It contains command, length, type, and an unknown encoded section. This packet is likely used for saving client configurations server-side and is sent during login. ```pseudo BYTE cmd BYTE[2] length; BYTE type; // file type, not sure of precise values BYTE[length-4] unknown; // encoded in some form ``` -------------------------------- ### Packet 0x1A: Object Information Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm This packet provides information about objects in the game world, including item IDs, model numbers, locations, and other properties. It has a variable length. ```APIDOC ## 0x1A Packet ### Description Provides detailed information about game objects, including items and corpses. ### Method N/A (Protocol Packet) ### Endpoint N/A (Protocol Packet) ### Parameters #### Structure - **cmd** (BYTE) - Command byte. - **blockSize** (BYTE[2]) - The size of the packet. - **itemID** (BYTE[4]) - The unique identifier for the item. - **model** (BYTE[2]) - The model number of the object. - **item count / model # for corpses** (BYTE[2]) - Item count or model number for corpses if itemID has a specific bit set. - **Incr Counter** (BYTE) - Increment model by this number, if model has a specific bit set. - **xLoc** (BYTE[2]) - The X-coordinate of the object's location. - **yLoc** (BYTE[2]) - The Y-coordinate of the object's location. - **direction** (BYTE) - The direction the object is facing, if yLoc has a specific bit set. - **zLoc** (BYTE) - The Z-coordinate (height) of the object. - **dye** (BYTE[2]) - Dye color information, if yLoc has a specific bit set. - **flag byte** (BYTE) - A flag byte for additional properties, if yLoc has another specific bit set. ### Request Example ```json { "cmd": "0x1A", "blockSize": "[size_bytes]", "itemID": "[item_id_bytes]", "model": "[model_bytes]", "item_count_or_corpse_model": "[value_bytes]", "incr_counter": "incr_byte", "xLoc": "[x_loc_bytes]", "yLoc": "[y_loc_bytes]", "direction": "direction_byte", "zLoc": "z_loc_byte", "dye": "[dye_bytes]", "flag_byte": "flag_byte" } ``` ### Response #### Success Response N/A (Protocol Packet) #### Response Example N/A (Protocol Packet) ``` -------------------------------- ### Game Server Login Packet (0x93) Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Packet used for logging into the game server. ```APIDOC ## GAME SERVER LOGIN PACKET (0x93) ### Description Packet used for logging into the game server. ### Method N/A (Packet structure) ### Endpoint N/A (Packet structure) ### Parameters #### Packet Fields - **cmd** (BYTE) - Command identifier - **key used** (BYTE[4]) - Key used for login - **sid** (BYTE[30]) - Session ID - **password** (BYTE[30]) - User password ``` -------------------------------- ### Miscellaneous Subcommands Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Documentation for other miscellaneous subcommands. ```APIDOC ## Miscellaneous Subcommands ### Subcommand 0x0a: wrestling stun ### Subcommand 0x0f: unknown **Note:** send once at login, client message **Structure:** - BYTE[5] unknown (0a 00 00 00 07) here ### Subcommand 0x21: (AOS) Ability icon confirm. **Note:** no data, just (bf 0 5 21), server side packet. Send after 0xd7. exact purpose unknown ``` -------------------------------- ### 0x6D Packet: Play Midi Music Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm This packet is used to play MIDI music, specifying the command and the music ID. ```APIDOC ## 0x6D Packet: Play Midi Music ### Description This packet is used to trigger the playback of MIDI music on the client. ### Method N/A (Packet-based communication) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **cmd** (BYTE) - The command byte, indicating this is a MIDI playback command. - **musicID** (BYTE[2]) - The identifier for the music track to be played. ### Request Example ```json { "cmd": "\x6D", "musicID": "\x01\x02" } ``` ### Response #### Success Response (200) N/A (This is a command packet) #### Response Example N/A ``` -------------------------------- ### Define Admin Strings Source: https://github.com/jonyrlima/tfg/blob/main/scripts/custom-tfg/t_personalmessage.txt Defines string aliases for different administrator privilege levels (PLEVELs). These are used to display human-readable titles for staff members in the game. ```script [DEFNAME admin_strings] admin_plevel_3 "Seer" admin_plevel_4 "Game Master" admin_plevel_5 "iGm" admin_plevel_6 "Administrator" admin_plevel_7 "Owner" ``` -------------------------------- ### Format String with Arguments Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/new_tooltips_info.txt These C# methods facilitate string formatting using various argument counts. They leverage the String.Format method to create formatted strings, which are then passed to an `Add` method. This is useful for creating log messages or structured data. ```csharp public void Add( int number, string format, object arg0 ) { Add( number, String.Format( format, arg0 ) ); } public void Add( int number, string format, object arg0, object arg1 ) { Add( number, String.Format( format, arg0, arg1 ) ); } public void Add( int number, string format, object arg0, object arg1, object arg2 ) { Add( number, String.Format( format, arg0, arg1, arg2 ) ); } public void Add( int number, string format, params object[] args ) { Add( number, String.Format( format, args ) ); } ``` ```csharp public void Add( string text ) { Add( 1042971, text ); } public void Add( string format, string arg0 ) { Add( 1042971, String.Format( format, arg0 ) ); } public void Add( string format, string arg0, string arg1 ) { Add( 1042971, String.Format( format, arg0, arg1 ) ); } public void Add( string format, string arg0, string arg1, string arg2 ) { Add( 1042971, String.Format( format, arg0, arg1, arg2 ) ); } public void Add( string format, params object[] args ) { Add( 1042971, String.Format( format, args ) ); } ``` -------------------------------- ### Party Management Subcommands Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Details on subcommands related to party creation, member management, and invitations. ```APIDOC ## Party Management Subcommands ### Subsubcommand 1: Add party members **Note:** Server Message **Structure:** - BYTE numMembers (total number of members in the party) - For each member in numMembers: - BYTE[4] id ### Subsubcommand 2: Remove a party member **Note:** Client message **Structure:** - BYTE[4] id (if 0, a targeting cursor appears) **Note:** Server message **Structure:** - BYTE numMembers (total number of members in the new party) - BYTE[4] idofPlayerRemoved - For each member in numMembers: - BYTE[4] id ### Subsubcommand 8: Accept join party invitation **Note:** Client message **Structure:** - BYTE[4] id (party leader’s id) ### Subsubcommand 9: Decline join party invitation **Note:** Client message **Structure:** - BYTE[4] id (party leader’s id) ``` -------------------------------- ### Extended Stats and Spellbook Subcommands Source: https://github.com/jonyrlima/tfg/blob/main/sphere/docs/packets/detailed_packets.htm Subcommands for handling player extended statistics and spellbook management. ```APIDOC ## Extended Stats and Spellbook Subcommands ### Subcommand: 0x19: Extended stats **Note:** server side packet. Send after 0x11 **Structure:** - BYTE type (always 2? never seen other value) - BYTE[4] serial - BYTE unknown (always 0?) - BYTE lockBits (Bits: XXSS DDII (s=strength, d=dex, i=int), 0 = up, 1 = down, 2 = locked) ### Subcommand: 0x1a: Extended stats **Note:** client side packet, send if player changed stats (lock) status **Structure:** - BYTE stat (0: str, 1: dex, 2:int) - BYTE status (0: up, 1:down, 2: locked) ### Subcommand 0x1b: New Spellbook **Note:** related packet: subcommand 1c, client side **Structure:** - BYTE[2] unknown, always 1 - BYTE[4] Spellbook serial - BYTE[2] Item Id - BYTE[2] scroll offset (1==regular, 101=necro, 201=paladin) - BYTE[8] spellbook content (first bit of first byte = spell #1, second bit of first byte = spell #2, first bit of second byte = spell #8, etc) ### Subcommand 0x1c: Spell selected, client side **Structure:** - BYTE[2] unknown, always 2 - BYTE[2] selected spell(0-indexed)+scroll offset from sub 0x1b ``` -------------------------------- ### List Players Function Source: https://github.com/jonyrlima/tfg/blob/main/scripts/custom-tfg/t_personalmessage.txt Initializes variables for the player list display and opens the player list dialog. It calculates the total number of pages based on the number of players and players per page. ```script [FUNCTION lista] ctag.list_numplayers=0 ctag.list_page=1 serv.allclients list_getplayers ctag.list_numpages=-1) / 10) + 1)> // 10 players per page dialog d_spherelist ```