@Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;

    // when this spell is on a MOBs Affected list,
    // it should consistantly prevent the mob
    // from trying to do ANYTHING except sleep
    if ((msg.amITarget(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.source() == mob.amFollowing())) unInvoke();
    if ((msg.amISource(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.target() == mob.amFollowing())) {
      mob.tell(L("You like @x1 too much.", mob.amFollowing().charStats().himher()));
      return false;
    } else if ((msg.amISource(mob))
        && (!mob.isMonster())
        && (msg.target() instanceof Room)
        && ((msg.targetMinor() == CMMsg.TYP_LEAVE) || (msg.sourceMinor() == CMMsg.TYP_RECALL))
        && (mob.amFollowing() != null)
        && (((Room) msg.target()).isInhabitant(mob.amFollowing()))) {
      mob.tell(L("You don't want to leave your friend."));
      return false;
    } else if ((msg.amISource(mob))
        && (mob.amFollowing() != null)
        && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW)) {
      mob.tell(L("You like @x1 too much.", mob.amFollowing().name()));
      return false;
    }

    return super.okMessage(myHost, msg);
  }
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((reRollFlag)
       && (affected instanceof MOB)
       && (msg.sourceMinor() == CMMsg.TYP_LOOK)
       && (msg.source() == affected)) {
     final MOB M = msg.source();
     if ((M.session() != null) && (M.playerStats() != null)) {
       final Ability me = this;
       CMLib.threads()
           .executeRunnable(
               new Runnable() {
                 @Override
                 public void run() {
                   try {
                     CMLib.login()
                         .promptBaseCharStats(
                             M.playerStats().getTheme(), M, 300, M.session(), bonusPointsPerStat);
                     M.recoverCharStats();
                     if (rePickClass)
                       M.baseCharStats()
                           .setCurrentClass(
                               CMLib.login()
                                   .promptCharClass(M.playerStats().getTheme(), M, M.session()));
                     M.recoverCharStats();
                     M.delEffect(me);
                     M.baseCharStats().getCurrentClass().grantAbilities(M, false);
                   } catch (final IOException e) {
                   }
                 }
               });
     }
   }
 }
Beispiel #3
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((myHost != null) && (myHost instanceof MOB) && (msg.amISource((MOB) myHost))) {
     if (((msg.targetMinor() == CMMsg.TYP_LEAVE)
         || (msg.sourceMinor() == CMMsg.TYP_ADVANCE)
         || (msg.sourceMinor() == CMMsg.TYP_RETREAT)
         || (msg.sourceMinor() == CMMsg.TYP_RECALL))) {
       msg.source().tell(L("You can't really go anywhere -- you're a rock!"));
       return false;
     }
   } else if (((msg.targetMajor() & CMMsg.MASK_MALICIOUS) > 0)
       && (myHost instanceof MOB)
       && (msg.amITarget(myHost))
       && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_ALWAYS))) {
     final MOB target = (MOB) msg.target();
     if ((!target.isInCombat())
         && (msg.source().isMonster())
         && (msg.source().location() == target.location())
         && (msg.source().getVictim() != target)) {
       msg.source().tell(L("Attack a rock?!"));
       if (target.getVictim() == msg.source()) {
         target.makePeace();
         target.setVictim(null);
       }
       return false;
     }
   }
   return super.okMessage(myHost, msg);
 }
Beispiel #4
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);
 }
Beispiel #5
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    final MOB mob = msg.source();
    if (mob.location() == null) return true;

    if (msg.amITarget(this))
      switch (msg.targetMinor()) {
        case CMMsg.TYP_HOLD:
        case CMMsg.TYP_WEAR:
        case CMMsg.TYP_WIELD:
        case CMMsg.TYP_GET:
          if ((!msg.source().charStats().getCurrentClass().ID().equals("Paladin"))
              || (!CMLib.flags().isGood(msg.source()))) {
            unWear();
            mob.location()
                .show(
                    mob,
                    null,
                    CMMsg.MSG_OK_ACTION,
                    L("@x1 flashes and flies out of <S-HIS-HER> hands!", name()));
            if (msg.source().isMine(this))
              CMLib.commands().postDrop(msg.source(), this, true, false, false);
            return false;
          }
          break;
        default:
          break;
      }
    return true;
  }
Beispiel #6
0
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if (msg.targetMinor() == CMMsg.TYP_ENTER) {
      if (msg.target() == this) {
        MOB mob = msg.source();
        if ((mob.location() != null) && (mob.location().roomID().length() > 0)) {
          int direction = -1;
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
            if (mob.location().getRoomInDir(d) == this) direction = d;
          }
          if (direction < 0) {
            mob.tell("Some great evil is preventing your movement that way.");
            return false;
          }
          msg.modify(
              msg.source(),
              getAltRoomFrom(mob.location(), direction),
              msg.tool(),
              msg.sourceCode(),
              msg.sourceMessage(),
              msg.targetCode(),
              msg.targetMessage(),
              msg.othersCode(),
              msg.othersMessage());
        }
      }
    }
    return true;
  }
Beispiel #7
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((affected != null)
       && (((msg.target() instanceof Room) && (msg.targetMinor() == CMMsg.TYP_ENTER))
           || ((msg.target() instanceof Rideable) && (msg.targetMinor() == CMMsg.TYP_SIT)))
       && ((msg.amITarget(affected)) || (msg.tool() == affected) || (affected instanceof Area))
       && (!CMLib.flags().isFalling(msg.source()))) {
     final HashSet<MOB> H = new HashSet<MOB>();
     if (noFollow) H.add(msg.source());
     else {
       msg.source().getGroupMembers(H);
       int hsize = 0;
       while (hsize != H.size()) {
         hsize = H.size();
         final HashSet H2 = (HashSet) H.clone();
         for (final Iterator e = H2.iterator(); e.hasNext(); ) {
           final Object O = e.next();
           if (O instanceof MOB) ((MOB) O).getRideBuddies(H);
         }
       }
     }
     for (final Object O : H) {
       if ((!(O instanceof MOB)) || (passesMuster((MOB) O))) return super.okMessage(myHost, msg);
     }
     msg.source().tell(L("You are not allowed in there."));
     return false;
   }
   return super.okMessage(myHost, msg);
 }
Beispiel #8
0
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (affected == null) return true;

    if (!super.okMessage(myHost, msg)) return false;

    MOB mob = msg.source();
    if (((!msg.amITarget(affected)) && (msg.tool() != affected))
        || (msg.source() == invoker())
        || (CMLib.law().doesHavePriviledgesHere(mob, msg.source().location()))
            && (text().toUpperCase().indexOf("MALICIOUS") < 0)) return true;

    switch (msg.targetMinor()) {
      case CMMsg.TYP_OPEN:
        mob.tell(affected.name() + " appears to be magically locked.");
        return false;
      case CMMsg.TYP_UNLOCK:
        mob.tell(affected.name() + " appears to be magically locked.");
        return false;
      case CMMsg.TYP_JUSTICE:
        if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_DELICATE)) return true;
      case CMMsg.TYP_DELICATE_HANDS_ACT:
        mob.tell(affected.name() + " appears to be magically protected.");
        return false;
      default:
        break;
    }
    return true;
  }
Beispiel #9
0
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (affected == null) return true;
   MOB mob = (MOB) affected;
   if ((msg.amISource(mob))
       && (mob.location() != null)
       && (msg.target() != null)
       && (msg.target() instanceof Room)) {
     if ((msg.sourceMinor() == CMMsg.TYP_ENTER)
         && ((mob.location().domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
             || (mob.location().domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))
         && (msg.target() == mob.location().getRoomInDir(Directions.UP))) {
       msg.source()
           .tell("Your water walking magic prevents you from ascending from the water surface.");
       return false;
     } else if ((msg.sourceMinor() == CMMsg.TYP_LEAVE)
         && (mob.location().domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
         && (mob.location().domainType() != Room.DOMAIN_INDOORS_WATERSURFACE)
         && (msg.tool() != null)
         && (msg.tool() instanceof Exit)) {
       for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
         Room R = mob.location().getRoomInDir(d);
         if ((R != null)
             && (mob.location().getReverseExit(d) == msg.tool())
             && ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
                 || (R.domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))) {
           triggerNow = true;
           msg.source().recoverEnvStats();
           return true;
         }
       }
     }
   }
   return true;
 }
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;
    if (!(affected instanceof MOB)) return true;

    if ((msg.target() == affected)
        && (msg.tool() instanceof Ability)
        && (msg.source() != affected)
        && (msg.targetMinor() == CMMsg.TYP_CAST_SPELL)
        && (msg.isTarget(CMMsg.MASK_MALICIOUS))
        && (CMLib.dice().rollPercentage() > 50)
        && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_DOMAINS)
            == Ability.DOMAIN_CURSING)
        && (((Ability) msg.tool()).castingQuality(msg.source(), (MOB) msg.target())
            == Ability.QUALITY_MALICIOUS)) {
      msg.source()
          .location()
          .show(
              (MOB) affected,
              msg.source(),
              CMMsg.MSG_OK_VISUAL,
              L("An curse from <T-NAME> against <S-NAME> is magically repelled."));
      return false;
    }
    return true;
  }
Beispiel #11
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.amITarget(this)
           || (msg.targetMinor() == CMMsg.TYP_ADVANCE)
           || (msg.targetMinor() == CMMsg.TYP_RETREAT))
       && (!msg.source().isMonster())
       && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints())
       && (CMLib.dice().rollPercentage() == 1)
       && (CMLib.dice().rollPercentage() == 1)
       && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
     Ability A = null;
     if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia");
     else A = CMClass.getAbility("Disease_Malaria");
     if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
       A.invoke(msg.source(), msg.source(), true, 0);
   }
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
     if (CMLib.dice().rollPercentage() < 10) {
       Ability A = CMClass.getAbility("Disease_Malaria");
       if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
         A.invoke(msg.source(), msg.source(), true, 0);
     }
   }
   super.executeMsg(myHost, msg);
 }
Beispiel #12
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());
  }
Beispiel #13
0
  public boolean open(
      MOB mob, Environmental openThis, String openableWord, int dirCode, boolean quietly) {
    final String openWord = (!(openThis instanceof Exit)) ? "open" : ((Exit) openThis).openWord();
    final String openMsg =
        quietly
            ? null
            : ("<S-NAME> " + openWord + "(s) <T-NAMESELF>.")
                + CMLib.protocol().msp("dooropen.wav", 10);
    final CMMsg msg =
        CMClass.getMsg(mob, openThis, null, CMMsg.MSG_OPEN, openMsg, openableWord, openMsg);
    if (openThis instanceof Exit) {
      final boolean open = ((Exit) openThis).isOpen();
      if ((mob.location().okMessage(msg.source(), msg)) && (!open)) {
        mob.location().send(msg.source(), msg);

        if (dirCode < 0)
          for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
            if (mob.location().getExitInDir(d) == openThis) {
              dirCode = d;
              break;
            }
        if ((dirCode >= 0) && (mob.location().getRoomInDir(dirCode) != null)) {
          final Room opR = mob.location().getRoomInDir(dirCode);
          final Exit opE = mob.location().getPairedExit(dirCode);
          if (opE != null) {
            final CMMsg altMsg =
                CMClass.getMsg(
                    msg.source(),
                    opE,
                    msg.tool(),
                    msg.sourceCode(),
                    null,
                    msg.targetCode(),
                    null,
                    msg.othersCode(),
                    null);
            opE.executeMsg(msg.source(), altMsg);
          }
          final int opCode = Directions.getOpDirectionCode(dirCode);
          if ((opE != null) && (opE.isOpen()) && (((Exit) openThis).isOpen())) {
            final boolean useShipDirs =
                (opR instanceof BoardableShip) || (opR.getArea() instanceof BoardableShip);
            final String inDirName =
                useShipDirs
                    ? Directions.getShipInDirectionName(opCode)
                    : Directions.getInDirectionName(opCode);
            opR.showHappens(CMMsg.MSG_OK_ACTION, L("@x1 @x2 opens.", opE.name(), inDirName));
          }
          return true;
        }
      }
    } else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      return true;
    }
    return false;
  }
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   if ((affected instanceof Room) || (affected instanceof Area)) {
     if ((msg.targetMinor() == CMMsg.TYP_LEAVE) || (msg.sourceMinor() == CMMsg.TYP_RECALL))
       removeMyAffectsFrom(msg.source());
     if (msg.targetMinor() == CMMsg.TYP_ENTER)
       addMeIfNeccessary(msg.source(), msg.source(), true, 0, maxTicks);
   }
   super.executeMsg(host, msg);
 }
