Examples of ChatAction


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

        Arrays.asList("needle", "magical needle", "magical", "mithril", "cloak", "mithril cloak", "task", "quest"),
        new AndCondition(new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "told_joke"), new PlayerHasItemWithHimCondition("magical needle")),
        ConversationStates.ATTENDING,
        null,
        new MultipleActions(
          new ChatAction() {
            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              final String[] questslot = player.getQuest(mithrilcloak.getQuestSlot()).split(";");   
              int needles = 1;
              int saidjoke = 1;
              if (questslot.length > 2) {
View Full Code Here

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

    // the second number is the number of needles that she's still going to use - player doesn't know number

    npc.add(ConversationStates.ATTENDING,
        Arrays.asList("magical", "mithril", "cloak", "mithril cloak", "task", "quest"),
        new QuestStateStartsWithCondition(mithrilcloak.getQuestSlot(), "sewing;"),
        ConversationStates.ATTENDING, null, new ChatAction() {
            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              final String[] tokens = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
              // hours -> milliseconds
              final long delay = REQUIRED_HOURS_SEWING * MathHelper.MILLISECONDS_IN_ONE_HOUR;
              final long timeRemaining = (Long.parseLong(tokens[1]) + delay)
View Full Code Here

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

    final SpeakerNPC npc = npcs.get("Baldemar");

    npc.add(ConversationStates.ATTENDING,
      ConversationPhrases.QUEST_MESSAGES, null,
      ConversationStates.QUEST_OFFERED, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          if (!player.hasQuest(QUEST_SLOT) || "rejected".equals(player.getQuest(QUEST_SLOT))) {
            raiser.say("I can forge a shield made from mithril along with several other items. Would you like me to do that?");
          } else if (player.isQuestCompleted(QUEST_SLOT)) {
            raiser.say("I would prefer you left me to my entertainment.");
            raiser.setCurrentState(ConversationStates.ATTENDING);
          } else {
            raiser.say("Why are you bothering me when you haven't completed your quest yet?");
            raiser.setCurrentState(ConversationStates.ATTENDING);
          }
        }
      });

    npc.add(ConversationStates.QUEST_OFFERED,
      ConversationPhrases.YES_MESSAGES, null,
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          raiser.say(I_WILL_NEED_MANY_THINGS);
          player.setQuest(QUEST_SLOT, "start;0;0;0;0;0;0;0;0;0;0;0;0;0;0");
          player.addKarma(10);
View Full Code Here

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

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
      new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
          new QuestStateStartsWithCondition(QUEST_SLOT, "start")),
      ConversationStates.ATTENDING, null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          final String[] tokens = player.getQuest(QUEST_SLOT).split(";");
         
          int idx1 = 1;
          for (ItemData itemdata : neededItems.values()) {
              itemdata.resetAmount();
              itemdata.subAmount(tokens[idx1]);
              idx1++;
          }

          boolean missingSomething = false;

          int size = neededItems.size();
          for (int idx = 1; !missingSomething && idx <= size; idx++) {
            ItemData itemData = neededItems.get(idx);
            missingSomething = proceedItem(player, raiser,
                itemData);
          }
         
          if (player.hasKilledSolo("black giant") && !missingSomething) {
            raiser.say("You've brought everything I need to forge the shield. Come back in "
              + REQUIRED_MINUTES
              + " minutes and it will be ready.");
            player.setQuest(QUEST_SLOT, "forging;" + System.currentTimeMillis());
          } else {
            if (!player.hasKilledSolo("black giant") && !missingSomething) {
              raiser.say("This shield can only be given to those who have killed a black giant, and without the help of others.");
            }

            StringBuilder sb = new StringBuilder(30);
            sb.append("start");
            for (ItemData id : neededItems.values()) {
              sb.append(";");
              sb.append(id.getAlreadyBrought());
            }
            player.setQuest(QUEST_SLOT, sb.toString());
             
          }
        }

 
        private boolean proceedItem(final Player player,
            final EventRaiser engine, final ItemData itemData) {
          if (itemData.getStillNeeded() > 0) {
           
            if (player.isEquipped(itemData.getName(), itemData.getStillNeeded())) {
              player.drop(itemData.getName(), itemData.getStillNeeded());
              itemData.setAmount(0);
            } else {
              final int amount = player.getNumberOfEquipped(itemData.getName());
              if (amount > 0) {
                player.drop(itemData.getName(), amount);
                itemData.subAmount(amount);
              }

              engine.say(itemData.getAnswer());
              return true;
            }
          }
          return false;
        }
      });

    npc.add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
            new QuestStateStartsWithCondition(QUEST_SLOT, "forging;")),
        ConversationStates.IDLE, null, new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {

          final String[] tokens = player.getQuest(QUEST_SLOT).split(";");
         
          final long delay = REQUIRED_MINUTES * MathHelper.MILLISECONDS_IN_ONE_MINUTE;
          final long timeRemaining = (Long.parseLong(tokens[1]) + delay)
              - System.currentTimeMillis();

          if (timeRemaining > 0L) {
            raiser.say("I haven't finished forging your shield. Please check back in "
              + TimeUtil.approxTimeUntil((int) (timeRemaining / 1000L))
              + ".");
            return;
          }

          raiser.say("I have finished forging your new mithril shield. Enjoy. Now I will see what Trillium has stored behind the counter for me. ;)");
          player.addXP(95000);
          player.addKarma(25);
          final Item mithrilshield = SingletonRepository.getEntityManager().getItem("mithril shield");
          mithrilshield.setBoundTo(player.getName());
          player.equipOrPutOnGround(mithrilshield);
          player.notifyWorldAboutChanges();
          player.setQuest(QUEST_SLOT, "done");
        }
      });

    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("forge", "missing"),
      new QuestStartedCondition(QUEST_SLOT),
      ConversationStates.ATTENDING,
      null,
      new ChatAction() {
        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          final String[] tokens = player.getQuest(QUEST_SLOT).split(";");

          final int neededMithrilBar = REQUIRED_MITHRIL_BAR
              - Integer.parseInt(tokens[1]);
View Full Code Here

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

      new AndCondition(new QuestInStateCondition(QUEST_SLOT, "start"), new PlayerHasItemWithHimCondition("pina colada")),
      ConversationStates.ATTENDING,
      null,
      new MultipleActions(
            new DropItemAction("pina colada"),
            new ChatAction() {
              public void fire(final Player player,
                  final Sentence sentence,
                  final EventRaiser npc) {
                int pieAmount = Rand.roll1D6() + 1;
                new EquipItemAction("fish pie", pieAmount, true).fire(player, sentence, npc);
View Full Code Here

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

    @Override
    protected void createDialog() {
      add(ConversationStates.IDLE, ConversationPhrases.GREETING_MESSAGES,
        new GreetingMatchesNameCondition(getName()), true,
        ConversationStates.IDLE, null,
        new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            if (!player.hasQuest(QUEST_SLOT)) {
              player.setQuest(QUEST_SLOT, "");
            }
View Full Code Here

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

    npc.add(ConversationStates.ATTENDING,
      Arrays.asList("iou", "henry", "charles", "note"),
      new QuestNotCompletedCondition(QUEST_SLOT),
      ConversationStates.ATTENDING, null,
      new ChatAction() {

        public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
          // from all notes that the player is carrying, try to
          // find the IOU note
          final List<Item> notes = player.getAllEquipped("note");
View Full Code Here

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

    final List<ChatAction> reward = new LinkedList<ChatAction>();
    reward.add(new DropItemAction("wood", REQUIRED_WOOD));
    reward.add(new IncreaseXPAction(50));
    reward.add(new SetQuestToTimeStampAction(QUEST_SLOT));
    reward.add(new IncreaseKarmaAction(10));
    reward.add(new ChatAction() {
      public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
        String rewardClass;
        if (Rand.throwCoin() == 1) {
          rewardClass = "meat";
        } else {
View Full Code Here

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

          ConversationPhrases.GREETING_MESSAGES,
          new AndCondition(new GreetingMatchesNameCondition(super.getName()),
              new QuestCompletedCondition(QUEST_SLOT)),
          ConversationStates.IDLE,
          "Hi again! Good bye, and remember to behave if you want a present next year!",
            new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                addHat(player);     
              }
          }
        );

        final List<ChatAction> reward = new LinkedList<ChatAction>();
        reward.add(new EquipItemAction("stocking"));
        reward.add(new SetQuestAction(QUEST_SLOT, "done"));
        reward.add(new ChatAction() {
                public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
                addHat(player);
            }
            }
        );
View Full Code Here

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

    npc.add(ConversationStates.ATTENDING,
        "enemy",
        new QuestInStateCondition(QUEST_SLOT, 0, "start"),
        ConversationStates.ATTENDING,
        null,
        new ChatAction() {
            public void fire(Player player, Sentence sentence, EventRaiser npc) {
              npc.say(enemyForces.get(player.getQuest(QUEST_SLOT, 1)).second());
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.