Beispiel #1
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 #2
0
 public Item isRuinedLoot(DVector policies, Item I) {
   if (I == null) return null;
   if ((CMath.bset(I.envStats().disposition(), EnvStats.IS_UNSAVABLE))
       || (CMath.bset(I.envStats().sensesMask(), EnvStats.SENSE_ITEMNORUIN))
       || (I instanceof Coins)) return I;
   if (I.name().toLowerCase().indexOf("ruined ") >= 0) return I;
   for (int d = 0; d < policies.size(); d++) {
     if ((((Vector) policies.elementAt(d, 3)).size() > 0)
         && (!CMLib.masking().maskCheck((Vector) policies.elementAt(d, 3), I, true))) continue;
     if (CMLib.dice().rollPercentage() > ((Integer) policies.elementAt(d, 1)).intValue()) continue;
     int flags = ((Integer) policies.elementAt(d, 2)).intValue();
     if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_WORN) && I.amWearingAt(Wearable.IN_INVENTORY))
       continue;
     else if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_UNWORN)
         && (!I.amWearingAt(Wearable.IN_INVENTORY))) continue;
     if (CMath.bset(flags, CMMiscUtils.LOOTFLAG_LOSS)) return null;
     Item I2 = CMClass.getItem("GenItem");
     I2.baseEnvStats().setWeight(I.baseEnvStats().weight());
     I2.setName(I.Name());
     I2.setDisplayText(I.displayText());
     I2.setDescription(I2.description());
     I2.recoverEnvStats();
     I2.setMaterial(I.material());
     String ruinDescAdder = null;
     switch (I2.material() & RawMaterial.MATERIAL_MASK) {
       case RawMaterial.MATERIAL_LEATHER:
       case RawMaterial.MATERIAL_CLOTH:
       case RawMaterial.MATERIAL_VEGETATION:
       case RawMaterial.MATERIAL_FLESH:
       case RawMaterial.MATERIAL_PAPER:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name()) + " is torn and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_METAL:
       case RawMaterial.MATERIAL_MITHRIL:
       case RawMaterial.MATERIAL_WOODEN:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name()) + " is battered and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_GLASS:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name())
                 + " is shattered and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_ROCK:
       case RawMaterial.MATERIAL_PRECIOUS:
       case RawMaterial.MATERIAL_PLASTIC:
         ruinDescAdder =
             CMStrings.capitalizeFirstLetter(I2.name()) + " is cracked and ruined beyond repair.";
         break;
       case RawMaterial.MATERIAL_UNKNOWN:
       case RawMaterial.MATERIAL_ENERGY:
       case RawMaterial.MATERIAL_LIQUID:
       default:
         ruinDescAdder = CMStrings.capitalizeFirstLetter(I2.name()) + " is ruined beyond repair.";
         break;
     }
     I2.setDescription(CMStrings.endWithAPeriod(I2.description()) + " " + ruinDescAdder);
     String oldName = I2.Name();
     I2.setName(CMLib.english().insertUnColoredAdjective(I2.Name(), "ruined"));
     int x = I2.displayText().toUpperCase().indexOf(oldName.toUpperCase());
     I2.setBaseValue(0);
     if (x >= 0)
       I2.setDisplayText(
           I2.displayText().substring(0, x)
               + I2.Name()
               + I2.displayText().substring(x + oldName.length()));
     return I2;
   }
   return I;
 }