コード例 #1
0
 @Override
 public String displayClassLevelOnly(MOB mob) {
   if (mob == null) return "";
   if (displayClassLevel != null) return displayClassLevel;
   final int classLevel = getClassLevel(getCurrentClass());
   String levelStr = null;
   if (classLevel >= mob.phyStats().level()) levelStr = "" + mob.phyStats().level();
   else levelStr = classLevel + "/" + mob.phyStats().level();
   return levelStr;
 }
コード例 #2
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return super.tick(ticking, tickID);

    final MOB mob = (MOB) affected;

    if (tickID != Tickable.TICKID_MOB) return true;
    if (!proficiencyCheck(null, 0, false)) return true;

    if ((!mob.isInCombat()) && (CMLib.flags().isSleeping(mob))) {
      roundsHibernating++;
      final double man =
          ((mob.charStats().getStat(CharStats.STAT_INTELLIGENCE)
              + mob.charStats().getStat(CharStats.STAT_WISDOM)));
      mob.curState()
          .adjMana(
              (int)
                  Math.round(
                      (man * .1)
                          + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                              / 2.0)),
              mob.maxState());
      mob.curState().setHunger(oldState.getHunger());
      mob.curState().setThirst(oldState.getThirst());
      final double move = mob.charStats().getStat(CharStats.STAT_STRENGTH);
      mob.curState()
          .adjMovement(
              (int)
                  Math.round(
                      (move * .1)
                          + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                              / 2.0)),
              mob.maxState());
      if (!CMLib.flags().isGolem(mob)) {
        final double hp = mob.charStats().getStat(CharStats.STAT_CONSTITUTION);
        if (!CMLib.combat()
            .postHealing(
                mob,
                mob,
                this,
                CMMsg.MASK_ALWAYS | CMMsg.TYP_CAST_SPELL,
                (int)
                    Math.round(
                        (hp * .1)
                            + ((mob.phyStats().level() + (2.0 * super.getXLEVELLevel(invoker())))
                                / 2.0)),
                null)) unInvoke();
      }
    } else {
      unInvoke();
      return false;
    }
    return super.tick(ticking, tickID);
  }
コード例 #3
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.isInCombat()) {
      mob.tell(L("You must be in combat to do this!"));
      return false;
    }
    final MOB victim = super.getTarget(mob, commands, givenTarget);
    if (victim == null) return false;
    if (((victim == mob.getVictim()) && (mob.rangeToTarget() > 0))
        || ((victim.getVictim() == mob) && (victim.rangeToTarget() > 0))) {
      mob.tell(L("You are too far away to disarm!"));
      return false;
    }
    if (mob.fetchWieldedItem() == null) {
      mob.tell(L("You need a weapon to disarm someone!"));
      return false;
    }
    Item hisWeapon = victim.fetchWieldedItem();
    if (hisWeapon == null) hisWeapon = victim.fetchHeldItem();
    if ((hisWeapon == null)
        || (!(hisWeapon instanceof Weapon))
        || ((((Weapon) hisWeapon).weaponClassification() == Weapon.CLASS_NATURAL))) {
      mob.tell(L("@x1 is not wielding a weapon!", victim.charStats().HeShe()));
      return false;
    }

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

    int levelDiff =
        victim.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff > 0) levelDiff = levelDiff * 5;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, victim);
    final boolean success = proficiencyCheck(mob, -levelDiff, auto) && (hit);
    if ((success)
        && ((hisWeapon.fitsOn(Wearable.WORN_WIELD))
            || hisWeapon.fitsOn(Wearable.WORN_WIELD | Wearable.WORN_HELD))) {
      if (mob.location().show(mob, victim, this, CMMsg.MSG_NOISYMOVEMENT, null)) {
        final CMMsg msg = CMClass.getMsg(victim, hisWeapon, null, CMMsg.MSG_DROP, null);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(victim, msg);
          mob.location()
              .show(
                  mob,
                  victim,
                  CMMsg.MSG_NOISYMOVEMENT,
                  auto ? L("<T-NAME> is disarmed!") : L("<S-NAME> disarm(s) <T-NAMESELF>!"));
        }
      }
    } else
      maliciousFizzle(mob, victim, L("<S-NAME> attempt(s) to disarm <T-NAMESELF> and fail(s)!"));
    return success;
  }
コード例 #4
0
 public MOB victimHere(Room room, MOB mob) {
   if (room == null) return null;
   if (mob == null) return null;
   for (int i = 0; i < room.numInhabitants(); i++) {
     final MOB M = room.fetchInhabitant(i);
     if ((M != null)
         && (M != mob)
         && (!CMLib.flags().isEvil(M))
         && (mob.mayIFight(M))
         && (M.phyStats().level() < (mob.phyStats().level() + 5))) return M;
   }
   return null;
 }
コード例 #5
0
 @Override
 public String displayClassLevel(MOB mob, boolean shortForm) {
   if (displayClassLevel != null) {
     if (shortForm) return displayClassName() + " " + displayClassLevel;
     return "level " + displayClassLevel + " " + displayClassName;
   }
   if (mob == null) return "";
   final int classLevel = getClassLevel(getCurrentClass());
   String levelStr = null;
   if (classLevel >= mob.phyStats().level()) levelStr = "" + mob.phyStats().level();
   else levelStr = classLevel + "/" + mob.phyStats().level();
   if (shortForm) return displayClassName() + " " + levelStr;
   return "level " + levelStr + " " + displayClassName();
 }
コード例 #6
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) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> incant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          target
              .curState()
              .adjThirst(
                  -150 - ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 100),
                  target.maxState().maxThirst(target.baseWeight()));
          mob.location()
              .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> feel(s) incredibly thirsty!"));
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> incant(s) to <T-NAMESELF>, but the spell fades."));
    // return whether it worked
    return success;
  }
コード例 #7
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    String dir = CMParms.combine(commands, 0);
    if (commands.size() > 0) dir = (String) commands.lastElement();
    int dirCode = Directions.getGoodDirectionCode(dir);
    if (!preInvoke(mob, commands, givenTarget, auto, asLevel, 0, 0.0)) return false;

    MOB highestMOB = getHighestLevelMOB(mob, null);
    int levelDiff =
        mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)) - getMOBLevel(highestMOB);

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

    boolean success = false;
    CMMsg msg =
        CMClass.getMsg(
            mob,
            null,
            this,
            auto ? CMMsg.MSG_OK_VISUAL : CMMsg.MSG_DELICATE_HANDS_ACT,
            "<S-NAME> walk(s) carefully " + Directions.getDirectionName(dirCode) + ".");
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      if (levelDiff < 0) levelDiff = levelDiff * 8;
      else levelDiff = levelDiff * 10;
      success = proficiencyCheck(mob, levelDiff, auto);
      int oldDex = mob.baseCharStats().getStat(CharStats.STAT_DEXTERITY);
      if (success) mob.baseCharStats().setStat(CharStats.STAT_DEXTERITY, oldDex + 100);
      mob.recoverCharStats();
      CMLib.tracking().walk(mob, dirCode, false, false);
      if (oldDex != mob.baseCharStats().getStat(CharStats.STAT_DEXTERITY))
        mob.baseCharStats().setStat(CharStats.STAT_DEXTERITY, oldDex);
      mob.recoverCharStats();
    }
    return success;
  }
コード例 #8
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;

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("^S<S-NAME> scream(s) a mighty RALLYING CRY!!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Set<MOB> h = properTargets(mob, givenTarget, auto);
        if (h == null) return false;
        for (final Object element : h) {
          final MOB target = (MOB) element;
          target.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) rallied!"));
          timesTicking = 0;
          hpUp = mob.phyStats().level() + (2 * getXLEVELLevel(mob));
          beneficialAffect(mob, target, asLevel, 0);
          target.recoverMaxState();
          if (target.fetchEffect(ID()) != null) mob.curState().adjHitPoints(hpUp, mob.maxState());
        }
      }
    } else beneficialWordsFizzle(mob, null, auto ? "" : L("<S-NAME> mumble(s) a weak rally cry."));

    // return whether it worked
    return success;
  }
