Skip to content
mtanksl edited this page Apr 24, 2024 · 20 revisions

Configuration

See Config.lua to configure which database to use and to configure the login and game binding port.

You can use Sqlite database, MySQL database, MSSQL database or InMemory database for test purposes.

What is done?

A lot of the elementary stuff is implemented, such as Tibia and Open Tibia's file format interpreters (.dat, .otb, .otbm, .pic, .spr), TCP socket management for login and game servers, packets and communication protocol (with RSA, Xtea, Adler32), task scheduler thread, main game dispatcher thread, the base objects, the base structures, etc.

I tried to implement the base Tibia's game mechanics on top of that. Controlling the character (walking, turning, changing outfit, etc), interacting with other players (say, whisper, yell, direct chat, channels, private channel, rule violation channel, etc), interacting with the game world (look item, move item, rotate item, use item, use item with creature, use item with item, etc).

And on top of that, basic game actions, like, gamemaster in-game commands, spells, runes, tools, etc.

But there is still a lot to be done.

How it works?

The server architecture is the following:

Packets are the primary unity. Incoming packets wrap the intent of the client and Outgoing packets wrap all the information of a server change that the client needs to receive in order to keep in sync.

Commands abstract away how and which clients needs to receive this information.

Commands can be intercepted and changed as they pass through a Pipeline of Command Handlers before executing.

Commands may generate events, which can be listened by Event Handlers.

Some command handlers and some event handlers have support for Plugins.

Before starting the server, all the classes that implement Script are loaded. This is when the pipeline order is set.

Every game object (item, monster, NPC and player) can have some Behaviour attached to it. Behaviour is like Unity's Component.

Behaviours can be attached during game object creation, using GameObjectScript.

Promises are used to represent asynchronous operation.

Lua scripts

You can use Lua scripts to extend any funcionality you want. See NPC scripts for examples and Lua 5.4 for the reference manual.

You can also add some breakpoints and debug those Lua scripts using the ZeroBrane Studio IDE. See How to debug scripts and How to add autocomplete for more info.