HowToAddMapsServerStendhal: Difference between revisions
Content deleted Content added
imported>Kymara add how to set configurator class and dont use ilisa as example. shes mixed java xml now. make it fictitious |
imported>Hendrik Brummermann No edit summary |
||
Line 1:
{{Navigation for Stendhal Top|Extending}}
{{Navigation for Stendhal
Of course you have already read:
* [[HowToUseTiledToCreateStendhalMaps]]
Line 36:
To enable a zone in the server, edit the file '''data/conf/zones/<area>.xml''' and add an entry (in the appropriate level/top-down/left-right order), giving it the zone name and map tmx file to use:
<source lang="xml">
<zone name="int_myarea_mylocation" file="interiors/myarea/mylocation.tmx"/>
<zone name="0_myarea_mylocation" level="0" x="100000" y="200000" file="Level 0/myarea/mylocation.tmx">
</
In the case of non-interior zones, the level and x/y coordinate should also be included in the <zone> element (setting them in the tmx file has been deprecated). For interior zones, the level xml attribute should '''not''' be set (for now). The coordinate starts at the top-left corner, and should align against (but never overlap) other zones in the same level.
Line 59:
Open the file and make sure that it looks like this:
<source lang="java">
package games.stendhal.server.maps.myarea.mylocation;
Line 66:
import games.stendhal.server.config.ZoneConfigurator;
public class MyEntity implements ZoneConfigurator {
* Configure a
* @param zone The zone to be configured.
*▼
▲ public void configureZone(StendhalRPZone zone, Map<String, String> attributes) {
▲ // Add/configure entity to "zone", using optional configuration "attributes"
▲ }
}
</
For each custom configuration code class, add appropriate "<configurator>" entries in your "<zone>" element, using the fully qualified package/class name of your java classes:
<source lang="xml">
<zone name="int_myarea_mylocation" file="interiors/myarea/mylocation.tmx">
<configurator class-name="games.stendhal.server.maps.myarea.mylocation.MyEntity"/>
</zone>
</
Now once it is added, test the result by starting server.
Line 146 ⟶ 145:
''SpeakerNPC npc = new SpeakerNPC() { ... }'' creates a new NPC. When added to a zone, NPCs are added it to a global list so next time you need to get the NPC for participating in a quest, or if you want to teleportto it, you can call it by its ''name'' using ''NPCList.get().get(name)''.
<source lang="java">
SpeakerNPC npc = new SpeakerNPC("name") {
/...
});
</
An example is:
<source lang="java">
SpeakerNPC npc = new SpeakerNPC("Mr Healer") {
protected void createPath() {
Line 186 ⟶ 185:
zone.add(npc);
</
The NPC is added to a list of NPC from where you can later obtain it for adding more dialogues for quests. So, it is very important to make sure the name you give to your NPC is unique.
Line 192 ⟶ 191:
It is a good idea to create a path that the NPC will follow on that area. Just used your tiled map or walk around in game and check coordinates to choose your nodes. You can also make the NPC stand still by using this instead:
<source lang="java">
// NPC does not
}
</source>
Your NPC will stand still at whatever point you set as the initial position with <code>npc.setPosition(x, y);</code>.
Line 213:
We need to tell the zone to load this configuration class file. The NPC in the example lives in the ados area, so the information is stored in data/conf/zones/ados.xml. The map she's on is called int_ados_magician_house, so the information is inside the <zone name="int_ados_magician_house" file="interiors/ados/magician_house.tmx"> </zone> section.
To load the java class file you created just add the line
<source lang="xml">
<configurator class-name="games.stendhal.server.maps.ados.magician_house.WizardNPC" />
</source>
right after the <zone ... tmx">
Check the location of the file matches the path set in the class name!
Line 225 ⟶ 227:
For example, here is the Java code for a simple NPC on Athor island:
<source lang="java">
import games.stendhal.server.entity.npc.SpeakerNPC;▼
npc.addGoodbye("Bye!");
▲ };
};
</source>
This will make the NPC react to typical words that players might say to him, e.g. "hi", "help", and "bye". This Java class is stored in the file <code>/src/games/stendhal/server/maps/athor/holiday_area/SwimmerNPC.java</code>. Of course this is just a simple example, and more sophisticated dialogs and behaviours are possible with more complex Java code.
Line 247 ⟶ 251:
Next, we need place the NPC and set the name and some other attributes. The NPC in the example lives on Athor island, so the information is stored in <code>data/conf/zones/athor.xml</code>. The map he's on is called 0_athor_island, so the information is inside the <code><zone name="0_athor_island"...> ... </zone></code> tag:
<source lang="xml">
<parameter name="
<parameter name="
<parameter name="node1">67,63</
</implementation>
</source>
* The first line says that the NPC should initially be placed at the point (67, 63).
Line 268 ⟶ 274:
If you don't want your NPC to walk around, just leave out the node parameters. Instead, you should add a parameter that defines in which direction the NPC should look on server startup (left, right, up, down), e.g.:
<source lang="xml">
<parameter name="direction">down</parameter>
</source>
Other attributes you can use:
<source lang="xml">
<attribute name="hp">50</attribute>
</source>
This will make the NPC look wounded (the health bar will be at the middle). Note that, as NPCs cannot be killed, this is only for decoration. If you leave this parameter out, the hitpoints will be set to 100, which means full health.
<source lang="xml">
<attribute name="level">10</attribute>
</source>
This sets the NPC's level of experience. Again, this is only for decoration, as NPCs don't fight or die.
| |||