コード例 #9
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = null;
    Ability reAffect = null;
    if (mob.isInCombat()) {
      if (mob.rangeToTarget() > 0) {
        mob.tell(L("You are too far away to touch!"));
        return false;
      }
      final MOB victim = mob.getVictim();
      reAffect = victim.fetchEffect("Undead_WeakEnergyDrain");
      if (reAffect == null) reAffect = victim.fetchEffect("Undead_EnergyDrain");
      if (reAffect != null) target = victim;
    }
    if (target == null) 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);

    String str = null;
    if (success) {
      str = auto ? "" : L("^S<S-NAME> extend(s) an energy draining hand to <T-NAMESELF>!^?");
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_MALICIOUS_MOVE | CMMsg.TYP_UNDEAD | (auto ? CMMsg.MASK_ALWAYS : 0),
              str);
      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> <S-IS-ARE> drained!"));
          if (reAffect != null) {
            if (reAffect instanceof Undead_EnergyDrain)
              ((Undead_EnergyDrain) reAffect).levelsDown++;
            ((StdAbility) reAffect)
                .setTickDownRemaining(
                    ((StdAbility) reAffect).getTickDownRemaining() + mob.phyStats().level());
            mob.recoverPhyStats();
            mob.recoverCharStats();
            mob.recoverMaxState();
          } else {
            direction = 1;
            if (target.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead"))
              direction = -1;
            success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          }
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> attempt(s) to drain <T-NAMESELF>, but fail(s)."));

    return success;
  }
コード例 #10
0
 public boolean supportsMending(Physical item) {
   if (!(item instanceof MOB)) return false;
   MOB caster = CMClass.getFactoryMOB();
   caster.basePhyStats().setLevel(CMProps.getIntVar(CMProps.SYSTEMI_LASTPLAYERLEVEL));
   caster.phyStats().setLevel(CMProps.getIntVar(CMProps.SYSTEMI_LASTPLAYERLEVEL));
   boolean canMend = returnOffensiveAffects(caster, item).size() > 0;
   caster.destroy();
   return canMend;
 }
コード例 #11
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Item target = null;
    if ((commands.size() == 0) && (!auto) && (givenTarget == null))
      target = Prayer_Sacrifice.getBody(mob.location());
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if ((!(target instanceof DeadBody))
        || (target.rawSecretIdentity().toUpperCase().indexOf("FAKE") >= 0)) {
      mob.tell(L("You may only desecrate the dead."));
      return false;
    }
    if ((((DeadBody) target).isPlayerCorpse())
        && (!((DeadBody) target).getMobName().equals(mob.Name()))
        && (((DeadBody) target).hasContent())) {
      mob.tell(L("You are not allowed to desecrate a players corpse."));
      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("<T-NAME> feel(s) desecrated!")
                  : L("^S<S-NAME> desecrate(s) <T-NAMESELF> before @x1.^?", hisHerDiety(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (CMLib.flags().isEvil(mob)) {
          double exp = 5.0;
          final int levelLimit = CMProps.getIntVar(CMProps.Int.EXPRATE);
          final int levelDiff = (mob.phyStats().level()) - target.phyStats().level();
          if (levelDiff > levelLimit) exp = 0.0;
          if (exp > 0.0)
            CMLib.leveler()
                .postExperience(
                    mob, null, null, (int) Math.round(exp) + super.getXPCOSTLevel(mob), false);
        }
        target.destroy();
        mob.location().recoverRoomStats();
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> attempt(s) to desecrate <T-NAMESELF>, but fail(s)."));

    // return whether it worked
    return success;
  }
コード例 #12
0
ファイル: Skills.java プロジェクト: kingdavid127/MUD
 protected StringBuilder getAbilities(
     MOB viewerM, MOB ableM, Vector ofTypes, int mask, boolean addQualLine, int maxLevel) {
   final int COL_LEN1 = ListingLibrary.ColFixer.fixColWidth(3.0, viewerM);
   final int COL_LEN2 = ListingLibrary.ColFixer.fixColWidth(18.0, viewerM);
   final int COL_LEN3 = ListingLibrary.ColFixer.fixColWidth(19.0, viewerM);
   int highestLevel = 0;
   final int lowestLevel = ableM.phyStats().level() + 1;
   final StringBuilder msg = new StringBuilder("");
   for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
     final Ability A = a.nextElement();
     int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
     if (level < 0) level = 0;
     if ((A != null)
         && (level > highestLevel)
         && (level < lowestLevel)
         && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask))))
       highestLevel = level;
   }
   if ((maxLevel >= 0) && (maxLevel < highestLevel)) highestLevel = maxLevel;
   for (int l = 0; l <= highestLevel; l++) {
     final StringBuilder thisLine = new StringBuilder("");
     int col = 0;
     for (final Enumeration<Ability> a = ableM.allAbilities(); a.hasMoreElements(); ) {
       final Ability A = a.nextElement();
       int level = CMLib.ableMapper().qualifyingLevel(ableM, A);
       if (level < 0) level = 0;
       if ((A != null)
           && (level == l)
           && (ofTypes.contains(Integer.valueOf(A.classificationCode() & mask)))) {
         if (thisLine.length() == 0) thisLine.append("\n\rLevel ^!" + l + "^?:\n\r");
         if ((++col) > 3) {
           thisLine.append("\n\r");
           col = 1;
         }
         thisLine.append(
             "^N[^H"
                 + CMStrings.padRight(Integer.toString(A.proficiency()), COL_LEN1)
                 + "%^?]^N"
                 + " " // +(A.isAutoInvoked()?"^H.^N":" ")
                 + CMStrings.padRight(
                     "^<HELP^>" + A.name() + "^</HELP^>", (col == 3) ? COL_LEN2 : COL_LEN3));
       }
     }
     if (thisLine.length() > 0) msg.append(thisLine);
   }
   if (msg.length() == 0) msg.append(L("^!None!^?"));
   else if (addQualLine)
     msg.append(
         L(
             "\n\r\n\rUse QUALIFY to see additional skills you can GAIN.")); // ^H.^N =
                                                                             // passive/auto-invoked."));
   return msg;
 }
コード例 #13
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;
    if (!(target instanceof Armor)) {
      mob.tell(L("@x1 cannot be refitted.", target.name(mob)));
      return false;
    }

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

    final boolean success =
        proficiencyCheck(
            mob,
            (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level())
                * 5),
            auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);

        if (target.phyStats().height() == 0)
          mob.tell(L("Nothing happens to @x1.", target.name(mob)));
        else {
          mob.location()
              .show(
                  mob,
                  target,
                  CMMsg.MSG_OK_VISUAL,
                  L("<T-NAME> begin(s) to magically resize itself!"));
          target.basePhyStats().setHeight(0);
        }
        target.recoverPhyStats();
        mob.location().recoverRoomStats();
      }

    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #14
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;

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

    if (success
        && (target.phyStats().level()
            < ((mob.phyStats().level() + super.getXLEVELLevel(mob)) / 2))) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto) | CMMsg.MASK_MALICIOUS,
              L("^S<S-NAME> @x1 for <T-NAME> to die.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        CMLib.combat().postDeath(target, target, null);
        DeadBody body = null;
        for (Enumeration<Item> i = mob.location().items(); i.hasMoreElements(); ) {
          final Item I = i.nextElement();
          if ((I instanceof DeadBody) && (((DeadBody) I).getMobName().equals(target.Name())))
            body = (DeadBody) I;
        }
        if (body == null) mob.tell(L("The death did not appear to create a body!"));
        else beneficialAffect(mob, body, asLevel, 0);
      }
    } else
      return maliciousFizzle(
          mob,
          target,
          L("^S<S-NAME> @x1 <T-NAME> to die, but nothing happens.^?", prayForWord(mob)));
    // return whether it worked
    return success;
  }
