Ejemplo n.º 1
0
  public void affectEnvStats(Environmental affected, EnvStats affectableStats) {
    super.affectEnvStats(affected, affectableStats);
    if ((affected instanceof MOB) && (((MOB) affected).location() != null)) {
      MOB mob = (MOB) affected;
      Room room = mob.location();
      int classLevel = mob.charStats().getClassLevel(this);
      if ((CMLib.flags().isHidden(mob))
          && (classLevel >= 30)
          && ((room.domainType() & Room.INDOORS) == 0)
          && (room.domainType() != Room.DOMAIN_OUTDOORS_CITY))
        affectableStats.setDisposition(affectableStats.disposition() | EnvStats.IS_NOT_SEEN);

      if (classLevel >= 5) {
        if (CMLib.flags().isInDark(room))
          affectableStats.setAttackAdjustment(
              affectableStats.attackAdjustment() - ((classLevel / 5) + 1));
        else if ((room.domainType() & Room.INDOORS) == 0)
          switch (room.getArea().getClimateObj().weatherType(room)) {
            case Climate.WEATHER_BLIZZARD:
            case Climate.WEATHER_CLOUDY:
            case Climate.WEATHER_DUSTSTORM:
            case Climate.WEATHER_HAIL:
            case Climate.WEATHER_RAIN:
            case Climate.WEATHER_SLEET:
            case Climate.WEATHER_SNOW:
            case Climate.WEATHER_THUNDERSTORM:
              break;
            default:
              affectableStats.setAttackAdjustment(
                  affectableStats.attackAdjustment() + ((classLevel / 5) + 1));
              break;
          }
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = mob;
    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;
    if (target.fetchEffect(this.ID()) != null) {
      mob.tell(target, null, null, L("<S-NAME> <S-IS-ARE> already observing."));
      return false;
    }

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

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

    final CMMsg msg =
        CMClass.getMsg(
            mob,
            target,
            this,
            auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_HANDS_ACT | CMMsg.MASK_EYES),
            auto
                ? L("<T-NAME> become(s) observant.")
                : L(
                    "<S-NAME> open(s) <S-HIS-HER> eyes and observe(s) <S-HIS-HER> surroundings carefully."));
    if (!success)
      return beneficialVisualFizzle(
          mob, null, L("<S-NAME> look(s) around carefully, but become(s) distracted."));
    else if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      beneficialAffect(mob, target, asLevel, 0);
    }
    return success;
  }
