Package games.stendhal.server.entity.npc.behaviour.impl

Examples of games.stendhal.server.entity.npc.behaviour.impl.HealerBehaviour


    zone.add(npc);
  }

    // Don't want to use standard responses for Heal, in fact what to modify them all, so just configure it all here.
    private void addHealer(final SpeakerNPC npc, final int cost) {
      final HealerBehaviour healerBehaviour = new HealerBehaviour(cost);
    final Engine engine = npc.getEngine();

    engine.add(ConversationStates.ATTENDING,
        ConversationPhrases.OFFER_MESSAGES,
        null,
        false,
        ConversationStates.ATTENDING,
        "Gimme money for beer. I heal, gis' cash.", null);

    engine.add(ConversationStates.ATTENDING,
        "heal",
        null,
        false,
        ConversationStates.HEAL_OFFERED,
            null, new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                currentBehavRes = new ItemParserResult(true, "heal", 1, null);
                        String badboymsg = "";
                int cost = healerBehaviour.getCharge(currentBehavRes, player);
                if (player.isBadBoy()) {
                  cost = cost * 2;
                  badboymsg = " Its more for nasty ones.";
                  currentBehavRes.setAmount(2);
                }
               
            if (cost != 0) {
                        raiser.say("For " + cost + " cash, ok?" + badboymsg);
                      }
              }
            });

    engine.add(ConversationStates.HEAL_OFFERED,
        ConversationPhrases.YES_MESSAGES,
        null,
            false,
            ConversationStates.IDLE,
            null, new ChatAction() {
              public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
                if (player.drop("money", healerBehaviour.getCharge(currentBehavRes, player))) {
                  healerBehaviour.heal(player);
                  raiser.say("All better now, everyone better. I love you, I do. Bye bye.");
                } else {
                  raiser.say("Pff, no money, no heal. Bye.");
                }

View Full Code Here


   * @param cost
   *            The price which can be positive for a lump sum cost, 0 for free healing
   *            or negative for a price dependent on level of player.
   */
  public void addHealer(final SpeakerNPC npc, final int cost) {
    final HealerBehaviour healerBehaviour = new HealerBehaviour(cost);
    final Engine engine = npc.getEngine();

    engine.add(ConversationStates.ATTENDING,
        ConversationPhrases.OFFER_MESSAGES, null,
        false, ConversationStates.ATTENDING, "I can #heal you.", null);

    engine.add(ConversationStates.ATTENDING, "heal", null,
        false, ConversationStates.ATTENDING,
        null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            ItemParserResult res = new ItemParserResult(true, "heal", 1, null);

            int cost = healerBehaviour.getCharge(res, player);
            currentBehavRes = res;
           
            String badboymsg = "";
            if (player.isBadBoy()) {
              cost = cost * 2;
              currentBehavRes.setAmount(2);
              badboymsg = " Healing costs more for those who slay others.";
            }

            if (cost > 0) {
              raiser.say("Healing costs " + cost
                  + "." + badboymsg + " Do you have that much?");

              raiser.setCurrentState(ConversationStates.HEAL_OFFERED); // success
            } else if (cost < 0) {
              // price depends on level if cost was set at -1
              // where the factor is |cost| and we have a +1
              // to avoid 0 charge.
              cost = player.getLevel() * Math.abs(cost) + 1;
              raiser.say("Healing someone of your abilities costs "
                  + cost
                  + " money." + badboymsg + " Do you have that much?");

              raiser.setCurrentState(ConversationStates.HEAL_OFFERED); // success
            } else {
              if ((player.getAtk() > 35) || (player.getDef() > 35)) {
                raiser.say("Sorry, I cannot heal you because you are way too strong for my limited powers.");
              } else if ((!player.isNew()
                  && (player.getLastPVPActionTime() > System
                      .currentTimeMillis()
                      - 2
                      * MathHelper.MILLISECONDS_IN_ONE_HOUR) || player.isBadBoy())) {
                // ignore the PVP flag for very young
                // characters
                // (low atk, low def AND low level)
                raiser.say("Sorry, but you have a bad aura, so that I am unable to heal you right now.");
              } else {
                raiser.say("There, you are healed. How else may I help you?");
                healerBehaviour.heal(player);
              }
            }

          }
    });

    engine.add(ConversationStates.HEAL_OFFERED,
        ConversationPhrases.YES_MESSAGES, null,
        false, ConversationStates.ATTENDING,
        null, new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
            int cost = healerBehaviour.getCharge(currentBehavRes, player);
            if (cost < 0) {
              cost = player.getLevel() * Math.abs(cost) + 1;
            }
            if (player.drop("money",
                cost)) {
              healerBehaviour.heal(player);
              raiser.say("There, you are healed. How else may I help you?");
            } else {
              raiser.say("I'm sorry, but it looks like you can't afford it.");
            }

View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.npc.behaviour.impl.HealerBehaviour

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.