예제 #1
0
 public int getGridChildY(Room loc) {
   try {
     return ((Integer) rooms.elementAt(rooms.indexOf(loc), 3)).intValue();
   } catch (Exception x) {
   }
   DVector rs = rooms.copyOf();
   for (int i = 0; i < rs.size(); i++)
     if (rs.elementAt(i, 1) == loc) return ((Integer) rs.elementAt(i, 3)).intValue();
   return -1;
 }
예제 #2
0
 public String getGridChildCode(Room loc) {
   if (roomID().length() == 0) return "";
   try {
     int x = rooms.indexOf(loc);
     return roomID()
         + "#("
         + ((Integer) rooms.elementAt(x, 2)).intValue()
         + ","
         + ((Integer) rooms.elementAt(x, 3)).intValue()
         + ")";
   } catch (Exception x) {
   }
   DVector rs = rooms.copyOf();
   for (int i = 0; i < rs.size(); i++)
     if (rs.elementAt(i, 1) == loc)
       return roomID()
           + "#("
           + ((Integer) rs.elementAt(i, 2)).intValue()
           + ","
           + ((Integer) rs.elementAt(i, 3)).intValue()
           + ")";
   return "";
 }
 @Override
 public void addPunishmentParm(int code, String parm) {
   final int index = punishmentParms.indexOf(Integer.valueOf(code));
   if (index >= 0) punishmentParms.removeElementAt(index);
   punishmentParms.addElement(Integer.valueOf(code), parm);
 }
 @Override
 public String getPunishmentParm(int code) {
   final int index = punishmentParms.indexOf(Integer.valueOf(code));
   if (index < 0) return "";
   return (String) punishmentParms.elementAt(index, 2);
 }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if ((mob.getWorshipCharID().length() == 0)
        || (CMLib.map().getDeity(mob.getWorshipCharID()) == null)) {
      if (!auto) mob.tell(L("You must worship a god to use this prayer."));
      return false;
    }
    final Deity D = CMLib.map().getDeity(mob.getWorshipCharID());
    if ((target.getWorshipCharID().length() > 0)
        && (CMLib.map().getDeity(target.getWorshipCharID()) != null)) {
      if (!auto)
        mob.tell(
            L(
                "@x1 worships @x2, and may not be converted with this prayer.",
                target.name(mob),
                target.getWorshipCharID()));
      return false;
    }
    if ((CMLib.flags().isAnimalIntelligence(target)
        || CMLib.flags().isGolem(target)
        || (D == null))) {
      if (!auto) mob.tell(L("@x1 can not be converted with this prayer.", target.name(mob)));
      return false;
    }
    if (!auto) {
      if (convertStack.contains(target)) {
        final Long L = (Long) convertStack.elementAt(convertStack.indexOf(target), 2);
        if ((System.currentTimeMillis() - L.longValue()) > CMProps.getMillisPerMudHour() * 5)
          convertStack.removeElement(target);
      }
      if (convertStack.contains(target)) {
        mob.tell(L("@x1 must wait to be undeniably faithful again.", target.name(mob)));
        return false;
      }
    }

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

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    int type = verbalCastCode(mob, target, auto);
    int mal = CMMsg.MASK_MALICIOUS;
    if (auto) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      mal = 0;
    }
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              type,
              auto ? "" : L("^S<S-NAME> @x1 for <T-NAMESELF> to BELIEVE!^?", prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(target, D, this, CMMsg.MSG_SERVE, L("<S-NAME> BELIEVE(S) !!!"));
      final CMMsg msg3 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_VERBAL | mal | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg))
          && (mob.location().okMessage(mob, msg3))
          && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg3);
        if ((msg.value() <= 0) && (msg3.value() <= 0)) {
          target.location().send(target, msg2);
          target.setWorshipCharID(godName);
          if (mob != target) CMLib.leveler().postExperience(mob, target, null, 25, false);
          godName = mob.getWorshipCharID();
          beneficialAffect(mob, target, asLevel, CMProps.getIntVar(CMProps.Int.TICKSPERMUDMONTH));
          convertStack.addElement(target, Long.valueOf(System.currentTimeMillis()));
        }
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          auto ? "" : L("<S-NAME> @x1 for <T-NAMESELF>, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }