# Multiplayer online game engine/pipeline

I am implementing online multiplayer game where client must be written in AS3 (Flash) to embed game into browser and server in C++ (abstract part of which is already written and used with other games).

Networking models may differ from each other, but currently I'm looking toward game's logic run on both client and server parts but they're written on different languages while it's not the main problem.

My previous game (pretty big one - was implemented with efforts of ~5 programmers in 1.5 years) was mainly "written" within electronic tables as structured objects with implemented inheritance: was written standalone tool which generated AS3 and C++ (languages of platforms to which the game was published) using specified electronic tables file (.xls or .ods). That file contained ~50 tables with ~50 rows and ~50 columns each and was mainly written by game designers which do not know any programming languages. But that game was single-player.

Having declared problem with my currently implementing MMO, I'm looking toward some vast pipeline, where will be resolved such problems like:

• game objects descriptions (which starships exist within game, how much HP they have, how fast move, what damage deal...)

• actions descriptions (what players or NPCs can do: attack each other, collect resources, build structures, move, teleport, cast spells) - actions are transmitted through server between clients

• influences (what happens when specified action applied on specified object, e.i "Ship A attacked Ship B: field "HP" of Ship B reduced by amount of field "damage" of Ship A"

Influences can be much more difficult, yes, e.i. "damage is twice it's size when Ship has >=5 allies around him in a 200 units range during night" and so on. If to be able to write such logic within some "design document" it will be easily possible to:

• let designers to do their job without programmer's intervention or any bug-prone programming

• validate described logic

• transfer (transform, convert) to any programming language where it will be executed

Did somebody worked on something like that? Is there some tools/engines/pipelines which concernes with it? How to handle all of this problems simultaneously in a best way or do I properly imagine my tasks and problems to myself?

There are no standard tools or processes here - every game is different and every team is different, so meeting their needs will vary from one to the next. All you can do is look at what options are available and pick the ones that suit you most.

If you want custom behaviour, that sounds like you'll need a scripting language. There's no magical tool (that I know of) which could translate a normal design document, even a well-written one, into usable game code that works in the language and engine of your choice. But a scripting language at least allows you to execute external files as if they were code. That allows people, maybe designers, to write behaviour in the scripting language without needing to edit the main game engine. Arguably your designers are becoming programmers at that stage, but hopefully the scripting language is easier to use than C++, and less bug-prone, but a lot of that depends on your choice of language and how you implement it.

Scripting languages can also function as data documents too, so designers can combine the behaviour and data in one file. However it is often more effective for data to be handled in a separate tool that you make yourself, or via a standard tool such as Excel. What is best for you will depend on the nature and amount of your data.

• I evaluate all MMOs where game logic is executed on both client and server similar, isn't it so? If it is, why must be they different? Everywhere are quests, missions, raids and so on... (previously I tried to use more common terms such as objects and influences but even such native can be used as well) – Slav Dec 17 '12 at 13:15
• They may look similar to the player, but they are not similar to the developer. Computer games are not made in a way that allows for interchangeable parts like that. For instance, there is no standard definition of what a 'quest' is, so there can't be a tool for designing one that works with all games. – Kylotan Dec 17 '12 at 13:26
• Well, I really don't see any obstacles that there CANNOT be such tools... As I sayd - all MMO are absolutely the same when they have server logic and similar game-play (so, EVE is different, for example, as it's game-play) - why should they implement all the same for each game separately? For example, UT-engine developers designed stand-alone engine with Unreal-script where it's not need to care about multiplayer syncronization - and I don't understrand why there are no similar tools/pipelines for MMOs - explanation can be only one, then: that MMOs' development is too modern to produce it... – Slav Dec 18 '12 at 15:06
• Technology is relatively easy to standardise. Game design is not. There are plenty of tools, libraries and engines for MMOs, but none of them address gameplay decisions, which are quite different across different games. – Kylotan Dec 18 '12 at 18:01
• Can you give more details about tools, libraries and engines, please? – Slav Dec 18 '12 at 18:46

Here's some more detail on the reasoning behind Kylotan's answer.

# Problem deconstruction

The "design document" that your designers work on is effectively a high-level programming language. They have a high-level API (your XLS/ODS loader) that they're writing their "code" to.

They want to express...

• properties that may be fixed (e.g. that a certain spaceship type has range = 200) which may be conditional (e.g. damage = 2*normalDamage during the night)
• behaviours (e.g. clicking fires laser toward cursor)

...in some format.

The questions condensed: What should that format be? How can I make it work in a pipeline?

This is what scripting languages are for.

Why? You can express properties in a table, but you cannot express behaviour without programming.
Why not just write a more complex API? Imagine if you did: You'd extend the API to allow designers to write conditional statements. Then maybe event callback functions. And then you'd realise you've implemented a scripting language.

Thankfully, scripting languages (Lua is pretty popular) are made to be easy to write and easy to interface with "heavy" code (such as C++).

Assuming C++ core code, you could expose an interface game to the scripting language and call the scripting language for values and behaviours from the core code whenever you need them.

In Lua, the above examples could be expressed like this:

shipTypes = {
{
type = "Assassin",
range = 200,
damageDealt = (game.isNight and 1000) or 500,
actions = {
leftClick = game.fireAt(pos)
}
}
}


Your game designers would, of course, have to learn Lua basics. (Or of whichever scripting language you choose.)

