Entity Definition HowTo

Introduction

The goal of this howto is to illustrate how to add new entities to the Cyphesis server.

Entity files

Entities are defined in XML files. These files are under the data directory under cyphesis source, and are installed under ($PREFIX)/etc/cyphesis/. The current ones used are:

basic.xml basic entities for any world
mason.xml entities for mason

XML Entity Definition

Cyphesis uses an XML file to register all the entities used in the game. Let's dive in head first, and we'll go over the entries line by line later.

Assuming we want to add a squirrel, we need to add the following lines to cyphesis-C++/mason.xml:

  <map>
    <map name="attributes">
      <map name="bbox">
        <list name="default">
          <float>-0.5</float>
          <float>-0.075</float>
          <float>0</float>
          <float>0.3</float>
          <float>0.075</float>
          <float>0.2</float>
        </list>
        <string name="visibility">public</string>
      </map>
      <map name="mass">
        <float name="default">1</float>
        <string name="visibility">public</string>
      </map>
      <map name="maxmass">
        <float name="default">2</float>
        <string name="visibility">private</string>
      </map>
    </map>
    <string name="id">squirrel</string>
    <string name="objtype">class</string>
    <list name="parents">
      <string>character</string>
    </list>
  </map>

The entity is defined by a list of their attributes. They are ordered alphabetically in the xml file.

id

The id is the unique identificator of the entity:

    <string name="id">squirrel</string>

This sets up a type of entity that will be called "squirrel".

objtype

Determines the type of the map. For game entities, it's always class.

    <string name="objtype">class</string>

parents

This list defines the parent entity (or entities) from which the new entity will inherit attributes.

    <list name="parents">
      <string>character</string>
    </list>

Currently we have the following base entities:

bbox

This is the bounding box of the entity. For a good definition of what a Bounding Box is, see Bounding Box at Wikipedia.

      <map name="bbox">
        <list name="default">
          <float>-0.5</float>
          <float>-0.075</float>
          <float>0</float>
          <float>0.3</float>
          <float>0.075</float>
          <float>0.2</float>
        </list>
        <string name="visibility">public</string>
      </map>

Other attributes

Other attributes such as the mass and the maxmass are not for all entities, but more specific. Any custom attribute can be added to any entity.

Attribute properties

Some of the attributes have properties.

default

The default value of an attribute.

visibility

The scope of the attribute. Possible values are:

Installing the new entity files

To install the new entity files run:

make install-data

cyaddrules to add the rules to the running server

cyloadrules to load the rules into the database (when persistance is enabled this won't be needed)

Authors: Kai Blin, Miguel Guzmán
Last Updated: 2005-12-06