Ejemplo n.º 3
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if ((!auto) && (!mob.isInCombat())) {
      mob.tell(L("You must be in combat first!"));
      return false;
    }

    MOB target = mob;
    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;

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

    // now see if it worked
    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_QUIETMOVEMENT,
              auto
                  ? L("<T-NAME> is braced for an attack!")
                  : L("<S-NAME> brace(s) for an attack!"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialVisualFizzle(
          mob, null, L("<S-NAME> attempt(s) to brace <S-HIM-HERSELF>, but get(s) distracted."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 4
0
 public void affectCharState(MOB affected, CharState affectableState) {
   super.affectCharState(affected, affectableState);
   if (affected.location() != null) {
     Room room = affected.location();
     if (affected.charStats().getClassLevel(this) >= 5) {
       if (CMLib.flags().isInDark(room)) {
         affectableState.setMana(affectableState.getMana() - (affectableState.getMana() / 4));
         affectableState.setMovement(
             affectableState.getMovement() - (affectableState.getMovement() / 4));
       } else if ((room.domainType() & Room.INDOORS) == 0)
         switch (room.getArea().getClimateObj().weatherType(room)) {
           case Climate.WEATHER_BLIZZARD:
           case Climate.WEATHER_CLOUDY:
           case Climate.WEATHER_DUSTSTORM:
           case Climate.WEATHER_HAIL:
           case Climate.WEATHER_RAIN:
           case Climate.WEATHER_SLEET:
           case Climate.WEATHER_SNOW:
           case Climate.WEATHER_THUNDERSTORM:
             break;
           default:
             affectableState.setMana(affectableState.getMana() + (affectableState.getMana() / 4));
             affectableState.setMovement(
                 affectableState.getMovement() + (affectableState.getMovement() / 4));
             break;
         }
     }
   }
 }
Ejemplo n.º 5
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
Ejemplo n.º 6
0
 public synchronized void clearDebri(Room room, int taskCode) {
   Tick almostTock = null;
   TockClient C = null;
   ItemTicker I = null;
   Iterator<TockClient> roomSet;
   MOB mob = null;
   for (Iterator<Tick> e = tickGroups(); e.hasNext(); ) {
     almostTock = e.next();
     roomSet = almostTock.getLocalItems(taskCode, room);
     if (roomSet != null)
       for (; roomSet.hasNext(); ) {
         C = (TockClient) roomSet.next();
         if (C.clientObject instanceof ItemTicker) {
           I = (ItemTicker) C.clientObject;
           almostTock.delTicker(C);
           I.setProperLocation(null);
         } else if (C.clientObject instanceof MOB) {
           mob = (MOB) C.clientObject;
           if ((mob.isMonster()) && (!room.isInhabitant(mob))) {
             mob.destroy();
             almostTock.delTicker(C);
           }
         }
       }
   }
 }
Ejemplo n.º 7
0
 protected boolean parsedOutIndividualSkill(MOB mob, String qual, Vector acodes) {
   if ((qual == null) || (qual.length() == 0) || (qual.equalsIgnoreCase("all"))) return false;
   if (qual.length() > 0)
     for (int i = 1; i < Ability.DOMAIN_DESCS.length; i++)
       if (Ability.DOMAIN_DESCS[i].replace('_', ' ').equalsIgnoreCase(qual)) return false;
       else if ((Ability.DOMAIN_DESCS[i].replace('_', ' ').indexOf('/') >= 0)
           && (Ability.DOMAIN_DESCS[i]
               .replace('_', ' ')
               .substring(Ability.DOMAIN_DESCS[i].indexOf('/') + 1)
               .equalsIgnoreCase(qual))) return false;
   final Ability A = CMClass.findAbility(qual);
   if ((A != null)
       && (CMLib.ableMapper().qualifiesByAnyCharClass(A.ID()))
       && (acodes.contains(Integer.valueOf(A.classificationCode() & Ability.ALL_ACODES)))) {
     final Ability A2 = mob.fetchAbility(A.ID());
     if (A2 == null) mob.tell(L("You don't know '@x1'.", A.name()));
     else {
       int level = CMLib.ableMapper().qualifyingLevel(mob, A2);
       if (level < 0) level = 0;
       final StringBuffer line = new StringBuffer("");
       line.append("\n\rLevel ^!" + level + "^?:\n\r");
       line.append(
           "^N[^H"
               + CMStrings.padRight(Integer.toString(A2.proficiency()), 3)
               + "%^?]^N "
               + CMStrings.padRight("^<HELP^>" + A2.name() + "^</HELP^>", 19));
       line.append("^?\n\r");
       if (mob.session() != null) mob.session().wraplessPrintln(line.toString());
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 8
0
 @Override
 public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
   final StringBuilder msg = new StringBuilder("");
   final Vector V = new Vector();
   V.add(Integer.valueOf(Ability.ACODE_THIEF_SKILL));
   V.add(Integer.valueOf(Ability.ACODE_SKILL));
   V.add(Integer.valueOf(Ability.ACODE_COMMON_SKILL));
   final String qual = CMParms.combine(commands, 1).toUpperCase();
   if (parsedOutIndividualSkill(mob, qual, V)) return true;
   final int[] level = new int[1];
   final int[] domain = new int[1];
   final String[] domainName = new String[1];
   domainName[0] = "";
   level[0] = -1;
   parseDomainInfo(mob, commands, V, level, domain, domainName);
   int mask = Ability.ALL_ACODES;
   if (domain[0] >= 0) {
     mask = mask | Ability.ALL_DOMAINS;
     for (int v = 0; v < V.size(); v++)
       V.setElementAt(Integer.valueOf(((Integer) V.get(v)).intValue() + domain[0]), v);
   }
   if ((domain[0] >= 0) || (qual.length() == 0))
     msg.append(
         L(
             "\n\r^HYour @x1skills:^? @x2",
             domainName[0].replace('_', ' '),
             getAbilities(mob, mob, V, mask, true, level[0]).toString()));
   if (!mob.isMonster()) mob.session().wraplessPrintln(msg.toString());
   return false;
 }
Ejemplo n.º 9
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    if ((!auto)
        && (!mob.isMonster())
        && (!disregardsArmorCheck(mob))
        && (mob.isMine(this))
        && (!renderedMundane)
        && (CMLib.dice().rollPercentage() < 50)) {
      if (!appropriateToMyFactions(mob)) {
        mob.tell(L("Extreme emotions disrupt your chant."));
        return false;
      } else if (!CMLib.utensils().armorCheck(mob, CharClass.ARMOR_LEATHER)) {
        mob.location()
            .show(
                mob,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("<S-NAME> watch(es) <S-HIS-HER> armor absorb <S-HIS-HER> magical energy!"));
        return false;
      }
    }
    return true;
  }
Ejemplo n.º 10
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((reRollFlag)
       && (affected instanceof MOB)
       && (msg.sourceMinor() == CMMsg.TYP_LOOK)
       && (msg.source() == affected)) {
     final MOB M = msg.source();
     if ((M.session() != null) && (M.playerStats() != null)) {
       final Ability me = this;
       CMLib.threads()
           .executeRunnable(
               new Runnable() {
                 @Override
                 public void run() {
                   try {
                     CMLib.login()
                         .promptBaseCharStats(
                             M.playerStats().getTheme(), M, 300, M.session(), bonusPointsPerStat);
                     M.recoverCharStats();
                     if (rePickClass)
                       M.baseCharStats()
                           .setCurrentClass(
                               CMLib.login()
                                   .promptCharClass(M.playerStats().getTheme(), M, M.session()));
                     M.recoverCharStats();
                     M.delEffect(me);
                     M.baseCharStats().getCurrentClass().grantAbilities(M, false);
                   } catch (final IOException e) {
                   }
                 }
               });
     }
   }
 }
Ejemplo n.º 11
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

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

    if (success) {

      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? L("An anti-plant shell surrounds <T-NAME>!")
                  : L("^S<S-NAME> cast(s) the anti-plant shell around <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> cast(s) a shell at <T-NAMESELF>, but the magic fizzles."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 12
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) strangely fertile!"));
        beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
      }
    } else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 13
0
 public static void doAnimalFollowerLevelingCheck(CharClass C, Environmental host, CMMsg msg) {
   if ((msg.sourceMessage() == null)
       && (msg.sourceMinor() == CMMsg.TYP_LEVEL)
       && (msg.source().isMonster())) {
     final MOB druidM = msg.source().amUltimatelyFollowing();
     if ((druidM != null)
         && (!druidM.isMonster())
         && (druidM.charStats().getCurrentClass().ID().equals(C.ID()))
         && (CMLib.flags().isAnimalIntelligence(msg.source())
             || msg.source()
                 .charStats()
                 .getMyRace()
                 .racialCategory()
                 .equalsIgnoreCase("Vegetation")
             || msg.source()
                 .charStats()
                 .getMyRace()
                 .racialCategory()
                 .equalsIgnoreCase("Stone Golem"))) {
       final int xp = msg.source().phyStats().level() * 5;
       if (xp > 0) {
         druidM.tell(
             CMLib.lang().L("Your stewardship has benefitted @x1.", msg.source().name(druidM)));
         CMLib.leveler().postExperience(druidM, null, null, xp, false);
       }
     }
   }
 }
Ejemplo n.º 14
0
 @Override
 public void spring(MOB target) {
   if (target.location() != null) {
     if ((!invoker().mayIFight(target))
         || (isLocalExempt(target))
         || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target))
         || (target == invoker())
         || (doesSaveVsTraps(target)))
       target
           .location()
           .show(
               target,
               null,
               null,
               CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
               L("<S-NAME> avoid(s) the water bomb!"));
     else if (target
         .location()
         .show(
             invoker(),
             target,
             this,
             CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
             L("@x1 explodes water all over <T-NAME>!", affected.name()))) {
       super.spring(target);
       final Ability A = CMClass.getAbility("Spell_Irritation");
       if (A != null) A.invoke(target, target, true, invoker().phyStats().level() + abilityCode());
     }
   }
 }
