Exemplo n.º 1
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_WEAPONATTACK)
       && (weaponClassification() == Weapon.CLASS_THROWN)) return;
   // msg.addTrailerMsg(CMClass.getMsg(msg.source(),this,CMMsg.MSG_DROP,null));
   else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && (msg.target() != null)
       && (msg.target() instanceof MOB)
       && (weaponClassification() == Weapon.CLASS_THROWN)) {
     unWear();
     msg.addTrailerMsg(
         CMClass.getMsg(msg.source(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_DROP, null));
     msg.addTrailerMsg(
         CMClass.getMsg((MOB) msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_GET, null));
     msg.addTrailerMsg(
         CMClass.getMsg(
             msg.source(), msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.TYP_GENERAL, null));
   } else if ((msg.tool() == this)
       && (msg.target() instanceof MOB)
       && (msg.targetMinor() == CMMsg.TYP_GENERAL)
       && (((MOB) msg.target()).isMine(this))
       && (msg.sourceMessage() == null)) {
     final Ability A = CMClass.getAbility("Thief_Bind");
     if (A != null) {
       A.setAffectedOne(this);
       A.invoke(msg.source(), (MOB) msg.target(), true, phyStats().level());
     }
   } else super.executeMsg(myHost, msg);
 }
Exemplo n.º 2
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((affected instanceof MOB)
        && (msg.amISource((MOB) affected))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.tool() instanceof Weapon)
        && (msg.value() > 0)
        && (msg.target() instanceof MOB)
        && (((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_THROWN)) {
      if (CMLib.dice().rollPercentage() < 25) helpProficiency((MOB) affected, 0);
      final CMMsg msg2 =
          CMClass.getMsg(
              (MOB) msg.target(),
              msg.tool(),
              this,
              CMMsg.MSG_OK_VISUAL,
              L("^F^<FIGHT^><T-NAME> fragment(s) in <S-NAME>!^</FIGHT^>^?"));
      CMLib.color().fixSourceFightColor(msg2);
      msg.addTrailerMsg(msg2);
      msg.setValue(
          msg.value()
              + (int)
                  Math.round(
                      CMath.mul(
                          3.0 * msg.value(),
                          CMath.div(proficiency(), 100.0 - (10.0 * getXLEVELLevel(invoker()))))));
    }

    return super.okMessage(myHost, msg);
  }
Exemplo n.º 3
0
  @Override
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    final MOB source = msg.source();
    if (!canFreelyBehaveNormal(affecting)) return;
    final MOB observer = (MOB) affecting;

    if ((source != observer)
        && (msg.amITarget(observer))
        && (msg.targetMinor() == CMMsg.TYP_GIVE)
        && (msg.tool() instanceof Coins)) {
      if ((CMLib.flags().canBeSeenBy(source, observer))
          && (CMLib.flags().canBeSeenBy(observer, source))) {
        double value = ((Coins) msg.tool()).getTotalValue();
        final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
        double takeCut = getMyCut(affecting, currency);
        double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
        if ((amountToTake > 0.0)
            && (amountToTake
                < CMLib.beanCounter()
                    .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
          amountToTake =
              CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
        value -= amountToTake;
        observer.recoverPhyStats();
        final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
        if ((value > 0.0) && (C != null)) {
          // this message will actually end up triggering the hand-over.
          final CMMsg newMsg =
              CMClass.getMsg(
                  observer,
                  source,
                  C,
                  CMMsg.MSG_SPEAK,
                  L("^T<S-NAME> say(s) 'Thank you for your business' to <T-NAMESELF>.^?"));
          C.setOwner(observer);
          final long num = C.getNumberOfCoins();
          final String curr = C.getCurrency();
          final double denom = C.getDenomination();
          C.destroy();
          C.setNumberOfCoins(num);
          C.setCurrency(curr);
          C.setDenomination(denom);
          msg.addTrailerMsg(newMsg);
        } else CMLib.commands().postSay(observer, source, L("Gee, thanks. :)"), true, false);
        ((Coins) msg.tool()).destroy();
      } else if (!CMLib.flags().canBeSeenBy(source, observer))
        CMLib.commands()
            .postSay(observer, null, L("Wha?  Where did this come from?  Cool!"), true, false);
    } else if ((msg.source() == observer)
        && (msg.target() instanceof MOB)
        && (msg.targetMinor() == CMMsg.TYP_SPEAK)
        && (msg.tool() instanceof Coins)
        && (((Coins) msg.tool()).amDestroyed())
        && (!msg.source().isMine(msg.tool()))
        && (!((MOB) msg.target()).isMine(msg.tool())))
      CMLib.beanCounter()
          .giveSomeoneMoney(msg.source(), (MOB) msg.target(), ((Coins) msg.tool()).getTotalValue());
  }
Exemplo n.º 4
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((msg.source().location() != null)
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && ((msg.value()) > 0)
       && (msg.tool() == this)
       && (msg.target() instanceof MOB)
       && (!((MOB) msg.target()).amDead())
       && (CMLib.flags().isEvil((MOB) msg.target()))) {
     final CMMsg msg2 =
         CMClass.getMsg(
             msg.source(),
             msg.target(),
             new HolyAvenger(),
             CMMsg.MSG_OK_ACTION,
             CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD,
             CMMsg.MSG_NOISYMOVEMENT,
             null);
     if (msg.source().location().okMessage(msg.source(), msg2)) {
       msg.source().location().send(msg.source(), msg2);
       int damage = CMLib.dice().roll(1, 15, 0);
       if (msg.value() > 0) damage = damage / 2;
       msg.addTrailerMsg(
           CMClass.getMsg(
               msg.source(),
               msg.target(),
               CMMsg.MSG_OK_ACTION,
               L(
                   "@x1 dispels evil within <T-NAME> and @x2 <T-HIM-HER>>!",
                   name(),
                   CMLib.combat().standardHitWord(Weapon.TYPE_BURSTING, damage))));
       final CMMsg msg3 =
           CMClass.getMsg(
               msg.source(),
               msg.target(),
               null,
               CMMsg.MSG_OK_VISUAL,
               CMMsg.MSG_DAMAGE,
               CMMsg.NO_EFFECT,
               null);
       msg3.setValue(damage);
       msg.addTrailerMsg(msg3);
     }
   }
 }
