public void addAffectOrBehavior(String substr) {
   int x = substr.indexOf('=');
   if (x >= 0) {
     String nam = substr.substring(0, x);
     if (nam.trim().length() == 0) {
       reactToName = substr.substring(1);
       return;
     }
     Behavior B = CMClass.getBehavior(nam);
     if (B != null) {
       B.setSavable(false);
       Object[] SET = new Object[] {B, substr.substring(x + 1)};
       unmanagedYet.add(SET);
       return;
     }
     Ability A = CMClass.getAbility(nam);
     if (A != null) {
       A.setSavable(false);
       A.makeNonUninvokable();
       Object[] SET = new Object[] {A, substr.substring(x + 1)};
       unmanagedYet.add(SET);
       return;
     }
     Command C = CMClass.getCommand(nam);
     if (C != null) {
       Object[] SET = new Object[] {C, substr.substring(x + 1)};
       unmanagedYet.add(SET);
     }
   }
 }
  @Override
  public boolean tick(Tickable ticking, int tickID) {

    if (!super.tick(ticking, tickID)) return false;
    if (affected == null) return false;
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if ((!mob.amDead()) && ((--diseaseTick) <= 0)) {
      diseaseTick = DISEASE_DELAY();
      if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2)
        mob.curState()
            .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState());
      mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT());
      if (!CMLib.flags().isSleeping(mob)) {
        final Command C = CMClass.getCommand("Sleep");
        try {
          if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED);
        } catch (final Exception e) {
        }
      }
      return true;
    }
    return true;
  }
Exemple #3
0
  @Override
  public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
    if (!mob.isMonster()) {
      if ((commands != null)
          && (commands.size() > 1)
          && (commands.get(1).toUpperCase().equals("OFF"))) {
        final Command C = CMClass.getCommand("NoSounds");
        if (C != null) {
          return C.execute(mob, commands, metaFlags);
        }
      }

      boolean force = false;
      if (commands != null) {
        for (final Object o : commands) {
          if (o.toString().equalsIgnoreCase("force")) force = true;
        }
      }
      final Session session = mob.session();
      if ((!mob.isAttributeSet(MOB.Attrib.SOUND))
          || (!session.getClientTelnetMode(Session.TELNET_MSP))) {
        session.changeTelnetMode(Session.TELNET_MSP, true);
        for (int i = 0; ((i < 5) && (!session.getClientTelnetMode(Session.TELNET_MSP))); i++) {
          try {
            mob.session().prompt("", 500);
          } catch (final Exception e) {
          }
        }
        if (session.getClientTelnetMode(Session.TELNET_MSP)) {
          mob.setAttribute(MOB.Attrib.SOUND, true);
          mob.tell(L("MSP Sound/Music enabled.\n\r"));
        } else if (force) {
          session.setClientTelnetMode(Session.TELNET_MSP, true);
          session.setServerTelnetMode(Session.TELNET_MSP, true);
          mob.setAttribute(MOB.Attrib.SOUND, true);
          mob.tell(L("MSP Sound/Music has been forceably enabled.\n\r"));
        } else mob.tell(L("Your client does not appear to support MSP."));
      } else {
        mob.tell(L("MSP Sound/Music is already enabled.\n\r"));
      }
    }
    return false;
  }
Exemple #4
0
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   final String str = L("Prop_WizInvis");
   final Ability A = mob.fetchEffect(str);
   boolean didSomething = false;
   if (A != null) {
     final Command C = CMClass.getCommand("WizInv");
     if ((C != null) && (C.securityCheck(mob))) {
       didSomething = true;
       C.execute(mob, new XVector<String>("WIZINV", "OFF"), metaFlags);
     }
   }
   final java.util.List<Ability> V = returnOffensiveAffects(mob);
   if (V.size() == 0) {
     if (!didSomething) mob.tell(L("You are not invisible or hidden!"));
   } else for (int v = 0; v < V.size(); v++) V.get(v).unInvoke();
   mob.location().recoverRoomStats();
   mob.location().recoverRoomStats();
   return false;
 }
 protected synchronized boolean shutdownPresence(MOB affected) {
   Room R = affected.location();
   if (((R == null) || (reactToM == null) || (!R.isInhabitant(reactToM)))) {
     MOB M = (MOB) super.affected;
     for (CMObject O : managed) {
       if ((O != null) && (O.ID().equals("Mood"))) {
         if (previousMood != null) {
           try {
             Command C = CMClass.getCommand("Mood");
             if (C != null) C.execute(M, CMParms.parse("MOOD " + previousMood), 0);
           } catch (Exception e) {
           }
         }
       } else if (O instanceof Environmental) ((Environmental) O).destroy();
     }
     affected.delEffect(this);
   }
   unmanagedYet.clear();
   managed.clear();
   return false;
 }
Exemple #6
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    boolean announce = false;
    if (commands.size() > 0) {
      if (((String) commands.lastElement()).equals("!")) {
        commands.removeElementAt(commands.size() - 1);
        announce = true;
      }
    }
    final MOB target = getTargetAnywhere(mob, commands, givenTarget, true);
    if (target == null) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto
                  ? L("<T-NAME> <T-IS-ARE> knocked out of <T-HIS-HER> shoes!!!")
                  : L(
                      "^F**<S-NAME> BLAST(S) <T-NAMESELF>**, knocking <T-HIM-HER> out of <T-HIS-HER> shoes!!^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (target.location().okMessage(mob, msg)) {
        target.location().send(mob, msg);
        if (target.curState().getHitPoints() > 2)
          target.curState().setHitPoints(target.curState().getHitPoints() / 2);
        if (target.curState().getMana() > 2)
          target.curState().setMana(target.curState().getMana() / 2);
        if (target.curState().getMovement() > 2)
          target.curState().setMovement(target.curState().getMovement() / 2);
        final Item I = target.fetchFirstWornItem(Wearable.WORN_FEET);
        if (I != null) {
          I.unWear();
          I.removeFromOwnerContainer();
          target.location().addItem(I, ItemPossessor.Expire.Player_Drop);
        }
        Log.sysOut("Banish", mob.Name() + " wrathed " + target.name() + ".");
        if (announce) {
          final Command C = CMClass.getCommand("Announce");
          try {
            C.execute(
                mob,
                new XVector(
                    "ANNOUNCE",
                    target.name()
                        + " is knocked out of "
                        + target.charStats().hisher()
                        + " shoes!!!"),
                Command.METAFLAG_FORCED);
          } catch (final Exception e) {
          }
        }
      }
    } else
      return beneficialVisualFizzle(
          mob,
          target,
          L("<S-NAME> attempt(s) to inflict <S-HIS-HER> wrath upon <T-NAMESELF>, but fail(s)."));
    return success;
  }
Exemple #7
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (mob.location().numInhabitants() == 1) {
      mob.tell("You will need to find someone to teach you first.");
      return false;
    }
    if (commands.size() == 1) {
      mob.tell("Learn what?  Enter QUALIFY or TRAIN to see what you can learn.");
      return false;
    }
    commands.removeElementAt(0);
    String teacherName = "";
    if (commands.size() > 1) {
      teacherName = " " + (String) commands.lastElement();
      if (teacherName.length() > 1) {
        commands.removeElementAt(commands.size() - 1);
        if ((commands.size() > 1) && (((String) commands.lastElement()).equalsIgnoreCase("FROM")))
          commands.removeElementAt(commands.size() - 1);
      } else teacherName = "";
    }

    String what = CMParms.combine(commands, 0);
    Vector V = Train.getAllPossibleThingsToTrainFor();
    if (V.contains(what.toUpperCase().trim())) {
      Vector CC = CMParms.makeVector("SAY", "I would like to be trained in " + what);
      mob.doCommand(CC, metaFlags);
      if (teacherName.length() > 0) commands.addElement(teacherName.trim());
      Command C = CMClass.getCommand("TRAIN");
      if (C != null) C.execute(mob, commands, metaFlags);
      return true;
    }
    if (CMClass.findAbility(what + teacherName, mob) != null) {
      Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + what);
      mob.doCommand(CC, metaFlags);
      return true;
    }
    ExpertiseLibrary.ExpertiseDefinition theExpertise = null;
    Vector V2 = CMLib.expertises().myListableExpertises(mob);
    for (Enumeration e = V2.elements(); e.hasMoreElements(); ) {
      ExpertiseLibrary.ExpertiseDefinition def =
          (ExpertiseLibrary.ExpertiseDefinition) e.nextElement();
      if ((def.name.equalsIgnoreCase(what + teacherName) || def.name.equalsIgnoreCase(what))
          || (def.name.toLowerCase().startsWith((what + teacherName).toLowerCase())
              && (CMath.isRomanNumeral(def.name.substring((what + teacherName).length()).trim())
                  || CMath.isNumber(def.name.substring((what + teacherName).length()).trim())))
          || (def.name.toLowerCase().startsWith((what).toLowerCase())
              && (CMath.isRomanNumeral(def.name.substring((what).length()).trim())
                  || CMath.isNumber(def.name.substring((what).length()).trim())))) {
        theExpertise = def;
        break;
      }
    }
    if (theExpertise == null)
      for (Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); ) {
        ExpertiseLibrary.ExpertiseDefinition def =
            (ExpertiseLibrary.ExpertiseDefinition) e.nextElement();
        if ((def.name.equalsIgnoreCase(what + teacherName) || def.name.equalsIgnoreCase(what))) {
          theExpertise = def;
          break;
        }
      }
    if (theExpertise != null) {
      Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + theExpertise.name);
      mob.doCommand(CC, metaFlags);
      return true;
    }

    for (int v = 0; v < V.size(); v++)
      if (((String) V.elementAt(v)).startsWith(what.toUpperCase().trim())) {
        Vector CC = CMParms.makeVector("SAY", "I would like to be trained in " + what);
        mob.doCommand(CC, metaFlags);
        if (teacherName.length() > 0) commands.addElement(teacherName.trim());
        Command C = CMClass.getCommand("TRAIN");
        if (C != null) C.execute(mob, commands, metaFlags);
        return true;
      }
    Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + what + teacherName);
    mob.doCommand(CC, metaFlags);
    return false;
  }