Esempio n. 1
1
  @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);
  }
Esempio n. 2
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);
 }
Esempio n. 3
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;
       }
     }
   }
 }
Esempio n. 4
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);
 }
Esempio n. 5
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);
   }
 }
Esempio n. 6
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);
 }
Esempio n. 7
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());
  }
Esempio n. 8
0
 @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);
 }
  @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;
  }
Esempio n. 10
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;
  }
Esempio n. 11
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);
 }
Esempio n. 12
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;
  }
Esempio n. 13
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);
  }
Esempio n. 14
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
Esempio n. 15
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);
 }
Esempio n. 16
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;
  }
Esempio n. 17
0
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);
    MOB myChar = (MOB) myHost;
    if (!super.okMessage(myChar, msg)) return false;

    if ((msg.amITarget(myChar))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.sourceMinor() == CMMsg.TYP_ACID)) {
      int recovery = myChar.charStats().getClassLevel(this);
      msg.setValue(msg.value() - recovery);
    } else if ((msg.amITarget(myChar))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.sourceMinor() == CMMsg.TYP_ELECTRIC)) {
      int recovery = msg.value();
      msg.setValue(msg.value() + recovery);
    }
    return true;
  }
Esempio n. 18
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);
         }
       }
     }
   }
 }
Esempio n. 19
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;
  }
Esempio n. 20
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);
 }
Esempio n. 21
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);
       }
     }
   }
 }
Esempio n. 22
0
 @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);
 }
Esempio n. 23
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && (msg.value() > 0)
       && (msg.target() != null)
       && (msg.target() instanceof MOB)
       && (weaponClassification() == Weapon.CLASS_THROWN)) {
     msg.setValue(0);
   }
   return true;
 }
Esempio n. 24
0
 @Override
 public boolean okMessage(Environmental affecting, CMMsg msg) {
   if (!super.okMessage(affecting, msg)) return false;
   final MOB source = msg.source();
   if (!canFreelyBehaveNormal(affecting)) return true;
   final MOB observer = (MOB) affecting;
   if ((source != observer)
       && (msg.amITarget(observer))
       && (msg.targetMinor() == CMMsg.TYP_GIVE)
       && (!CMSecurity.isAllowed(source, source.location(), CMSecurity.SecFlag.CMDROOMS))
       && (msg.tool() != null)) {
     if (!(msg.tool() instanceof Coins)) {
       CMLib.commands()
           .postSay(observer, source, L("I'm sorry, I can only accept money."), true, false);
       return false;
     } else if (!doIExchangeThisCurrency(affecting, ((Coins) msg.tool()).getCurrency())) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I don't accept that kind of currency."),
               true,
               false);
       return false;
     }
     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) || (C == null)) {
       CMLib.commands()
           .postSay(
               observer,
               source,
               L("I'm sorry, I can not change such a small amount."),
               true,
               false);
       return false;
     }
   }
   return true;
 }
Esempio n. 25
0
  @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);
  }
Esempio n. 26
0
 public static boolean robberyCheck(LandTitle A, CMMsg msg) {
   if (((msg.targetMinor() == CMMsg.TYP_GET) && (!msg.isTarget(CMMsg.MASK_INTERMSG)))
       || (msg.targetMinor() == CMMsg.TYP_PUSH)
       || (msg.targetMinor() == CMMsg.TYP_PULL)) {
     if ((msg.target() instanceof Item)
         && (((Item) msg.target()).owner() == msg.source().location())
         && ((!(msg.tool() instanceof Item)) || (msg.source().isMine(msg.tool())))
         && (!msg.sourceMajor(CMMsg.MASK_ALWAYS))
         && (A.getOwnerName().length() > 0)
         && (msg.source().location() != null)
         && (msg.othersMessage() != null)
         && (msg.othersMessage().length() > 0)
         && (!shopkeeperMobPresent(msg.source().location()))
         && (!CMLib.law().doesHavePriviledgesHere(msg.source(), msg.source().location()))) {
       final Room R = msg.source().location();
       final LegalBehavior B = CMLib.law().getLegalBehavior(R);
       if (B != null) {
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if (CMLib.law().doesHavePriviledgesHere(M, R)) return true;
         }
         MOB D = null;
         final Clan C = CMLib.clans().getClan(A.getOwnerName());
         if (C != null) D = C.getResponsibleMember();
         else D = CMLib.players().getLoadPlayer(A.getOwnerName());
         if (D == null) return true;
         B.accuse(
             CMLib.law().getLegalObject(R),
             msg.source(),
             D,
             new String[] {"PROPERTYROB", "THIEF_ROBBERY"});
       }
     }
     return true;
   }
   return false;
 }
Esempio n. 27
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);
  }
Esempio n. 28
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)))
       && (!CMLib.flags().isFalling(msg.source()))
       && ((msg.amITarget(affected)) || (msg.tool() == affected) || (affected instanceof Area))) {
     if ((!msg.source().isMonster()) && (!msg.source().isAttribute(MOB.Attrib.PLAYERKILL))) {
       msg.source().tell(L("You must have your playerkill flag set to enter here."));
       return false;
     }
   }
   if ((!msg.source().isMonster()) && (!msg.source().isAttribute(MOB.Attrib.PLAYERKILL))) {
     final Room R = CMLib.map().roomLocation(msg.source());
     if ((R != null)
         && ((R == affected)
             || (R.getArea() == affected)
             || ((affected instanceof Area) && (((Area) affected).inMyMetroArea(R.getArea()))))) {
       msg.source().tell(L("Your PLAYERKILL flag is now ON!"));
       msg.source().setAttribute(MOB.Attrib.PLAYERKILL, true);
     }
   }
   return super.okMessage(myHost, msg);
 }
Esempio n. 29
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.targetMinor() == CMMsg.TYP_ENTER)
       && (msg.target() == affected)
       && (msg.source() != invoker())
       && (!msg.source().Name().equals(text()))
       && (!sprung)
       && (invoker() != null)
       && (invoker().mayIFight(msg.source()))
       && ((canBeUninvoked())
           || (!CMLib.law().doesHavePriviledgesHere(msg.source(), (Room) affected)))
       && (CMLib.dice().rollPercentage()
           > msg.source().charStats().getSave(CharStats.STAT_SAVE_TRAPS)))
     CMLib.combat().postDeath(invoker(), msg.source(), msg);
   super.executeMsg(myHost, msg);
 }
Esempio n. 30
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((!super.okMessage(myHost, msg)) || (affected == null) || (!(affected instanceof Item))) {
     unInvoke();
     return false;
   }
   if (msg.amITarget(affected))
     switch (msg.targetMinor()) {
       case CMMsg.TYP_GET:
       case CMMsg.TYP_PUSH:
       case CMMsg.TYP_PULL:
       case CMMsg.TYP_REMOVE:
         unInvoke();
         break;
     }
   return true;
 }