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
This is how NPCs
''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.
npc.initHP(100);
Line 185 ⟶ 186:
</pre>
<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
'''
This is
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.
| |||