Finding your way around the Stendhal Server Code

From Arianne
Jump to navigation Jump to search

Stendhal code design


Are you trying to find your way around the source code of the Stendhal server? Then you should continue reading here as it is going to be explained. This document expects that you have basic knowledge of Java and have already configured your Development Environment.

So, you can find the main server code in the package games.stendhal.server and some more dependencies in games.stendhal.common.

Packages

So lets have a look at the packages in games.stendhal.server:

package name purpose
actions commands send by players from the client to the server
core the main logic of Stendhal which keeps all the pieces together
entity everything you can interact with in game (players, monsters, items, portals, ...)
events events send from the server to the client
extensions ignore this for now
maps all the interactive stuff of maps (including quests, npcs)
script Misc Scripts that can be executed by GMs (see Scripts For Admins)
util just a few methods that make coding easier

actions

In the games.stendhal.server.actions package the command send from the clients are handled. This includes all the /-commands that can be entered in the chat line but also things like moving around, attacking creatures. We are currently restructuring this package into subpackages to make it easier to find things.

core

The core package includes the basic infrastructure of Stendhal. In case you just want to add NPCs, quests, maps, dungeons, items and monsters you will not need to change anything here. Have a look at the packages entities, maps, actions and events.

entity

This is most likely the complexes package of the server. It contains all the interactive objects of the game world:

creature all the creatures (hostile monsters and pets)
items the logic of items like weapons, money, scrolls, food,... (see data/conf/items/*.xml)
mapstuff objects that can added to the maps like portals, chest, signs, respawn points, ...
npc human NPCs you can talk to (implemented using a FSM and special code for healers, sellers, ...)
player player-objects
slots slots like player bags, chest content, corpse content
spell a postponed attempt to introduce magic

events

The package games.stendhal.server.events contains subclasses of RPEvent that are send by the server to the clients to notify them about events like a private message. At the end of 2007 we started to introduce this concept so not all the code is converted yet. In the past we used normal attributes of entities that have been removed the next turn.

maps

The files in this package setup the interactive parts of maps. It is structures into subpackages for all the major areas of the StendhalAtlas. The files in this package are invoked by the zone configuration .xml-files in data/conf/zones. The java files in this package only contain high level code. The actual work is done by classes from the entities packages.

NPCs would be defined here, see Stendhal NPC Coding.

There is a special subfolder called "quests". This is not a normal region but quests are put here. Most quests extend the behavior of NPC created in the code for the map zones. See Stendhal Quest Coding.