コード例 #1
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (affected == null) return false;
    if (!(affected instanceof MOB)) return false;
    final MOB mob = (MOB) affected;
    if (mob.location().numInhabitants() == 1) return true;
    final Vector choices = new Vector();
    for (final Enumeration<Ability> a = mob.effects(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((A != null)
          && (A.canBeUninvoked())
          && (!A.ID().equals(ID()))
          && (A.abstractQuality() == Ability.QUALITY_MALICIOUS)
          && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER))
          && (!A.isAutoInvoked())) choices.addElement(A);
    }
    if (choices.size() == 0) return true;
    final MOB target = mob.location().fetchRandomInhabitant();
    final Ability thisOne = (Ability) choices.elementAt(CMLib.dice().roll(1, choices.size(), -1));
    if ((target == null) || (thisOne == null) || (target.fetchEffect(ID()) != null)) return true;
    if (CMLib.dice().rollPercentage() > (target.charStats().getSave(CharStats.STAT_SAVE_DISEASE))) {
      ((Ability) this.copyOf()).invoke(target, target, true, 0);
      if (target.fetchEffect(ID()) != null)
        ((Ability) thisOne.copyOf()).invoke(target, target, true, 0);
    } else spreadImmunity(target);
    return true;
  }
コード例 #2
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;
  }
コード例 #3
0
ファイル: Prayer_Fertilize.java プロジェクト: Cocanuta/Marble
 public boolean tick(Tickable ticking, int tickID) {
   if ((affected != null) && (affected instanceof Room)) {
     Room R = (Room) affected;
     if ((R.myResource() & RawMaterial.MATERIAL_MASK) == RawMaterial.MATERIAL_VEGETATION)
       for (int m = 0; m < R.numInhabitants(); m++) {
         MOB M = R.fetchInhabitant(m);
         if (M != null) {
           Ability A = M.fetchEffect("Farming");
           if (A == null) A = M.fetchEffect("Foraging");
           if (A != null) A.setAbilityCode(2);
         }
       }
   }
   return super.tick(ticking, tickID);
 }
コード例 #4
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;
  }
コード例 #5
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;
    if ((tickID == Tickable.TICKID_MOB) && (affected instanceof MOB)) {
      final MOB mob = (MOB) affected;
      if (!DATA.containsKey(mob)) DATA.put(mob, new int[DATA_TOTAL]);
      final int[] data = DATA.get(mob);
      if ((mob.session() != null) && (mob.session().getPreviousCMD() != null)) {
        if ((lastCommand != null)
            && (!CMParms.combine(mob.session().getPreviousCMD(), 0).equals(lastCommand))) {
          data[DATA_TYPEDCOMMAND]++;
          List<MOB> V = null;
          if (mob.session().getAddress() != null) V = IPS.get(mob.session().getAddress());

          if (V != null)
            for (int v = 0; v < V.size(); v++) {
              final MOB M = V.get(v);
              if (M == mob) continue;
              if (M.session() == null) continue;
              if (!CMLib.flags().isInTheGame(M, true)) continue;
              final String hisLastCmd = CMParms.combine(mob.session().getPreviousCMD(), 0);
              final Archon_Multiwatch A = (Archon_Multiwatch) M.fetchEffect(ID());
              if (A != null) {
                if ((A.lastCommand != null) && (!A.lastCommand.equals(hisLastCmd)))
                  data[DATA_SYNCHROFOUND]++;
                break;
              }
            }
        }
        lastCommand = CMParms.combine(mob.session().getPreviousCMD(), 0);
      }
    }
    return true;
  }
コード例 #6
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;
  }
コード例 #7
0
ファイル: Chant_AnimalSpy.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    if (commands.size() < 1) {
      mob.tell("Chant to whom?");
      return false;
    }
    String mobName = CMParms.combine(commands, 0).trim().toUpperCase();
    MOB target = getTarget(mob, commands, givenTarget);

    Room newRoom = mob.location();
    if (target != null) {
      newRoom = target.location();
      if ((!CMLib.flags().isAnimalIntelligence(target)) || (target.amFollowing() != mob)) {
        mob.tell("You have no animal follower named '" + mobName + "' here.");
        return false;
      }
    } else {
      mob.tell("You have no animal follower named '" + mobName + "' here.");
      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
                  ? ""
                  : "^S<S-NAME> chant(s) to <T-NAMESELF>, invoking the a mystical connection.^?");
      CMMsg msg2 = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
      if ((mob.location().okMessage(mob, msg))
          && ((newRoom == mob.location()) || (newRoom.okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if (newRoom != mob.location()) newRoom.send(target, msg2);
        spy = target;
        beneficialAffect(mob, spy, asLevel, 0);
        Ability A = spy.fetchEffect(ID());
        if (A != null) {
          mob.addNonUninvokableEffect((Ability) A.copyOf());
          A.setAffectedOne(spy);
        }
      }

    } else
      beneficialVisualFizzle(
          mob, target, "<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.");

    // return whether it worked
    return success;
  }
