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
  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. 3
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. 4
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. 5
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 boolean okMessage(Environmental host, CMMsg msg) {
   if (msg.amITarget(this)) {
     switch (msg.targetMinor()) {
       case CMMsg.TYP_ACTIVATE:
         if (!isInstalled()) {
           if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG))
             msg.source().tell(L("@x1 is not installed or connected.", name()));
           return false;
         } else if (!isAllWiringHot(this)) {
           if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG))
             msg.source()
                 .tell(L("The panel containing @x1 is not activated or connected.", name()));
           return false;
         }
         break;
       case CMMsg.TYP_DEACTIVATE:
         break;
       case CMMsg.TYP_LOOK:
         break;
       case CMMsg.TYP_POWERCURRENT:
         if ((!(this instanceof FuelConsumer))
             && (!(this instanceof PowerGenerator))
             && activated()
             && (powerNeeds() > 0)
             && (msg.value() > 0)) {
           double amtToTake = Math.min((double) powerNeeds(), (double) msg.value());
           msg.setValue(msg.value() - (int) Math.round(amtToTake));
           amtToTake *= getFinalManufacturer().getEfficiencyPct();
           if (subjectToWearAndTear() && (usesRemaining() <= 200))
             amtToTake *= CMath.div(usesRemaining(), 100.0);
           setPowerRemaining(Math.min(powerCapacity(), Math.round(amtToTake) + powerRemaining()));
         }
         break;
     }
   }
   return super.okMessage(host, msg);
 }
Esempio n. 7
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;
  }
Esempio n. 8
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if (temporarilyDisable) return true;
    final MOB mob = msg.source();
    if (affected instanceof MOB) {
      if (msg.amISource((MOB) affected)) {
        if (CMLib.flags().isInFlight(mob)) {
          damageToTake = 0;
          unInvoke();
          return true;
        }
        if (msg.targetMajor(CMMsg.MASK_MOVE)
            && (!hitTheCeiling)
            && (msg.sourceMinor() != CMMsg.TYP_FLEE)) {
          msg.source().tell(L("You are too busy falling to do that right now."));
          return false;
        }
      }
    }
    return true;
  }
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   if (msg.amITarget(this)) {
     switch (msg.targetMinor()) {
       case CMMsg.TYP_ACTIVATE:
         if ((msg.source().location() != null)
             && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)))
           msg.source()
               .location()
               .show(msg.source(), this, CMMsg.MSG_OK_VISUAL, L("<S-NAME> activate(s) <T-NAME>."));
         this.activate(true);
         break;
       case CMMsg.TYP_DEACTIVATE:
         if ((msg.source().location() != null)
             && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)))
           msg.source()
               .location()
               .show(
                   msg.source(), this, CMMsg.MSG_OK_VISUAL, L("<S-NAME> deactivate(s) <T-NAME>."));
         this.activate(false);
         break;
       case CMMsg.TYP_LOOK:
         super.executeMsg(host, msg);
         if (CMLib.flags().canBeSeenBy(this, msg.source()))
           msg.source()
               .tell(
                   L(
                       "@x1 is currently @x2",
                       name(),
                       (activated() ? "connected.\n\r" : "deactivated/disconnected.\n\r")));
         return;
       case CMMsg.TYP_REPAIR:
         if (CMLib.dice().rollPercentage() < msg.value()) {
           setUsesRemaining(usesRemaining() < 100 ? 100 : usesRemaining());
           msg.source().tell(L("@x1 is now repaired.\n\r", name()));
         } else {
           final int repairRequired = 100 - usesRemaining();
           if (repairRequired > 0) {
             int repairApplied =
                 (int) Math.round(CMath.mul(repairRequired, CMath.div(msg.value(), 100)));
             if (repairApplied < 0) repairApplied = 1;
             setUsesRemaining(usesRemaining() + repairApplied);
             msg.source().tell(L("@x1 is now @x2% repaired.\n\r", name(), "" + usesRemaining()));
           }
         }
         break;
       case CMMsg.TYP_ENHANCE:
         if ((CMLib.dice().rollPercentage() < msg.value())
             && (CMLib.dice().rollPercentage() < 50)) {
           float addAmt = 0.01f;
           if (getInstalledFactor() < 1.0) {
             addAmt = (float) (CMath.div(100.0, msg.value()) * 0.1);
             if (addAmt < 0.1f) addAmt = 0.1f;
           }
           setInstalledFactor(this.getInstalledFactor() + addAmt);
           msg.source().tell(msg.source(), this, null, L("<T-NAME> is now enhanced.\n\r"));
         } else {
           msg.source()
               .tell(
                   msg.source(),
                   this,
                   null,
                   L("Your attempt to enhance <T-NAME> has failed.\n\r"));
         }
         break;
     }
   }
   super.executeMsg(host, msg);
 }
