Stendhal NPC Coding: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Kymara m : changed to ; oops |
imported>Madmetzger |
||
| (18 intermediate revisions by 2 users not shown) | |||
| Line 60: | Line 60: | ||
*/ |
*/ |
||
public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) { |
public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) { |
||
buildNPC(zone |
buildNPC(zone); |
||
} |
} |
||
| Line 68: | Line 68: | ||
<source lang="java"> |
<source lang="java"> |
||
private void buildNPC(final StendhalRPZone zone |
private void buildNPC(final StendhalRPZone zone) { |
||
final SpeakerNPC npc = new SpeakerNPC("Mr Healer") { |
final SpeakerNPC npc = new SpeakerNPC("Mr Healer") { |
||
protected void createPath() { |
protected void createPath() { |
||
| Line 78: | Line 78: | ||
protected void createDialog() { |
protected void createDialog() { |
||
// Lets the NPC reply with "Hallo" when a player greets him. But we could have set |
// Lets the NPC reply with "Hallo" when a player greets him. But we could have set a custom greeting inside the () |
||
addGreeting(); |
addGreeting(); |
||
// Lets the NPC reply when a player says "job" |
// Lets the NPC reply when a player says "job" |
||
| Line 134: | Line 134: | ||
We set its outfit either by: |
We set its outfit either by: |
||
* setting its class to a PNG image that exists at ''data/sprites/npc'', e.g. <code>npc.setEntityClass("welcomernpc");</code> |
* setting its class to a [[StendhalRefactoringGraphics#NPCs|PNG image]] that exists at ''data/sprites/npc'', e.g. <code>npc.setEntityClass("welcomernpc");</code> |
||
* setting its outfit with setOutfit method e.g. <code>npc.setOutfit(new Outfit(0, 05, 01, 06, 01));</code> |
* setting its outfit with setOutfit method e.g. <code>npc.setOutfit(new Outfit(0, 05, 01, 06, 01));</code> - see [http://stendhalgame.org/hudson/job/stendhal_HEAD/javadoc/games/stendhal/server/entity/Outfit.html Outfit javadoc] |
||
It is nice to set a description for when the player does ''Look''. If you don't set one, it will just say: ''You see [NPC Name].'' |
It is nice to set a description for when the player does ''Look''. If you don't set one, it will just say: ''You see [NPC Name].'' |
||