コード例 #8
0
ファイル: Thief_Ambush.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.fetchEffect("Thief_Hide") != null) {
      mob.tell("You are already hiding.");
      return false;
    }

    if (mob.isInCombat()) {
      mob.tell("Not while in combat!");
      return false;
    }

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

    Set<MOB> H = mob.getGroupMembers(new HashSet<MOB>());
    if (!H.contains(mob)) H.add(mob);
    int numBesidesMe = 0;
    for (Iterator e = H.iterator(); e.hasNext(); ) {
      MOB M = (MOB) e.next();
      if ((M != mob) && (mob.location().isInhabitant(M))) numBesidesMe++;
    }
    if (numBesidesMe == 0) {
      mob.tell("You need a group to set up an ambush!");
      return false;
    }
    for (int i = 0; i < mob.location().numInhabitants(); i++) {
      MOB M = mob.location().fetchInhabitant(i);
      if ((M != null) && (M != mob) && (!H.contains(M)) && (CMLib.flags().canSee(M))) {
        mob.tell(M, null, null, "<S-NAME> is watching you too closely.");
        return false;
      }
    }
    boolean success = proficiencyCheck(mob, 0, auto);

    if (!success)
      beneficialVisualFizzle(mob, null, "<S-NAME> attempt(s) to set up an ambush, but fail(s).");
    else {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              auto ? CMMsg.MSG_OK_ACTION : (CMMsg.MSG_DELICATE_HANDS_ACT | CMMsg.MASK_MOVE),
              "<S-NAME> set(s) up an ambush, directing everyone to hiding places.");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        Ability hide = CMClass.getAbility("Thief_Hide");
        for (Iterator e = H.iterator(); e.hasNext(); ) {
          MOB M = (MOB) e.next();
          hide.invoke(M, M, true, adjustedLevel(mob, asLevel));
        }
      } else success = false;
    }
    return success;
  }
コード例 #9
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = CMLib.players().getLoadPlayer(CMParms.combine(commands, 0));
    if (target == null) target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    final Archon_Record A = (Archon_Record) target.fetchEffect(ID());
    if (A != null) {
      target.delEffect(A);
      if (target.playerStats() != null) target.playerStats().setLastUpdated(0);
      mob.tell(L("@x1 will no longer be recorded.", target.Name()));
      return true;
    }

    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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              L("^F<S-NAME> begin(s) recording <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final String filename = "/" + target.Name() + System.currentTimeMillis() + ".log";
        final CMFile file = new CMFile(filename, null, CMFile.FLAG_LOGERRORS);
        if (!file.canWrite()) {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut("Record", mob.Name() + " failed to start recording " + target.name() + ".");
        } else {
          if (!CMSecurity.isASysOp(mob) || (CMSecurity.isASysOp(target)))
            Log.sysOut(
                "Record",
                mob.Name() + " started recording " + target.name() + " to /" + filename + ".");
          final Archon_Record A2 = (Archon_Record) copyOf();
          final Session F = (Session) CMClass.getCommon("FakeSession");
          F.initializeSession(null, Thread.currentThread().getThreadGroup().getName(), filename);
          if (target.session() == null) target.setSession(F);
          A2.sess = F;
          target.addNonUninvokableEffect(A2);
          mob.tell(L("Enter RECORD @x1 again to stop recording.", target.Name()));
        }
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
コード例 #10
0
 @Override
 @SuppressWarnings("rawtypes")
 public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
   try {
     cookingID = "";
     int num = 1;
     while (mob.fetchEffect("MasterDistilling" + cookingID) != null)
       cookingID = Integer.toString(++num);
     final List<String> noUninvokes = new Vector<String>(1);
     for (int i = 0; i < mob.numEffects(); i++) {
       final Ability A = mob.fetchEffect(i);
       if (((A instanceof MasterDistilling) || A.ID().equals("Distilling"))
           && (noUninvokes.size() < 5)) noUninvokes.add(A.ID());
     }
     this.noUninvokes = noUninvokes;
     return super.invoke(mob, commands, givenTarget, auto, asLevel);
   } finally {
     cookingID = "";
   }
 }
コード例 #11
0
  @Override
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    super.executeMsg(myHost, msg);
    // the sex rules
    if (!(affected instanceof MOB)) return;

    final MOB myChar = (MOB) affected;
    if (msg.target() instanceof MOB) {
      final MOB mate = (MOB) msg.target();
      if ((msg.amISource(myChar))
          && (msg.tool() instanceof Social)
          && (msg.tool().Name().equals("MATE <T-NAME>") || msg.tool().Name().equals("SEX <T-NAME>"))
          && (msg.sourceMinor() != CMMsg.TYP_CHANNEL)
          && (myChar.charStats().getStat(CharStats.STAT_GENDER)
              != mate.charStats().getStat(CharStats.STAT_GENDER))
          && ((mate.charStats().getStat(CharStats.STAT_GENDER) == ('M'))
              || (mate.charStats().getStat(CharStats.STAT_GENDER) == ('F')))
          && ((myChar.charStats().getStat(CharStats.STAT_GENDER) == ('M'))
              || (myChar.charStats().getStat(CharStats.STAT_GENDER) == ('F')))
          && (!mate.charStats().getMyRace().canBreedWith(myChar.charStats().getMyRace()))
          && (myChar.location() == mate.location())
          && (myChar
                  .fetchWornItems(
                      Wearable.WORN_LEGS | Wearable.WORN_WAIST, (short) -2048, (short) 0)
                  .size()
              == 0)
          && (mate.fetchWornItems(
                      Wearable.WORN_LEGS | Wearable.WORN_WAIST, (short) -2048, (short) 0)
                  .size()
              == 0)
          && ((mate.charStats().getStat(CharStats.STAT_AGE) == 0)
              || ((mate.charStats().ageCategory() > Race.AGE_CHILD)
                  && (mate.charStats().ageCategory() < Race.AGE_OLD)))
          && ((myChar.charStats().getStat(CharStats.STAT_AGE) == 0)
              || ((myChar.charStats().ageCategory() > Race.AGE_CHILD)
                  && (myChar.charStats().ageCategory() < Race.AGE_OLD)))) {
        MOB female = myChar;
        MOB male = mate;
        if ((mate.charStats().getStat(CharStats.STAT_GENDER) == ('F'))) {
          female = mate;
          male = myChar;
        }
        final Ability A = CMClass.getAbility("Pregnancy");
        if ((A != null)
            && (female.fetchAbility(A.ID()) == null)
            && (female.fetchEffect(A.ID()) == null)) {
          A.invoke(male, female, true, 0);
          unInvoke();
        }
      }
    }
  }
コード例 #12
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental 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, "<S-NAME> <S-IS-ARE> already a water walker.");
      return false;
    }

    // the invoke method for spells receives as
    // parameters the invoker, and the REMAINING
    // command line parameters, divided into words,
    // and added as String objects to a vector.
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB.  Then tell everyone else
      // what happened.
      invoker = mob;
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : "^S<S-NAME> chant(s) to <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (target.location() == mob.location()) {
          target
              .location()
              .show(target, null, CMMsg.MSG_OK_ACTION, "<S-NAME> feel(s) a little lighter!");
          success = beneficialAffect(mob, target, asLevel, 0);
        }
      }
    } else
      return beneficialWordsFizzle(
          mob, target, "<S-NAME> chant(s) to <T-NAMESELF>, but the magic fizzles.");

    // return whether it worked
    return success;
  }
コード例 #13
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((plantsLocationR == null) || (littlePlantsI == null)) return false;
   if (plantsLocationR.myResource() != littlePlantsI.material()) {
     oldMaterial = plantsLocationR.myResource();
     plantsLocationR.setResource(littlePlantsI.material());
   }
   for (int i = 0; i < plantsLocationR.numInhabitants(); i++) {
     final MOB M = plantsLocationR.fetchInhabitant(i);
     if (M.fetchEffect("Chopping") != null) {
       unInvoke();
       break;
     }
   }
   return true;
 }
コード例 #14
0
ファイル: Play_Break.java プロジェクト: Cocanuta/Marble
 public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
   boolean foundOne = false;
   for (int a = 0; a < mob.numEffects(); a++) // personal affects
   {
     Ability A = mob.fetchEffect(a);
     if ((A != null) && (A instanceof Play)) foundOne = true;
   }
   if (!foundOne) {
     mob.tell(auto ? "There is noone playing." : "You aren't playing anything.");
     return true;
   }
   unplayAll(mob, mob);
   mob.location()
       .show(mob, null, CMMsg.MSG_NOISE, auto ? "Silence." : "<S-NAME> stop(s) playing.");
   mob.location().recoverRoomStats();
   return true;
 }
コード例 #15
0
ファイル: Visible.java プロジェクト: yohanesgultom/CoffeeMud
 @Override
 public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException {
   final String str = L("Prop_WizInvis");
   final Ability A = mob.fetchEffect(str);
   boolean didSomething = false;
   if (A != null) {
     final Command C = CMClass.getCommand("WizInv");
     if ((C != null) && (C.securityCheck(mob))) {
       didSomething = true;
       C.execute(mob, new XVector<String>("WIZINV", "OFF"), metaFlags);
     }
   }
   final java.util.List<Ability> V = returnOffensiveAffects(mob);
   if (V.size() == 0) {
     if (!didSomething) mob.tell(L("You are not invisible or hidden!"));
   } else for (int v = 0; v < V.size(); v++) V.get(v).unInvoke();
   mob.location().recoverRoomStats();
   mob.location().recoverRoomStats();
   return false;
 }
コード例 #16
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if (target.fetchEffect(ID()) != null) {
      mob.tell(L("You already healed by fire."));
      return false;
    }

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

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

    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> @x1 for flaming healing.^?", prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("An aura surrounds <S-NAME>."));
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          L(
              "<S-NAME> @x1 for flaming healing, but <S-HIS-HER> plea is not answered.",
              prayWord(mob)));

    // return whether it worked
    return success;
  }
コード例 #17
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(ID()) != null) {
      mob.tell(target, null, null, L("<S-NAME> already <S-HAS-HAVE> protection from curses."));
      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> attain(s) a blessed mind and body.")
                  : L("^S<S-NAME> @x1 for protection from curses.^?", prayWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          L("<S-NAME> @x1 for protection from curses, but nothing happens.", prayWord(mob)));

    // return whether it worked
    return success;
  }
コード例 #18
0
ファイル: Archon_Freeze.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    Ability A = target.fetchEffect(ID());
    if (A != null) {
      A.unInvoke();
      mob.tell(target.Name() + " is released from his freezedness.");
      return true;
    }

    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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto
                  ? "A frozen chill falls upon <T-NAME>!"
                  : "^F<S-NAME> freeze(s) <T-NAMESELF>.^?");
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> <S-IS-ARE> frozen!");
        beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
        Log.sysOut("Freeze", mob.name() + " freezed " + target.name() + ".");
      }
    } else
      return beneficialVisualFizzle(
          mob, target, "<S-NAME> attempt(s) to freeze <T-NAMESELF>, but fail(s).");
    return success;
  }
コード例 #19
0
ファイル: Spell_Slow.java プロジェクト: bozimmerman/CoffeeMud
  @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;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

    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> cast(s) a spell on <T-NAMESELF>.^?"));
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        if (msg.value() <= 0) {
          R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> slow(s) down!"));
          final Ability A = target.fetchEffect("Spell_MassSlow");
          if (A != null) A.unInvoke();
          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;
  }
コード例 #20
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

    final Ability A = target.fetchEffect(ID());
    if (A != null) {
      A.unInvoke();
      mob.tell(L("@x1 is released from his hushing.", target.Name()));
      return true;
    }

    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,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? L("Silence falls upon <T-NAME>!") : L("^F<S-NAME> hush(es) <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> <S-IS-ARE> hushed!"));
        beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
        Log.sysOut("Banish", mob.Name() + " hushed " + target.name() + ".");
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
コード例 #21
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 detecting invisibility."));
      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> open(s) <S-HIS-HER> softly glowing eyes.")
                  : L("^S<S-NAME> incant(s) softly, and open(s) <S-HIS-HER> glowing eyes.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      beneficialVisualFizzle(
          mob,
          null,
          L("<S-NAME> incant(s) and open(s) <S-HIS-HER> eyes softly, but the spell fizzles."));

    return success;
  }
コード例 #22
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if ((mob.fetchEffect(ID()) != null) || (mob.fetchEffect("Chant_Grapevine") != null)) {
      mob.tell("You are already listening through a grapevine.");
      return false;
    }
    MOB tapped = null;
    for (int i = 0; i < mob.location().numItems(); i++) {
      Item I = mob.location().fetchItem(i);
      if ((I != null) && (isPlant(I) != null)) {
        Ability A = isPlant(I);
        if ((A != null) && (A.invoker() != mob)) tapped = A.invoker();
      }
    }

    Vector myRooms = (tapped == null) ? null : Druid_MyPlants.myPlantRooms(tapped);
    if ((myRooms == null) || (myRooms.size() == 0)) {
      mob.tell("There doesn't appear to be any plants around here to listen through.");
      return false;
    }
    Item myPlant = Druid_MyPlants.myPlant(mob.location(), tapped, 0);
    if ((!auto) && (myPlant == null)) {
      mob.tell("You must be in the same room as someone elses plants to initiate this chant.");
      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,
              myPlant,
              this,
              verbalCastCode(mob, myPlant, auto),
              auto
                  ? ""
                  : "^S<S-NAME> chant(s) to <T-NAMESELF> and listen(s) carefully to <T-HIM-HER>!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        myChants = new Vector();
        beneficialAffect(mob, mob, asLevel, 0);
        Chant_TapGrapevine C = (Chant_TapGrapevine) mob.fetchEffect(ID());
        if (C == null) return false;
        for (int i = 0; i < myRooms.size(); i++) {
          Room R = (Room) myRooms.elementAt(i);
          int ii = 0;
          myPlant = Druid_MyPlants.myPlant(R, tapped, ii);
          while (myPlant != null) {
            Ability A = myPlant.fetchEffect(ID());
            if (A != null) myPlant.delEffect(A);
            myPlant.addNonUninvokableEffect((Ability) C.copyOf());
            A = myPlant.fetchEffect(ID());
            if (A != null) myChants.addElement(A);
            ii++;
            myPlant = Druid_MyPlants.myPlant(R, tapped, ii);
          }
        }
        C.myChants = (Vector) myChants.clone();
        myChants = new Vector();
      }

    } else
      beneficialVisualFizzle(
          mob, myPlant, "<S-NAME> chant(s) to <T-NAMESELF>, but nothing happens.");

    // return whether it worked
    return success;
  }