Esempio n. 10
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((clanID().length() > 0) && (msg.amITarget(this))) {
      if (msg.source().getClanRole(clanID()) == null) {
        if ((msg.targetMinor() == CMMsg.TYP_GET)
            || (msg.targetMinor() == CMMsg.TYP_PUSH)
            || (msg.targetMinor() == CMMsg.TYP_PULL)
            || (msg.targetMinor() == CMMsg.TYP_CAST_SPELL)) {
          final Room R = CMLib.map().roomLocation(this);
          if (CMLib.clans().findRivalrousClan(msg.source()) == null) {
            msg.source().tell(L("You must belong to an elligible clan to take a clan item."));
            return false;
          } else if (R != null) {
            for (int i = 0; i < R.numInhabitants(); i++) {
              final MOB M = R.fetchInhabitant(i);
              if ((M != null)
                  && (M.isMonster())
                  && (M.getClanRole(clanID()) != null)
                  && (CMLib.flags().aliveAwakeMobileUnbound(M, true))
                  && (CMLib.flags().canBeSeenBy(this, M))
                  && (!CMLib.flags().isAnimalIntelligence(M))) {
                R.show(
                    M, null, CMMsg.MSG_QUIETMOVEMENT, L("<S-NAME> guard(s) @x1 closely.", name()));
                return false;
              }
            }
            String rulingClan = "";
            final LegalBehavior B = CMLib.law().getLegalBehavior(R);
            if (B != null) rulingClan = B.rulingOrganization();
            if (msg.source().getClanRole(rulingClan) == null) {
              msg.source()
                  .tell(L("You must conquer and fully control this area to take the clan flag."));
              return false;
            }
            if ((B != null) && (!B.isFullyControlled())) {
              msg.source().tell(L("Your clan does not yet fully control the area."));
              return false;
            }
          }
        } else if ((msg.targetMinor() == CMMsg.TYP_DROP)
            && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_INTERMSG))) {
          final Room R = msg.source().location();
          LandTitle T = null;
          Area A = null;
          LegalBehavior B = null;
          if (R != null) {
            A = R.getArea();
            T = CMLib.law().getLandTitle(R);
          }
          if ((T == null)
              || ((!T.getOwnerName().equals(clanID()))
                  && ((!T.getOwnerName().equals(msg.source().getLiegeID()))
                      || (!msg.source().isMarriedToLiege()))
                  && (!T.getOwnerName().equals(msg.source().Name())))) {
            boolean ok = false;
            if (A != null) {
              B = CMLib.law().getLegalBehavior(R);
              if (B != null) ok = B.controlPoints() > 0;
            }
            if (!ok) {
              msg.source()
                  .tell(
                      L("You can not place a flag here, this place is controlled by the Archons."));
              return false;
            }
          }
        }
      } else if ((msg.targetMinor() == CMMsg.TYP_GET)
          && (msg.source().location() != null)
          && (msg.source().isMonster())) {
        boolean foundOne = false;
        for (int i = 0; i < msg.source().location().numInhabitants(); i++) {
          final MOB M = msg.source().location().fetchInhabitant(i);
          if ((M != null) && (!M.isMonster()) && (M.getClanRole(clanID()) != null)) {
            foundOne = true;
            break;
          }
        }
        if (!foundOne) {
          msg.source().tell(L("You are guarding @x1 too closely.", name()));
          return false;
        }
      }
    }

    if (StdClanItem.stdOkMessage(this, msg)) {
      if ((clanID().length() > 0)
          && (msg.amITarget(this))
          && (msg.targetMinor() == CMMsg.TYP_DROP)) {
        final LegalBehavior B = CMLib.law().getLegalBehavior(msg.source().location());
        final String rulingClan = (B != null) ? B.rulingOrganization() : "";
        if (rulingClan.length() == 0)
          msg.source()
              .tell(
                  L("Area '@x1' is presently neutral.", msg.source().location().getArea().name()));
        else {
          msg.source()
              .tell(
                  L(
                      "Area '@x1' is presently controlled by @x2.",
                      msg.source().location().getArea().name(),
                      rulingClan));
          if (!rulingClan.equals(clanID())) {
            int relation = Clan.REL_WAR;
            final Clan C = CMLib.clans().getClan(clanID());
            if (C == null) {
              msg.source().tell(L("This ancient relic from a lost clan fades out of existence."));
              this.destroy();
              return false;
            }
            relation = C.getClanRelations(rulingClan);
            if (relation != Clan.REL_WAR) {
              msg.source()
                  .tell(
                      L("You must be at war with this clan to put down your flag on their area."));
              return false;
            }
          }
        }
      }
      return super.okMessage(myHost, msg);
    }
    return false;
  }