예제 #1
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    final MOB mob = (MOB) affected;
    if (mob == null) return false;
    if (song == null) {
      if ((whom == null)
          || (commonRoomSet == null)
          || (!commonRoomSet.contains(whom.location()))
          || (CMLib.flags().isSleeping(invoker))
          || (!CMLib.flags().canBeSeenBy(whom, invoker))) return unsingMe(mob, null);
    }

    if ((whom != null)
        && (song != null)
        && (affected == invoker())
        && (CMLib.dice().rollPercentage() < 10)) {
      final Hashtable<Integer, Integer> H = getSongBenefits(song);
      final Vector<Integer> V = new Vector<Integer>();
      for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); )
        V.addElement(e.nextElement());
      final Integer I = V.elementAt(CMLib.dice().roll(1, V.size(), -1));
      final String[] chk = stuff[I.intValue()];
      invoker()
          .location()
          .show(invoker(), this, whom, CMMsg.MSG_SPEAK, L("<S-NAME> sing(s) '@x1'.", chk[3]));
    }

    if (!super.tick(ticking, tickID)) return false;

    return true;
  }
예제 #2
0
 public void ensureCmds() {
   synchronized (cmds) {
     if (cmds.size() == 0) {
       for (final String[] element : stuff) cmds.put(element[0], element);
     }
   }
 }
예제 #3
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;
    if ((tickID == Tickable.TICKID_MOB) && (affected instanceof MOB)) {
      final MOB mob = (MOB) affected;
      if (!DATA.containsKey(mob)) DATA.put(mob, new int[DATA_TOTAL]);
      final int[] data = DATA.get(mob);
      if ((mob.session() != null) && (mob.session().getPreviousCMD() != null)) {
        if ((lastCommand != null)
            && (!CMParms.combine(mob.session().getPreviousCMD(), 0).equals(lastCommand))) {
          data[DATA_TYPEDCOMMAND]++;
          List<MOB> V = null;
          if (mob.session().getAddress() != null) V = IPS.get(mob.session().getAddress());

          if (V != null)
            for (int v = 0; v < V.size(); v++) {
              final MOB M = V.get(v);
              if (M == mob) continue;
              if (M.session() == null) continue;
              if (!CMLib.flags().isInTheGame(M, true)) continue;
              final String hisLastCmd = CMParms.combine(mob.session().getPreviousCMD(), 0);
              final Archon_Multiwatch A = (Archon_Multiwatch) M.fetchEffect(ID());
              if (A != null) {
                if ((A.lastCommand != null) && (!A.lastCommand.equals(hisLastCmd)))
                  data[DATA_SYNCHROFOUND]++;
                break;
              }
            }
        }
        lastCommand = CMParms.combine(mob.session().getPreviousCMD(), 0);
      }
    }
    return true;
  }
예제 #4
0
파일: Druid.java 프로젝트: kingdavid127/MUD
 public static void doAnimalFreeingCheck(CharClass C, Environmental host, CMMsg msg) {
   if ((msg.source() != host)
       && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW)
       && (msg.source().isMonster())
       && (host instanceof MOB)
       && (!((MOB) host).isMonster())
       && (msg.target() == host)
       && (msg.source().getStartRoom() != null)
       && (CMLib.law().isACity(msg.source().getStartRoom().getArea()))
       && (((MOB) host).charStats().getCurrentClass().ID().equals(C.ID()))
       && (CMLib.flags().isAnimalIntelligence(msg.source())
           || msg.source().charStats().getMyRace().racialCategory().equalsIgnoreCase("Vegetation")
           || msg.source()
               .charStats()
               .getMyRace()
               .racialCategory()
               .equalsIgnoreCase("Stone Golem"))
       && (CMLib.flags().flaggedAffects(msg.source(), Ability.FLAG_SUMMONING).size() == 0)
       && (msg.source().location() != null)
       && (!msg.source().amDestroyed())
       && (CMLib.flags().isInTheGame((MOB) host, true))
       && (!CMLib.law().isACity(msg.source().location().getArea()))) {
     Object[] stuff = (Object[]) animalChecking.get(host);
     final Room room = msg.source().location();
     if ((stuff == null)
         || (System.currentTimeMillis() - ((Long) stuff[0]).longValue()
             > (room.getArea().getTimeObj().getDaysInMonth()
                 * room.getArea().getTimeObj().getHoursInDay()
                 * CMProps.getMillisPerMudHour()))) {
       stuff = new Object[3];
       stuff[0] = Long.valueOf(System.currentTimeMillis());
       animalChecking.remove(host);
       animalChecking.put(host, stuff);
       stuff[1] = Integer.valueOf(0);
       stuff[2] = new Vector();
     }
     if ((((Integer) stuff[1]).intValue() < 19)
         && (!((List) stuff[2]).contains("" + msg.source()))) {
       stuff[1] = Integer.valueOf(((Integer) stuff[1]).intValue() + 1);
       ((MOB) host)
           .tell(
               CMLib.lang()
                   .L(
                       "You have freed @x1 from @x2.",
                       msg.source().name((MOB) host),
                       (msg.source().getStartRoom().getArea().name())));
       CMLib.leveler()
           .postExperience((MOB) host, null, null, ((Integer) stuff[1]).intValue(), false);
     }
   }
 }
