コード例 #1
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
  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);
  }
コード例 #2
0
ファイル: Spell_EnchantArrows.java プロジェクト: bbailey/ewok
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    Item target = super.getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;

    if ((!(target instanceof Ammunition))
        || (!((Ammunition) target).ammunitionType().equalsIgnoreCase("arrows"))) {
      mob.tell(mob, target, null, "You can't enchant <T-NAME> ith an Enchant Arrows spell!");
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int experienceToLose = getXPCOSTAdjustment(mob, 5);
    CMLib.leveler().postExperience(mob, null, null, -experienceToLose, false);

    boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : "^S<S-NAME> hold(s) <T-NAMESELF> and cast(s) a spell.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = target.fetchEffect(ID());
        if ((A != null) && (CMath.s_int(A.text()) > 2))
          mob.tell("You are not able to enchant " + target.name() + " further.");
        else {
          mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, "<T-NAME> glows!");
          if (A == null) {
            A = (Ability) copyOf();
            target.addNonUninvokableEffect(A);
          }
          A.setMiscText("" + (CMath.s_int(A.text()) + 1));
          target.recoverEnvStats();
          mob.recoverEnvStats();
        }
      }

    } else
      beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> hold(s) <T-NAMESELF> tightly and whisper(s), but fail(s) to cast a spell.");

    // return whether it worked
    return success;
  }
コード例 #3
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
 public void outfit(MOB mob, Vector items) {
   if ((mob == null) || (items == null) || (items.size() == 0)) return;
   for (int i = 0; i < items.size(); i++) {
     Item I = (Item) items.elementAt(i);
     if (mob.fetchInventory("$" + I.name() + "$") == null) {
       I = (Item) I.copyOf();
       I.text();
       I.recoverEnvStats();
       mob.addInventory(I);
       if (I.whereCantWear(mob) <= 0) I.wearIfPossible(mob);
       if (((I instanceof Armor) || (I instanceof Weapon))
           && (I.amWearingAt(Wearable.IN_INVENTORY))) I.destroy();
     }
   }
 }
コード例 #4
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
 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;
 }