Object Structure
GameObj
The server-side object representation:server-go/shared/obj.go
Reference to the object’s static data (name, textures, flags)
The chunk coordinates containing this object (cached for efficient packet handling)
Current visual/functional state (0-255), determines which texture to display
Object Data Format
Object definitions use the GRPGOBJ data format:data-go/grpgobj/grpgobj.go
Internal name for the object
Unique identifier for the object type
Bitmask controlling object behavior (STATE, INTERACT)
Array of texture IDs - index corresponds to state number
Text shown to player when hovering over the object (only if INTERACT flag set)
Object Flags
Objects use a flag system to define their capabilities:data-go/grpgobj/grpgobj.go
STATE Flag
Indicates the object has multiple visual states:- Not set: Object has single texture (
Textures[0]) - Set: Object has multiple textures indexed by state number
- Example: A berry bush with states 0 (with berries) and 1 (picked)
INTERACT Flag
Indicates the object can be interacted with:- Not set: Object is purely decorative
- Set: Object has an interaction script and displays
InteractText - Interaction triggers the registered
OnObjInteractcallback
The
InteractText field is only serialized when the INTERACT flag is set, saving bandwidth.State Management
Object states control which texture is displayed and can be changed through scripts:Getting State
server-go/scripts/context.go
Setting State
server-go/scripts/context.go
ObjUpdate packet is broadcast to all players in the chunk.
Example: Berry Bush
server-go/content/berry_bush.go
- Player interacts with berry bush (state 0)
- Object changes to picked state (state 1)
- Player receives berries and XP
- After 100 ticks, berries respawn (state 0)
Data Format
Objects are loaded from the GRPGOBJ binary format:Reading Objects
data-go/grpgobj/grpgobj.go
Interaction System
Players can interact with objects that have the INTERACT flag set. See Content Scripting for details on implementing interactions.Interaction Context
TheObjInteractCtx provides methods for:
- Reading/writing object state
- Modifying player inventory
- Granting skill XP
- Scheduling timed callbacks
Chunk-based Optimization
Objects cache their chunk position for efficient packet handling:- Broadcasting state updates to nearby players
- Sending initial object data to newly connected clients
- Processing spatial queries
Chunk position is calculated as
{X: pos.X / 16, Y: pos.Y / 16} using 16x16 chunks.Next Steps
Content Scripting
Learn how to create interactive object behaviors
Inventories
Understand the inventory system for storing collected items