예제 #5
0
 @Override
 public void affectCharStats(MOB affected, CharStats affectableStats) {
   if ((whom != null) && (song != null)) {
     final Hashtable<Integer, Integer> H = getSongBenefits(song);
     for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) {
       final Integer I = e.nextElement();
       final String[] chk = stuff[I.intValue()];
       if ((chk != null) && (chk[1].startsWith("c"))) {
         int ticks = H.get(I).intValue();
         if (ticks > 50) ticks = 50;
         if (ticks <= 0) ticks = 1;
         final int stat = CMath.s_int(chk[2]);
         if (CharStats.CODES.isBASE(stat)) if (ticks > 5) ticks = 5;
         affectableStats.setStat(
             stat, affectableStats.getStat(stat) + ticks + getXLEVELLevel(invoker()));
       }
     }
   }
 }
예제 #6
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((whom != null)
       && (song == null)
       && (msg.amISource(whom))
       && (CMLib.flags().canBeSeenBy(whom, invoker()))) {
     if (trail == null) trail = new StringBuffer("");
     ensureCmds();
     if (cmds.containsKey("" + msg.sourceMinor())) trail.append(msg.sourceMinor() + ";");
   }
   super.executeMsg(myHost, msg);
 }
예제 #7
0
  @Override
  public void executeMsg(Environmental host, CMMsg msg) {
    super.executeMsg(host, msg);
    if ((affected instanceof MOB) && (msg.amISource((MOB) affected))) {
      if (!DATA.containsKey(msg.source())) DATA.put(msg.source(), new int[DATA_TOTAL]);
      final int[] data = DATA.get(msg.source());

      if (data == null) return;
      if (msg.tool() instanceof Social) {
        if (nonIPnonMonsterWithMe(msg.source())) data[DATA_GOODSOCIAL]++;
        if ((msg.target() instanceof MOB) && (!((MOB) msg.target()).isMonster()))
          data[DATA_DIRSOCIAL]++;
        data[DATA_ANYSOCIAL]++;
      } else
        switch (msg.sourceMinor()) {
          case CMMsg.TYP_SPEAK:
            if ((msg.othersMessage() != null)
                && (msg.sourceMessage() != null)
                && (msg.othersMinor() == msg.sourceMinor())
                && (msg.source().location() != null)
                && (msg.source().session() != null)) {
              if (msg.sourceMessage().indexOf("order(s)") > 0) {
                if ((msg.target() instanceof MOB)
                    && (((MOB) msg.target()).session() != null)
                    && (((MOB) msg.target())
                        .session()
                        .getAddress()
                        .equals(msg.source().session().getAddress()))) data[DATA_ORDER]++;
              } else {
                if (nonIPnonMonsterWithMe(msg.source())) data[DATA_GOODSPEECH]++;
                if ((msg.target() instanceof MOB) && (!((MOB) msg.target()).isMonster()))
                  data[DATA_DIRSPEECH]++;
                data[DATA_ANYSPEECH]++;
              }
            }
            break;
        }
    }
  }
예제 #8
0
 @Override
 public void affectPhyStats(Physical affected, PhyStats affectableStats) {
   if ((whom != null) && (song != null)) {
     final Hashtable<Integer, Integer> H = getSongBenefits(song);
     for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) {
       final Integer I = e.nextElement();
       final String[] chk = stuff[I.intValue()];
       if ((chk != null) && (chk[1].startsWith("e"))) {
         int ticks = H.get(I).intValue();
         if (ticks <= 0) ticks = 1;
         switch (chk[2].charAt(0)) {
           case 'a':
             if (ticks > 25) ticks = 25;
             affectableStats.setAttackAdjustment(
                 affectableStats.attackAdjustment() + ticks + getXLEVELLevel(invoker()));
             break;
           default:
             break;
         }
       }
     }
   }
 }