Beispiel #15
0
  public boolean okMessage(Environmental host, CMMsg msg) {
    if (!super.okMessage(host, msg)) return false;

    if ((msg.target() == affected)
        && (msg.targetMinor() == CMMsg.TYP_ENTER)
        && (affected instanceof Room)
        && (isLaw(msg.source()))) {
      msg.source().tell("You don't think there's anything going on in there.");
      return false;
    }
    return true;
  }
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (CMLib.flags().isSleeping(this)) return super.okMessage(myHost, msg);

    if ((msg.targetMinor() == CMMsg.TYP_ENTER) && (msg.amITarget(this))) {
      final Rideable ladder = CMLib.tracking().findALadder(msg.source(), this);
      if (ladder != null) {
        msg.source().setRiding(ladder);
        msg.source().recoverPhyStats();
      }
      if ((getRoomInDir(Directions.DOWN) != msg.source().location())) return true;
    }
    return super.okMessage(myHost, msg);
  }
Beispiel #17
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if (((msg.sourceMinor() == CMMsg.TYP_TELL) || (msg.othersMajor(CMMsg.MASK_CHANNEL)))
        && ((msg.source() == affected)
            || ((msg.source().location() == CMLib.map().roomLocation(affected))
                && (msg.source().isMonster())
                && (msg.source().willFollowOrdersOf((MOB) affected))))) {
      msg.source().tell(L("Your message drifts into oblivion."));
      return false;
    }
    return true;
  }
Beispiel #18
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (affected == null) {
     this.unInvoke();
     return;
   }
   if (affected instanceof Item) {
     final Item body = (Item) affected;
     if (msg.amITarget(body)) {
       if ((msg.targetMinor() == CMMsg.TYP_OPEN)
           || (msg.targetMinor() == CMMsg.TYP_GIVE)
           || (msg.targetMinor() == CMMsg.TYP_GET)
           || (msg.targetMinor() == CMMsg.TYP_JUSTICE)
           || (msg.targetMinor() == CMMsg.TYP_GENERAL)
           || (msg.targetMinor() == CMMsg.TYP_LOCK)
           || (msg.targetMinor() == CMMsg.TYP_PULL)
           || (msg.targetMinor() == CMMsg.TYP_PUSH)
           || (msg.targetMinor() == CMMsg.TYP_UNLOCK)) {
         this.spring(msg.source());
         return;
       }
     }
   }
 }
Beispiel #19
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
   } else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_FILL)
       && (msg.target() instanceof Container)
       && (((Container) msg.target()).capacity() > 0)) {
     final Container container = (Container) msg.target();
     final Item I = CMClass.getItem("GenLiquidResource");
     I.setName(L("some milk"));
     I.setDisplayText(L("some milk has been left here."));
     I.setDescription(L("It looks like milk"));
     I.setMaterial(RawMaterial.RESOURCE_MILK);
     I.setBaseValue(RawMaterial.CODES.VALUE(RawMaterial.RESOURCE_MILK));
     I.basePhyStats().setWeight(1);
     CMLib.materials().addEffectsToResource(I);
     I.recoverPhyStats();
     I.setContainer(container);
     if (container.owner() != null)
       if (container.owner() instanceof MOB) ((MOB) container.owner()).addItem(I);
       else if (container.owner() instanceof Room)
         ((Room) container.owner()).addItem(I, ItemPossessor.Expire.Resource);
   }
 }
Beispiel #20
0
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    if ((msg.target() == null) || (!(msg.target() instanceof MOB))) return;
    MOB source = msg.source();
    MOB observer = (MOB) affecting;
    MOB target = (MOB) msg.target();

    if ((source != observer)
        && (target != observer)
        && (source != target)
        && (CMath.bset(msg.targetCode(), CMMsg.MASK_MALICIOUS))
        && (!observer.isInCombat())
        && (CMLib.flags().canBeSeenBy(source, observer))
        && (CMLib.flags().canBeSeenBy(target, observer))
        && (!BrotherHelper.isBrother(source, observer, false))
        && ((CMLib.flags().isEvil(target) && CMLib.flags().isEvil(observer))
            || (CMLib.flags().isNeutral(target) && CMLib.flags().isNeutral(observer))
            || (CMLib.flags().isGood(target) && CMLib.flags().isGood(observer)))) {
      Aggressive.startFight(
          observer,
          source,
          true,
          false,
          CMLib.flags().getAlignmentName(observer) + " PEOPLE UNITE! CHARGE!");
    }
  }