コード例 #15
0
  public List<Ability> returnOffensiveAffects(MOB caster, Physical fromMe) {
    MOB newMOB = CMClass.getFactoryMOB();
    MOB newerMOB = CMClass.getFactoryMOB();
    Vector offenders = new Vector(1);

    CMMsg msg = CMClass.getMsg(newMOB, newerMOB, null, CMMsg.MSG_LOOK, null);
    for (int a = 0; a < fromMe.numEffects(); a++) // personal
    {
      Ability A = fromMe.fetchEffect(a);
      if (A != null) {
        newMOB.recoverPhyStats();
        A.affectPhyStats(newMOB, newMOB.phyStats());
        if ((!CMLib.flags().canSee(newMOB)) || (!A.okMessage(newMOB, msg)))
          if ((A.invoker() == null)
              || ((A.invoker() != null)
                  && (A.invoker().phyStats().level())
                      <= (caster.phyStats().level() + 1 + (2 * getXLEVELLevel(caster)))))
            offenders.addElement(A);
      }
    }
    newMOB.destroy();
    newerMOB.destroy();
    return offenders;
  }
コード例 #16
0
 public int getUndeadLevel(final MOB mob, double baseLvl, double corpseLevel) {
   final ExpertiseLibrary exLib = CMLib.expertises();
   final double deathLoreExpertiseLevel = super.getXLEVELLevel(mob);
   final double appropriateLoreExpertiseLevel = super.getX1Level(mob);
   final double charLevel = mob.phyStats().level();
   final double maxDeathLoreExpertiseLevel =
       exLib.getHighestListableStageBySkill(mob, ID(), ExpertiseLibrary.Flag.LEVEL);
   final double maxApproLoreExpertiseLevel =
       exLib.getHighestListableStageBySkill(mob, ID(), ExpertiseLibrary.Flag.X1);
   double lvl =
       (charLevel * appropriateLoreExpertiseLevel / maxApproLoreExpertiseLevel)
           - (baseLvl + 4 + (2 * maxDeathLoreExpertiseLevel));
   if (lvl < 0.0) lvl = 0.0;
   lvl += baseLvl + (2 * deathLoreExpertiseLevel);
   if (lvl > corpseLevel) lvl = corpseLevel;
   return (int) Math.round(lvl);
 }
コード例 #17
0
 public MOB getInvokerMOB(Environmental source, Environmental target) {
   MOB mob = getBestInvokerMOB(affected);
   if (mob == null) mob = getBestInvokerMOB(source);
   if (mob == null) mob = getBestInvokerMOB(target);
   if (mob == null) mob = invokerMOB;
   if (mob == null) {
     Room R = CMLib.map().roomLocation(target);
     if (R == null) R = CMLib.map().roomLocation(target);
     if (R == null) R = CMLib.map().getRandomRoom();
     mob = CMLib.map().getFactoryMOB(R);
     mob.setName(L("invoker"));
     mob.basePhyStats().setLevel(affected.phyStats().level());
     mob.phyStats().setLevel(affected.phyStats().level());
   }
   invokerMOB = mob;
   return invokerMOB;
 }
コード例 #18
0
ファイル: Spell_Mend.java プロジェクト: kingdavid127/MUD
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final Item target = getTarget(mob, null, givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;
    if (!target.subjectToWearAndTear()) {
      mob.tell(L("@x1 cannot be mended.", target.name(mob)));
      return false;
    }

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

    final boolean success =
        proficiencyCheck(
            mob,
            (((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) - target.phyStats().level())
                * 5),
            auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              (auto ? "<T-NAME> begins to shimmer!" : "^S<S-NAME> incant(s) at <T-NAMESELF>!^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (target.usesRemaining() >= 100) mob.tell(L("Nothing happens to @x1.", target.name(mob)));
        else {
          mob.location()
              .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to glow and mend!"));
          target.setUsesRemaining(100);
        }
        target.recoverPhyStats();
        mob.location().recoverRoomStats();
      }

    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #19
0
ファイル: Visible.java プロジェクト: yohanesgultom/CoffeeMud
 public static java.util.List<Ability> returnOffensiveAffects(Physical fromMe) {
   final MOB newMOB = CMClass.getFactoryMOB();
   newMOB.setLocation(CMLib.map().roomLocation(fromMe));
   final List<Ability> offenders = new Vector<Ability>();
   for (int a = 0; a < fromMe.numEffects(); a++) // personal
   {
     final Ability A = fromMe.fetchEffect(a);
     if ((A != null) && (A.canBeUninvoked())) {
       try {
         newMOB.recoverPhyStats();
         A.affectPhyStats(newMOB, newMOB.phyStats());
         if (CMLib.flags().isInvisible(newMOB) || CMLib.flags().isHidden(newMOB)) offenders.add(A);
       } catch (final Exception e) {
       }
     }
   }
   newMOB.destroy();
   return offenders;
 }
コード例 #20
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if ((msg.amITarget(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.tool() instanceof Ability)
        && (!mob.amDead())) {
      final Ability A = (Ability) msg.tool();
      if (CMath.bset(A.flags(), Ability.FLAG_PARALYZING)) {
        msg.addTrailerMsg(
            CMClass.getMsg(
                mob,
                null,
                CMMsg.MSG_OK_VISUAL,
                L("The uninhibiting barrier around <S-NAME> repels the @x1.", A.name())));
        return false;
      }
      final MOB newMOB = CMClass.getFactoryMOB();
      final CMMsg msg2 = CMClass.getMsg(newMOB, null, null, CMMsg.MSG_SIT, null);
      newMOB.recoverPhyStats();
      try {
        A.affectPhyStats(newMOB, newMOB.phyStats());
        if ((!CMLib.flags().aliveAwakeMobileUnbound(newMOB, true))
            || (CMath.bset(A.flags(), Ability.FLAG_PARALYZING))
            || (!A.okMessage(newMOB, msg2))) {
          msg.addTrailerMsg(
              CMClass.getMsg(
                  mob,
                  null,
                  CMMsg.MSG_OK_VISUAL,
                  L("The uninhibiting barrier around <S-NAME> repels the @x1.", A.name())));
          newMOB.destroy();
          return false;
        }
      } catch (final Exception e) {
      }
      newMOB.destroy();
    }
    return true;
  }
コード例 #21
0
 @Override
 public void spring(MOB mob) {
   final Room room = mob.location();
   if (room != null) {
     final Set<MOB> friendlySet = new HashSet<MOB>();
     if (invoker() != null) invoker().getGroupMembers(friendlySet);
     room.show(
         mob,
         affected,
         CMMsg.MSG_OK_ACTION,
         L("<T-NAME> explodes, spraying clumps of stomach acid everywhere!"));
     for (final Enumeration<MOB> m = room.inhabitants(); m.hasMoreElements(); ) {
       MOB M = m.nextElement();
       if ((M != null) && (!friendlySet.contains(M))) {
         final MOB invoker = (invoker() != null) ? invoker() : M;
         final int damage = CMLib.dice().roll(4, 5 + invoker.phyStats().level(), 0);
         CMLib.combat()
             .postDamage(
                 invoker,
                 M,
                 this,
                 damage,
                 CMMsg.MASK_MALICIOUS | CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID,
                 Weapon.TYPE_MELTING,
                 L("The acid clumps <DAMAGE> <T-NAME>!"));
         if ((!M.isInCombat())
             && (M.isMonster())
             && (M != invoker)
             && (M.location() == invoker.location())
             && (M.location().isInhabitant(invoker))
             && (CMLib.flags().canBeSeenBy(invoker, M)))
           CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem());
       }
     }
   }
   Physical affected = this.affected;
   unInvoke();
   if (affected instanceof Item) ((Item) affected).destroy();
 }
コード例 #22
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;

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    Item Bread = null;
    Item BreadContainer = null;
    for (int i = 0; i < target.numItems(); i++) {
      final Item I = target.getItem(i);
      if ((I != null) && (I instanceof Food)) {
        if (I.container() != null) {
          Bread = I;
          BreadContainer = I.container();
        } else {
          Bread = I;
          BreadContainer = null;
          break;
        }
      }
    }
    if ((Bread != null) && (BreadContainer != null))
      CMLib.commands().postGet(target, BreadContainer, Bread, false);
    if (Bread == null) {
      final ShopKeeper SK = CMLib.coffeeShops().getShopKeeper(target);
      if (SK != null) {
        for (final Iterator<Environmental> i = SK.getShop().getStoreInventory(); i.hasNext(); ) {
          final Environmental E2 = i.next();
          if ((E2 != null) && (E2 instanceof Food)) {
            Bread = (Item) E2.copyOf();
            target.addItem(Bread);
            break;
          }
        }
      }
    }
    if ((success) && (Bread != null)) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              L(
                  "^S<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread!^?",
                  prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_MALICIOUS_VERBAL | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg)) && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg2);
        if ((msg.value() <= 0) && (msg2.value() <= 0)) {
          msg =
              CMClass.getMsg(
                  target,
                  mob,
                  Bread,
                  CMMsg.MSG_GIVE,
                  L("<S-NAME> gladly donate(s) <O-NAME> to <T-NAMESELF>."));
          if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
        }
      }
    } else
      maliciousFizzle(
          mob,
          target,
          auto
              ? ""
              : L(
                  "<S-NAME> @x1 for <T-NAMESELF> to provide <S-HIS-HER> daily bread, but nothing happens.",
                  prayWord(mob)));

    // return whether it worked
    return success;
  }