예제 #9
0
 @Override
 public void affectCharState(MOB affected, CharState affectableStats) {
   if ((whom != null) && (song != null)) {
     final Hashtable<Integer, Integer> H = getSongBenefits(song);
     for (final Enumeration<Integer> e = H.keys(); e.hasMoreElements(); ) {
       final Integer I = e.nextElement();
       final String[] chk = stuff[I.intValue()];
       if ((chk != null) && (chk[1].startsWith("s"))) {
         int ticks = H.get(I).intValue();
         if (ticks > 50) ticks = 50;
         if (ticks <= 0) ticks = 1;
         switch (chk[2].charAt(0)) {
           case 'h':
             affectableStats.setHunger(
                 affectableStats.getHunger() + ticks + getXLEVELLevel(invoker()));
             break;
           case 't':
             affectableStats.setThirst(
                 affectableStats.getThirst() + ticks + getXLEVELLevel(invoker()));
             break;
           case 'v':
             affectableStats.setMovement(
                 affectableStats.getMovement() + ticks + getXLEVELLevel(invoker()));
             break;
           case 'm':
             affectableStats.setMana(
                 affectableStats.getMana() + ticks + getXLEVELLevel(invoker()));
             break;
           case 'i':
             affectableStats.setHitPoints(
                 affectableStats.getHitPoints() + ticks + getXLEVELLevel(invoker()));
             break;
         }
       }
     }
   }
 }
예제 #10
0
  public Hashtable<Integer, Integer> getSongBenefits(String s) {
    if (benefits != null) return benefits;
    benefits = new Hashtable<Integer, Integer>();

    int x = s.indexOf(';');
    while (x >= 0) {
      final int code = CMath.s_int(s.substring(0, x));
      s = s.substring(x + 1);
      x = s.indexOf(';');
      if (x >= 0) {
        final int tick = CMath.s_int(s.substring(0, x));
        s = s.substring(x + 1);
        benefits.put(Integer.valueOf(code), Integer.valueOf(tick));
      }
      x = s.indexOf(';');
    }
    return benefits;
  }
예제 #11
0
 public Hashtable<String, String> getSongs() {
   if (songs != null) return songs;
   String t = miscText;
   int x = t.indexOf("|~|");
   songs = new Hashtable<String, String>();
   while (x >= 0) {
     final String n = t.substring(0, x);
     t = t.substring(x + 3);
     x = t.indexOf("[|]");
     String y = "";
     if (x >= 0) {
       y = t.substring(0, x);
       t = t.substring(x + 3);
       songs.put(n, y);
     }
     x = t.indexOf("|~|");
   }
   return songs;
 }
예제 #12
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    timeOut = 0;
    if (auto) return false;

    final Hashtable<String, String> H = getSongs();
    if (commands.size() == 0) {
      final Song_Ode A = (Song_Ode) mob.fetchEffect(ID());
      if ((A != null) && (A.whom != null) && (A.song == null)) {
        final String str = L("^S<S-NAME> finish(es) composing the @x1.^?", A.songOf());
        final CMMsg msg =
            CMClass.getMsg(
                mob,
                null,
                this,
                (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
                str);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(mob, msg);
          mob.delEffect(A);
          getSongs().put(A.whom.name(), A.composition());
          whom = null;
          return true;
        }
        return false;
      }

      final StringBuffer str = new StringBuffer("");
      for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); )
        str.append(e.nextElement() + " ");
      mob.tell(L("Compose or sing an ode about whom?"));
      if (str.length() > 0)
        mob.tell(L("You presently have odes written about: @x1.", str.toString().trim()));
      return false;
    }
    String name = CMParms.combine(commands, 0);
    for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) {
      final String key = e.nextElement();
      if (CMLib.english().containsString(key, name)) {
        invoker = mob;
        originRoom = mob.location();
        commonRoomSet = getInvokerScopeRoomSet(null);
        name = key;
        song = H.get(name);
        benefits = null;
        whom = mob.location().fetchInhabitant(name);
        if ((whom == null) || (!whom.name().equals(name))) whom = CMLib.players().getPlayer(name);
        if ((whom == null) || (!whom.name().equals(name))) {
          whom = CMClass.getMOB("StdMOB");
          whom.setName(name);
          whom.setLocation(mob.location());
        }
        return super.invoke(mob, commands, givenTarget, auto, asLevel);
      }
    }

    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if (target == mob) {
      mob.tell(L("You may not compose an ode about yourself!"));
      return false;
    }

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      unsingAll(mob, mob);
      invoker = mob;
      originRoom = mob.location();
      commonRoomSet = getInvokerScopeRoomSet(null);
      whom = target;
      final String str = L("^S<S-NAME> begin(s) to compose an @x1.^?", songOf());
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
              str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        final Song_Ode newOne = (Song_Ode) copyOf();
        newOne.whom = target;
        newOne.trail = new StringBuffer("");
        newOne.song = null;
        mob.addEffect(newOne);
      }
    } else
      mob.location()
          .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> lose(s) <S-HIS-HER> inspiration."));
    return success;
  }
