HowToAddMapsServerStendhal: Difference between revisions

Content deleted Content added
imported>Kymara
Create a map file: more corrections.
imported>Kymara
Adding NPCs: corrections and help
Line 139:
Usually we add NPCs (non-player characters) to make world more alive and to use them in Quests. It is because of that reason, that is so important that you add NPC on the zone they are.
 
=== The oldjava way ===
 
This is how NPCs used toshould be added to the world. The downside of this is that you need a lot of Java code. IfBut you'reat addingleast newall NPCs,the considerNPC-specific usingstuff theis newin wayone offile. doingAnd it,the asjava describedis innot theso nexthard, as you'll sectionsee.
 
''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)''.
Line 179:
// This determines how the NPC will look like.
npc.setEntityClass("welcomernpc");
// Set the initial position to be the first node on the Path you defined above.
npc.setPotitionsetPosition(9, 5);
npc.initHP(100);
 
Line 185 ⟶ 186:
</pre>
 
Because theThe NPC is added to a list of NPC from where you can later obtain it for adding more dialogues for quests. MakeSo, it is very important to make sure the name you give to your NPC is unique.
 
Just after that itIt 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:
And then create a dialog. Dialogs and such are explained in Quest sections.
 
<pre>protected void createPath() {
Now simply assign an id to the NPC, set its outfit either by:
// NPC does not move
setPath(null);
}
</pre>
 
Your NPC will stand still at whatever point you set as the initial position with <pre>npc.setPosition(x, y);</pre>.
 
And then create a dialog. Dialogs and such are explained in Quest sections, but you should find the exmaple above covers most options and the options like addHelp are quite self-explanatory.
 
Now simply assign an id to the NPC (with the line <pre>zone.assignRPObjectID(npc);</pre>, and then set its outfit either by:
* setting its class to a PNG image that exists at ''data/sprites/npc''
* setting its outfit with setOutfit method.
Line 199 ⟶ 209:
Once that is done add the NPC to zone using ''zone.add()'' method.
 
=== The newmixed xml-java way ===
'''DonIf you're editing files for use in Stendhal, please don't use this. Use the all java way above. This way you have to edit two files to keep track of your NPC! We don't want that. For your own game, do as you like :)'''
This is the newanother way of adding NPCs. It requires less Java coding skills; Java code is only required for the dialog and for special behaviour, everything else is defined in XML. But it's messy as you end up with half of the NPC information in one file and half in another.
 
First, you need to create a Java file for the dialog. You should put it in a subpackage of <code>games.stendhal.server.maps</code>; the package describes where NPC is located.