コード例 #23
0
ファイル: WeatherAffects.java プロジェクト: Cocanuta/Marble
  public boolean tick(Tickable ticking, int tickID) {
    int realLastWeather = super.lastWeather;
    if (!super.tick(ticking, tickID)) return false;
    Area A = CMLib.map().areaLocation(ticking);
    if (A == null) return false;
    Climate C = A.getClimateObj();
    if (C == null) return false;
    lastWeather = realLastWeather;

    // handle freeze overs
    if ((coldWeather(lastWeather))
        && (coldWeather(C.weatherType(null)))
        && (lastWeather != C.weatherType(null))
        && (A.getTimeObj().getSeasonCode() == TimeClock.SEASON_WINTER)
        && (CMLib.dice().rollPercentage() < freezeOverChance)) {
      if (ticking instanceof Room) {
        Room R = (Room) ticking;
        if ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
            && (CMLib.dice().rollPercentage() < freezeOverChance)
            && (R instanceof Drink)
            && (((Drink) R).liquidType() == RawMaterial.RESOURCE_FRESHWATER)) {
          Ability A2 = CMClass.getAbility("Spell_IceSheet");
          if (A2 != null) {
            MOB mob = CMLib.map().getFactoryMOB(R);
            A2.invoke(mob, R, true, 0);
            mob.destroy();
          }
        }
      } else
        for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
          Room R = (Room) e.nextElement();
          if ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
              && (CMLib.dice().rollPercentage() < freezeOverChance)) {
            Ability A2 = CMClass.getAbility("Spell_IceSheet");
            if (A2 != null) {
              MOB mob = CMLib.map().getFactoryMOB(R);
              A2.invoke(mob, R, true, 0);
              mob.destroy();
            }
          }
        }
    }
    if ((botherDown--) == 1) {
      resetBotherTicks();
      switch (C.weatherType(null)) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SLEET:
        case Climate.WEATHER_SNOW:
        case Climate.WEATHER_HAIL:
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_RAIN:
          for (Enumeration<Room> r = A.getProperMap(); r.hasMoreElements(); ) {
            Room R = (Room) r.nextElement();
            if (CMLib.map().hasASky(R))
              for (int i = 0; i < R.numInhabitants(); i++) {
                MOB mob = R.fetchInhabitant(i);
                if ((mob != null)
                    && (!mob.isMonster())
                    && (CMLib.flags().aliveAwakeMobile(mob, true))
                    && (CMath.bset(mob.getBitmap(), MOB.ATT_AUTOWEATHER)))
                  mob.tell(C.getWeatherDescription(A));
              }
          }
          break;
      }
    }
    if ((diseaseDown--) == 1) {
      resetDiseaseTicks();
      int coldChance = 0;
      int fluChance = 0;
      int frostBiteChance = 0;
      int heatExhaustionChance = 0;
      switch (C.weatherType(null)) {
        case Climate.WEATHER_BLIZZARD:
        case Climate.WEATHER_SLEET:
        case Climate.WEATHER_SNOW:
          coldChance = 99;
          fluChance = 25;
          frostBiteChance = 15;
          break;
        case Climate.WEATHER_HAIL:
          coldChance = 50;
          frostBiteChance = 10;
          break;
        case Climate.WEATHER_THUNDERSTORM:
        case Climate.WEATHER_RAIN:
          coldChance = 25;
          break;
        case Climate.WEATHER_WINTER_COLD:
          coldChance = 75;
          fluChance = 10;
          frostBiteChance = 5;
          break;
        case Climate.WEATHER_HEAT_WAVE:
          heatExhaustionChance = 15;
          break;
        case Climate.WEATHER_DROUGHT:
          heatExhaustionChance = 20;
          break;
      }

      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())) continue;

        MOB M = S.mob();
        Room R = M.location();

        if ((R.domainConditions() & Room.CONDITION_COLD) > 0) {
          if (coldChance > 0) coldChance += 10;
          if (coldChance > 0) fluChance += 5; // yes, cold is related this way to flu
          if (frostBiteChance > 0)
            frostBiteChance = frostBiteChance + (int) Math.round(CMath.mul(frostBiteChance, 0.5));
        }
        if ((R.domainConditions() & Room.CONDITION_HOT) > 0) {
          if (heatExhaustionChance > 0) heatExhaustionChance += 10;
        }
        if ((R.domainConditions() & Room.CONDITION_WET) > 0) {
          if (coldChance > 0) coldChance += 5;
          if (heatExhaustionChance > 5) heatExhaustionChance -= 5;
          if (frostBiteChance > 0)
            frostBiteChance = frostBiteChance + (int) Math.round(CMath.mul(frostBiteChance, 0.25));
        }
        int save =
            (M.charStats().getSave(CharStats.STAT_SAVE_COLD)
                    + M.charStats().getSave(CharStats.STAT_SAVE_WATER))
                / 2;
        if ((CMLib.dice().rollPercentage() < (coldChance - save))
            && ((C.weatherType(M.location()) != Climate.WEATHER_CLEAR))) {
          long coveredPlaces = 0;
          for (int l = 0; l < ALL_COVERED_SPOTS.length; l++)
            if (M.getWearPositions(ALL_COVERED_SPOTS[l]) == 0)
              coveredPlaces = coveredPlaces | ALL_COVERED_SPOTS[l];
          Item I = null;
          for (int i = 0; i < M.numItems(); i++) {
            I = M.getItem(i);
            if ((I == null) || (I.amWearingAt(Wearable.IN_INVENTORY))) continue;
            if (I.amWearingAt(Wearable.WORN_ABOUT_BODY))
              coveredPlaces = coveredPlaces | Wearable.WORN_TORSO | Wearable.WORN_LEGS;
            for (int l = 0; l < ALL_COVERED_SPOTS.length; l++)
              if (I.amWearingAt(ALL_COVERED_SPOTS[l]))
                coveredPlaces = coveredPlaces | ALL_COVERED_SPOTS[l];
          }
          if ((coveredPlaces != ALL_COVERED_CODE)
              && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
            Ability COLD = CMClass.getAbility("Disease_Cold");
            if (CMLib.dice().rollPercentage()
                < (fluChance
                    + (((M.location().domainConditions() & Room.CONDITION_WET) > 0) ? 10 : 0)))
              COLD = CMClass.getAbility("Disease_Flu");
            if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
          }
        }
        if ((CMLib.dice().rollPercentage() < (frostBiteChance - save))
            && ((C.weatherType(M.location()) != Climate.WEATHER_CLEAR))) {
          long unfrostedPlaces = 0;
          for (int l = 0; l < ALL_FROST_SPOTS.length; l++)
            if (M.getWearPositions(ALL_FROST_SPOTS[l]) == 0)
              unfrostedPlaces = unfrostedPlaces | ALL_FROST_SPOTS[l];
          Item I = null;
          for (int i = 0; i < M.numItems(); i++) {
            I = M.getItem(i);
            if ((I == null) || (I.amWearingAt(Wearable.IN_INVENTORY))) continue;
            for (int l = 0; l < ALL_FROST_SPOTS.length; l++)
              if (I.amWearingAt(ALL_FROST_SPOTS[l]))
                unfrostedPlaces = unfrostedPlaces | ALL_FROST_SPOTS[l];
          }
          if ((unfrostedPlaces != ALL_FROST_CODE)
              && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
            Ability COLD = CMClass.getAbility("Disease_FrostBite");
            if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
          }
        }
        if ((heatExhaustionChance > 0)
            && (CMLib.dice().rollPercentage()
                < (heatExhaustionChance - M.charStats().getSave(CharStats.STAT_SAVE_FIRE)))
            && (C.weatherType(M.location()) != Climate.WEATHER_CLEAR)
            && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
          Ability COLD = CMClass.getAbility("Disease_HeatExhaustion");
          if ((COLD != null) && (M.fetchEffect(COLD.ID()) == null)) COLD.invoke(M, M, true, 0);
        }
      }
    }
    if ((rumbleDown--) == 1) {
      resetRumbleTicks();
      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())
            || (!CMath.bset(S.mob().getBitmap(), MOB.ATT_AUTOWEATHER))) continue;
        Room R = S.mob().location();
        if (R != null) {
          switch (C.weatherType(null)) {
            case Climate.WEATHER_THUNDERSTORM:
              {
                if (C.weatherType(R) != Climate.WEATHER_THUNDERSTORM) {
                  if ((R.domainType() & Room.INDOORS) > 0) {
                    if ((R.getArea() != null)
                        && CMath.div(
                                R.getArea().getAreaIStats()[Area.Stats.INDOOR_ROOMS.ordinal()],
                                R.getArea().properSize())
                            < 0.90)
                      S.mob()
                          .tell(
                              "^JA thunderous rumble and CRACK of lightning can be heard outside.^?"
                                  + CMProps.msp("thunder.wav", 40));
                  } else
                    S.mob()
                        .tell(
                            "^JA thunderous rumble and CRACK of lightning can be heard.^?"
                                + CMProps.msp("thunder.wav", 40));
                } else if (R.getArea().getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  S.mob()
                      .tell(
                          "^JA thunderous rumble and CRACK of lightning can be heard as the pounding rain soaks you.^?"
                              + CMProps.msp("thunderandrain.wav", 40));
                else
                  S.mob()
                      .tell(
                          "^JA bolt of lightning streaks across the sky as the pounding rain soaks you!^?"
                              + CMProps.msp("thunderandrain.wav", 40));
                break;
              }
            case Climate.WEATHER_BLIZZARD:
              if (C.weatherType(R) == Climate.WEATHER_BLIZZARD)
                S.mob()
                    .tell(
                        "^JSwirling clouds of snow buffet you.^?"
                            + CMProps.msp("blizzard.wav", 40));
              break;
            case Climate.WEATHER_SNOW:
              if (C.weatherType(R) == Climate.WEATHER_SNOW)
                S.mob().tell("^JSnowflakes fall lightly on you.^?");
              break;
            case Climate.WEATHER_DUSTSTORM:
              if (C.weatherType(R) == Climate.WEATHER_DUSTSTORM)
                S.mob()
                    .tell(
                        "^JSwirling clouds of dust assault you.^?" + CMProps.msp("windy.wav", 40));
              break;
            case Climate.WEATHER_HAIL:
              if (C.weatherType(R) == Climate.WEATHER_HAIL)
                S.mob()
                    .tell(
                        "^JYou are being pelleted by hail! Ouch!^?" + CMProps.msp("hail.wav", 40));
              break;
            case Climate.WEATHER_RAIN:
              if (C.weatherType(R) == Climate.WEATHER_RAIN)
                S.mob().tell("^JThe rain is soaking you!^?" + CMProps.msp("rainlong.wav", 40));
              break;
            case Climate.WEATHER_SLEET:
              if (C.weatherType(R) == Climate.WEATHER_SLEET)
                S.mob()
                    .tell(
                        "^JCold and blistering sleet is soaking you numb!^?"
                            + CMProps.msp("rain.wav", 40));
              break;
            case Climate.WEATHER_WINDY:
              if (C.weatherType(R) == Climate.WEATHER_WINDY)
                S.mob().tell("^JThe wind gusts around you.^?" + CMProps.msp("wind.wav", 40));
              break;
          }
        }
      }
    }
    if ((lightningDown--) == 1) {
      resetLightningTicks();
      if (C.weatherType(null) == Climate.WEATHER_THUNDERSTORM) {
        boolean playerAround = false;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_THUNDERSTORM)) continue;
          playerAround = true;
        }
        if (playerAround) {
          Room R = A.getRandomProperRoom();
          MOB M = R.fetchRandomInhabitant();
          if (M != null) {
            Ability A2 = CMClass.getAbility("Chant_SummonLightning");
            if (A2 != null) {
              A2.setMiscText("RENDER MUNDANE");
              A2.invoke(M, M, true, M.phyStats().level());
            }
          } else R = null;
          Room R2 = null;
          for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            R2 = (Room) e.nextElement();
            if ((R2 != R) && (R2.numInhabitants() > 0))
              if ((A.getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  || (C.weatherType(R2) != Climate.WEATHER_THUNDERSTORM)) {
                if ((R2.domainType() & Room.INDOORS) > 0)
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JA thunderous rumble and crack of lightning can be heard outside.^?"
                          + CMProps.msp("thunder2.wav", 40));
                else
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JA thunderous rumble and crack of lightning can be heard.^?"
                          + CMProps.msp("thunder2.wav", 40));
              } else
                R2.showHappens(
                    CMMsg.MSG_OK_ACTION,
                    "^JYou hear a thunderous rumble as a bolt of lightning streaks across the sky!^?"
                        + CMProps.msp("thunder3.wav", 40));
          }
        }
      }
    }
    if ((tornadoDown--) == 1) {
      resetTornadoTicks();
      if ((C.weatherType(null) == Climate.WEATHER_THUNDERSTORM)
          || (C.weatherType(null) == Climate.WEATHER_WINDY)) {
        boolean playerAround = false;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_THUNDERSTORM)) continue;
          playerAround = true;
        }
        if (playerAround) {
          Room R = A.getRandomProperRoom();
          MOB M = R.fetchRandomInhabitant();
          if (M != null) {
            Ability A2 = CMClass.getAbility("Chant_SummonTornado");
            if (A2 != null) {
              A2.setMiscText("RENDER MUNDANE");
              MOB mob = CMLib.map().getFactoryMOB(R);
              A2.invoke(mob, null, true, 0);
              mob.destroy();
            }
          } else R = null;
          Room R2 = null;
          for (Enumeration<Room> e = A.getProperMap(); e.hasMoreElements(); ) {
            R2 = (Room) e.nextElement();
            if ((R2 != R) && (R2.numInhabitants() > 0))
              if ((A.getTimeObj().getTODCode() == TimeClock.TIME_DAY)
                  || (C.weatherType(R2) != Climate.WEATHER_THUNDERSTORM)) {
                if ((R2.domainType() & Room.INDOORS) > 0)
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JThe terrible rumble of a tornado can be heard outside.^?"
                          + CMProps.msp("tornado.wav", 40));
                else
                  R2.showHappens(
                      CMMsg.MSG_OK_ACTION,
                      "^JThe terrible rumble of a tornado can be heard.^?"
                          + CMProps.msp("tornado.wav", 40));
              } else
                R2.showHappens(
                    CMMsg.MSG_OK_ACTION,
                    "^JA huge and terrible tornado touches down somewhere near by.^?"
                        + CMProps.msp("tornado.wav", 40));
          }
        }
      }
    }
    if ((dustDown--) == 1) {
      resetDustTicks();
      if (C.weatherType(null) == Climate.WEATHER_DUSTSTORM) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_DUSTSTORM)) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = R.fetchRandomInhabitant();
          if ((M != null)
              && (C.weatherType(R) == Climate.WEATHER_DUSTSTORM)
              && (!CMLib.flags().isSleeping(M))) {
            Ability A2 = CMClass.getAbility("Skill_Dirt");
            if (A2 != null) A2.invoke(M, M, true, 0);
          }
        }
      }
    }
    if ((hailDown--) == 1) {
      resetHailTicks();
      if (C.weatherType(null) == Climate.WEATHER_HAIL) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || (C.weatherType(S.mob().location()) != Climate.WEATHER_HAIL)) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = R.fetchRandomInhabitant();
          Ability A2 = CMClass.getAbility("Chant_SummonHail");
          if ((A2 != null) && (C.weatherType(R) == Climate.WEATHER_HAIL)) {
            A2.setMiscText("RENDER MUNDANE");
            A2.invoke(M, M, true, M.phyStats().level());
          }
        }
      }
    }
    if ((C.weatherType(null) == Climate.WEATHER_DROUGHT)
        && (CMLib.dice().rollPercentage() < droughtFireChance)) {
      Room R = CMLib.map().roomLocation((Environmental) ticking);
      if ((R == null) && (ticking instanceof Area)) R = ((Area) ticking).getRandomProperRoom();
      if ((R != null)
          && ((R.domainType() & Room.INDOORS) == 0)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_SWAMP)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_UNDERWATER)
          && (R.domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
          && ((R.domainConditions() & Room.CONDITION_WET) == 0)) {
        Item I = R.getRandomItem();
        if ((I != null) && (CMLib.flags().isGettable(I)))
          switch (I.material() & RawMaterial.MATERIAL_MASK) {
            case RawMaterial.MATERIAL_CLOTH:
            case RawMaterial.MATERIAL_LEATHER:
            case RawMaterial.MATERIAL_PAPER:
            case RawMaterial.MATERIAL_VEGETATION:
            case RawMaterial.MATERIAL_WOODEN:
              {
                Ability A2 = CMClass.getAbility("Burning");
                MOB mob = CMLib.map().getFactoryMOB(R);
                R.showHappens(
                    CMMsg.MSG_OK_VISUAL,
                    I.Name()
                        + " spontaneously combusts in the seering heat!"
                        + CMProps.msp("fire.wav", 40));
                A2.invoke(mob, I, true, 0);
                mob.destroy();
              }
              break;
          }
      }
    }
    if ((gustDown--) == 1) {
      resetGustTicks();
      if ((C.weatherType(null) == Climate.WEATHER_WINDY)
          || (C.weatherType(null) == Climate.WEATHER_BLIZZARD)
          || (C.weatherType(null) == Climate.WEATHER_DUSTSTORM)) {
        Vector choices = new Vector();
        Room R = null;
        for (Session S : CMLib.sessions().localOnlineIterable()) {
          if ((S.mob() == null)
              || (S.mob().location() == null)
              || (S.mob().location().getArea() != A)
              || (S.mob().isMonster())
              || ((C.weatherType(S.mob().location()) != Climate.WEATHER_WINDY)
                  && (C.weatherType(S.mob().location()) != Climate.WEATHER_BLIZZARD)
                  && (C.weatherType(S.mob().location()) != Climate.WEATHER_DUSTSTORM))) continue;
          R = S.mob().location();
          if ((R != null) && (!choices.contains(R))) choices.addElement(R);
        }
        if (choices.size() > 0) {
          R = (Room) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
          MOB M = CMLib.map().getFactoryMOB(R);
          Ability A2 = CMClass.getAbility("Chant_WindGust");
          if (A2 != null) {
            A2.setMiscText("RENDER MUNDANE");
            A2.invoke(M, M, true, M.phyStats().level());
          }
          M.destroy();
        }
      }
    }
    if ((rustDown--) == 1) {
      resetRustTicks();
      for (Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.mob() == null)
            || (S.mob().location() == null)
            || (S.mob().location().getArea() != A)
            || (S.mob().isMonster())) continue;
        int rustChance = 0;
        switch (C.weatherType(S.mob().location())) {
          case Climate.WEATHER_BLIZZARD:
          case Climate.WEATHER_SLEET:
          case Climate.WEATHER_SNOW:
            rustChance = 5;
            break;
          case Climate.WEATHER_HAIL:
            rustChance = 5;
            break;
          case Climate.WEATHER_THUNDERSTORM:
          case Climate.WEATHER_RAIN:
            rustChance = 5;
            break;
        }

        MOB M = S.mob();
        Room R = M.location();

        switch (R.domainType()) {
          case Room.DOMAIN_INDOORS_UNDERWATER:
          case Room.DOMAIN_INDOORS_WATERSURFACE:
          case Room.DOMAIN_OUTDOORS_WATERSURFACE:
          case Room.DOMAIN_OUTDOORS_UNDERWATER:
            rustChance += 5;
            break;
          default:
            break;
        }
        if ((R.domainConditions() & Room.CONDITION_WET) > 0) rustChance += 2;
        if (CMLib.dice().rollPercentage() < rustChance) {
          int weatherType = C.weatherType(R);
          Vector rustThese = new Vector();
          for (int i = 0; i < M.numItems(); i++) {
            Item I = M.getItem(i);
            if (I == null) continue;
            if ((!I.amWearingAt(Wearable.IN_INVENTORY))
                && (((I.material() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_METAL))
                && (I.subjectToWearAndTear())
                && ((CMLib.dice().rollPercentage() > I.phyStats().ability() * 25)))
              rustThese.addElement(I);
            else if (I.amWearingAt(Wearable.WORN_ABOUT_BODY)
                && (((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_METAL))) {
              rustThese.clear();
              break;
            }
          }
          if (R != null)
            for (int i = 0; i < rustThese.size(); i++) {
              Item I = (Item) rustThese.elementAt(i);
              CMMsg msg =
                  CMClass.getMsg(
                      M,
                      I,
                      null,
                      CMMsg.MASK_ALWAYS | CMMsg.TYP_WATER,
                      (weatherType != 0) ? "<T-NAME> rusts." : "<T-NAME> rusts in the water.",
                      CMMsg.TYP_WATER,
                      null,
                      CMMsg.NO_EFFECT,
                      null);
              if (R.okMessage(M, msg)) {
                R.send(M, msg);
                if (msg.value() <= 0) {
                  I.setUsesRemaining(I.usesRemaining() - 1);
                  if (I.usesRemaining() <= 0) {
                    msg =
                        CMClass.getMsg(
                            M,
                            null,
                            null,
                            CMMsg.MSG_OK_VISUAL,
                            I.name() + " is destroyed!",
                            null,
                            I.name() + " carried by " + M.name() + " is destroyed!");
                    if (R.okMessage(M, msg)) R.send(M, msg);
                    I.destroy();
                  }
                }
              }
            }
        }
      }
    }
    if (ticking instanceof Room) lastWeather = C.weatherType((Room) ticking);
    else lastWeather = C.weatherType(null);
    return true;
  }
