HowToAddItemsStendhal
You can add new item to game in a few very simple steps:
Edit items.xml
Download stendhal-0.51-src.tar.gz from the stendhal-website and unpack it. items.xml is located in the /data/conf/ directory. The file contains all the description of the items in game. For example.
<item name="dagger">
<type class="sword" subclass="dagger"/>
<implementation class-name="games.stendhal.server.entity.item.Item"/>
<attributes>
<atk value="8"/>
</attributes>
<weight value="0.2"/>
<equipable>
<slot name="lhand"/>
<slot name="rhand"/>
<slot name="bag"/>
</equipable>
</item>
It is important to understand how it works.
We must give a name to the item and it is done in the item 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/
items/
class/
subclass.png
This way we can reuse a single GFX for different items. For example: knife+1, old knife, elvish knife, ...
Inside the attributes tag you can specify the attributes the entity has:
- ATK it is a value proportional to the damage the item can do.
- DEF it is a value proportional to how much damage the item can block.
For Stackable items like food, money, drinks, arrows, we can use:
- quantity
To configure stackable items in the xml, use the alternative implementation:
<implementation class-name="games.stendhal.server.entity.item.StackableItem"/>
And for foods, drinks and potions we have
- amount
- regen
- frequency
Aditionally you need to specify where the item can be equipped:
- rhand
- lhand
- armor
- head
- legs
- feet
Add GFX
Now place the 32x32 sprite in the folder data/sprites/items/<class>/<subclass>.png
Edit GameObjects
Usually you need to register your item unless it really does nothing.
register("item",null,Item.class);
register("item","book",Book.class);
register("item","food",StackableItem.class);
register("item","drink",StackableItem.class);
register("item","money",StackableItem.class);
register("item","projectiles",StackableItem.class);
Add to game
You perhaps will want to add items at Quests or create them on Maps.