• I don't see any benefits which Lua offers: everything must be hardcoded, no compile-time verification (which is the worst part: if you programmed Thanksgiving Day prizes - you will know if you made any misprints only when that day will come), slow (fast, but much slower than C++ and takes ~13ms to call empty function within AS3 virtual-machine implementation). – Slav Dec 18 '12 at 15:17
• Lua is only a popular example, not necessarily the best choice! However: Almost any scripting language will run slower than C++ and certainly anything will run slowly in an AS3 virtual machine. Also, do remember that compile-time verification is not a substitute for software testing. – Anko Dec 18 '12 at 16:07

You can take a look at eathena project, a mmorpg server clone. I used to practice with it because it contains a simple scripting language to design the whole game and you can find tools for free for designing the scenes or just make them yourself, there is a lot of information out there about it.

When I was newbier I wrote a reader for some of those files such as .gat containing tile description and the like. You can take a look at the sources at google code and also you can see screenshots about tests of the functions at picasa

There may be other free sources of mmo servers but that's the one I know most :). I hope it helps.

• Are there any options for clients besides the official (and illegal) RO ones? I'd love a simple, open source (M)MOG stack. – drxzcl Dec 17 '12 at 15:04
• @drxzcl: I don't know, I was writing my own, not a RO client but a client that can interact with some RO formats such as server packets, tile descriptions, etc. Plus the eA server I mentioned has a simple scripting language that anyone can handle and I believe there are also some editors for those, for instance I tried one to configure the items of the shop npcs, but there are map editors, converters from 3ds max, etc. It shouldn't be hard to code a client for it if you choose the right tools and have some time or someone to lend you a hand. – Pablo Ariel Dec 29 '12 at 4:49

I've worked professionally in several games with various teams, and I have to tell you that game designers (they like to call them "planners" in here) love using Excel to tweak all the in-game data. As programmers, we would be idiots not to let them use it.

With Excel and a good and fast ad-hoc excel-to-code converter, not only they can use a tool they are familiar with, but also they can do formulas, check averages, graphs, link to other files and so on, to make sure their data is just as they want it to be.

What I've done in the past, is, when making a new feature that has tweakable data, create a new Excel book. The first sheet contains the exportable data, which has to have a specific formatting so the converter can convert it unambiguously, so I make a skeleton with some test data, and briefly explain what can be changed and what can't be changed. The rest of the sheets are free for them to use.

The converter is a simple script, which can be made in Ruby, Python, C#, or my favorite: VBA. It takes the data from the exportable data sheet and creates one or more source files (in C, C++, Assembly, PHP, SQL, INI, or whatever it is that your game understands) which contain the necessary data as hardcoded data, and places them in the correct source folder.

Each time a change is made, the planner runs the converter and builds the game, or whatever she has to do (you have a one-click build process, and the possibility for each team member to have a separate game environment, right?). She can then immediately test her changes on her workstation without having to call a programmer.

Once she is satisfied with her changes, she pushes them to source control, and everybody is happy!

This is a very useful way to let game planners modify game data. Also, since the resulting data is hardcoded, it may run faster in the final binary.

Needless to say, this works optimally with data that is tabular in nature, such as monster attributes, spell parameters, stage configuration and the like. It is worthy to note that Excel tables are specially useful to store all the game texts, which everybody will thank you to when it's time to translate the game to spanish, french, german and 10 other languages.

However, this doesn't work with data that is scriptable in nature, such as Enemy/AI behavior and menus. For those, what we have done in the past is decide a set of basic building blocks (the AI for a coward enemy, an aggressive enemy, a healer, etc) and either let them assign them with another excel table, or give them basic instructions on how to tweak them to achieve their own purposes.

Finally, very complex data, such as the actual levels; or data that may be tabular but cannot be easily understood by just seeing numbers, such as enemy/agent positions, can't be done either with scripts or excel tables. You're going to have to make a small editor that shows data in an easy to understand manner, and generates data in a way the game program can understand it. I prefer C# with Windows Forms, as it is very easy to make anything in it.

Do not expect or require your game tweakers to script everything themselves. That's just you being lazy. Writing programs, even if scripts is our job, not theirs, so it's at the least lazy, and at worst dangerous.

But anyways, that's what I've experienced. In conclusion, what I think is best, is to talk with your tweakers, ask them what is the data they want to tweak, and how they imagine themselves tweaking it, and make a solution that is as close as possible to what they want. Game balance is very critical, and we want them to do their job as best as they can.

That is one of the many responsibilities of a game programmer.

• Excel is lovely for their formulas, yeah, but we have some problem which I cannot solve for now: there are no arrays - only tables, i.e. if I have 10 characters each having 4 spells, I must describe 10 objects within characters table and 40 objects within spells table and specify 4 comma-separated spells (links are implemented as part of generating language) within spells column of table characters, but instead was chosen approach with 4 columns within table characters (first_spell, second_spell ...) - both are pretty ugly anyway. – Slav Dec 22 '12 at 21:59
• Well, that was pretty specific answer what is making me curious: 2 different programmers implemented almost the same things to make their different games and even more: my previous game was single-player but now I'm using the same approach (exactly that one generator) within my MMO game because philosophical units of programming are the same there: objects, their properties and dependencies - fit for such different game types. – Slav Dec 22 '12 at 22:07