HowToAddMapsServerStendhal: Difference between revisions

Content deleted Content added
imported>Chad3f
imported>Chad3f
Line 143:
This is how NPCs used to be added to the world. The downside of this is that you need a lot of Java code. If you're adding new NPCs, consider using the new way of doing it, as described in the next section.
 
''SpeakerNPC npc = new SpeakerNPC() { ... }'' creates a new NPC. ''NPCList.get().add(npc)''When addsadded 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)''.
<pre>
SpeakerNPC npc = new SpeakerNPC("name") {
Line 161:
SpeakerNPC npc = new SpeakerNPC("Ilisa") {
protected void createPath() {
List<Path.Node> nodes=new LinkedList<Path.Node>();
nodes.add(new Path.Node(9,5));
nodes.add(new Path.Node(14,5));
Line 181:
}
});
 
NPCList.get().add(npc);
zone.assignRPObjectID(npc);
// This determines how the NPC will look like.
npc.putsetEntityClass("class", "welcomernpc");
npc.setsetPotition(9, 5);
npc.initHP(100);
 
zone.add(npc);
</pre>
 
Because we used '''NPCList.get().add(npc)''', the NPC is added to a list of NPC from where you can later obtain it for adding more dialogues for quests. Make sure the name you give to your NPC is unique.
 
Just after that it is a good idea to create a path that the NPC will follow on that area.