从头开始实现一个 Ragnarok 在线服务器,仅为娱乐
Rust ro 3 years journey blog post
rust-ro is a Ragnarok MMO Server implementation written in Rust.
This project does not aim to compete with herculesWS or rathena.
Although the architecture and technical decision of this project are very different than rathena or hercules, both projects are still a source of inspiration and remain source of truth for game behavior.
In addition, this project kept some concept of existing implementations: for example this project support same scripting language for NPC meaning that existing scripts should work on this implementation and use the same database structure than rathena and some naming convention were kept.
Architecture and technical decision are documented here
The project started on August 2021 with the ambition to being able to connect on the server and navigate across maps to see monsters.
Today February 2023 a lot of features have been added, at the end of readme. My ultimate goal would be to have a fully playable implementation for PRE-RE, supporting packet version 20120307.
I am working on this project for fun and also to provide a more accessible way than existing implementation to understand how Ragnarok game works for educational purpose. Each feature is covered with tests to provide internal documentation.
The packets parser, builder and serializer are all taking packet version as parameter. The packet db also support condition around packet attributes and packet id
Although I mentioned above wanting to fully support packet version 20120307, this implementation can support any packet version, it is just I am testing exclusively with my own open source client using this packet version and thus i am implementing only packet in this version.
Below issues are under active development
To understand what is going on at this project, check the architectures notes.
lib: contains either, proc-macro, reusable structure, generated codelib/packets: Structure for packets generated by tools/packets from tools/packets_db filelib/models: Plain old data structure to be reused in multiple moduleslib/configuration: Structure for configuration with serde deserializer implementationlib/skills: Generated structures for skills from configuration and also manually implemented skills methodsserver: server coreserver/proxy: A proxy implementation to be use between a client and an emulator (rathena or hercules) in order to capture packetsserver/repository: data access layer of the server, any access to dabase is written from this layerserver/server: global event loop, map instance event loop, persistence event loopserver/server/boot: any method require in order to boostrap server state (script loader, maploader, mob spawn...)server/server/model: Plain old non-reusable data structure (queue, cells, etc..)server/server/request_handler: controller layer, any packet receive from client pass to a controller firstserver/server/script: interface between server and script virtual machine, provides hook implementation of the virtual machineserver/server/service: any logic of the game is implemented in this layerserver/server/state: Data structure containing game state (character session, character state, mob state)server/util: Any utility methodstools: code generatortools/map-cache: generate map cache from map filestools/packets: generate packets structure from database filetools/skills: generate skills structure from configuration file tools/stat-calc: A javascript/html stat calculator, cleaned up to better understand stats and combat calculation. Also added feature to generate test fixtures, to validate our implementationHere's a list of pre-requisites to run rust-ro:
First, make a copy from config.template.json to config.json:
cd rust-ro
cp config.template.json config.jsonInside this JSON, you will find database related variables, game related variables (exp_rate, drop_rate etc) as well.
The entire database structure was based on rAthena but instead of using MySQL, we decided to go with PostgreSQL. There's minor modifications so far but until we mapped some constraints.
The choice to use Postgresql instead of MySQL was mainly motivated because I know better how to operate Postgresql than MySQL, and know better how Postgresql (mvcc) works internally. In addition past years Postgresql gained more traction than MySQL and its open source model
If you already have Docker installed in your machine, we prepared a docker-compose.yml with all configs ready for your ragnarok server.
Go to /docker and run:
docker-compose up -dThe first time, along with postgresql initdb is run, our custom script init.sh will be execute, it will create ragnarok database and create ragnarok user using postgres user. Then it will create ragnarok table using ragnarok user.
It comes with a default player account with following credentials: admin/qwertz
If you have PostgreSQL installed in your machine, you will need to log-in into PSQL and create the user, dabase and give the necessary privilege for it:
sudo -u postgres psqlRun the queries below:
CREATE USER ragnarok WITH PASSWORD 'ragnarok';
CREATE DATABASE ragnarok;
GRANT ALL PRIVILEGES ON DATABASE ragnarok TO ragnarok;
ALTER DATABASE ragnarok OWNER TO ragnarok;After that, exit pgsql and import our /rust-ro/db/pg.sql via cli with:
…So far, we have a few executables being compiled together with the project:
cargo run --package tools --bin maps-toolcargo run --package tools --bin packets-toolcargo run --package tools --bin skills-struct-generatorThe goal of the project is to run all packages from packetver 20120307, we decided to use roBrowserLegacy.
If you have interest to contribute in a client with packetver 20120307, open a new issue and let's make it happen!
The stat calculator is a highly customized* fork of from https://web.archive.org/web/20090319055622/http://rode.doddlercon.com/db/calc/index.php
*Customized :
The idea behind reusing stat calculator is to validate implementation of battle and status calculation.
Output of stat calculator may be false and in this case we will check result against hercules or rathena.
cd tools/stat-calc
npm run devIn proxy mode:
A compilation of progress made so far, click on streamable video below
https://user-images.githubusercontent.com/1909074/178155321-d3eeb4b8-32ed-4901-bbfe-b101b1a5a56d.mp4
Debug server state with a UI
Some list of features that was developed so far:
This project is currently half-open* to contribution. The reason is that all basis have not been put in place already and there are many thing to design yet.
However if you are motivated and want to contribute you can take a look to the contribution guide
* contribution can be made under certain condition
暂无开放 Issues,或尚未同步最近议题。