Beispiel #21
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if (msg.amITarget(this)) {
     final MOB mob = msg.source();
     switch (msg.targetMinor()) {
       case CMMsg.TYP_GET:
       case CMMsg.TYP_REMOVE:
         {
           unWear();
           setContainer(null);
           if (!mob.isMine(this)) {
             mob.setQuestPoint(mob.getQuestPoint() + 1);
             CMLib.players().bumpPrideStat(mob, PrideStat.QUESTPOINTS_EARNED, 1);
           }
           if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_OPTIMIZE))
             mob.location().recoverRoomStats();
           destroy();
           return;
         }
       default:
         break;
     }
   }
   super.executeMsg(myHost, msg);
 }
Beispiel #22
0
 @Override
 public void executeMsg(Environmental affecting, CMMsg msg) {
   super.executeMsg(affecting, msg);
   if (msg.amITarget(affecting)) {
     boolean activated = false;
     if (affecting instanceof MOB) {
       if ((msg.targetMajor(CMMsg.MASK_MALICIOUS)) && (!msg.source().isMonster()))
         activated = true;
     } else if ((affecting instanceof Food) || (affecting instanceof Drink)) {
       if ((msg.targetMinor() == CMMsg.TYP_EAT) || (msg.targetMinor() == CMMsg.TYP_DRINK))
         activated = true;
     } else if ((affecting instanceof Armor) || (affecting instanceof Weapon)) {
       if ((msg.targetMinor() == CMMsg.TYP_WEAR)
           || (msg.targetMinor() == CMMsg.TYP_HOLD)
           || (msg.targetMinor() == CMMsg.TYP_WIELD)) activated = true;
     } else if (affecting instanceof Item) {
       if ((msg.targetMinor() == CMMsg.TYP_GET)
           || (msg.targetMinor() == CMMsg.TYP_PUSH)
           || (msg.targetMinor() == CMMsg.TYP_PULL)) activated = true;
     } else activated = true;
     if (activated) {
       synchronized (killTrigger) {
         killTrigger[0] = true;
         if (!CMLib.threads().isTicking(this, Tickable.TICKID_MISCELLANEOUS))
           CMLib.threads().startTickDown(this, Tickable.TICKID_MISCELLANEOUS, 500, 1);
       }
     }
   }
 }
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   super.executeMsg(host, msg);
   if ((msg.sourceMinor() == CMMsg.TYP_DEATH)
       && (msg.source() != host)
       && (msg.source().location() != CMLib.map().roomLocation(host))) DoneEquipping = false;
 }
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (affected == null) return super.okMessage(myHost, msg);

    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if ((msg.amITarget(mob))
          && (!msg.amISource(mob))
          && (mob.location() != msg.source().location())
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING))
          && (!mob.amDead())) {
        final Ability A = (Ability) msg.tool();
        if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG))
          msg.source()
              .location()
              .showHappens(
                  CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!"));
        return false;
      }
    } else if (affected instanceof Room) {
      final Room R = (Room) affected;
      if ((msg.tool() instanceof Ability)
          && (msg.source().location() != null)
          && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) {
        final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING);
        final boolean teleport =
            CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING);
        final boolean shere =
            (msg.source().location() == affected)
                || ((affected instanceof Area)
                    && (((Area) affected).inMyMetroArea(msg.source().location().getArea())));
        if ((!shere)
            && (!summon)
            && (teleport)
            && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) {
          if ((msg.source().location() != null) && (msg.source().location() != R))
            msg.source()
                .location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!"));
          R.showHappens(
              CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air."));
          return false;
        }
      }
    }
    return super.okMessage(myHost, msg);
  }