Ejemplo n.º 15
0
 @Override
 protected Item buildMyPlant(MOB mob, Room room) {
   final int code = material & RawMaterial.RESOURCE_MASK;
   final Item newItem = CMClass.getBasicItem("GenItem");
   final String name =
       CMLib.english().startWithAorAn(RawMaterial.CODES.NAME(code).toLowerCase() + " tree");
   newItem.setName(name);
   newItem.setDisplayText(L("@x1 grows here.", newItem.name()));
   newItem.setDescription("");
   newItem.basePhyStats().setWeight(10000);
   CMLib.flags().setGettable(newItem, false);
   newItem.setMaterial(material);
   newItem.setSecretIdentity(mob.Name());
   newItem.setMiscText(newItem.text());
   room.addItem(newItem);
   final Chant_SummonTree newChant = new Chant_SummonTree();
   newItem.basePhyStats().setLevel(10 + newChant.getX1Level(mob));
   newItem.setExpirationDate(0);
   room.showHappens(
       CMMsg.MSG_OK_ACTION,
       L("a tall, healthy @x1 tree sprouts up.", RawMaterial.CODES.NAME(code).toLowerCase()));
   room.recoverPhyStats();
   newChant.plantsLocationR = room;
   newChant.littlePlantsI = newItem;
   if (CMLib.law().doesOwnThisLand(mob, room)) {
     newChant.setInvoker(mob);
     newChant.setMiscText(mob.Name());
     newItem.addNonUninvokableEffect(newChant);
   } else newChant.beneficialAffect(mob, newItem, 0, (newChant.adjustedLevel(mob, 0) * 240) + 450);
   room.recoverPhyStats();
   return newItem;
 }