Exemplo n.º 5
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if ((msg.amITarget(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.tool() instanceof Ability)
        && (!mob.amDead())) {
      final Ability A = (Ability) msg.tool();
      if (CMath.bset(A.flags(), Ability.FLAG_PARALYZING)) {
        msg.addTrailerMsg(
            CMClass.getMsg(
                mob,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("The uninhibiting barrier around <S-NAME> repels the @x1.", A.name())));
        return false;
      }
      final MOB newMOB = CMClass.getFactoryMOB();
      final CMMsg msg2 = CMClass.getMsg(newMOB, null, null, CMMsg.MSG_SIT, null);
      newMOB.recoverPhyStats();
      try {
        A.affectPhyStats(newMOB, newMOB.phyStats());
        if ((!CMLib.flags().aliveAwakeMobileUnbound(newMOB, true))
            || (CMath.bset(A.flags(), Ability.FLAG_PARALYZING))
            || (!A.okMessage(newMOB, msg2))) {
          msg.addTrailerMsg(
              CMClass.getMsg(
                  mob,
                  null,
                  CMMsg.MSG_OK_VISUAL,
                  L("The uninhibiting barrier around <S-NAME> repels the @x1.", A.name())));
          newMOB.destroy();
          return false;
        }
      } catch (final Exception e) {
      }
      newMOB.destroy();
    }
    return true;
  }
Exemplo n.º 6
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((System.currentTimeMillis() - lastClanCheck) > TimeManager.MILI_HOUR) {
     lastClanCheck = System.currentTimeMillis();
     if ((clanID().length() > 0) && (CMLib.clans().getClan(clanID()) == null)) {
       destroy();
       return;
     }
   }
   if (StdClanItem.stdExecuteMsg(this, msg)) {
     super.executeMsg(myHost, msg);
     if ((msg.amITarget(this))
         && (clanID().length() > 0)
         && (msg.source().getClanRole(clanID()) != null)) {
       final Room R = msg.source().location();
       if (R == null) return;
       if ((msg.targetMinor() == CMMsg.TYP_DROP) && (msg.trailerMsgs() == null)) {
         msg.addTrailerMsg(CMClass.getMsg(msg.source(), this, CMMsg.MSG_LOOK, null));
         setRightfulOwner(R);
       } else if ((msg.targetMinor() == CMMsg.TYP_LOOK)
           || (msg.targetMinor() == CMMsg.TYP_EXAMINE)) {
         final LegalBehavior B = CMLib.law().getLegalBehavior(R);
         String s = "";
         if (B != null) s = B.conquestInfo(CMLib.law().getLegalObject(R));
         if (s.length() > 0) msg.source().tell(s);
         else msg.source().tell(L("This area is under the control of the Archons."));
         return;
       } else if ((msg.targetMinor() == CMMsg.TYP_SPEAK)
           && (CMSecurity.isAllowed(msg.source(), R, CMSecurity.SecFlag.CMDROOMS))
           && (msg.targetMessage() != null)) {
         final String msgStr = CMStrings.getSayFromMessage(msg.targetMessage().toUpperCase());
         final String alert = "I HEREBY DECLARE THIS AREA";
         final int msgIndex = msgStr.indexOf(alert);
         if (msgIndex >= 0) {
           final LegalBehavior B = CMLib.law().getLegalBehavior(R);
           if (B != null) B.setControlPoints(clanID(), B.controlPoints() + 1);
         }
       }
     }
   }
 }
