Exemplo n.º 1
0
  public void recursiveDropMOB(MOB mob, Room room, Item thisContainer, boolean bodyFlag) {
    // caller is responsible for recovering any env
    // stat changes!

    if (CMLib.flags().isHidden(thisContainer))
      thisContainer
          .baseEnvStats()
          .setDisposition(
              thisContainer.baseEnvStats().disposition()
                  & ((int) EnvStats.ALLMASK - EnvStats.IS_HIDDEN));
    mob.delInventory(thisContainer);
    thisContainer.unWear();
    if (!bodyFlag) bodyFlag = (thisContainer instanceof DeadBody);
    if (bodyFlag) {
      room.addItem(thisContainer);
      thisContainer.setExpirationDate(0);
    } else room.addItemRefuse(thisContainer, CMProps.getIntVar(CMProps.SYSTEMI_EXPIRE_PLAYER_DROP));
    thisContainer.recoverEnvStats();
    boolean nothingDone = true;
    do {
      nothingDone = true;
      for (int i = 0; i < mob.inventorySize(); i++) {
        Item thisItem = mob.fetchInventory(i);
        if ((thisItem != null) && (thisItem.container() == thisContainer)) {
          recursiveDropMOB(mob, room, thisItem, bodyFlag);
          nothingDone = false;
          break;
        }
      }
    } while (!nothingDone);
  }
Exemplo n.º 2
0
 public int processVariableEquipment(MOB mob) {
   int newLastTickedDateTime = 0;
   if (mob != null) {
     Room R = mob.location();
     if (R != null) {
       for (int i = 0; i < R.numInhabitants(); i++) {
         MOB M = R.fetchInhabitant(i);
         if ((M != null) && (!M.isMonster()) && (CMSecurity.isAllowed(M, R, "CMDMOBS"))) {
           newLastTickedDateTime = -1;
           break;
         }
       }
       if (newLastTickedDateTime == 0) {
         Vector rivals = new Vector();
         for (int i = 0; i < mob.inventorySize(); i++) {
           Item I = mob.fetchInventory(i);
           if ((I != null)
               && (I.baseEnvStats().rejuv() > 0)
               && (I.baseEnvStats().rejuv() < Integer.MAX_VALUE)) {
             Vector V = null;
             for (int r = 0; r < rivals.size(); r++) {
               Vector V2 = (Vector) rivals.elementAt(r);
               Item I2 = (Item) V2.firstElement();
               if (I2.rawWornCode() == I.rawWornCode()) {
                 V = V2;
                 break;
               }
             }
             if (V == null) {
               V = new Vector();
               rivals.addElement(V);
             }
             V.addElement(I);
           }
         }
         for (int i = 0; i < rivals.size(); i++) {
           Vector V = (Vector) rivals.elementAt(i);
           if ((V.size() == 1) || (((Item) V.firstElement()).rawWornCode() == 0)) {
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (CMLib.dice().rollPercentage() < I.baseEnvStats().rejuv()) mob.delInventory(I);
               else {
                 I.baseEnvStats().setRejuv(0);
                 I.envStats().setRejuv(0);
               }
             }
           } else {
             int totalChance = 0;
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               totalChance += I.baseEnvStats().rejuv();
             }
             int chosenChance = CMLib.dice().roll(1, totalChance, 0);
             totalChance = 0;
             Item chosenI = null;
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (chosenChance <= (totalChance + I.baseEnvStats().rejuv())) {
                 chosenI = I;
                 break;
               }
               totalChance += I.baseEnvStats().rejuv();
             }
             for (int r = 0; r < V.size(); r++) {
               Item I = (Item) V.elementAt(r);
               if (chosenI != I) mob.delInventory(I);
               else {
                 I.baseEnvStats().setRejuv(0);
                 I.envStats().setRejuv(0);
               }
             }
           }
         }
         if (mob instanceof ShopKeeper) {
           rivals = new Vector();
           CoffeeShop shop = ((ShopKeeper) mob).getShop();
           for (int v = 0; v < shop.getBaseInventory().size(); v++) {
             Environmental E = (Environmental) shop.getBaseInventory().elementAt(v);
             if ((E.baseEnvStats().rejuv() > 0) && (E.baseEnvStats().rejuv() < Integer.MAX_VALUE))
               rivals.addElement(E);
           }
           for (int r = 0; r < rivals.size(); r++) {
             Environmental E = (Environmental) rivals.elementAt(r);
             if (CMLib.dice().rollPercentage() > E.baseEnvStats().rejuv())
               shop.delAllStoreInventory(E);
             else {
               E.baseEnvStats().setRejuv(0);
               E.envStats().setRejuv(0);
             }
           }
         }
         mob.recoverEnvStats();
         mob.recoverCharStats();
         mob.recoverMaxState();
       }
     }
   }
   return newLastTickedDateTime;
 }