コード例 #24
0
ファイル: Prayer_Weather.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int size = mob.location().getArea().numberOfProperIDedRooms();
    size = size - ((mob.phyStats().level() + (2 * super.getXLEVELLevel(mob))) * 20);
    if (size < 0) size = 0;
    boolean success = proficiencyCheck(mob, -size, auto);
    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto
                  ? "The sky changes color!"
                  : "^S<S-NAME> " + prayWord(mob) + " for a change in weather!^?");
      if (mob.location().okMessage(mob, msg)) {
        int switcher = CMLib.dice().roll(1, 3, 0);
        mob.location().send(mob, msg);
        switch (mob.location().getArea().getClimateObj().weatherType(mob.location())) {
          case Climate.WEATHER_BLIZZARD:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_BLIZZARD);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_BLIZZARD);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SNOW);
            break;
          case Climate.WEATHER_CLEAR:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_CLOUDY:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_DROUGHT:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_DUSTSTORM);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_HEAT_WAVE);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_DUSTSTORM:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_DUSTSTORM);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_HAIL:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_HAIL);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_HEAT_WAVE:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_DUSTSTORM);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_RAIN:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_SLEET:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_SNOW:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_BLIZZARD);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SLEET);
            else
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_THUNDERSTORM:
            if (switcher == 1)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_WINDY:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location()
                  .getArea()
                  .getClimateObj()
                  .setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_WINTER_COLD:
            if (switcher == 1)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_WINDY);
            else if (switcher == 2)
              mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_SNOW);
            else mob.location().getArea().getClimateObj().setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          default:
            break;
        }
        mob.location().getArea().getClimateObj().forceWeatherTick(mob.location().getArea());
      }
    } else
      beneficialVisualFizzle(mob, null, "<S-NAME> " + prayWord(mob) + ", but nothing happens.");

    return success;
  }
コード例 #25
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(L("Pay Off Whom?"));
      return false;
    }
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((target.charStats().getStat(CharStats.STAT_INTELLIGENCE) < 3) || (!target.isMonster())) {
      mob.tell(L("You can't pay off @x1.", target.name(mob)));
      return false;
    }

    final LegalBehavior B = CMLib.law().getLegalBehavior(mob.location());
    final Area A = (B == null) ? null : CMLib.law().getLegalObject(mob.location());
    if ((A == null) || (B == null)) {
      mob.tell(L("There's no point in paying off @x1.", target.name(mob)));
      return false;
    }

    boolean isJudge = B.isJudge(A, target);
    if ((!isJudge) && (!B.isAnyOfficer(A, target))) {
      mob.tell(L("Paying off @x1 won't help you.", target.name(mob)));
      return false;
    }

    final List<LegalWarrant> warrants = B.getWarrantsOf(A, mob);
    if ((warrants == null) || (warrants.size() == 0)) {
      mob.tell(L("Pay off @x1? Why? You aren't in any trouble.", target.name(mob)));
      return false;
    }

    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("@x1 is already paid off.", target.name(mob)));
      return false;
    }

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

    double amountRequired =
        CMLib.beanCounter().getTotalAbsoluteNativeValue(target)
            + ((double)
                    ((100l
                        - ((mob.charStats().getStat(CharStats.STAT_CHARISMA)
                                + (2l * getXLEVELLevel(mob)))
                            * 2)))
                * target.phyStats().level());
    if (isJudge) amountRequired *= 2;

    final String currency = CMLib.beanCounter().getCurrency(target);
    boolean success = proficiencyCheck(mob, 0, auto);

    if ((!success) || (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired)) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_SPEAK,
              L(
                  "^T<S-NAME> attempt(s) to pay off <T-NAMESELF> to '@x1', but no deal is reached.^?",
                  CMParms.combine(commands, 0)));
      if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
      if (CMLib.beanCounter().getTotalAbsoluteValue(mob, currency) < amountRequired) {
        final String costWords = CMLib.beanCounter().nameCurrencyShort(currency, amountRequired);
        mob.tell(L("@x1 requires @x2 to do this.", target.charStats().HeShe(), costWords));
      }
      success = false;
    } else {
      final String costWords = CMLib.beanCounter().nameCurrencyShort(target, amountRequired);
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSG_THIEF_ACT,
              L("^T<S-NAME> pay(s) off <T-NAMESELF>.^?", CMParms.combine(commands, 0), costWords));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        CMLib.beanCounter().subtractMoney(mob, currency, amountRequired);
        CMLib.beanCounter().addMoney(mob, currency, amountRequired);
        if (isJudge) {
          for (LegalWarrant W : warrants) {
            if (W.punishment() > 0) W.setPunishment(W.punishment() - 1);
          }
        } else {
          clearWarrants(target, mob, mob.location(), A, B);
          super.beneficialAffect(mob, target, asLevel, 0);
        }
      }
      target.recoverPhyStats();
    }
    return success;
  }