Exemplo n.º 7
0
  @Override
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    final MOB mob = msg.source();

    switch (msg.targetMinor()) {
      case CMMsg.TYP_WAND_USE:
        if (msg.amITarget(this) && ((msg.tool() == null) || (msg.tool() instanceof Physical)))
          waveIfAble(mob, (Physical) msg.tool(), msg.targetMessage());
        break;
      case CMMsg.TYP_SPEAK:
        if ((msg.sourceMinor() == CMMsg.TYP_SPEAK) && (!amWearingAt(Wearable.IN_INVENTORY))) {
          boolean alreadyWanding = false;
          final List<CMMsg> trailers = msg.trailerMsgs();
          if (trailers != null)
            for (final CMMsg msg2 : trailers)
              if (msg2.targetMinor() == CMMsg.TYP_WAND_USE) alreadyWanding = true;
          final String said = CMStrings.getSayFromMessage(msg.sourceMessage());
          if ((!alreadyWanding) && (checkWave(mob, said)))
            msg.addTrailerMsg(
                CMClass.getMsg(
                    msg.source(),
                    this,
                    msg.target(),
                    CMMsg.NO_EFFECT,
                    null,
                    CMMsg.MASK_ALWAYS | CMMsg.TYP_WAND_USE,
                    said,
                    CMMsg.NO_EFFECT,
                    null));
        }
        break;
      default:
        break;
    }
    super.executeMsg(myHost, msg);
  }