Beispiel #25
0
 public static void doAnimalFollowerLevelingCheck(CharClass C, Environmental host, CMMsg msg) {
   if ((msg.sourceMessage() == null)
       && (msg.sourceMinor() == CMMsg.TYP_LEVEL)
       && (msg.source().isMonster())) {
     final MOB druidM = msg.source().amUltimatelyFollowing();
     if ((druidM != null)
         && (!druidM.isMonster())
         && (druidM.charStats().getCurrentClass().ID().equals(C.ID()))
         && (CMLib.flags().isAnimalIntelligence(msg.source())
             || msg.source()
                 .charStats()
                 .getMyRace()
                 .racialCategory()
                 .equalsIgnoreCase("Vegetation")
             || msg.source()
                 .charStats()
                 .getMyRace()
                 .racialCategory()
                 .equalsIgnoreCase("Stone Golem"))) {
       final int xp = msg.source().phyStats().level() * 5;
       if (xp > 0) {
         druidM.tell(
             CMLib.lang().L("Your stewardship has benefitted @x1.", msg.source().name(druidM)));
         CMLib.leveler().postExperience(druidM, null, null, xp, false);
       }
     }
   }
 }
Beispiel #26
0
 public void roomAffectFully(CMMsg msg, Room room, int dirCode) {
   room.send(msg.source(), msg);
   if ((msg.target() == null) || (!(msg.target() instanceof Exit))) return;
   if (dirCode < 0) {
     for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--)
       if (room.getExitInDir(d) == msg.target()) {
         dirCode = d;
         break;
       }
   }
   if (dirCode < 0) return;
   Exit pair = room.getPairedExit(dirCode);
   if (pair != null) {
     CMMsg altMsg = null;
     if ((msg.targetCode() == CMMsg.MSG_OPEN) && (pair.isLocked())) {
       altMsg =
           CMClass.getMsg(
               msg.source(),
               pair,
               msg.tool(),
               CMMsg.MSG_UNLOCK,
               null,
               CMMsg.MSG_UNLOCK,
               null,
               CMMsg.MSG_UNLOCK,
               null);
       pair.executeMsg(msg.source(), altMsg);
     }
     altMsg =
         CMClass.getMsg(
             msg.source(),
             pair,
             msg.tool(),
             msg.sourceCode(),
             null,
             msg.targetCode(),
             null,
             msg.othersCode(),
             null);
     pair.executeMsg(msg.source(), altMsg);
   }
 }
Beispiel #27
0
 @Override
 public boolean okMessage(Environmental host, CMMsg msg) {
   if (!super.okMessage(host, msg)) return false;
   if ((msg.targetMinor() == CMMsg.TYP_REMOVE)
       && (msg.target() == affected)
       && (affected instanceof Item)
       && (((Item) affected).amWearingAt(Wearable.WORN_NECK))) {
     if (CMLib.dice().rollPercentage()
         > (msg.source().charStats().getStat(CharStats.STAT_STRENGTH) * 3)) {
       msg.source()
           .location()
           .show(
               msg.source(),
               affected,
               CMMsg.MSG_OK_VISUAL,
               L("<S-NAME> struggle(s) to remove <T-NAME> and fail(s)."));
       return false;
     }
   }
   return true;
 }
 @Override
 public boolean okMessage(Environmental host, CMMsg msg) {
   if ((affected instanceof MOB)
       && (msg.amISource((MOB) affected))
       && (msg.sourceMinor() == CMMsg.TYP_REBUKE)
       && (msg.target() != null)
       && ((msg.target() == invoker()) || (msg.target().Name().equals(godName)))) {
     msg.source().tell(L("Your faith is too undeniable."));
     return false;
   }
   return super.okMessage(host, msg);
 }
Beispiel #29
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((myHost != null) && (myHost instanceof MOB) && (msg.amISource((MOB) myHost))) {
     if (((msg.targetMinor() == CMMsg.TYP_LEAVE)
         || (msg.sourceMinor() == CMMsg.TYP_ADVANCE)
         || (msg.sourceMinor() == CMMsg.TYP_RETREAT))) {
       msg.source().tell(L("You can't really go anywhere -- you are rooted!"));
       return false;
     }
   }
   return super.okMessage(myHost, msg);
 }
 @Override
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if ((msg.source() == affected)
       && (msg.targetMinor() == CMMsg.TYP_SELL)
       && (msg.tool() instanceof Item)) {
     Ability A = ((Item) msg.tool()).fetchEffect("Prop_PrivateProperty");
     if (A != null) {
       ((Item) msg.tool()).delEffect(A);
       addBackMap.put((Item) msg.tool(), A);
     }
   }
   return super.okMessage(myHost, msg);
 }