Пример #1
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String whom = CMParms.combine(commands, 0);
    int dirCode = Directions.getGoodDirectionCode(whom);
    if (!CMLib.flags().canHear(mob)) {
      mob.tell("You don't hear anything.");
      return false;
    }

    if (room != null)
      for (final Enumeration<Ability> a = room.effects(); a.hasMoreElements(); ) {
        final Ability A = a.nextElement();
        if ((A.ID().equals(ID())) && (invoker() == mob)) A.unInvoke();
      }
    room = null;
    if (dirCode < 0) room = mob.location();
    else {
      if ((mob.location().getRoomInDir(dirCode) == null)
          || (mob.location().getExitInDir(dirCode) == null)) {
        mob.tell("Listen which direction?");
        return false;
      }
      room = mob.location().getRoomInDir(dirCode);
      if ((room.domainType() & Room.INDOORS) == 0) {
        mob.tell("You can only listen indoors.");
        return false;
      }
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    boolean success = false;
    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_SMALL_HANDS_ACT),
            CMMsg.MSG_OK_VISUAL,
            CMMsg.MSG_OK_VISUAL,
            "<S-NAME> listen(s)"
                + ((dirCode < 0) ? "" : " " + Directions.getDirectionName(dirCode))
                + ".");
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      success = proficiencyCheck(mob, 0, auto);
      int numberHeard = 0;
      int levelsHeard = 0;
      for (int i = 0; i < room.numInhabitants(); i++) {
        MOB inhab = room.fetchInhabitant(i);
        if ((inhab != null)
            && (!CMLib.flags().isSneaking(inhab))
            && (!CMLib.flags().isHidden(inhab))
            && (inhab != mob)) {
          numberHeard++;
          if (inhab.phyStats().level() > (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))))
            levelsHeard +=
                (inhab.phyStats().level()
                    - (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))));
        }
      }
      if ((success) && (numberHeard > 0)) {
        if (((proficiency() + (getXLEVELLevel(mob) * 10)) > (50 + levelsHeard))
            || (room == mob.location())) {
          mob.tell("You definitely hear " + numberHeard + " creature(s).");
          if (proficiency() > ((room == mob.location()) ? 50 : 75)) {
            sourceRoom = mob.location();
            beneficialAffect(mob, room, asLevel, ((room == mob.location()) ? 0 : 10));
          }
        } else mob.tell("You definitely hear something.");
      } else mob.tell("You don't hear anything.");
    }
    return success;
  }