Package games.stendhal.server.entity.npc

Examples of games.stendhal.server.entity.npc.ChatAction


        addJob("If passengers want to #board the #ferry to the mainland, I take them to the ship with this rowing boat.");
        addReply(
            "ferry",
        "The ferry sails regularly between this island and the mainland, Faiumoni. You can #board it when it's here. Ask me for the #status to find out where it is currently.");
        add(ConversationStates.ATTENDING, "status", null,
            ConversationStates.ATTENDING, null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            npc.say(ferrystate.toString());
          }
        });

        add(ConversationStates.ATTENDING, "board", null,
            ConversationStates.ATTENDING, null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {

            if (ferrystate == Status.ANCHORED_AT_ISLAND) {
              npc.say("In order to board the ferry, you have to pay "
                  + AthorFerry.PRICE
                  + " gold. Do you want to pay?");
              npc.setCurrentState(ConversationStates.SERVICE_OFFERED);
            } else {
              npc.say(ferrystate.toString()
                  + " You can only board the ferry when it's anchored at the island.");
            }
          }
        });

        add(ConversationStates.SERVICE_OFFERED,
            ConversationPhrases.YES_MESSAGES, null,
            ConversationStates.ATTENDING, null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            if (player.drop("money", AthorFerry.PRICE)) {
              player.teleport(getShipZone(), 27, 33, Direction.LEFT, null);

            } else {
View Full Code Here


        setPath(null);
      }

      @Override
      protected void createDialog() {
        addGreeting(null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            String reply = "I am summoning a barrier to keep the #balrog away.";

            if (player.getLevel() < 150) {
              reply += " The balrog will kill you instantly. Run away!.";
            } else {
              reply += " I will keep the barrier to protect Faiumoni. Kill it.";
            }
            raiser.say(reply);
          }
        });

        addReply("balrog",
            "The fearest creature that Bolrogh army has.");
        addGoodbye();
      }
    };

    npc.addInitChatMessage(null, new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
        if (!player.hasQuest("AenihataReward")
            && (player.getLevel() >= 150)) {
          player.setQuest("AenihataReward", "done");
View Full Code Here

        setPath(null);
      }

      @Override
      protected void createDialog() {
        addGreeting(null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            String reply = "There is something huge there! Everyone is very nervous. ";
            if (player.getLevel() < 60) {
              reply += "You are too weak to enter there.";
            } else {
              reply += "Be careful.";
            }
            raiser.say(reply);
          }
        });
        addJob("I am a dwarf Guardian and try to abandon adventurers to their fate.");
        addHelp("Take care when you are running through the tunnels of the Semos mines. There are some strong creatures waiting! If you need a better equipment, you can ask Harold in the Semos Tavern for some offers, maybe he can help you out...");
        addGoodbye();
      }
    };

    npc.addInitChatMessage(null, new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
        if (!player.hasQuest("PhalkFirstChat")) {
          player.setQuest("PhalkFirstChat", "done");
          player.addXP(500);
          ((SpeakerNPC) raiser.getEntity()).listenTo(player, "hi");
View Full Code Here

    // player wants to know what his own karma is
    npc.add(ConversationStates.QUESTION_1,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final long roundedkarma = Math.round(player.getKarma());
          final String Yk = "Your karma ";
          final String canseekarma = "Now you can always see your karma,";
          final String rk = Long.toString(roundedkarma);
View Full Code Here

        addHelp("I can give you advice on your #weapon.");
        addQuest("Let me advise you on your #weapon.");
        addOffer("I'd like to comment on your #weapon, if I may.");
        addGoodbye("Don't forget to listen in on my teachings to these cadets, you may find it helpful!");
        add(ConversationStates.ATTENDING, "weapon", null, ConversationStates.ATTENDING,
                null, new ChatAction() {

                  public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                    final Item weapon = player.getWeapon();
                    if (weapon != null) {
                      String comment;
View Full Code Here

            "Which creature you would like to hear more about?", null);

        add(ConversationStates.QUESTION_1, "",
            new NotCondition(new TriggerInListCondition(ConversationPhrases.GOODBYE_MESSAGES)),
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser speakerNPC) {
            final String creatureName = sentence.getTriggerExpression().getNormalized();
            final DefaultCreature creature = SingletonRepository.getEntityManager().getDefaultCreature(creatureName);
            if (creature == null) {
              speakerNPC.say("I have never heard of such a creature! Please tell the name again.");
              speakerNPC.setCurrentState(ConversationStates.QUESTION_1);
            } else {
              stateInfo.setCreatureName(creatureName);
              if (INFORMATION_BASE_COST > 0) {
                final int informationCost = getCost(player, creature);
                stateInfo.setInformationCost(informationCost);
                speakerNPC.say("This information costs "
                    + informationCost
                    + ". Are you still interested?");
                speakerNPC.setCurrentState(ConversationStates.BUY_PRICE_OFFERED);
              } else {
                speakerNPC.say(getCreatureInfo(player,
                    stateInfo.getCreatureName())
                    + " If you want to hear about another creature, just tell me which.");
                speakerNPC.setCurrentState(ConversationStates.QUESTION_1);
              }
            }
          }

          private int getCost(final Player player, final DefaultCreature creature) {
            return (int) (INFORMATION_BASE_COST + INFORMATION_COST_LEVEL_FACTOR
                * creature.getLevel());
          }
        });

        add(ConversationStates.BUY_PRICE_OFFERED,
            ConversationPhrases.YES_MESSAGES, null,
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser speakerNPC) {
            if (stateInfo.getCreatureName() != null) {
              if (player.drop("money",
                  stateInfo.getInformationCost())) {
                String infoString = getCreatureInfo(player, stateInfo.getCreatureName());
View Full Code Here

        setDirection(Direction.RIGHT);
      }

    };

    npc.addInitChatMessage(null, new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
        if (!player.hasQuest("TadFirstChat")) {
          player.setQuest("TadFirstChat", "done");
          ((SpeakerNPC) raiser.getEntity()).listenTo(player, "hi");
        }
View Full Code Here

    final SpeakerNPC npc2 = npcs.get("Thonatus");

    npc2.add(ConversationStates.ATTENDING, Arrays.asList("heroes", "who", "hero", "status"),
         new NotCondition(new DeathMatchEmptyCondition()), ConversationStates.ATTENDING,
         null,
         new ChatAction() {
           public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
             final List<Player> dmplayers = arena.getPlayers();
             final List<String> dmplayernames = new LinkedList<String>();
             for (Player dmplayer : dmplayers) {
               dmplayernames.add(dmplayer.getName());
             }
             // List the players inside deathmatch
             npc.say("There are heroes battling right now in the deathmatch. If you want to go and join "
                 + Grammar.enumerateCollection(dmplayernames) + ", then make the #challenge.");
           }
         });

    npc2.add(ConversationStates.ATTENDING, Arrays.asList("heroes", "who", "hero", "status") , new DeathMatchEmptyCondition(),
         ConversationStates.ATTENDING,
         "Are you a hero? Make the #challenge if you are sure you want to join the deathmatch.", null);

    npc2.add(ConversationStates.ATTENDING, "challenge",
         new AndCondition(new LevelGreaterThanCondition(19),
              new DeathMatchEmptyCondition(),
              new NotCondition(new PlayerHasPetOrSheepCondition())),
         ConversationStates.IDLE, null,        
         new TeleportAction("0_ados_wall_n", 100, 86, Direction.DOWN));


    npc2.add(ConversationStates.ATTENDING, "challenge",
       new AndCondition(new LevelGreaterThanCondition(19),
            new NotCondition(new DeathMatchEmptyCondition()),
            new NotCondition(new PlayerHasPetOrSheepCondition())),
         ConversationStates.QUESTION_1, null,        
         new ChatAction() {
           public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
             final List<Player> dmplayers = arena.getPlayers();
             final List<String> dmplayernames = new LinkedList<String>();
             for (Player dmplayer : dmplayers) {
               dmplayernames.add(dmplayer.getName());
View Full Code Here

        addGreeting("#elddir a evlos tsum uoy ecalp siht #evael ot kees uoy fI");
        add(ConversationStates.ATTENDING, "evael", null, ConversationStates.QUESTION_1, "?erus uoy erA .truh lliw tI", null);
        final List<ChatAction> processStep = new LinkedList<ChatAction>();
        processStep.add(new TeleportAction("int_afterlife", 31, 23, Direction.UP));
        processStep.add(new DecreaseKarmaAction(100.0));
        processStep.add(new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
            player.subXP(10000);
            // wipe riddle slot if player decided they couldnt answer it and would take the karma hit
            if (player.hasQuest("solve_riddles")) {
              player.removeQuest("solve_riddles");
View Full Code Here

        setPath(new FixedPath(nodes, true));
      }

      @Override
      protected void createDialog() {
        addGreeting(null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
              if (player.hasQuest(QUEST_SLOT)) {
            final long delay = REQUIRED_DAYS * MathHelper.MILLISECONDS_IN_ONE_DAY;
            final long timeRemaining = (Long.parseLong(player.getQuest(QUEST_SLOT))
                      + delay) - System.currentTimeMillis();
            if (timeRemaining > 0L) {
                raiser.say("The egg is still hatching, and will be for at least another "
                    + TimeUtil.timeUntil((int) (timeRemaining / 1000L))
                    + ".");
                return;
                  }

                if (player.hasPet()) {
                    // we don't want him to give a dragon if player already has a pet
                    raiser.say("I cannot give your newly hatched dragon to you if I don't think you'll give it your full attention! Come back when you don't have another pet with you.");
                    return;
                }

              raiser.say("Your egg has hatched! So, here you go, a nippy little baby dragon of your own. Don't forget it'll want some #food soon. And remember to #protect it.");
                   final BabyDragon babydragon = new BabyDragon(player);

                   babydragon.setPosition(raiser.getX(), raiser.getY() + 1);

                   player.setPet(babydragon);
                // clear the quest slot completely when it's not
                // being used to store egg hatching times
                   player.removeQuest(QUEST_SLOT);
                   player.notifyWorldAboutChanges();
              } else if (player.isEquipped("mythical egg")) {
                raiser.say("Where did you get that egg from?! Never mind. Tell me if you need me to #hatch it for you. It is my hobby, after all.");
              } else {
              raiser.say("Hi. I don't get so many visitors, down here.");
              }
          }
        });
            addReply("hatch", null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
              if (player.hasPet()) {
            // there's actually also a check for this when the egg is hatched,
            // but we might as well warn player here that they wouldn't be allowed two.
              raiser.say("You've already got a pet. If you get another they might fight ... or worse ...");
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.ChatAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.