예제 #1
0
  public void run() {
    while (isAllSuspended())
      try {
        Thread.sleep(2000);
      } catch (Exception e) {
      }

    if ((!CMSecurity.isDisabled("UTILITHREAD")) && (!CMSecurity.isDisabled("THREADTHREAD"))) {
      checkHealth();
      Resources.removeResource("SYSTEM_HASHED_MASKS");
    }
  }
예제 #2
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);
 }
예제 #3
0
 @Override
 public void level(MOB mob, List<String> newAbilityIDs) {
   super.level(mob, newAbilityIDs);
   if (CMSecurity.isDisabled(CMSecurity.DisFlag.LEVELS)) return;
   final int attArmor =
       (((int) Math.round(CMath.div(mob.charStats().getStat(CharStats.STAT_DEXTERITY), 9.0))) + 1);
   mob.tell(L("^NYour grace grants you a defensive bonus of ^H@x1^?.^N", "" + attArmor));
 }
예제 #4
0
 @Override
 public CMObject newInstance() {
   if (!CMSecurity.isDisabled(CMSecurity.DisFlag.THINGRIDS)) return super.newInstance();
   return new EndlessOcean().newInstance();
 }
예제 #5
0
 @Override
 public boolean securityCheck(MOB mob) {
   return super.securityCheck(mob) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.MSP));
 }
예제 #6
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    tickStatus = Tickable.STATUS_MISC + 0;
    super.tick(ticking, tickID);

    tickStatus = Tickable.STATUS_MISC + 1;
    if (tickID != Tickable.TICKID_MOB) {
      tickStatus = Tickable.STATUS_NOT;
      return true;
    }
    if (!canFreelyBehaveNormal(ticking)) {
      tickStatus = Tickable.STATUS_NOT;
      return true;
    }
    final MOB mob = (MOB) ticking;

    // ridden things dont wander!
    if (ticking instanceof Rideable)
      if (((Rideable) ticking).numRiders() > 0) {
        tickStatus = Tickable.STATUS_NOT;
        return true;
      }
    tickStatus = Tickable.STATUS_MISC + 2;
    if (((mob.amFollowing() != null) && (mob.location() == mob.amFollowing().location()))
        || (!CMLib.flags().canTaste(mob))) {
      tickStatus = Tickable.STATUS_NOT;
      return true;
    }

    tickStatus = Tickable.STATUS_MISC + 3;
    final Room thisRoom = mob.location();
    MOB victim = GoodGuardian.anyPeaceToMake(mob.location(), mob);
    GoodGuardian.keepPeace(mob, victim);
    victim = null;
    int dirCode = -1;
    tickStatus = Tickable.STATUS_MISC + 4;
    for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
      tickStatus = Tickable.STATUS_MISC + 5 + d;
      final Room room = thisRoom.getRoomInDir(d);
      final Exit exit = thisRoom.getExitInDir(d);
      if ((room != null) && (exit != null) && (okRoomForMe(mob, thisRoom, room, false))) {
        tickStatus = Tickable.STATUS_MISC + 20 + d;
        if (exit.isOpen()) {
          tickStatus = Tickable.STATUS_MISC + 40 + d;
          victim = GoodGuardian.anyPeaceToMake(room, mob);
          if (victim != null) {
            dirCode = d;
            break;
          }
          tickStatus = Tickable.STATUS_MISC + 60 + d;
        }
        tickStatus = Tickable.STATUS_MISC + 80 + d;
      }
      if (dirCode >= 0) break;
      tickStatus = Tickable.STATUS_MISC + 100 + d;
    }
    tickStatus = Tickable.STATUS_MISC + 120;
    if ((dirCode >= 0) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.MOBILITY))) {
      tickStatus = Tickable.STATUS_MISC + 121;
      CMLib.tracking().walk(mob, dirCode, false, false);
      tickStatus = Tickable.STATUS_MISC + 122;
      GoodGuardian.keepPeace(mob, victim);
      tickStatus = Tickable.STATUS_MISC + 123;
    }
    tickStatus = Tickable.STATUS_NOT;
    return true;
  }
예제 #7
0
 public CMObject newInstance() {
   if (!CMSecurity.isDisabled("THINGRIDS")) return super.newInstance();
   return new UnderSaltWaterGrid().newInstance();
 }
예제 #8
0
  public static int updateLotWithThisData(
      Room R,
      LandTitle T,
      boolean resetRoomName,
      boolean clearAllItems,
      List optPlayerList,
      int lastNumItems) {
    boolean updateItems = false;
    boolean updateExits = false;
    boolean updateRoom = false;
    synchronized (("SYNC" + R.roomID()).intern()) {
      R = CMLib.map().getRoom(R);
      if (T.getOwnerName().length() == 0) {
        Item I = null;
        for (int i = R.numItems() - 1; i >= 0; i--) {
          I = R.getItem(i);
          if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue;
          CMLib.catalog().updateCatalogIntegrity(I);
          if (clearAllItems) {
            I.destroy();
            updateItems = true;
          } else {
            if (I.expirationDate() == 0) {
              long now = System.currentTimeMillis();
              now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP));
              I.setExpirationDate(now);
            }
            if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) {
              I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
              I.recoverPhyStats();
            }
          }
        }
        Ability A = null;
        if (clearAllItems)
          for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) {
            A = a.nextElement();
            if (((A != null)
                && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) {
              A.unInvoke();
              R.delEffect(A);
              updateRoom = true;
            }
          }
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
          final Room R2 = R.rawDoors()[d];
          Exit E = R.getRawExit(d);
          if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
            E.setKeyName("");
            E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
            updateExits = true;
            if (R2 != null) {
              E = R2.getRawExit(Directions.getOpDirectionCode(d));
              if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
                E.setKeyName("");
                E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
                CMLib.database().DBUpdateExits(R2);
                R2.getArea().fillInAreaRoom(R2);
              }
            }
          }
        }
        if (updateExits) {
          CMLib.database().DBUpdateExits(R);
          R.getArea().fillInAreaRoom(R);
        }
        if (updateItems) CMLib.database().DBUpdateItems(R);
        if (updateRoom) CMLib.database().DBUpdateRoom(R);
        colorForSale(R, T.rentalProperty(), resetRoomName);
        return -1;
      }

      if ((lastNumItems < 0)
          && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS))
          && (optPlayerList != null)) {
        boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null);
        if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null);
        if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName());
        if (!playerExists)
          for (int i = 0; i < optPlayerList.size(); i++)
            if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) {
              playerExists = true;
              break;
            }
        if (!playerExists) {
          T.setOwnerName("");
          T.updateLot(null);
          return -1;
        }
      }

      int x = R.description().indexOf(SALESTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }
      x = R.description().indexOf(RENTSTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }

      // this works on the priciple that
      // 1. if an item has ONLY been removed, the lastNumItems will be != current # items
      // 2. if an item has ONLY been added, the dispossessiontime will be != null
      // 3. if an item has been added AND removed, the dispossession time will be != null on the
      // added
      if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true;

      for (int i = 0; i < R.numItems(); i++) {
        final Item I = R.getItem(i);
        if ((I.expirationDate() != 0)
            && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id")))
            && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) {
          I.setExpirationDate(0);
          updateItems = true;
        }

        if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) {
          I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
          I.recoverPhyStats();
          updateItems = true;
        }
      }
      lastNumItems = R.numItems();
      if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems))
        CMLib.database().DBUpdateItems(R);
    }
    return lastNumItems;
  }