Stendhal NPC Coding: Difference between revisions
Content deleted Content added
imported>Kymara No edit summary |
imported>Kymara No edit summary |
||
Line 5:
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.
This is how NPCs
A java file should define the path they walk on, basic dialog and how they look. It can also define the selling, buying, healing or producing behaviour of an NPC. The NPC is only loaded into a zone if you also edit the zone's xml file, to configure the zone using that java file.
More complicated dialog for NPCs, such as you'd find in a quest, is covered in [[Stendhal Quest Coding]]. But the basics for any NPC used in a quest should still be written as below.
== Define NPC with Java ==
''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">
Line 74 ⟶ 79:
Once that is done add the NPC to zone using ''zone.add()'' method.
== Configure zone xml ==
We need to tell
To load the java class file you created just add the line
<source lang="xml">
| |||