コード例 #26
0
ファイル: Chant_SummonRain.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (((mob.location().domainType() & Room.INDOORS) > 0) && (!auto)) {
      mob.tell("You must be outdoors for this chant to work.");
      return false;
    }
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int size = mob.location().getArea().numberOfProperIDedRooms();
    size = size / (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)));
    if (size < 0) size = 0;
    boolean success = proficiencyCheck(mob, -size, auto);
    if (success) {
      Climate C = mob.location().getArea().getClimateObj();
      Climate oldC = (Climate) C.copyOf();
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              verbalCastCode(mob, null, auto),
              auto
                  ? "^JThe sky changes color!^?"
                  : "^S<S-NAME> chant(s) into the sky for water!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        switch (C.weatherType(mob.location())) {
          case Climate.WEATHER_BLIZZARD:
            C.setNextWeatherType(Climate.WEATHER_BLIZZARD);
            break;
          case Climate.WEATHER_CLEAR:
            C.setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_CLOUDY:
            C.setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_DROUGHT:
            C.setNextWeatherType(Climate.WEATHER_CLEAR);
            break;
          case Climate.WEATHER_DUSTSTORM:
            C.setNextWeatherType(Climate.WEATHER_CLOUDY);
            break;
          case Climate.WEATHER_HAIL:
            C.setNextWeatherType(Climate.WEATHER_SLEET);
            break;
          case Climate.WEATHER_HEAT_WAVE:
            C.setNextWeatherType(Climate.WEATHER_RAIN);
            break;
          case Climate.WEATHER_RAIN:
            C.setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            break;
          case Climate.WEATHER_SLEET:
            C.setNextWeatherType(Climate.WEATHER_SLEET);
            break;
          case Climate.WEATHER_SNOW:
            C.setNextWeatherType(Climate.WEATHER_SLEET);
            break;
          case Climate.WEATHER_THUNDERSTORM:
            C.setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            break;
          case Climate.WEATHER_WINDY:
            C.setNextWeatherType(Climate.WEATHER_THUNDERSTORM);
            break;
          case Climate.WEATHER_WINTER_COLD:
            C.setNextWeatherType(Climate.WEATHER_SNOW);
            break;
          default:
            break;
        }
        C.forceWeatherTick(mob.location().getArea());
        Chant_CalmWeather.xpWorthyChange(mob, mob.location().getArea(), oldC, C);
      }
    } else
      beneficialVisualFizzle(
          mob, null, "<S-NAME> chant(s) into the sky for water, but the magic fizzles.");

    return success;
  }
コード例 #27
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 2) {
      if (mob.isMonster() && (commands.size() == 1)) {
        final String parm = correctItem(mob);
        if (parm != null) commands.add(parm);
      }
      if (commands.size() < 2) {
        mob.tell(L("You must specify a target, and what item to swap on the target!"));
        return false;
      }
    }
    final Item I = mob.findItem(null, commands.get(commands.size() - 1));
    if ((I == null) || (!CMLib.flags().canBeSeenBy(I, mob))) {
      mob.tell(L("You don't seem to have '@x1'.", (commands.get(commands.size() - 1))));
      return false;
    }
    if (((I instanceof Armor) && (I.basePhyStats().armor() > 1))
        || ((I instanceof Weapon) && (I.basePhyStats().damage() > 1))) {
      mob.tell(L("@x1 is not buffoonish enough!", I.name(mob)));
      return false;
    }
    commands.remove(commands.size() - 1);

    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    final Item targetItem = targetItem(target);
    if (targetItem == null) {
      if (!freePosition(target)) {
        mob.tell(L("@x1 has no free wearing positions!", target.name(mob)));
        return false;
      }
    }

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

    int levelDiff = target.phyStats().level() - mob.phyStats().level();

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (levelDiff > 0)
      levelDiff = -(levelDiff * ((!CMLib.flags().canBeSeenBy(mob, target)) ? 5 : 15));
    else levelDiff = -(levelDiff * ((!CMLib.flags().canBeSeenBy(mob, target)) ? 1 : 2));

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              (CMMsg.MSG_NOISYMOVEMENT | CMMsg.MASK_DELICATE | CMMsg.MASK_MALICIOUS)
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? "" : L("<S-NAME> do(es) buffoonery to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        long position = -1;
        if (targetItem != null) {
          position = targetItem.rawWornCode();
          targetItem.unWear();
        } else {
          final Vector<Long> free = getFreeWearingPositions(target);
          if (free.size() < 1) {
            mob.tell(L("@x1 has no free wearing positions!", target.name(mob)));
            return false;
          }
          if ((free.contains(Long.valueOf(Wearable.WORN_WIELD)))
              && ((I instanceof Weapon) || (!(I instanceof Armor)))) position = Wearable.WORN_WIELD;
          else position = free.elementAt(CMLib.dice().roll(1, free.size(), -1)).longValue();
        }
        if (position >= 0) {
          I.unWear();
          target.moveItemTo(I);
          I.wearAt(position);
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) buffoonery on <T-NAMESELF>, but fail(s)."));

    return success;
  }