コード例 #23
0
ファイル: CoffeeUtensils.java プロジェクト: bbailey/ewok
  public boolean resurrect(MOB tellMob, Room corpseRoom, DeadBody body, int XPLevel) {
    MOB rejuvedMOB = CMLib.players().getPlayer(((DeadBody) body).mobName());
    if (rejuvedMOB != null) {
      rejuvedMOB.tell("You are being resurrected.");
      if (rejuvedMOB.location() != corpseRoom) {
        rejuvedMOB
            .location()
            .showOthers(rejuvedMOB, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> disappears!");
        corpseRoom.bringMobHere(rejuvedMOB, false);
      }
      Ability A = rejuvedMOB.fetchAbility("Prop_AstralSpirit");
      if (A != null) rejuvedMOB.delAbility(A);
      A = rejuvedMOB.fetchEffect("Prop_AstralSpirit");
      if (A != null) rejuvedMOB.delEffect(A);

      int it = 0;
      while (it < rejuvedMOB.location().numItems()) {
        Item item = rejuvedMOB.location().fetchItem(it);
        if ((item != null) && (item.container() == body)) {
          CMMsg msg2 = CMClass.getMsg(rejuvedMOB, body, item, CMMsg.MSG_GET, null);
          rejuvedMOB.location().send(rejuvedMOB, msg2);
          CMMsg msg3 = CMClass.getMsg(rejuvedMOB, item, null, CMMsg.MSG_GET, null);
          rejuvedMOB.location().send(rejuvedMOB, msg3);
          it = 0;
        } else it++;
      }
      body.delEffect(body.fetchEffect("Age")); // so misskids doesn't record it
      body.destroy();
      rejuvedMOB
          .baseEnvStats()
          .setDisposition(
              CMath.unsetb(rejuvedMOB.baseEnvStats().disposition(), EnvStats.IS_SITTING));
      rejuvedMOB
          .envStats()
          .setDisposition(
              CMath.unsetb(rejuvedMOB.baseEnvStats().disposition(), EnvStats.IS_SITTING));
      rejuvedMOB.location().show(rejuvedMOB, null, CMMsg.MSG_NOISYMOVEMENT, "<S-NAME> get(s) up!");
      corpseRoom.recoverRoomStats();
      Vector whatsToDo = CMParms.parse(CMProps.getVar(CMProps.SYSTEM_PLAYERDEATH));
      for (int w = 0; w < whatsToDo.size(); w++) {
        String whatToDo = (String) whatsToDo.elementAt(w);
        if (whatToDo.startsWith("UNL")) CMLib.leveler().level(rejuvedMOB);
        else if (whatToDo.startsWith("ASTR")) {
        } else if (whatToDo.startsWith("PUR")) {
        } else if ((whatToDo.trim().equals("0")) || (CMath.s_int(whatToDo) > 0)) {
          if (XPLevel >= 0) {
            int expLost = (CMath.s_int(whatToDo) + (2 * XPLevel)) / 2;
            rejuvedMOB.tell("^*You regain " + expLost + " experience points.^?^.");
            CMLib.leveler().postExperience(rejuvedMOB, null, null, expLost, false);
          }
        } else if (whatToDo.length() < 3) continue;
        else if (XPLevel >= 0) {
          double lvl = (double) body.envStats().level();
          for (int l = body.envStats().level(); l < rejuvedMOB.envStats().level(); l++)
            lvl = lvl / 2.0;
          int expRestored = (int) Math.round(((100.0 + (2.0 * ((double) XPLevel))) * lvl) / 2.0);
          rejuvedMOB.tell("^*You regain " + expRestored + " experience points.^?^.");
          CMLib.leveler().postExperience(rejuvedMOB, null, null, expRestored, false);
        }
      }
      return true;
    } else
      corpseRoom.show(
          tellMob,
          body,
          CMMsg.MSG_OK_VISUAL,
          "<T-NAME> twitch(es) for a moment, but the spirit is too far gone.");
    return false;
  }
コード例 #24
0
ファイル: Spell_Repulsion.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Set<MOB> h = properTargets(mob, givenTarget, auto);
    if ((h == null) || (h.size() == 0)) {
      mob.tell("There doesn't appear to be anyone here worth repelling.");
      return false;
    }

    // the invoke method for spells receives as
    // parameters the invoker, and the REMAINING
    // command line parameters, divided into words,
    // and added as String objects to a vector.
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    if (success) {
      if (mob.location()
          .show(
              mob,
              null,
              this,
              somanticCastCode(mob, null, auto),
              auto ? "" : "^S<S-NAME> wave(s) <S-HIS-HER> arms and cast(s) a spell.^?"))
        for (Iterator f = h.iterator(); f.hasNext(); ) {
          MOB target = (MOB) f.next();

          // it worked, so build a copy of this ability,
          // and add it to the affects list of the
          // affected MOB.  Then tell everyone else
          // what happened.
          CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
          if ((mob.location().okMessage(mob, msg)) && (target.fetchEffect(this.ID()) == null)) {
            mob.location().send(mob, msg);
            if (msg.value() <= 0) {
              amountRemaining = 130;
              if (target.location() == mob.location()) {
                success =
                    maliciousAffect(
                        mob,
                        target,
                        asLevel,
                        ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 10),
                        -1);
                int level = 2;
                if ((CMLib.ableMapper().qualifyingClassLevel(mob, this) > 0)
                    && ((adjustedLevel(mob, asLevel)
                            - CMLib.ableMapper().qualifyingClassLevel(mob, this))
                        > 10))
                  level +=
                      ((adjustedLevel(mob, asLevel)
                                  - CMLib.ableMapper().qualifyingClassLevel(mob, this))
                              - 10)
                          / 10;
                if (level < 2) level = 2;
                target
                    .location()
                    .show(target, null, CMMsg.MSG_OK_ACTION, "<S-NAME> become(s) repelled!");
                if ((target.getVictim() != null) && (target.rangeToTarget() > 0))
                  target.setAtRange(target.rangeToTarget());
                else if (target.location().maxRange() < level)
                  target.setAtRange(target.location().maxRange());
                else target.setAtRange(level);
                if (target.getVictim() != null)
                  target.getVictim().setAtRange(target.rangeToTarget());
                if (mob.getVictim() == null) mob.setVictim(null); // correct range
                if (target.getVictim() == null) target.setVictim(null); // correct range
              }
            }
          }
        }
    } else
      return maliciousFizzle(
          mob, null, "<S-NAME> wave(s) <S-HIS-HER> arms, but the spell fizzles.");

    // return whether it worked
    return success;
  }
