HowToAddMapsServerStendhal: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
No edit summary
imported>Mort
→Adding NPC: This was terribly outdated. I updated it, but it doesn't yet describe the new XML stuff.
Line 150:
 
 
''npcs.add("name",SpeakerNPC npc = new SpeakerNPC() { ...) }'' creates a new NPC. and''NPCList.get().add(npc)'' adds 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 ''npcsNPCList.get().get(name)''.
<pre>
NPCSpeakerNPC npc =npcs.add("name", new SpeakerNPC("name") {
{/...
});
});
</pre>
 
Line 167 ⟶ 166:
 
<pre>
SpeakerNPC npc =npcs.add("Ilisa", new SpeakerNPC("Ilisa") {
protected void createPath() {▼
{
List<Path.Node> nodes=new LinkedList<Path.Node>();
▲ protected void createPath()
nodes.add(new Path.Node(149,5));▼
{
List<Path.Node> nodes=.add(new LinkedList<Path.Node>(14,5));
nodes.add(new Path.Node setPath(9nodes,5)true);
▲ nodes.add(new Path.Node(14,5));
setPath(nodes,true);
}
 
protected void createDialog() {
// Lets the NPC reply with "Hallo" when a player greets her
{
Behaviours. addGreeting(this);
// Lets the NPC reply when a player says "job"
Behaviours. addJob(this, "I have healing abilities and I heal wounded players. I also sell potions and antidotes.");
Behaviours.addHelp(this, "Ask me to #heal you and I will help you or ask me #offer and I will show my shop's stuff.");▼
// Lets the NPC reply when a player asks for help
Behaviours.addSeller(this, new Behaviours.SellerBehaviour(shops.get("healing")));▼
▲ Behaviours. addHelp(this, "Ask me to #heal you and I will help you or ask me #offer and I will show my shop's stuff.");
Behaviours.addHealer(this, 0);▼
// Makes the NPC sell potions and antidote
Behaviours.addGoodbye(this);▼
▲ Behaviours. addSeller(this, new Behaviours.SellerBehaviour(shops.get("healing")));
// Lets the NPC heal players for free
▲ Behaviours. addHealer(this, 0);
▲ Behaviours. addGoodbye(this);
}
});
NPCList.get().add(npc);
zone.assignRPObjectID(npc);
// This determines how the NPC will look like.
npc.put("class","welcomernpc");
npc.setput(9"class",5 "welcomernpc");
npc.set(9, 5);
npc.initHP(100);
zone.add(npc);
</pre>
 
UseBecause we used '''npcsNPCList.get().add(npc)''' as this way, 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.
And then create a dialog. Dialogs and such are explained in Quest sections.
 
Now simply assign an id to the npcNPC, set its outfit either by:
* setting its class to a PNG image that exists at ''data/sprites/npc''
* setting its outfit with setOutfit method.