Exemplo n.º 8
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((myHost == null) || (!(myHost instanceof MOB))) return;
   final MOB mob = (MOB) myHost;
   if (msg.amISource(mob)) {
     if (((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
         && (msg.target() instanceof Wand)
         && (mob.charStats().getClassLevel(this) >= 30)) {
       final String message =
           "<O-NAME> has " + ((Wand) msg.target()).usesRemaining() + " charges remaining.";
       msg.addTrailerMsg(
           CMClass.getMsg(
               mob,
               null,
               msg.target(),
               CMMsg.MSG_OK_VISUAL,
               CMMsg.NO_EFFECT,
               CMMsg.NO_EFFECT,
               message));
     } else if (msg.tool() != null) {
       if (msg.tool().ID().equals("Skill_Spellcraft")) {
         if ((msg.tool().text().length() > 0) && (msg.target() instanceof MOB)) {
           Ability A = ((MOB) msg.target()).fetchAbility(msg.tool().text());
           if (A == null) return;
           final Ability myA = mob.fetchAbility(A.ID());
           if (myA != null) {
             if ((!A.isSavable())
                 && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
                 && (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30))
               addAbilityToSpellcraftList(mob, A);
           } else if (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30) {
             final Vector<Ability> otherChoices = new Vector<Ability>();
             for (int a = 0; a < mob.numAbilities(); a++) {
               final Ability A2 = mob.fetchAbility(a);
               if ((A2 != null)
                   && (!A2.isSavable())
                   && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
                 otherChoices.addElement(A2);
             }
             A = (Ability) A.copyOf();
             A.setProficiency(0);
             A.setSavable(false);
             if (otherChoices.size() > (mob.charStats().getClassLevel(this) / 3)) {
               final Ability A2 =
                   otherChoices.elementAt(CMLib.dice().roll(1, otherChoices.size(), -1));
               clearAbilityFromSpellcraftList(mob, A2);
             }
             addAbilityToSpellcraftList(mob, A);
           }
         }
       } else if (msg.tool().ID().equals("Spell_Scribe")
           || msg.tool().ID().equals("Spell_EnchantWand")
           || msg.tool().ID().equals("Spell_MagicItem")
           || msg.tool().ID().equals("Spell_StoreSpell")
           || msg.tool().ID().equals("Spell_WardArea")) {
         final Ability A = mob.fetchAbility(msg.tool().text());
         if ((A != null) && (!A.isSavable())) clearAbilityFromSpellcraftList(mob, A);
       } else if (msg.tool() instanceof Ability) {
         final Ability A = mob.fetchAbility(msg.tool().ID());
         if ((A != null)
             && (!A.isSavable())
             && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
           clearAbilityFromSpellcraftList(mob, A);
       }
     }
   }
 }
Exemplo n.º 9
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    final Room R = mob.location();
    boolean quiet = false;
    if ((commands != null)
        && (commands.size() > 1)
        && (((String) commands.lastElement()).equalsIgnoreCase("UNOBTRUSIVELY"))) {
      commands.remove(commands.size() - 1);
      quiet = true;
    }
    final String textMsg = "<S-NAME> look(s) ";
    if (R == null) return false;
    if ((commands != null) && (commands.size() > 1)) {
      Environmental thisThang = null;

      if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("at")))
        commands.remove(1);
      else if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("to")))
        commands.remove(1);
      final String ID = CMParms.combine(commands, 1);

      if ((ID.toUpperCase().startsWith("EXIT") && (commands.size() == 2))
          && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) {
        final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null);
        if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF))
          exitMsg.setValue(CMMsg.MASK_OPTIMIZE);
        if (R.okMessage(mob, exitMsg)) R.send(mob, exitMsg);
        return false;
      }
      if (ID.equalsIgnoreCase("SELF") || ID.equalsIgnoreCase("ME")) thisThang = mob;

      if (thisThang == null) thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, noCoinFilter);
      if (thisThang == null)
        thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, Wearable.FILTER_ANY);
      if ((thisThang == null)
          && (commands.size() > 2)
          && (((String) commands.get(1)).equalsIgnoreCase("in"))) {
        commands.remove(1);
        final String ID2 = CMParms.combine(commands, 1);
        thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID2, Wearable.FILTER_ANY);
        if ((thisThang != null)
            && ((!(thisThang instanceof Container)) || (((Container) thisThang).capacity() == 0))) {
          mob.tell(L("That's not a container."));
          return false;
        }
      }
      int dirCode = -1;
      Environmental lookingTool = null;
      if (thisThang == null) {
        dirCode = Directions.getGoodDirectionCode(ID);
        if (dirCode >= 0) {
          final Room room = R.getRoomInDir(dirCode);
          final Exit exit = R.getExitInDir(dirCode);
          if ((room != null) && (exit != null)) {
            thisThang = exit;
            lookingTool = room;
          } else {
            mob.tell(L("You don't see anything that way."));
            return false;
          }
        }
      }
      if (thisThang != null) {
        String name = "at <T-NAMESELF>";
        if ((thisThang instanceof Room) || (thisThang instanceof Exit)) {
          if (thisThang == R) name = "around";
          else if (dirCode >= 0)
            name =
                ((R instanceof BoardableShip) || (R.getArea() instanceof BoardableShip))
                    ? Directions.getShipDirectionName(dirCode)
                    : Directions.getDirectionName(dirCode);
        }
        final CMMsg msg =
            CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK, textMsg + name + ".");
        if ((thisThang instanceof Room)
            && (mob.isAttribute(MOB.Attrib.AUTOEXITS))
            && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) {
          final CMMsg exitMsg =
              CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK_EXITS, null);
          if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF))
            exitMsg.setValue(CMMsg.MASK_OPTIMIZE);
          msg.addTrailerMsg(exitMsg);
        }
        if (R.okMessage(mob, msg)) R.send(mob, msg);
      } else mob.tell(L("You don't see that here!"));
    } else {
      if ((commands != null) && (commands.size() > 0))
        if (((String) commands.get(0)).toUpperCase().startsWith("E")) {
          mob.tell(L("Examine what?"));
          return false;
        }

      final CMMsg msg =
          CMClass.getMsg(
              mob,
              R,
              null,
              CMMsg.MSG_LOOK,
              (quiet ? null : textMsg + "around."),
              CMMsg.MSG_LOOK,
              (quiet ? null : textMsg + "at you."),
              CMMsg.MSG_LOOK,
              (quiet ? null : textMsg + "around."));
      if ((mob.isAttribute(MOB.Attrib.AUTOEXITS))
          && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)
          && (CMLib.flags().canBeSeenBy(R, mob))) {
        final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null);
        if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF))
          exitMsg.setValue(CMMsg.MASK_OPTIMIZE);
        msg.addTrailerMsg(exitMsg);
      }
      if (R.okMessage(mob, msg)) R.send(mob, msg);
    }
    return false;
  }