Ejemplo n.º 16
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

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

    if (success) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> incant(s) at <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> get(s) sick!"));
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but the spell fizzles."));

    // return whether it worked
    return success;
  }
Ejemplo n.º 17
0
  @Override
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if (!(CMLib.intermud().imc2online())) {
      mob.tell(L("IMC2 is unavailable."));
      return false;
    }
    commands.remove(0);
    if (commands.size() < 1) {
      IMC2Error(mob);
      return false;
    }
    final String str = (String) commands.get(0);
    if (!(CMLib.intermud().imc2online())) mob.tell(L("IMC2 is unavailable."));
    else if (str.equalsIgnoreCase("list")) CMLib.intermud().giveIMC2MudList(mob);
    else if (str.equalsIgnoreCase("locate"))
      CMLib.intermud().i3locate(mob, CMParms.combine(commands, 1));
    else if (str.equalsIgnoreCase("channels")
        && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2))
      CMLib.intermud().giveIMC2ChannelsList(mob);
    else if (str.equalsIgnoreCase("info"))
      CMLib.intermud().imc2mudInfo(mob, CMParms.combine(commands, 1));
    else if (str.equalsIgnoreCase("restart")
        && CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.IMC2)) {
      try {
        mob.tell(CMLib.hosts().get(0).executeCommand("START IMC2"));
      } catch (final Exception e) {
        Log.errOut("IMC2Cmd", e);
      }
    } else IMC2Error(mob);

    return false;
  }
Ejemplo n.º 18
0
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    if ((msg.target() == null) || (!(msg.target() instanceof MOB))) return;
    MOB source = msg.source();
    MOB observer = (MOB) affecting;
    MOB target = (MOB) msg.target();

    if ((source != observer)
        && (target != observer)
        && (source != target)
        && (CMath.bset(msg.targetCode(), CMMsg.MASK_MALICIOUS))
        && (!observer.isInCombat())
        && (CMLib.flags().canBeSeenBy(source, observer))
        && (CMLib.flags().canBeSeenBy(target, observer))
        && (!BrotherHelper.isBrother(source, observer, false))
        && ((CMLib.flags().isEvil(target) && CMLib.flags().isEvil(observer))
            || (CMLib.flags().isNeutral(target) && CMLib.flags().isNeutral(observer))
            || (CMLib.flags().isGood(target) && CMLib.flags().isGood(observer)))) {
      Aggressive.startFight(
          observer,
          source,
          true,
          false,
          CMLib.flags().getAlignmentName(observer) + " PEOPLE UNITE! CHARGE!");
    }
  }
