pko-client-reference
Reference guide for PKO (Pirates King Online) game client source code. Use this skill when you need to understand: (1) Game 3D file format specifications (.lgo, .lmo, .lws, .lac files), (2) How the game engine uses character, mesh, animation, or map data, (3) Verify if current import/export code correctly handles game file structures, (4) Understand bone/skeleton hierarchies, texture mapping, or animation systems, (5) Debug or validate any aspect of the file conversion between PKO formats and glTF.
SKILL.md
| Name | pko-client-reference |
| Description | Reference guide for PKO (Pirates King Online) game client source code. Use this skill when you need to understand: (1) Game 3D file format specifications (.lgo, .lmo, .lws, .lac files), (2) How the game engine uses character, mesh, animation, or map data, (3) Verify if current import/export code correctly handles game file structures, (4) Understand bone/skeleton hierarchies, texture mapping, or animation systems, (5) Debug or validate any aspect of the file conversion between PKO formats and glTF. |
name: pko-client-reference description: "Reference guide for PKO (Pirates King Online) game client source code. Use this skill when you need to understand: (1) Game 3D file format specifications (.lgo, .lmo, .lws, .lac files), (2) How the game engine uses character, mesh, animation, or map data, (3) Verify if current import/export code correctly handles game file structures, (4) Understand bone/skeleton hierarchies, texture mapping, or animation systems, (5) Debug or validate any aspect of the file conversion between PKO formats and glTF."
PKO Client Reference
Overview
This skill provides guidance for referencing the PKO game client source code located in client-src/ (symlink to /mnt/i/Work/Client2019). The source code contains the authoritative implementation of how the game engine loads and uses 3D models, animations, textures, and other game assets.
When to Reference Client Source
Reference the client source code when:
- File Format Questions: Need to understand the binary format or structure of
.lgo,.lmo,.lws,.lac, or other game files - Data Usage Verification: Want to see how the game engine actually uses specific fields or data structures
- Import/Export Validation: Need to verify that the Rust implementation in
src-tauri/src/character/correctly handles game data - Bone/Skeleton Systems: Understanding bone hierarchies, link points (dummy nodes), or animation binding
- Rendering Details: How textures, materials, shaders, or vertex data are processed
- Animation Systems: How poses, keyframes, and animation blending work
Client Source Structure
The client source is organized into three main directories:
Engine (client-src/Engine/sdk/)
Core 3D engine implementation with low-level file loading and rendering:
-
include/: Header files defining data structures and APIsMPCharacter.h: Character loading, bone system, pose/animation APIMPMap.h,MPMapData.h: Map loading and terrainMPModelEff.h: Model effects and renderinglwModel.h,lwModelObject.h: Core model data structureslwAnimCtrl.h,lwAnimKeySetPRS.h: Animation control and keyframe systemslwSysCharacter.h: Character system implementation
-
src/: Implementation files (.cpp)MPCharacter.cpp: Character loading logiclwModel.cpp: Model file parsinglwAnimCtrl.cpp,lwAnimKeySetPRS.cpp: Animation implementationMPMapData.cpp: Map data structures
Client (client-src/Client/src/)
Game client implementation with higher-level game logic:
Character.cpp,Character.h: Game character class (extends CharacterModel)CharacterModel.cpp,CharacterModel.h: Character model management, part loading, item attachment- Defines link point IDs (LINK_ID_HEAD, LINK_ID_RIGHTHAND, etc.)
- Character part system and equipment attachment
Actor.cpp,Actor.h: Base actor class for game entities- Various game-specific systems (inventory, skills, UI, etc.)
Common (client-src/Common/)
Shared utilities and data structures used by both engine and client.
Key Concepts
Character Loading (MPChaLoadInfo)
Characters are loaded with:
- Bone file: Skeleton structure defining bone hierarchy
- Part files: Up to
LW_MAX_SUBSKIN_NUMseparate mesh parts (head, body, legs, etc.) - Pixel shader: Optional shader for rendering effects
See MPCharacter.h:38-52 for MPChaLoadInfo structure.
Link Points (Dummy Nodes)
Characters have 16+ predefined link points for attaching items/effects:
dummy_0throughdummy_15: Attachment points (head, hands, chest, feet, etc.)- Defined in
CharacterModel.h:46-66
File Loading Pattern
Most game files follow this pattern:
- Engine defines low-level loading (
MPCharacter::Load(),lwModel::Load()) - Files are loaded from the game's file system (usually in
character/,model/,animation/folders) - Data is parsed into internal structures
- Rendering system uses the loaded data
Workflow
When you need to reference the client source:
-
Identify the Question: What specific aspect do you need to understand?
- File format structure → Look at parsing code in
.cppfiles - Data field meanings → Check header files (
.h) for structure definitions - Usage patterns → See how functions are called in client code
- File format structure → Look at parsing code in
-
Find Relevant Files:
- Character/model loading:
MPCharacter.h/.cpp,CharacterModel.h/.cpp - Animation:
lwAnimCtrl.h/.cpp,lwAnimKeySetPRS.h/.cpp - Core data structures:
lwModel.h/.cpp,lwModelObject.h/.cpp - Map/terrain:
MPMap.h/.cpp,MPMapData.cpp
- Character/model loading:
-
Read the Implementation:
Use Read tool to examine the relevant source files Focus on structure definitions, file loading functions, and data processing -
Cross-Reference with Current Code:
- Compare client source implementation with Rust code in
src-tauri/src/character/ - Verify that binary formats, field sizes, and data interpretations match
- Check that conversions to glTF preserve the intended structure
- Compare client source implementation with Rust code in
-
Document Findings: When you discover important details, consider noting them for future reference
Common Reference Patterns
Understanding a Binary Format
- Find the load function (e.g.,
MPCharacter::LoadBone()) - Read how it opens and parses the file
- Note byte order, data types, and structure layout
- Verify Rust implementation matches
Verifying Bone/Skeleton Handling
- Check
MPCharacter::InitBone()andLoadBone()inMPCharacter.cpp - See how bones are stored and accessed
- Compare with
src-tauri/src/character/model.rsbone parsing - Verify bone hierarchy and transformations match
Understanding Animation System
- Review
lwAnimCtrl.hfor animation control structures - Check
lwAnimKeySetPRS.hfor keyframe data (Position, Rotation, Scale) - See how poses are played with
PlayPose()functions - Verify
src-tauri/src/character/animation.rshandles animation data correctly
Checking Link Point Usage
- See
CharacterModel.h:46-66for link point definitions - Check how items are attached with
AttachItem()functions - Verify that equipment attachment in the tool uses correct link IDs
Tips
- Start with headers (
.h): They define structures and APIs without implementation details - Then read implementation (
.cpp): Shows actual data processing and file formats - Use grep/search: The codebase is large; search for specific function names or data structures
- Watch for macros: Constants like
LW_MAX_SUBSKIN_NUM,LINK_ID_HEADdefine important limits - Check comments: Some files have Chinese comments that explain functionality
- Binary formats: Look for
fread(),fopen(), byte-by-byte parsing to understand file structures
Example Usage
User asks: "How are character bones stored in the .lgo file?"
Response:
- Read
client-src/Engine/sdk/src/MPCharacter.cppfocusing onLoadBone()function - Identify the binary format for bone data
- Compare with
src-tauri/src/character/model.rsbone parsing - Verify that the Rust code correctly reads bone hierarchy, transformations, and indices
User asks: "What does the link_item_id field mean in character files?"
Response:
- Read
client-src/Engine/sdk/include/MPCharacter.hforlwSceneItemLinkInfostructure - Read
client-src/Client/src/CharacterModel.hfor link point definitions - See how
link_item_idis used in attachment functions - Explain that it identifies which bone/dummy node an item attaches to
Reference Files
For detailed code exploration, see:
- references/key_files.md: List of most important source files with descriptions