logo

TheoWorlds Builder SDK v2 Documentation

How To's

1. Adding/modifying the characters

To add a new character (same information applies to modifying an existing one):

  1. Create the new character FLA (using our examples) and compile the SWF. Place it into the /library/characters/ folder.
    Note!Make sure you name the frame labels accordingly.

  2. Edit the characters.xml:
         <i id="2" url="library/characters/woman.swf" speed="180">
    id - has to be unique
    url - make sure it points to the SWF you created in 1)

    The rest of the functions are automatically performed by the Map Editor, so you don't have to do them, unless you are doing the changes manually, without the Map Editor.

  3. In the map XML you have to include the reference to the character's library XML file:
         <library>
              <lib url="library/characters.xml"/>
         </library>


  4. On the map, to place the character, use:
         <character>
              <c col="7" row="12" libID="3" libItemID="2" mainCharacter="yes" direction="5" name="me" brainType="controlled"/>
         </character>


    Once again, this code is automatically added by the Map Editor. The libID is the ID of the library (defined at the top of each library's XML) - it has to be unique for each library. The libItemID is the same as the character id listed in the characters.xml <i> block.

    Note!In order for the Map Editor to be able to add all those references, it has to know about all the libraries - through the catalog.xml file. Make sure that the libraries IDs listed in the catalog.xml are the same as the ones listed inside the libraries XML files (and unique).

    Note!If you are creating a chat application, with users joining the chat dynamically, the characters are not added through the map XML files - they are added "on-the-fly" by the application.

2. new! Adding local bots (automated characters)

If you have a game where you need to have "monsters" on the map, you can use so-called "bots". Those are the characters that act on their own, according to the AI logic assigned to them.

We made it very easy to add bots and even included a simple example - check SimpleBotDemo.swf application in your main folder. This applications adds the bots to the map using the code. But usually you will be adding bots by including them into map XML, as you do with furniture and other objects (Map Editor generates the XML in that case).

Just add this block to the map XML and the bot will be added to the map when it loads:

          <character>
       <c col="17" row="9" libID="3" libItemID="2" mainCharacter="no" direction="2" name="bot" brainType="random"/>
    </character>

Here is the parameters:

  • col, row, libID, libItemID, name - this works the same as with map furniture
  • direction - the direction in which the character is turned initially
  • mainCharacter - make sure it equals to "no", since a bot is not a character you control on the map
  • brainType -this is the most important parameter. It tells what AI logic the character should use. For the bots we created a simple logic called "random" that makes them move and talk randomly. It's stored in the CharacterLogicRandom class (com/theoworlds/builder/CharacterLogicRandom.as). You can modify it or extend it to create your own bots behaviors.

Note!IMPORTANT: These are "local" bots. It means they will not work in multi-user environment (they will, but each user will see different bots, since they are created locally). To create bots for multi-user applications, you would need to write a socket server extension that creates them on the server and then synchronizes them between the clients.

 
 
 
Last updated: September 16, 2009