Ejemplo n.º 19
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;
    if ((affected == null) || (invoker == null)) return false;

    final MOB mob = (MOB) affected;
    if ((--diseaseTick) <= 0) {
      diseaseTick = 5;
      String str = null;
      switch (CMLib.dice().roll(1, 5, 0)) {
        case 1:
          str = L("<S-NAME> double(s) over and dry heave(s).");
          break;
        case 2:
          str = L("<S-NAME> sneeze(s). AAAAAAAAAAAAAACHOOO!!!!");
          break;
        case 3:
          str = L("<S-NAME> shake(s) feverishly.");
          break;
        case 4:
          str = L("<S-NAME> look(s) around weakly.");
          break;
        case 5:
          str = L("<S-NAME> cough(s) and shudder(s) feverishly.");
          break;
      }
      if (str != null) mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, str);
      return true;
    }
    return true;
  }
Ejemplo n.º 20
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;
  }
Ejemplo n.º 21
0
 @Override
 public void spring(MOB target) {
   if ((target != invoker()) && (target.location() != null)) {
     if ((doesSaveVsTraps(target))
         || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target)))
       target
           .location()
           .show(
               target,
               null,
               null,
               CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
               L("<S-NAME> avoid(s) setting off a gas trap!"));
     else if (target
         .location()
         .show(
             target,
             target,
             this,
             CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
             L("<S-NAME> set(s) off a trap! The room fills with gas!"))) {
       super.spring(target);
       Ability A = CMClass.getAbility(text());
       if (A == null) A = CMClass.getAbility("Poison");
       for (int i = 0; i < target.location().numInhabitants(); i++) {
         final MOB M = target.location().fetchInhabitant(i);
         if ((M != null) && (M != invoker()) && (A != null))
           if (invoker().mayIFight(M)) A.invoke(invoker(), M, true, 0);
       }
       if ((canBeUninvoked()) && (affected instanceof Item)) disable();
     }
   }
 }
Ejemplo n.º 22
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     if ((mob.isMonster()) && (mob.isInCombat())) return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
Ejemplo n.º 23
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> feel(s) magically protected."
                  : "^S<S-NAME> invoke(s) an absorbing barrier of protection around <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, "<S-NAME> attempt(s) to invoke an absorbing barrier, but fail(s).");

    return success;
  }
Ejemplo n.º 24
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);
 }
Ejemplo n.º 25
0
  public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException {
    if ((mob == null) || (mob.playerStats() == null)) return false;

    if (commands.size() < 2) {
      String pageBreak =
          (mob.playerStats().getPageBreak() != 0)
              ? ("" + mob.playerStats().getPageBreak())
              : "Disabled";
      mob.tell(
          "Change your page break to what? Your current page break setting is: "
              + pageBreak
              + ". Enter a number larger than 0 or 'disable'.");
      return false;
    }
    String newBreak = CMParms.combine(commands, 1);
    int newVal = mob.playerStats().getWrap();
    if ((CMath.isInteger(newBreak)) && (CMath.s_int(newBreak) > 0)) newVal = CMath.s_int(newBreak);
    else if ("DISABLED".startsWith(newBreak.toUpperCase())) newVal = 0;
    else {
      mob.tell(
          "'" + newBreak + "' is not a valid setting. Enter a number larger than 0 or 'disable'.");
      return false;
    }
    mob.playerStats().setPageBreak(newVal);
    String pageBreak =
        (mob.playerStats().getPageBreak() != 0)
            ? ("" + mob.playerStats().getPageBreak())
            : "Disabled";
    mob.tell("Your new page break setting is: " + pageBreak + ".");
    return false;
  }
Ejemplo n.º 26
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    final MOB mob = msg.source();
    if (mob.location() == null) return true;

    if (msg.amITarget(this))
      switch (msg.targetMinor()) {
        case CMMsg.TYP_HOLD:
        case CMMsg.TYP_WEAR:
        case CMMsg.TYP_WIELD:
        case CMMsg.TYP_GET:
          if ((!msg.source().charStats().getCurrentClass().ID().equals("Paladin"))
              || (!CMLib.flags().isGood(msg.source()))) {
            unWear();
            mob.location()
                .show(
                    mob,
                    null,
                    CMMsg.MSG_OK_ACTION,
                    L("@x1 flashes and flies out of <S-HIS-HER> hands!", name()));
            if (msg.source().isMine(this))
              CMLib.commands().postDrop(msg.source(), this, true, false, false);
            return false;
          }
          break;
        default:
          break;
      }
    return true;
  }
Ejemplo n.º 27
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);
  }
