HowToAddItemsStendhal: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Ufizavipupu No edit summary |
imported>AntumDeluge →Add GFX: add asset warning |
||
| (84 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
---- |
|||
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> |
|||
---- |
|||
=[http://ezemitekywe.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]= |
|||
---- |
|||
=[http://ezemitekywe.co.cc CLICK HERE]= |
|||
---- |
|||
</div> |
|||
{{Navigation for Stendhal Top}} |
{{Navigation for Stendhal Top}} |
||
{{Navigation for Stendhal Extenders}} |
{{Navigation for Stendhal Extenders}} |
||
You can add new item to game in a few very simple steps: |
You can add new item to game in a few very simple steps: |
||
== Preparation == |
|||
| ⚫ | |||
| ⚫ | |||
Setup a development environment as described in [[Stendhal on Eclipse]]. |
|||
| ⚫ | |||
| ⚫ | |||
The file contains all the description of the items in game. |
The file contains all the description of the items in game. |
||
Lets start with how to do weapons, for example in swords.xml: |
Lets start with how to do weapons, for example in swords.xml: |
||
<pre> |
|||
<item name="dagger"> |
|||
<type class="sword" subclass="dagger" tileid="-1"/> |
|||
<description>You see a dagger, it is little more than decorative but you can jab pretty fast with it.</description> |
|||
<implementation class-name="games.stendhal.server.entity.item.Item"/> <attributes> |
|||
<atk value="8"/> |
|||
<rate value="3"/> |
|||
</attributes> |
|||
<weight value="0.2"/> |
|||
<value value="8533"/> |
|||
<equipable> |
|||
<slot name="bag"/> |
|||
<slot name="lhand"/> |
|||
<slot name="rhand"/> |
|||
</equipable> |
|||
</item> |
|||
</pre> |
|||
It is important to understand how it works. |
It is important to understand how it works. |
||
| Line 48: | Line 44: | ||
The implementation tag should be copied from above, unless the item is stackable, in which case use: |
The implementation tag should be copied from above, unless the item is stackable, in which case use: |
||
<pre> |
|||
<implementation class-name="games.stendhal.server.entity.item.StackableItem"/> |
|||
</pre> |
|||
Inside the ''attributes'' tag you can specify the attributes the weapon has: |
Inside the ''attributes'' tag you can specify the attributes the weapon has: |
||
| Line 82: | Line 78: | ||
For scrolls, most of which are teleport scrolls, follow the examples in scrolls.xml for what implementation to use. The attribute INFOSTRING for marked scrolls is the destination of the scroll, e.g. |
For scrolls, most of which are teleport scrolls, follow the examples in scrolls.xml for what implementation to use. The attribute INFOSTRING for marked scrolls is the destination of the scroll, e.g. |
||
<pre> |
|||
<infostring value="0_nalwor_city 40 60"/> |
|||
</pre> |
|||
For summon scrolls the INFOSTRING is the creature name, but the implementation |
For summon scrolls the INFOSTRING is the creature name, but the implementation |
||
<pre> |
|||
<implementation class-name="games.stendhal.server.entity.item.scroll.SummonScroll"/> |
|||
</pre> |
|||
takes care of this, so you do not set it. |
takes care of this, so you do not set it. |
||
| Line 109: | Line 105: | ||
= Add GFX= |
= Add GFX= |
||
{{AssetWarning}} |
|||
| ⚫ | |||
| ⚫ | |||
See also [[StendhalRefactoringGraphics#Items| How to know graphics specifications for items]] |
See also [[StendhalRefactoringGraphics#Items| How to know graphics specifications for items]] |
||
| Line 116: | Line 114: | ||
= Register the class = |
= Register the class = |
||
So far we have defined what the item is like to the server. Registering the class tells the client what to do with it. (Is it stackable and should have numbers displayed, is it useable and should have a Use displayed?) '''Most classes are already registered and you may be able to ignore this section... read on to find out.''' |
|||
Usually you need to register your item class unless it really does nothing. If you're adding an item which is like what we already have (i.e. just a new shield) it's done for you, the shield class is registered. Add your item to the rest in ''src/games/stendhal/client/entity/EntityMap.java'' |
|||
Items will default to behave as a non stackable, non useable Item to the client. This covers armor, weapons, most items that don't change. Stackable but non useable classes get registered by class i.e. money, missiles, herbs etc. And most Useable items like food, drink, are registered as a whole class. So if you are adding to any existing class you very likely can ignore all this following stuff. Just come back if something doesn't work... like you expected to be able to use your new item and can't. Or if you are adding a totally new class. |
|||
| ⚫ | |||
register("item","book",Book.class); |
|||
| ⚫ | |||
register("item","drink",StackableItem.class); |
|||
register("item","money",StackableItem.class); |
|||
register("item","projectiles",StackableItem.class); |
|||
So, if you have a new class and you want it to be stackable or useable <small>or is a totally new client side object, extending Item,</small> then add your class with type (item), class and your chosen behaviour to the rest in ''src/games/stendhal/client/entity/factory/EntityMap.java'', e.g. |
|||
<source lang = "java"> |
|||
| ⚫ | |||
// flower was a new class of stackables |
|||
Creatures can drop items, see [[HowToAddCreaturesStendhal]]. Perhaps you will want your NPC to equip the player with an item as part of a quest, see [[HowToCreateQuests]] or an NPC to sell the item. For the latter you will need to understand NPC seller behaviour which should be covered separately. Until that is done, look at Seller examples such as Margaret in Semos Tavern in your source code. |
|||
| ⚫ | |||
// drink was a new class of Useables |
|||
register("item", "drink", null, UseableItem.class); |
|||
// Box is a new client side object |
|||
| ⚫ | |||
</source> |
|||
What if your item is part of a class which has a mixture of stackable and non stackable or useable and non useable? Remember the default is non stackable and non useable. So then you need to register the special ones individually. This is done by type (item), class, as before, and also subclass (same as in the xml) to specify which exact item you meant. |
|||
<source lang = "java"> |
|||
// most tools don't have a Use but the sugar mill should. the subclass in xml is sugarmill |
|||
register("item", "tool", "sugarmill", UseableItem.class); |
|||
</source> |
|||
Finally, go to ''src/games/stendhal/client/gui/j2d/entity/EntityViewFactory.java'' and configure item in the same way only if you needed to add to EntityMap above. The examples are |
|||
<source lang = "java"> |
|||
// flower was a new class of stackables |
|||
register("item", "flower", null, StackableItem2DView.class); |
|||
// drink was a new class of Useables |
|||
register("item", "drink", null, UseableItem2DView.class); |
|||
// Box is a new client side object |
|||
register("item", "box", null, Box2DView.class); |
|||
// most tools don't have a Use but the sugar mill should. the subclass in xml is sugarmill |
|||
register("item", "tool", "sugarmill", UseableItem2DView.class); |
|||
</source> |
|||
== Add Grammar == |
|||
Item names should be short and enough to identify the item, but in spoken and written English there may be some extra words associated with saying the item. For example, Carmen should offer to sell ''100 bottles of potion'' not ''100 potion''. (Add npc text example here?) |
|||
Some examples: |
|||
{| |
|||
|- |
|||
|potion |
|||
|bottle of potion |
|||
|- |
|||
|leather legs |
|||
|pair of leather legs |
|||
|- |
|||
|wine |
|||
|glass of wine |
|||
|- |
|||
|plate armor |
|||
|suit of plate armor |
|||
|- |
|||
|meat |
|||
|piece of meat |
|||
|} |
|||
To add such a grammatical prefix to NPC speech and speech recognition, edit [http://arianne.cvs.sourceforge.net/viewvc/arianne/stendhal/src/games/stendhal/common/grammar/PrefixManager.java src/games/stendhal/common/grammar/PrefixManager.java]. |
|||
{{TODO|The new structure needs documentation on the different options for register, registerEnd and registerPrefix.}} |
|||
| ⚫ | |||
===Dropped by creature=== |
|||
You can have a creature drop your newly made item. This is done by editing that creature in its XML file, found in the file location [http://arianne.cvs.sourceforge.net/viewvc/arianne/data/conf/creatures?view=markup projects/stendhal/data/conf/creatures]. Every creature in the game is located in this folder, categorized by creature type. For example, rats can be found in the file [http://arianne.cvs.sourceforge.net/viewvc/arianne/data/conf/creatures/animal.xml?view=markup projects/stendhal/data/conf/creatures/animal.xml]. |
|||
===Add to map or grower=== |
|||
You may wish to add items to a map (for player to pick up or harvest). You can either add to zone by creating a java file (good for one - off items like the poison and scroll of Haizen's table in his hut) or add using tiled which is more work initially but allows you to add to the objects layer in tiled again and again in future. (Good for iron ore to collect from the ground, herbs etc). This needs a whole tutorial on spawners (also knows as growers), please see [[HowToAddGrowers]]. |
You may wish to add items to a map (for player to pick up or harvest). You can either add to zone by creating a java file (good for one - off items like the poison and scroll of Haizen's table in his hut) or add using tiled which is more work initially but allows you to add to the objects layer in tiled again and again in future. (Good for iron ore to collect from the ground, herbs etc). This needs a whole tutorial on spawners (also knows as growers), please see [[HowToAddGrowers]]. |
||
===Sold by NPC=== |
|||
If the NPC is not already created, you can [[Stendhal NPC Coding|code a new NPC]]. Then you will need to add a seller behaviour to your NPC, which should be covered separately. Until that is done, look at Seller examples such as Margaret in Semos Tavern in your source code. The file is [http://arianne.cvs.sourceforge.net/viewvc/arianne/stendhal/src/games/stendhal/server/maps/semos/tavern/BarMaidNPC.java?view=markup src/games/stendhal/server/maps/semos/tavern/BarMaidNPC.java]. If you have any problems with the NPC understanding the item name, you might like to check [[How to test NPC Parser]]. |
|||
===Produced by NPC=== |
|||
If the NPC is not already created, you can [[Stendhal NPC Coding|code a new NPC]]. You will need to add a Producer behaviour to your NPC, which should be covered separately. Until that is done, look at Producer examples such as Arlindo in Ados Bakery in your source code. The file is [http://arianne.cvs.sourceforge.net/viewvc/arianne/stendhal/src/games/stendhal/server/maps/ados/bakery/BakerNPC.java?view=markup src/games/stendhal/server/maps/ados/bakery/BakerNPC.java]. If you have any problems with the NPC understanding the item name, you might like to check [[How to test NPC Parser]]. |
|||
===Item Quests and Quest Rewards=== |
|||
Perhaps you will want your NPC to equip the player with an item as part of a quest, see [[HowToCreateQuests]]. You can also add your items to either the [[StendhalQuest#Daily_Item_Quest|Daily Item quest]] or the [[StendhalQuest#Kirdneh_Museum_needs_help.21|Weekly item quest]], which are related to the appearance around the world (e.g. rare item?). |
|||