Example #1
0
 public String getTickStatusSummary(Tickable obj) {
   if (obj == null) return "";
   long code = obj.getTickStatus();
   if (obj instanceof Environmental) {
     if (CMath.bset(code, Tickable.STATUS_BEHAVIOR)) {
       long b = (code - Tickable.STATUS_BEHAVIOR);
       String codeWord = "Behavior #" + b;
       if ((b >= 0) && (b < ((Environmental) obj).numBehaviors())) {
         Behavior B = ((Environmental) obj).fetchBehavior((int) b);
         codeWord += " (" + B.name() + ": " + B.getTickStatus();
       } else codeWord += " (#Error#)";
       return codeWord;
     } else if (CMath.bset(code, Tickable.STATUS_SCRIPT) && (obj instanceof MOB)) {
       long b = (code - Tickable.STATUS_SCRIPT);
       String codeWord = "Script #" + b;
       if ((b >= 0) && (b < ((MOB) obj).numScripts())) {
         ScriptingEngine S = ((MOB) obj).fetchScript((int) b);
         codeWord += " (" + CMStrings.limit(S.getScript(), 20) + ": " + S.getTickStatus();
       }
       return codeWord;
     } else if ((code & STATUS_ALLMISCTICKS) > 0) {
       long base = (code & STATUS_ALLMISCTICKS);
       int num = 0;
       for (int i = 1; i < 6; i++)
         if ((1 << (10 + i)) == base) {
           num = i;
           break;
         }
       return "Misc" + num + " Activity #" + (code - base);
     } else if (CMath.bset(code, Tickable.STATUS_AFFECT)) {
       long b = (code - Tickable.STATUS_AFFECT);
       String codeWord = "Effect #" + b;
       if ((b >= 0) && (b < ((Environmental) obj).numEffects())) {
         Environmental E = ((Environmental) obj).fetchEffect((int) b);
         codeWord += " (" + E.name() + ": " + E.getTickStatus() + ")";
       }
       return codeWord;
     }
   }
   String codeWord = null;
   if (CMath.bset(code, Tickable.STATUS_BEHAVIOR)) codeWord = "Behavior?!";
   else if (CMath.bset(code, Tickable.STATUS_SCRIPT)) codeWord = "Script?!";
   else if (CMath.bset(code, Tickable.STATUS_AFFECT)) codeWord = "Effect?!";
   else
     switch ((int) code) {
       case (int) Tickable.STATUS_ALIVE:
         codeWord = "Alive";
         break;
       case (int) Tickable.STATUS_REBIRTH:
         codeWord = "Rebirth";
         break;
       case (int) Tickable.STATUS_CLASS:
         codeWord = "Class";
         break;
       case (int) Tickable.STATUS_DEAD:
         codeWord = "Dead";
         break;
       case (int) Tickable.STATUS_END:
         codeWord = "End";
         break;
       case (int) Tickable.STATUS_FIGHT:
         codeWord = "Fighting";
         break;
       case (int) Tickable.STATUS_NOT:
         codeWord = "!";
         break;
       case (int) Tickable.STATUS_OTHER:
         codeWord = "Other";
         break;
       case (int) Tickable.STATUS_RACE:
         codeWord = "Race";
         break;
       case (int) Tickable.STATUS_START:
         codeWord = "Start";
         break;
       case (int) Tickable.STATUS_WEATHER:
         codeWord = "Weather";
         break;
       default:
         codeWord = "?";
         break;
     }
   return codeWord;
 }