コード例 #28
0
ファイル: Chant_WarpWood.java プロジェクト: kingdavid127/MUD
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB mobTarget = getTarget(mob, commands, givenTarget, true, false);
    Item target = getPossibility(mobTarget);
    if (target == null)
      target = getTarget(mob, mob.location(), givenTarget, commands, Wearable.FILTER_ANY);
    if (target == null) return false;
    if (((target.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_WOODEN)
        || (!target.subjectToWearAndTear())) {
      mob.tell(L("That can't be warped."));
      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("<T-NAME> starts warping!") : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?"));
      final CMMsg msg2 =
          CMClass.getMsg(mob, mobTarget, this, verbalCastCode(mob, mobTarget, auto), null);
      if ((mob.location().okMessage(mob, msg))
          && ((mobTarget == null) || (mob.location().okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if (mobTarget != null) mob.location().send(mob, msg2);
        if (msg.value() <= 0) {
          int damage =
              100
                  + (mob.phyStats().level() + (2 * super.getXLEVELLevel(mob)))
                  - target.phyStats().level();
          if (CMLib.flags().isABonusItems(target))
            damage = (int) Math.round(CMath.div(damage, 2.0));
          target.setUsesRemaining(target.usesRemaining() - damage);
          if (mobTarget == null)
            mob.location()
                .show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> begin(s) to twist and warp!"));
          else
            mob.location()
                .show(
                    mobTarget,
                    target,
                    CMMsg.MSG_OK_VISUAL,
                    L("<T-NAME>, possessed by <S-NAME>, twists and warps!"));
          if (target.usesRemaining() > 0) target.recoverPhyStats();
          else {
            target.setUsesRemaining(100);
            mob.location().show(mob, target, CMMsg.MSG_OK_VISUAL, L("<T-NAME> is destroyed!"));
            target.unWear();
            target.destroy();
            mob.location().recoverRoomStats();
          }
        }
      }
    } else return maliciousFizzle(mob, null, L("<S-NAME> chant(s), but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #29
0
ファイル: Falling.java プロジェクト: bozimmerman/CoffeeMud
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (tickID != Tickable.TICKID_MOB) return true;

    if (affected == null) return false;
    if (--fallTickDown > 0) return true;
    fallTickDown = 1;

    int direction = Directions.DOWN;
    String addStr = L("down");
    if (reversed()) {
      direction = Directions.UP;
      addStr = L("upwards");
    }
    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if (mob == null) return false;
      if (mob.location() == null) return false;

      if (CMLib.flags().isInFlight(mob)) {
        damageToTake = 0;
        unInvoke();
        return false;
      } else if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
      else {
        if (mob.phyStats().weight() < 1) {
          mob.tell(L("\n\r\n\rYou are floating gently @x1.\n\r\n\r", addStr));
        } else {
          mob.tell(L("\n\r\n\rYOU ARE FALLING @x1!!\n\r\n\r", addStr.toUpperCase()));
          int damage =
              CMLib.dice()
                  .roll(
                      1,
                      (int)
                          Math.round(
                              CMath.mul(
                                  CMath.mul(mob.maxState().getHitPoints(), 0.1),
                                  CMath.div(mob.baseWeight(), 150.0))),
                      0);
          if (damage > (mob.maxState().getHitPoints() / 3))
            damage = (mob.maxState().getHitPoints() / 3);
          damageToTake = reversed() ? damage : (damageToTake + damage);
        }
        temporarilyDisable = true;
        CMLib.tracking().walk(mob, direction, false, false);
        temporarilyDisable = false;
        if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
        return true;
      }
    } else if (affected instanceof Item) {
      final Item item = (Item) affected;
      if ((room == null) && (item.owner() != null) && (item.owner() instanceof Room))
        room = (Room) item.owner();

      if ((room == null)
          || ((room != null) && (!room.isContent(item)))
          || (!CMLib.flags().isGettable(item))
          || (item.container() != null)
          || (CMLib.flags().isInFlight(item.ultimateContainer(null)))
          || (room.getRoomInDir(direction) == null)) {
        unInvoke();
        return false;
      }
      if (room.numItems() > 100) {
        fallTickDown = CMLib.dice().roll(1, room.numItems() / 50, 0);
        if ((--fallTickDown) > 0) return true;
      }
      final Room nextRoom = room.getRoomInDir(direction);
      if (canFallFrom(room, direction)) {
        room.show(invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls @x1.", addStr));
        nextRoom.moveItemTo(item, ItemPossessor.Expire.Player_Drop);
        room = nextRoom;
        nextRoom.show(
            invoker,
            null,
            item,
            CMMsg.MSG_OK_ACTION,
            L("<O-NAME> falls in from @x1.", (reversed() ? "below" : "above")));
        return true;
      }
      if (reversed()) return true;
      unInvoke();
      return false;
    }

    return false;
  }
コード例 #30
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 ((mob.getWorshipCharID().length() == 0)
        || (CMLib.map().getDeity(mob.getWorshipCharID()) == null)) {
      if (!auto) mob.tell(L("You must worship a god to use this prayer."));
      return false;
    }
    final Deity D = CMLib.map().getDeity(mob.getWorshipCharID());
    if ((target.getWorshipCharID().length() > 0)
        && (CMLib.map().getDeity(target.getWorshipCharID()) != null)) {
      if (!auto)
        mob.tell(
            L(
                "@x1 worships @x2, and may not be converted with this prayer.",
                target.name(mob),
                target.getWorshipCharID()));
      return false;
    }
    if ((CMLib.flags().isAnimalIntelligence(target)
        || CMLib.flags().isGolem(target)
        || (D == null))) {
      if (!auto) mob.tell(L("@x1 can not be converted with this prayer.", target.name(mob)));
      return false;
    }
    if (!auto) {
      if (convertStack.contains(target)) {
        final Long L = (Long) convertStack.elementAt(convertStack.indexOf(target), 2);
        if ((System.currentTimeMillis() - L.longValue()) > CMProps.getMillisPerMudHour() * 5)
          convertStack.removeElement(target);
      }
      if (convertStack.contains(target)) {
        mob.tell(L("@x1 must wait to be undeniably faithful again.", target.name(mob)));
        return false;
      }
    }

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

    int levelDiff =
        target.phyStats().level() - (mob.phyStats().level() + (2 * getXLEVELLevel(mob)));
    if (levelDiff < 0) levelDiff = 0;
    final boolean success = proficiencyCheck(mob, -(levelDiff * 25), auto);
    int type = verbalCastCode(mob, target, auto);
    int mal = CMMsg.MASK_MALICIOUS;
    if (auto) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      mal = 0;
    }
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              type,
              auto ? "" : L("^S<S-NAME> @x1 for <T-NAMESELF> to BELIEVE!^?", prayWord(mob)));
      final CMMsg msg2 =
          CMClass.getMsg(target, D, this, CMMsg.MSG_SERVE, L("<S-NAME> BELIEVE(S) !!!"));
      final CMMsg msg3 =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MSK_CAST_VERBAL | mal | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if ((mob.location().okMessage(mob, msg))
          && (mob.location().okMessage(mob, msg3))
          && (mob.location().okMessage(mob, msg2))) {
        mob.location().send(mob, msg);
        mob.location().send(mob, msg3);
        if ((msg.value() <= 0) && (msg3.value() <= 0)) {
          target.location().send(target, msg2);
          target.setWorshipCharID(godName);
          if (mob != target) CMLib.leveler().postExperience(mob, target, null, 25, false);
          godName = mob.getWorshipCharID();
          beneficialAffect(mob, target, asLevel, CMProps.getIntVar(CMProps.Int.TICKSPERMUDMONTH));
          convertStack.addElement(target, Long.valueOf(System.currentTimeMillis()));
        }
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          auto ? "" : L("<S-NAME> @x1 for <T-NAMESELF>, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }