HowToAddCreaturesStendhal

From Arianne
Revision as of 15:38, 5 November 2008 by imported>Kymara (Add GFX: clean up)
Jump to navigation Jump to search

You can add new creatures to game in a few very simple steps:

Edit creature.xml

This file contains all the description of the creatures in game. For example.

  <creature name="deer">
    <type class="animal" subclass="deer" tileid="animal.png:9"/>
    <description></description>
    <attributes>
      <atk value="5"/>
      <def value="9"/>
      <hp value="20"/>
      <speed value="1.0"/>
      <size value="1,1"/>
    </attributes>
    <level value="0"/>
    <experience value="0"/>
    <respawn value="900"/>
    <drops>
      <item value="meat" quantity="[1,3]" probability="60.0"/>
      <item value="ham" quantity="[1,2]" probability="30.0"/>
      <item value="antidote" quantity="[1,1]" probability="5.0"/>
    </drops>
    <equips>
    </equips>
    <ai>
      <profile name="non_offensive"/>
      <profile name="animal"/>
      <profile name="coward"/>
      <profile name="patrolling"/>
    </ai>
  </creature>

It is important to understand how it works.

We must give a name to the creature and it is done in the creature tag. Then we specify the class and the subclass on the type tag. If you check the way sprites are structure at client you will realize that it is in a similar fashion to:

 sprites/
     monsters/
         class/
             subclass.png


The next attribute inside type tag is tileid that points to the file and position (starting from 0) of this monster sprite in the logic/creature/class.png file.

Inside the attributes tag you can specify the attributes the entity has:

  • ATK it is a value proportional to the damage the creature can do.
  • DEF it is a value proportional to how much damage the creature can block. Note also the defense is also proportional to creature level.
  • HP is the health measure
  • Speed it is how fast creature moves. Range from 0 to 1.
  • Size it is the size of the collision area on the ground of the creature in tiles: usually 1x1

Now the level and experience tags. The level is used by the balancer application and the players to measure a creature (because they don't know ATK, DEF or HP values ). The experience determine the reward the player will get by killing this creature. respawn is how long it takes to respawn. 0.005 * respawn is the average respawn time, in minutes. The actual respawn is randomly chosen from the interval [respawn/2 , 3 respawn/2].

Now the drops tag specify what the creature drops when it is killed. Each of the item has a probability of being dropped (probability attribute) and the quantity of it that may be dropped (quantity attribute). If you only want it to drop one item, we still write the quantity as between 1 and 1, like [1,1].

Aditionally you can equip items at a creature slots:

  • rhand
  • lhand
  • armor
  • head
  • legs
  • feet

It is a good idea not to equip creatures ( because they take more memory ) if it is possible. Archers should equip arrows and bows. So they'll have extra attack from this. So you should give them less attack than other creatures of similar level or they will be too strong.

AI to do with coward/brave and human/animal etc are useless right now. Don't worry about them, just copy and paste the data. A non_offensive creature does not select you as an enemy until you attack it, at which point it moves towards you. An offensive creature selects you as an enemy once you are close enough to it. A patrolling creature follows a set path. A non patrolling creature never moves even when you attack it. Other ai profiles which are more complex are lifesteal, heal and archer. Easiest first, is archer. An archer profiled creature uses a ranged attack where it always tries to stay 1 tile from what it is attacking. Next heal, if it has heal profile with params [5,50] say, then it heals 5 HP each time a certain number of turns has passed. The second number determines the number of turns, the bigger it is the longer the interval. Finally the lifesteal profile which has a parameter between 0 and 1. Lets explain by example. We have some creature with lifesteal 0.5. He hits a player and causes 20 hp of damage from the player. That means he 'lifesteals' 10 HP of damage back which heals him. The player hurts just as much (like normal) but the creature heals 50% of any damage it makes.

Add GFX

Now you need to find a nice sprite for your monster.

Please see How to know graphics specifications for creatures

Now place the sprite in the folder data/sprites/monsters/<class>/<subclass>.png

Register the class

Just in case your sprite is not an standard size (48x64) you will need to use a different Creature class, there is probably already one there available like giant_human or huge_animal, etc. If not, add your creature src/games/stendhal/client/entity/EntityMap.java, like this:

   register("creature","small_animal",SmallCreature.class);
   register("creature","giant_animal",BigCreature.class);
   register("creature",null,NormalCreature.class);


Add to game

Open tiled/tileset/logic/creature/<class>.png with your favourite GFX editor ( The GIMP ) and simply add a reduced version of your monsters to next free position, make sure you add that position to tileid attribute inside creatures.xml

You are done with it. Now let's play.

Balance a creature

If you have played against it you will have seen that the creature is either too weak or too strong for its level. So you can run games.stendhal.tools.BalanceRPGame <creature name> and it will give you correct ATK, DEF, HP, XP for the level you placed. It is important to choose a good initial values so that it works.



Back to stendhal main wiki page