A Python implementation of the Reborn game server, supporting v6.037 protocol with Python NPC scripting.
- v6.037 Protocol Support: Full ENCRYPT_GEN_5 encryption/compression
- Python NPC Scripting: Write NPC behaviors in Python
- Asyncio-based: Efficient async networking
- Compatible with pyReborn: Connect with the pyReborn pygame client
- List Server Integration: Optional registration with Graal list server for:
- Server discovery and player browsing
- Account verification (when enabled)
- Cross-server messaging
- Automatic reconnection with exponential backoff
# Install
pip install -e .
# Run server
python run_server.py
# Or as a module
python -m pygserverThen connect with pyReborn:
cd ../pyReborn
python -m pyreborn.example_pygame <username> <password> localhost 14900pygserver/
├── __init__.py # Package exports
├── __main__.py # `python -m pygserver` entry point
├── server.py # Main GameServer class (asyncio)
├── player.py # Player connection handling
├── level.py # Level loading and management
├── npc.py # NPC system with Python scripting
├── weapon.py # Weapon definitions
├── world.py # World/GMAP management
├── config.py # Server configuration
├── listserver.py # List server client (registration/verification)
├── combat.py # Combat system (bombs, arrows, damage)
├── items.py # Item system (ground items, chests)
├── baddy.py # Baddy/enemy system
├── horse.py # Horse/mount system
├── rc.py # RC (Remote Control) admin system
├── nc.py # NC (NPC Control) system
├── filesystem.py # File serving system
├── account.py # Account management and persistence
└── protocol/
├── packets.py # Packet builders (uses reborn-protocol)
├── codec.py # Re-export shim → reborn_protocol.codec
├── constants.py # Re-export shim → reborn_protocol.constants
└── encryption.py # Re-export shim → reborn_protocol.encryption
The server uses the shared reborn-protocol library for:
- Encryption/codec (ENCRYPT_GEN_5, packet framing)
- Protocol constants (PLI/PLO/SVI/SVO packet IDs, PLPROP/NPCPROP property IDs)
NPCs are scripted in Python. Create a .py file in the npcs/ directory:
class GreeterNPC:
"""A friendly NPC that greets players."""
def on_created(self, npc):
"""Called when the NPC is created."""
npc.image = "pics1.png"
npc.x = 32.0
npc.y = 32.0
npc.say("Welcome!")
npc.set_timer(5.0)
def on_player_enters(self, npc, player):
"""Called when a player enters the level."""
npc.say(f"Hello, {player.nickname}!")
def on_player_chats(self, npc, player, message):
"""Called when a player chats."""
if "hello" in message.lower():
npc.say(f"Hi {player.nickname}!")
def on_timeout(self, npc):
"""Called when timer expires."""
npc.move(1, 0) # Move right
npc.set_timer(5.0)on_created(npc)- NPC initializedon_timeout(npc)- Timer expiredon_player_enters(npc, player)- Player entered levelon_player_leaves(npc, player)- Player left levelon_player_chats(npc, player, message)- Player sent chaton_player_touches(npc, player)- Player touched NPC
# Properties
npc.id # NPC ID
npc.name # NPC name
npc.x, npc.y # Position (tiles)
npc.direction # Facing (0=up, 1=left, 2=down, 3=right)
npc.image # Sprite image
npc.gani # Animation name
npc.message # Chat message
npc.flags # Custom flags dict
# Methods
npc.move(dx, dy) # Move by offset
npc.warp(level, x, y) # Warp to location
npc.set_image(image) # Set sprite
npc.set_ani(animation) # Set animation
npc.set_timer(seconds) # Set timeout
npc.say(text) # Show message
npc.hide() / npc.show() # Visibility
npc.destroy() # Remove NPC
npc.get_flag(name) # Get flag
npc.set_flag(name, value) # Set flagCreate serveroptions.txt:
# Server Identity
name = My Server
description = A Python-powered game server
language = English
url = http://www.example.com/
# Network
serverport = 14900
serverip = AUTO
localip = AUTO
# List Server (Optional)
listip = listserver.graal.in
listport = 14900
# Set enable_listserver = true in Python config to activate
# Access Control
staff = admin,moderator
noverifylogin = true
# Starting Location
startlevel = onlinestartlocal.nw
startx = 30
starty = 30.5
# Limits
maxplayers = 100To enable list server registration:
from pygserver import GameServer, ServerConfig
config = ServerConfig.from_file("serveroptions.txt")
config.enable_listserver = True # Enable registration
config.hq_password = "your-hq-password" # Optional HQ password
config.hq_level = 1 # HQ access level (1-3)
server = GameServer(config)When enabled, the server will:
- Register with the list server on startup
- Send player join/leave notifications
- Support account verification (if
verify_login = True) - Automatically reconnect if disconnected
- Version: 6.037 (G3D0311C)
- Encryption: ENCRYPT_GEN_5 (XOR cipher with compression)
- Compression: Dynamic (uncompressed/zlib/bz2)
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytestBased on GServer-v2 C++ architecture:
| C++ Class | Python Module | Purpose |
|---|---|---|
| TServer | server.py | Main server loop |
| TPlayer | player.py | Player connections |
| TLevel | level.py | Level management |
| TNPC | npc.py | NPC system |
| TWeapon | weapon.py | Weapons |
| TMap | world.py | World/GMAP |
MIT License - See LICENSE file.