Example #2
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if ((commands.size() == 1) && (((String) commands.firstElement()).startsWith("QUESTW")))
      commands.addElement("WON");
    if ((commands.size() > 1) && (((String) commands.elementAt(1)).equalsIgnoreCase("WON"))) {
      Vector qVec = new Vector();
      for (int q = 0; q < CMLib.quests().numQuests(); q++) {
        Quest Q = CMLib.quests().fetchQuest(q);
        if (Q.wasWinner(mob.Name())) {
          String name = Q.displayName().trim().length() > 0 ? Q.displayName() : Q.name();
          if (!qVec.contains(name)) qVec.addElement(name);
        }
      }
      Collections.sort(qVec);
      StringBuffer msg = new StringBuffer("^HQuests you are listed as having won:^?^N\n\r");
      for (int i = 0; i < qVec.size(); i++) msg.append(((String) qVec.elementAt(i)) + "^N\n\r");
      if (!mob.isMonster()) mob.tell(msg.toString());
    } else if ((commands.size() > 2)
        && (((String) commands.elementAt(1)).equalsIgnoreCase("DROP"))) {
      ScriptingEngine foundS = null;
      for (Enumeration<ScriptingEngine> e = mob.scripts(); e.hasMoreElements(); ) {
        ScriptingEngine SE = e.nextElement();
        if (SE == null) continue;
        if ((SE.defaultQuestName().length() > 0)
            && (CMLib.quests().findQuest(SE.defaultQuestName()) == null)) foundS = SE;
      }
      if (foundS != null) mob.delScript(foundS);
      foundS = null;

      String rest = CMParms.combine(commands, 2);
      Quest Q = CMLib.quests().findQuest(rest);
      if (Q == null) {
        mob.tell("There is no such quest as '" + rest + "'.");
        return false;
      }
      for (Enumeration<ScriptingEngine> e = mob.scripts(); e.hasMoreElements(); ) {
        ScriptingEngine SE = e.nextElement();
        if (SE == null) continue;
        if ((SE.defaultQuestName().length() > 0)
            && (SE.defaultQuestName().equalsIgnoreCase(Q.name()))) foundS = SE;
      }
      if (foundS == null) {
        mob.tell("You have not accepted a quest called '" + rest + "'.  Enter QUESTS for a list.");
        return false;
      }
      if ((!mob.isMonster()
          && (mob.session()
              .confirm("Drop the quest '" + Q.name() + "', are you sure (y/N)?", "N")))) {
        CMLib.coffeeTables().bump(Q, CoffeeTableRow.STAT_QUESTDROPPED);
        mob.delScript(foundS);
        mob.tell("Quest dropped.");
        return false;
      }
    } else if (commands.size() == 1) {
      List<Quest> qQVec = CMLib.quests().getPlayerPersistantQuests(mob);
      Vector<String> qVec = new Vector<String>();
      for (Quest Q : qQVec) {
        String name = Q.displayName().trim().length() > 0 ? Q.displayName() : Q.name();
        if (!qVec.contains(name)) qVec.addElement(name);
      }
      Collections.sort(qVec);
      StringBuffer msg = new StringBuffer("^HQuests you are listed as having accepted:^?^N\n\r");
      for (int i = 0; i < qVec.size(); i++) msg.append(((String) qVec.elementAt(i)) + "^N\n\r");
      if (!mob.isMonster())
        mob.tell(msg.toString() + "\n\r^HEnter QUEST [QUEST NAME] for more information.^N^.");

    } else {
      String rest = CMParms.combine(commands, 1);
      Quest Q = CMLib.quests().findQuest(rest);
      if (Q == null) {
        mob.tell("There is no such quest as '" + rest + "'.");
        return false;
      }
      ScriptingEngine foundS = null;
      for (Enumeration<ScriptingEngine> e = mob.scripts(); e.hasMoreElements(); ) {
        ScriptingEngine SE = e.nextElement();
        if (SE == null) continue;
        if ((SE.defaultQuestName().length() > 0)
            && (SE.defaultQuestName().equalsIgnoreCase(Q.name()))) foundS = SE;
      }
      if (foundS == null) {
        mob.tell("You have not accepted a quest called '" + rest + "'.  Enter QUESTS for a list.");
        return false;
      }
      String name = Q.displayName().trim().length() > 0 ? Q.displayName() : Q.name();
      if (!Q.name().equals(name)) name += " (" + Q.name() + ")";
      mob.tell("^HQuest Information: ^w" + name + "^N");
      String instructions = null;
      if ((instructions == null) || (instructions.length() == 0))
        instructions = foundS.getVar("*", "INSTRUCTIONS");
      if ((instructions == null) || (instructions.length() == 0))
        instructions = Q.isStat("INSTRUCTIONS") ? Q.getStat("INSTRUCTIONS") : null;
      if ((instructions == null) || (instructions.length() == 0))
        instructions = "No further information available.";
      String timeRemaining = foundS.getVar("*", "TIME_REMAINING");
      if ((timeRemaining != null) && (timeRemaining.length() > 0)) {
        String timeRemainingType = foundS.getVar("*", "TIME_REMAINING_TYPE");
        if (((timeRemainingType.equalsIgnoreCase("TICKS") || (timeRemainingType.length() == 0))
            && (CMath.isInteger(timeRemaining)))) {
          long ticks = CMath.s_int(timeRemaining);
          ticks *= CMProps.getTickMillis();
          if (ticks > 60000) timeRemaining = (ticks / 60000) + " minutes";
          else timeRemaining = (ticks / 1000) + " seconds";
        } else if (timeRemainingType.length() > 0) timeRemaining += " " + timeRemainingType;
      }
      String progress = foundS.getVar("*", "PROGRESS");
      mob.tell("^w" + instructions + "^N");
      if ((timeRemaining != null) && (timeRemaining.length() > 0))
        mob.tell("\n\r^yTime Remaining: ^w" + timeRemaining + "^N");
      if ((progress != null) && (progress.length() > 0))
        mob.tell("\n\r^yProgress: ^w" + progress + "^N");
    }
    return false;
  }