예제 #13
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) {
      DATA.clear();
      IPS.clear();
      final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>();
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.getAddress().length() > 0) && (S.mob() != null)) {
          List V = ipes.get(S.getAddress());
          if (V == null) {
            V = new Vector();
            ipes.put(S.getAddress(), V);
          }
          if (!V.contains(S.mob())) V.add(S.mob());
        }
      }
      final StringBuffer rpt = new StringBuffer("");
      for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) {
        final String addr = (String) e.nextElement();
        final List<MOB> names = ipes.get(addr);
        if (names.size() > 1) {
          IPS.put(addr, names);
          rpt.append("Watch #" + (IPS.size()) + " added: ");
          for (int n = 0; n < names.size(); n++) {
            final MOB MN = names.get(n);
            if (MN.fetchEffect(ID()) == null) {
              final Ability A = (Ability) copyOf();
              MN.addNonUninvokableEffect(A);
              A.setSavable(false);
            }
            rpt.append(MN.Name() + " ");
          }
          rpt.append("\n\r");
        }
      }
      if (rpt.length() == 0)
        rpt.append("No users with duplicate IDs found.  Try MULTIWATCH ADD name1 name2 ... ");
      mob.tell(rpt.toString());
      return true;
    } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) {
      boolean foundLegacy = false;
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) {
          foundLegacy = true;
          break;
        }
      }
      if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) {
        mob.tell(L("Multiwatch is already off."));
        return false;
      }
      for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) {
        final List<MOB> V = e.nextElement();
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null)) {
          final MOB M = S.mob();
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      mob.tell(L("Multiplay watcher is now turned off."));
      DATA.clear();
      IPS.clear();
      return true;
    } else if ((commands.size() > 1)
        && ((String) commands.firstElement()).equalsIgnoreCase("add")) {
      final Vector V = new Vector();
      for (int i = 1; i < commands.size(); i++) {
        final String name = (String) commands.elementAt(i);
        final MOB M = CMLib.players().getPlayer(name);
        if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M);
        else mob.tell(L("'@x1' is not online.", name));
      }
      if (V.size() > 1) {
        for (int n = 0; n < V.size(); n++) {
          final MOB MN = (MOB) V.elementAt(n);
          if (MN.fetchEffect(ID()) == null) {
            final Ability A = (Ability) copyOf();
            MN.addNonUninvokableEffect(A);
            A.setSavable(false);
          }
        }
        IPS.put("MANUAL" + (IPS.size() + 1), V);
        mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size()));
      }
      return true;
    } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) {
      final StringBuffer report = new StringBuffer("");
      for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) {
        final String key = e.nextElement();
        int sync = 0;
        final List<MOB> V = IPS.get(key);
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final int data[] = DATA.get(M);
          if (data != null) sync += data[DATA_SYNCHROFOUND];
        }
        report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r");
        report.append(
            CMStrings.padRight(L("Name"), 25)
                + CMStrings.padRight(L("Speech"), 15)
                + CMStrings.padRight(L("Socials"), 15)
                + CMStrings.padRight(L("CMD"), 10)
                + CMStrings.padRight(L("ORDERS"), 10)
                + "\n\r");
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          int data[] = DATA.get(M);
          if (data == null) data = new int[DATA_TOTAL];
          report.append(CMStrings.padRight(M.Name(), 25));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH],
                  15));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL],
                  15));
          report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10));
          report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10));
          report.append("\n\r");
        }
        report.append("\n\r");
      }

      mob.tell(report.toString());
      return true;
    } else {
      mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2.."));
      return false;
    }
  }
예제 #14
0
 public Map<String, String> makeMySpellsH(List<Ability> V) {
   final Hashtable<String, String> spellH = new Hashtable<String, String>();
   for (int v = 0; v < V.size(); v++) spellH.put(V.get(v).ID(), V.get(v).ID());
   return spellH;
 }