コード例 #25
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    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) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB.  Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : (mob == target)
                      ? "^S<S-NAME> close(s) <T-HIS-HER> eyes and peer(s) into <T-HIS-HER> own nostrils.^?"
                      : "^S<S-NAME> peer(s) into the nostrils of <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = target.fetchEffect("Allergies");
        if (A == null)
          mob.tell(
              mob, target, null, "<T-NAME> seem(s) like <T-HE-SHE> is not allergic to anything.");
        else {

          Vector allergies = new Vector();
          Vector V = CMParms.parse(A.text().toUpperCase().trim());
          for (int i = 0; i < V.size(); i++) {
            if (CMParms.contains(RawMaterial.RESOURCE_DESCS, (String) V.elementAt(i)))
              allergies.addElement(((String) V.elementAt(i)).toLowerCase());
            else {
              Race R = CMClass.getRace((String) V.elementAt(i));
              if (R != null) allergies.addElement(R.name());
            }
          }
          mob.tell(
              mob,
              target,
              null,
              "<T-NAME> seem(s) like <T-HE-SHE> is allergic to " + CMParms.toStringList(V) + ".");
        }
      }
    } else if (mob == target)
      beneficialWordsFizzle(
          mob,
          target,
          auto
              ? ""
              : "<S-NAME> close(s) <T-HIS-HER> eyes and peer(s) into <T-HIS-HER> own nostrils, but then blink(s).");
    else
      beneficialWordsFizzle(
          mob,
          target,
          auto ? "" : "<S-NAME> peer(s) into the nostrils of <T-NAMESELF>, but then blink(s).");

    // return whether it worked
    return success;
  }
コード例 #26
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;
  }
コード例 #27
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;
  }
