Esempio n. 1
0
 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);
     }
   }
 }
Esempio n. 2
0
 protected void initializeAllManaged(MOB affected) {
   if (unmanagedYet.size() == 0) return;
   initializeManagedObjects(affected);
   while (unmanagedYet.size() > 0) {
     Object[] thing = unmanagedYet.removeFirst();
     if (thing[0] instanceof Command) {
       Command C = (Command) thing[0];
       try {
         String cmdparms =
             C.getAccessWords()[0]
                 + " "
                 + CMStrings.replaceAll((String) thing[1], "<TARGET>", reactToM.Name());
         affected.enqueCommand(CMParms.parse(cmdparms), Command.METAFLAG_FORCED, 0);
       } catch (Exception e) {
       }
       managed.add(C);
       continue;
     }
   }
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 protected boolean initializeManagedObjects(MOB affected) {
   if (unmanagedYet.size() == 0) return false;
   boolean didAnything = false;
   SLinkedList<Object[]> commands = new SLinkedList<Object[]>();
   while (unmanagedYet.size() > 0) {
     Object[] thing = unmanagedYet.removeFirst();
     if (thing[0] instanceof Ability) {
       if (((Ability) thing[0]).ID().equalsIgnoreCase("Mood")) {
         previousMood = "";
         Ability A = affected.fetchEffect("Mood");
         if (A != null) previousMood = A.text();
         if (previousMood.trim().length() == 0) previousMood = "NORMAL";
       }
       Ability A = (Ability) thing[0];
       A.setAffectedOne(affected);
       A.setMiscText((String) thing[1]);
       managed.add(A);
       didAnything = true;
       continue;
     }
     if (thing[0] instanceof Behavior) {
       Behavior B = (Behavior) thing[0];
       B.startBehavior(affected);
       B.setParms((String) thing[1]);
       managed.add(B);
       didAnything = true;
       continue;
     }
     if (thing[0] instanceof Command) {
       commands.add(thing);
       continue;
     }
   }
   unmanagedYet = commands;
   if (didAnything) {
     affected.recoverCharStats();
     affected.recoverPhyStats();
     affected.recoverMaxState();
   }
   return didAnything;
 }