HistorianGeographerNPC.java :  » Game » Arianne-RPG-0.83 » games » stendhal » server » maps » semos » library » Java Open Source

Java Open Source » Game » Arianne RPG 0.83 
Arianne RPG 0.83 » games » stendhal » server » maps » semos » library » HistorianGeographerNPC.java
package games.stendhal.server.maps.semos.library;

import games.stendhal.server.core.config.ZoneConfigurator;
import games.stendhal.server.core.engine.StendhalRPZone;
import games.stendhal.server.core.pathfinder.FixedPath;
import games.stendhal.server.core.pathfinder.Node;
import games.stendhal.server.entity.npc.ChatAction;
import games.stendhal.server.entity.npc.ConversationPhrases;
import games.stendhal.server.entity.npc.ConversationStates;
import games.stendhal.server.entity.npc.SpeakerNPC;
import games.stendhal.server.entity.npc.parser.Sentence;
import games.stendhal.server.entity.player.Player;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class HistorianGeographerNPC implements ZoneConfigurator {
  /**
   * Configure a zone.
   *
   * @param  zone    The zone to be configured.
   * @param  attributes  Configuration attributes.
   */
  public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) {
    buildSemosLibraryArea(zone, attributes);
  }

  private void buildSemosLibraryArea(final StendhalRPZone zone, final Map<String, String> attributes) {
    final SpeakerNPC npc = new SpeakerNPC("Zynn Iwuhos") {

      @Override
      protected void createPath() {
        final List<Node> nodes = new LinkedList<Node>();
        nodes.add(new Node(15, 3));
        nodes.add(new Node(12, 3));
        nodes.add(new Node(12, 6));
        nodes.add(new Node(13, 6));
        nodes.add(new Node(13, 7));
        nodes.add(new Node(13, 6));
        nodes.add(new Node(15, 6));
        nodes.add(new Node(15, 7));
        nodes.add(new Node(15, 6));
        nodes.add(new Node(17, 6));
        nodes.add(new Node(17, 7));
        nodes.add(new Node(17, 3));
        setPath(new FixedPath(nodes, true));
      }

      @Override
      protected void createDialog() {
        add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES, null, ConversationStates.ATTENDING,
                null, new ChatAction() {

                  public void fire(final Player player, final Sentence sentence, final SpeakerNPC engine) {
                    // A little trick to make NPC remember if it has met
                    // player before anc react accordingly
                    // NPC_name quest doesn't exist anywhere else neither is
                    // used for any other purpose
                    if (player.isQuestCompleted("Zynn")) {
                      engine.say("Hi again, " + player.getTitle() + ". How can I #help you this time?");
                    } else {
                      engine.say("Hi, potential reader! Here you can find records of the history of Semos, and lots of interesting facts about this island of Faiumoni. If you like, I can give you a quick introduction to its #geography and #history! I also keep up with the #news, so feel free to ask me about that.");
                      player.setQuest("Zynn", "done");
                    }
                  }
                });
        addHelp("I can best help you by sharing my knowledge of Faiumoni's #geography and #history, as well as the latest #news.");
        addJob("I'm a historian and geographer, committed to writing down every objective fact about Faiumoni. Did you know I wrote most of the books in this library? Well, apart from \"Know How To Kill Creatures\", of course... Hayunn Naratha wrote that.");

        addQuest("I don't think there's really anything you could do for me right now. But thanks for asking!");

        add(ConversationStates.ATTENDING, Arrays.asList("offer", "buy", "trade", "deal", "scroll", "scrolls", "home", "empty",
                "marked", "summon", "magic", "wizard", "sorcerer"), null, ConversationStates.ATTENDING,
                "I don't sell scrolls anymore... I had a big argument with my supplier, #Haizen.", null);

        add(
                ConversationStates.ATTENDING,
                Arrays.asList("haizen", "haizen."),
                null,
                ConversationStates.ATTENDING,
                "Haizen? He's a wizard who lives in a small hut between Semos and Ados. I used to sell his scrolls here, but we had an argument... you'll have to go see him yourself, I'm afraid.",
                null);
      }
    };

    npc.setEntityClass("wisemannpc");
    npc.setPosition(15, 3);
    npc.initHP(100);
    zone.add(npc);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.