コード例 #28
0
ファイル: Falling.java プロジェクト: bozimmerman/CoffeeMud
 protected boolean stopFalling(MOB mob) {
   final Room R = mob.location();
   if (reversed()) {
     if (!hitTheCeiling) {
       hitTheCeiling = true;
       if (R != null)
         R.show(
             mob,
             null,
             CMMsg.MSG_OK_ACTION,
             L("<S-NAME> hit(s) the ceiling.@x1", CMLib.protocol().msp("splat.wav", 50)));
       CMLib.combat()
           .postDamage(
               mob, mob, this, damageToTake, CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE, -1, null);
     }
     return true;
   }
   hitTheCeiling = false;
   unInvoke();
   if (R != null) {
     if (isAirRoom(R))
       R.show(
           mob,
           null,
           CMMsg.MSG_OK_ACTION,
           L("<S-NAME> stop(s) falling.@x1", CMLib.protocol().msp("splat.wav", 50)));
     else if (CMLib.flags().isWaterySurfaceRoom(R) || CMLib.flags().isUnderWateryRoom(R))
       R.show(
           mob,
           null,
           CMMsg.MSG_OK_ACTION,
           L("<S-NAME> hit(s) the water.@x1", CMLib.protocol().msp("splat.wav", 50)));
     else {
       R.show(
           mob,
           null,
           CMMsg.MSG_OK_ACTION,
           L("<S-NAME> hit(s) the ground.@x1", CMLib.protocol().msp("splat.wav", 50)));
       if (CMath.div(damageToTake, mob.maxState().getHitPoints()) > 0.05) {
         LimbDamage damage = (LimbDamage) mob.fetchEffect("BrokenLimbs");
         if (damage == null) {
           damage = (LimbDamage) CMClass.getAbility("BrokenLimbs");
           damage.setAffectedOne(mob);
         }
         List<String> limbs = damage.unaffectedLimbSet();
         if (limbs.size() > 0) {
           if (mob.fetchEffect(damage.ID()) == null) {
             mob.addEffect(damage);
             damage.makeLongLasting();
           }
           damage.damageLimb(limbs.get(CMLib.dice().roll(1, limbs.size(), -1)));
         }
       }
     }
     CMLib.combat()
         .postDamage(
             mob, mob, this, damageToTake, CMMsg.MASK_ALWAYS | CMMsg.TYP_JUSTICE, -1, null);
   }
   mob.delEffect(this);
   return false;
 }
コード例 #29
0
ファイル: Song_Ode.java プロジェクト: bozimmerman/CoffeeMud
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    timeOut = 0;
    if (auto) return false;

    final Hashtable<String, String> H = getSongs();
    if (commands.size() == 0) {
      final Song_Ode A = (Song_Ode) mob.fetchEffect(ID());
      if ((A != null) && (A.whom != null) && (A.song == null)) {
        final String str = L("^S<S-NAME> finish(es) composing the @x1.^?", A.songOf());
        final CMMsg msg =
            CMClass.getMsg(
                mob,
                null,
                this,
                (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
                str);
        if (mob.location().okMessage(mob, msg)) {
          mob.location().send(mob, msg);
          mob.delEffect(A);
          getSongs().put(A.whom.name(), A.composition());
          whom = null;
          return true;
        }
        return false;
      }

      final StringBuffer str = new StringBuffer("");
      for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); )
        str.append(e.nextElement() + " ");
      mob.tell(L("Compose or sing an ode about whom?"));
      if (str.length() > 0)
        mob.tell(L("You presently have odes written about: @x1.", str.toString().trim()));
      return false;
    }
    String name = CMParms.combine(commands, 0);
    for (final Enumeration<String> e = H.keys(); e.hasMoreElements(); ) {
      final String key = e.nextElement();
      if (CMLib.english().containsString(key, name)) {
        invoker = mob;
        originRoom = mob.location();
        commonRoomSet = getInvokerScopeRoomSet(null);
        name = key;
        song = H.get(name);
        benefits = null;
        whom = mob.location().fetchInhabitant(name);
        if ((whom == null) || (!whom.name().equals(name))) whom = CMLib.players().getPlayer(name);
        if ((whom == null) || (!whom.name().equals(name))) {
          whom = CMClass.getMOB("StdMOB");
          whom.setName(name);
          whom.setLocation(mob.location());
        }
        return super.invoke(mob, commands, givenTarget, auto, asLevel);
      }
    }

    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    if (target == mob) {
      mob.tell(L("You may not compose an ode about yourself!"));
      return false;
    }

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      unsingAll(mob, mob);
      invoker = mob;
      originRoom = mob.location();
      commonRoomSet = getInvokerScopeRoomSet(null);
      whom = target;
      final String str = L("^S<S-NAME> begin(s) to compose an @x1.^?", songOf());
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              (auto ? CMMsg.MASK_ALWAYS : 0) | CMMsg.MSG_DELICATE_SMALL_HANDS_ACT,
              str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        final Song_Ode newOne = (Song_Ode) copyOf();
        newOne.whom = target;
        newOne.trail = new StringBuffer("");
        newOne.song = null;
        mob.addEffect(newOne);
      }
    } else
      mob.location()
          .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> lose(s) <S-HIS-HER> inspiration."));
    return success;
  }
コード例 #30
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (CMParms.combine(commands, 0).equalsIgnoreCase("auto")) {
      DATA.clear();
      IPS.clear();
      final Hashtable<String, List<MOB>> ipes = new Hashtable<String, List<MOB>>();
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S.getAddress().length() > 0) && (S.mob() != null)) {
          List V = ipes.get(S.getAddress());
          if (V == null) {
            V = new Vector();
            ipes.put(S.getAddress(), V);
          }
          if (!V.contains(S.mob())) V.add(S.mob());
        }
      }
      final StringBuffer rpt = new StringBuffer("");
      for (final Enumeration e = ipes.keys(); e.hasMoreElements(); ) {
        final String addr = (String) e.nextElement();
        final List<MOB> names = ipes.get(addr);
        if (names.size() > 1) {
          IPS.put(addr, names);
          rpt.append("Watch #" + (IPS.size()) + " added: ");
          for (int n = 0; n < names.size(); n++) {
            final MOB MN = names.get(n);
            if (MN.fetchEffect(ID()) == null) {
              final Ability A = (Ability) copyOf();
              MN.addNonUninvokableEffect(A);
              A.setSavable(false);
            }
            rpt.append(MN.Name() + " ");
          }
          rpt.append("\n\r");
        }
      }
      if (rpt.length() == 0)
        rpt.append("No users with duplicate IDs found.  Try MULTIWATCH ADD name1 name2 ... ");
      mob.tell(rpt.toString());
      return true;
    } else if (CMParms.combine(commands, 0).equalsIgnoreCase("stop")) {
      boolean foundLegacy = false;
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null) && (S.mob().fetchEffect(ID()) != null)) {
          foundLegacy = true;
          break;
        }
      }
      if ((DATA.size() == 0) && (IPS.size() == 0) && (!foundLegacy)) {
        mob.tell(L("Multiwatch is already off."));
        return false;
      }
      for (final Enumeration<List<MOB>> e = IPS.elements(); e.hasMoreElements(); ) {
        final List<MOB> V = e.nextElement();
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      for (final Session S : CMLib.sessions().localOnlineIterable()) {
        if ((S != null) && (S.mob() != null)) {
          final MOB M = S.mob();
          final Ability A = M.fetchEffect(ID());
          if (A != null) M.delEffect(A);
        }
      }
      mob.tell(L("Multiplay watcher is now turned off."));
      DATA.clear();
      IPS.clear();
      return true;
    } else if ((commands.size() > 1)
        && ((String) commands.firstElement()).equalsIgnoreCase("add")) {
      final Vector V = new Vector();
      for (int i = 1; i < commands.size(); i++) {
        final String name = (String) commands.elementAt(i);
        final MOB M = CMLib.players().getPlayer(name);
        if ((M.session() != null) && (CMLib.flags().isInTheGame(M, true))) V.addElement(M);
        else mob.tell(L("'@x1' is not online.", name));
      }
      if (V.size() > 1) {
        for (int n = 0; n < V.size(); n++) {
          final MOB MN = (MOB) V.elementAt(n);
          if (MN.fetchEffect(ID()) == null) {
            final Ability A = (Ability) copyOf();
            MN.addNonUninvokableEffect(A);
            A.setSavable(false);
          }
        }
        IPS.put("MANUAL" + (IPS.size() + 1), V);
        mob.tell(L("Manual Watch #@x1 added.", "" + IPS.size()));
      }
      return true;
    } else if ((commands.size() == 0) && (DATA.size() > 0) && (IPS.size() > 0)) {
      final StringBuffer report = new StringBuffer("");
      for (final Enumeration<String> e = IPS.keys(); e.hasMoreElements(); ) {
        final String key = e.nextElement();
        int sync = 0;
        final List<MOB> V = IPS.get(key);
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          final int data[] = DATA.get(M);
          if (data != null) sync += data[DATA_SYNCHROFOUND];
        }
        report.append("^x" + key + "^?^., Syncs: " + sync + "\n\r");
        report.append(
            CMStrings.padRight(L("Name"), 25)
                + CMStrings.padRight(L("Speech"), 15)
                + CMStrings.padRight(L("Socials"), 15)
                + CMStrings.padRight(L("CMD"), 10)
                + CMStrings.padRight(L("ORDERS"), 10)
                + "\n\r");
        for (int v = 0; v < V.size(); v++) {
          final MOB M = V.get(v);
          int data[] = DATA.get(M);
          if (data == null) data = new int[DATA_TOTAL];
          report.append(CMStrings.padRight(M.Name(), 25));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSPEECH] + "/" + data[DATA_DIRSPEECH] + "/" + data[DATA_ANYSPEECH],
                  15));
          report.append(
              CMStrings.padRight(
                  data[DATA_GOODSOCIAL] + "/" + data[DATA_DIRSOCIAL] + "/" + data[DATA_ANYSOCIAL],
                  15));
          report.append(CMStrings.padRight(data[DATA_TYPEDCOMMAND] + "", 10));
          report.append(CMStrings.padRight(data[DATA_ORDER] + "", 10));
          report.append("\n\r");
        }
        report.append("\n\r");
      }

      mob.tell(report.toString());
      return true;
    } else {
      mob.tell(L("Try MULTIWATCH AUTO, MULTIWATCH STOP, or MULTIWATCH ADD name1 name2.."));
      return false;
    }
  }