HowToAddCreaturesStendhal
You can add new creatures to game in a few very simple steps:
Edit creatures in xml files
In folder data\conf\creatures you will find xml files that contain 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"/>
<corpse name="animal"/>
<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. The class should be a general description suitable for a range of creatures (say, dwarf). The subclass needs to be the name of the image, which must be located at:
data/ 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. Note also the total attack is also proportional to creature level.
- DEF it is a value proportional to how much damage the creature can block. Note also the total defense is also proportional to creature level.
- HP is the health measure
- Speed it is how fast creature moves. Range from 0 to 1, 1 is speed of player.
- 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 in the damage calculations for attack and defense, as well as chance of player hitting it or chance of hitting player, and the players to measure a creature . The experience determine the reward the player will get by killing this creature. respawn is how long it takes to respawn. The actual respawn uses a memoryless distribution so that if you wait for respawn time you have a better than half chance of finding the creature, but the respawn itself does not depend at all on when the creature was last killed.
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].
Equipping items to creatures
You can equip items at a creature's slots:
- rhand
- lhand
- armor
- head
- legs
- feet
Equipping with defensive items does not change the attack or def so it is not worth doing at the moment. Equipping with weapons makes the creature hit with the rate of the weapon. It does not add to the attack. If a creature is equipped with weapon of rate less than 5, is attacking faster, so it needs a smaller attack than other creatures of similar level. Likewise slower hitting creatures should hit harder to have the same overall effect.
Unless you want the creature to attack with a rate other than the default of 5, it is a good idea not to equip creatures ( because they take more memory ). Archers should equip arrows and bows so they have something to shoot with.
If a creature equips a weapon the drops are not changed.
Corpses
You can specify what corpse image the creature should use and say how big that corpse is (if bigger than 1x1). The images are in data/sprites/corpse. For a bigger corpse than the example above (deer uses animal) the syntax is:
<corpse name="giant_humanoid" width="2" height="2"/>
AI profiles
These are added as in the example above. See also StendhalBestiary where examples are given of creatures with each profile.
- offensive / non offensive
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.
- patrolling / non patrolling
A patrolling creature follows a set path. A non patrolling creature never moves even when you attack it.
- coward / stupid coward/ brave
A coward runs away when you attack it. A brave creature does not. A stupid coward is not so smart at changing directions when it meets a wall and just runs into it.
- animal / human
These mean nothing at the moment.
- archer
An archer profiled creature uses a ranged attack where it always tries to stay some tiles away from what it is attacking. The ai profile adds some attack on top of normal creatures so an archer should be given less attack than creatures of a similar level.
- lifesteal
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.
- heal
Creatures can have a heal profile which has two parameters [regen amount, turns]. For 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.
- poison
Poisonous creatures with parameters [chance, poison item] have a chance/100 probability of poisoning you every time they hit you. Your defence does not help you defend against a poisonous creature. They poison with a specific poisonous item, so that the total amount poisoned, the frequency and the amount of health lost each time is taken from the poison item itself.
- rare
Some creatures can be given very low probability of spawning (which gives an average respawn time which is very long, say 6 weeks) and these should not be requested by the Mayor as a kill, nor appear in deathmatch which would ruin the novelty of them. For these use the rare ai profile. They cannot be summoned in raids except in a test server, again to make sure the surprise of them is not spoilt.
- hidden
Hidden creatures simply do not show on the stendhal website page for creatures.
Add GFX
WARNING:
If you add images, audio, or any other type of asset to the source code tree without citing whether or not you are the original author of the work, the source where the work originates, & appropriate licensing, the assets WILL BE REMOVED OR REPLACED. Please do not add any material that you do not know where it came from. This creates more work for us where we could spend the time elsewhere improving the game.
Acceptable citing can be done within the Git commit of the asset or in the appropriate file in the sources directory. If you want to add an asset via the GitHub issues or SourceForge trackers, please cite sources & licensing in the description. If you are the original author of the work simply state that you are, even if you are releasing the work into the public domain. If the work is originally created for Stendhal & is not hosted on another site, then you do not need to reference a source. Be mindful of the definition of a derivative work & give credit to original authors when required by the licensing. We suggest crediting original authors even when they do not require to do so. This helps us keep track of sources.
Acceptable licenses are (from most restrictive to least) Creative Commons Attribution-ShareAlike (CC BY-SA), Creative Commons Attribution (CC BY), OpenGameArt.org Attribution (OGA BY), & Creative Commons Zero (CC0). If you want to dedicate the work to the public domain please use the CC0 license. Using GPL/LGPL licensing is acceptable as well, but it is preferable to use one of the aforementioned licenses. Derivative works can be licensed under a more restrictive license (e.g. you can use CC BY-SA for a derivative of a CC BY licensed asset) but not under a lesser one (e.g. you cannot use OGA BY for a derivative of a CC BY licensed asset).
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
Then open the map you want to add the creature at. Use the objects layer not 2_object! and place the tile you just created, where you want the creature to respawn. See Tiled Tutorial if you are not familiar with map editing.
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 <name of creature> 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. The balancer bases its output on the configured creature level & HP values. So those two values must be decided on & set in the XML configuration. Before running the balancer ATK, DEF, & XP can be set to any value as the balancer ignores these.
IMPORTANT NOTE: The balancer does not make any adjustments to configured creatures nor does it report whether or not a creature is balanced in its current configuration. It only outputs suggested ATK, DEF, & XP values based on the creature's current configured level & HP values. It is up to you to manually change any configured creatures' stats.
Using the Balancer Utility
The balancer is a tool that suggests appropriate ATK, DEF, & optionally XP reward for creatures in the game. Before using the utility to balance a creature, the creature must be configured in an appropriate XML file located under data/conf/creatures/
.
Eclipse
Steps:
- Open the debug or run configurations.
- Under "Java Application" press the "New launch configuration" button.
- "Main" tab:
- Under "Main class" set the value to "games.stendhal.tools.BalanceRPGame".
- "Classpath" tab:
- Select "User Entries".
- Press "Advanced".
- In the window that pops up select "Add Folders" & press "OK".
- Select the Stendhal project folder & press "OK".
- "Arguments" tab:
- Under "Program arguments" you can list (space separated) the creatures you want to test. If the creature you want to test contains whitespace in its name, you must surround its name with quotes ("). If you do not put anything in this field, the balancer will run through all registered creatures.
- There is currently one recognized argument for the "VM arguments section. That is "-Dshowxp". If this value is set, the output of the balancer will include a suggested XP reward value for defeating the creature.
- Run the balancer by pressing the "Debug" or "Run" button.
Command Line
NOTE: To execute the balancer CLASSPATH must include the following:
Linux/Unix:
./build/build_stendhaltools/:./:./build/build_server/:./tests/:./libs/*
Windows:
.\\build\\build_stendhaltools;.;.\\build\\build_server;tests;.\\libs\\*
Steps:
- From your command line, navigate to the root directory of the Stendhal source.
- Before you can use the enemy balancer, the Stendhal server & tools must be compiled. If you have Apache Ant installed, this can be accomplished by running:
ant compile_stendhaltools server_build
- Execute the following command(s):
- To run through all configured creatures/enemies:
java -cp "./build/build_stendhaltools/:./:./build/build_server/:./tests/:./libs/*" games.stendhal.tools.BalanceRPGame
- For only specific creatures, append the creature names to the end of the command:
java -cp "./build/build_stendhaltools/:./:./build/build_server/:./tests/:./libs/*" games.stendhal.tools.BalanceRPGame orc "mountain orc"
- NOTE: Creature names containing whitespace must be enclosed in quotes (").
- To display XP suggestion, add the
-Dshowxp
option:java -cp "./build/build_stendhaltools/:./:./build/build_server/:./tests/:./libs/*" -Dshowxp games.stendhal.tools.BalanceRPGame
- To run through all configured creatures/enemies:
Ant Command Line
NOTES:
- To run the balancer using the
ant
command, you will need to have Apache Ant installed. - Currently this method does NOT support running the balancer without any creature name arguments.
- Currently this method does NOT support displaying XP suggestion.
Steps:
- From your command line, navigate to the root directory of the Stendhal source.
- Execute the following command (replace "name" with the creature you want to balance):
ant balance -Dcreature="name"
- Multiple creatures can be processed at once by simply adding multiple creature names separated with whitespace:
-Dcreature="lion tiger bear"
- Creature names containing whitespace must be enclosed within nested double or single quotes. Examples:
-Dcreature="\"mountain orc\""
(single creature)-Dcreature="'mountain orc'"
(single creature)-Dcreature='"mountain orc"'
(single creature)-Dcreature="'mountain orc' orc"
(multiple creatures)
Implementing Output
- After the balancer has finished running its simulation, it will output suggested values for ATK, DEF, & XP (if the "-Dshowxp" option is set).
- Open the XML file where the creature is configured & use the suggested values to fine tune the creature's ATK, DEF, & XP values.