Ejemplo n.º 28
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> whistle(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> attain(s) an aquatic aura!"));
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> whistle(s) to <T-NAMESELF>, but nothing happens."));

    return success;
  }
Ejemplo n.º 29
0
 public Set<MOB> getDeadMOBsFrom(Environmental whoE) {
   if (whoE instanceof MOB) {
     final MOB mob = (MOB) whoE;
     final Room room = mob.location();
     if (room != null) return getEveryoneHere(mob, room);
   } else if (whoE instanceof Item) {
     final Item item = (Item) whoE;
     final Environmental E = item.owner();
     if (E != null) {
       final Room room = getTickersRoom(whoE);
       if (room != null) {
         if ((E instanceof MOB) && ((mask == null) || (CMLib.masking().maskCheck(mask, E, false))))
           return new XHashSet<MOB>((MOB) E);
         else if (E instanceof Room) return getEveryoneHere(null, (Room) E);
         room.recoverRoomStats();
       }
     }
   } else if (whoE instanceof Room) return getEveryoneHere(null, (Room) whoE);
   else if (whoE instanceof Area) {
     final Set<MOB> allMobs = new HashSet<MOB>();
     for (final Enumeration r = ((Area) whoE).getMetroMap(); r.hasMoreElements(); ) {
       final Room R = (Room) r.nextElement();
       allMobs.addAll(getEveryoneHere(null, R));
     }
   }
   return new HashSet<MOB>();
 }
Ejemplo n.º 30
0
  @Override
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    final MOB source = msg.source();
    if (!canFreelyBehaveNormal(affecting)) return;
    final MOB observer = (MOB) affecting;

    if ((source != observer)
        && (msg.amITarget(observer))
        && (msg.targetMinor() == CMMsg.TYP_GIVE)
        && (msg.tool() instanceof Coins)) {
      if ((CMLib.flags().canBeSeenBy(source, observer))
          && (CMLib.flags().canBeSeenBy(observer, source))) {
        double value = ((Coins) msg.tool()).getTotalValue();
        final String currency = ((Coins) msg.tool()).getCurrency().toUpperCase();
        double takeCut = getMyCut(affecting, currency);
        double amountToTake = CMLib.beanCounter().abbreviatedRePrice(observer, value * takeCut);
        if ((amountToTake > 0.0)
            && (amountToTake
                < CMLib.beanCounter()
                    .getLowestDenomination(CMLib.beanCounter().getCurrency(observer))))
          amountToTake =
              CMLib.beanCounter().getLowestDenomination(CMLib.beanCounter().getCurrency(observer));
        value -= amountToTake;
        observer.recoverPhyStats();
        final Coins C = CMLib.beanCounter().makeBestCurrency(observer, value);
        if ((value > 0.0) && (C != null)) {
          // this message will actually end up triggering the hand-over.
          final CMMsg newMsg =
              CMClass.getMsg(
                  observer,
                  source,
                  C,
                  CMMsg.MSG_SPEAK,
                  L("^T<S-NAME> say(s) 'Thank you for your business' to <T-NAMESELF>.^?"));
          C.setOwner(observer);
          final long num = C.getNumberOfCoins();
          final String curr = C.getCurrency();
          final double denom = C.getDenomination();
          C.destroy();
          C.setNumberOfCoins(num);
          C.setCurrency(curr);
          C.setDenomination(denom);
          msg.addTrailerMsg(newMsg);
        } else CMLib.commands().postSay(observer, source, L("Gee, thanks. :)"), true, false);
        ((Coins) msg.tool()).destroy();
      } else if (!CMLib.flags().canBeSeenBy(source, observer))
        CMLib.commands()
            .postSay(observer, null, L("Wha?  Where did this come from?  Cool!"), true, false);
    } else if ((msg.source() == observer)
        && (msg.target() instanceof MOB)
        && (msg.targetMinor() == CMMsg.TYP_SPEAK)
        && (msg.tool() instanceof Coins)
        && (((Coins) msg.tool()).amDestroyed())
        && (!msg.source().isMine(msg.tool()))
        && (!((MOB) msg.target()).isMine(msg.tool())))
      CMLib.beanCounter()
          .giveSomeoneMoney(msg.source(), (MOB) msg.target(), ((Coins) msg.tool()).getTotalValue());
  }