Пример #1
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.isInCombat()) {
      mob.tell(L("You can't hibernate while in combat!"));
      return false;
    }
    if (!CMLib.flags().isSitting(mob)) {
      mob.tell(L("You must be in a sitting, restful position to hibernate."));
      return false;
    }
    // now see if it worked
    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              CMMsg.MSG_SLEEP | CMMsg.MASK_MAGIC,
              L("<S-NAME> begin(s) to hibernate..."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        oldState = mob.curState();
        beneficialAffect(mob, mob, asLevel, Ability.TICKS_FOREVER);
        helpProficiency(mob, 0);
      }
    } else
      return beneficialVisualFizzle(
          mob, null, L("<S-NAME> chant(s) to hibernate, but lose(s) concentration."));

    // return whether it worked
    return success;
  }
Пример #2
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (invoker() != null) && (affected instanceof MOB)) {
     final MOB mob = (MOB) affected;
     final Set<MOB> invokerGroup = invoker().getGroupMembers(new HashSet<MOB>());
     if (mob != invoker()) {
       if (mob.location() != invoker().location()) unInvoke();
       else {
         if (invokerGroup.contains(mob)) unInvoke();
         else if (mob.isInCombat()) {
           int levels = invoker().charStats().getClassLevel("Templar");
           if (levels < 0) levels = invoker().phyStats().level();
           if (CMLib.dice().rollPercentage() >= levels) {
             final MOB newvictim = mob.location().fetchRandomInhabitant();
             if (newvictim != mob) mob.setVictim(newvictim);
           }
         }
       }
     } else if ((mob.location() != null) && (CMLib.flags().isEvil(invoker()))) {
       for (int m = 0; m < mob.location().numInhabitants(); m++) {
         final MOB M = mob.location().fetchInhabitant(m);
         if ((M != null)
             && (M != invoker())
             && (!invokerGroup.contains(M))
             && (!M.Name().equals(mob.getLiegeID())))
           beneficialAffect(invoker, M, 0, Ability.TICKS_FOREVER);
       }
     }
   }
   return true;
 }
Пример #3
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((myHost != null) && (myHost instanceof MOB) && (msg.amISource((MOB) myHost))) {
     if (((msg.targetMinor() == CMMsg.TYP_LEAVE)
         || (msg.sourceMinor() == CMMsg.TYP_ADVANCE)
         || (msg.sourceMinor() == CMMsg.TYP_RETREAT)
         || (msg.sourceMinor() == CMMsg.TYP_RECALL))) {
       msg.source().tell(L("You can't really go anywhere -- you're a rock!"));
       return false;
     }
   } else if (((msg.targetMajor() & CMMsg.MASK_MALICIOUS) > 0)
       && (myHost instanceof MOB)
       && (msg.amITarget(myHost))
       && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_ALWAYS))) {
     final MOB target = (MOB) msg.target();
     if ((!target.isInCombat())
         && (msg.source().isMonster())
         && (msg.source().location() == target.location())
         && (msg.source().getVictim() != target)) {
       msg.source().tell(L("Attack a rock?!"));
       if (target.getVictim() == msg.source()) {
         target.makePeace();
         target.setVictim(null);
       }
       return false;
     }
   }
   return super.okMessage(myHost, msg);
 }
Пример #4
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     if ((mob.isMonster()) && (mob.isInCombat())) return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
Пример #5
0
  public void executeMsg(Environmental affecting, CMMsg msg) {
    super.executeMsg(affecting, msg);
    if ((msg.target() == null) || (!(msg.target() instanceof MOB))) return;
    MOB source = msg.source();
    MOB observer = (MOB) affecting;
    MOB target = (MOB) msg.target();

    if ((source != observer)
        && (target != observer)
        && (source != target)
        && (CMath.bset(msg.targetCode(), CMMsg.MASK_MALICIOUS))
        && (!observer.isInCombat())
        && (CMLib.flags().canBeSeenBy(source, observer))
        && (CMLib.flags().canBeSeenBy(target, observer))
        && (!BrotherHelper.isBrother(source, observer, false))
        && ((CMLib.flags().isEvil(target) && CMLib.flags().isEvil(observer))
            || (CMLib.flags().isNeutral(target) && CMLib.flags().isNeutral(observer))
            || (CMLib.flags().isGood(target) && CMLib.flags().isGood(observer)))) {
      Aggressive.startFight(
          observer,
          source,
          true,
          false,
          CMLib.flags().getAlignmentName(observer) + " PEOPLE UNITE! CHARGE!");
    }
  }
Пример #6
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if ((!auto) && (!mob.isInCombat())) {
      mob.tell(L("You must be in combat first!"));
      return false;
    }

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

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

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

    // return whether it worked
    return success;
  }
Пример #7
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;
  }
Пример #8
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;
  }
Пример #9
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);
  }
Пример #10
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if ((affected == null) || (!(affected instanceof Room))) return super.tick(ticking, tickID);

    if ((--damageTickDown) >= 0) return super.tick(ticking, tickID);
    damageTickDown = 4;

    HashSet H = null;
    if ((invoker() != null) && (invoker().location() == affected)) {
      H = new HashSet();
      invoker().getGroupMembers(H);
    }
    final Room R = (Room) affected;
    for (int i = 0; i < R.numInhabitants(); i++) {
      final MOB M = R.fetchInhabitant(i);
      if ((M != null) && ((H == null) || (!H.contains(M)))) {
        if (invoker() != null) {
          final int harming = CMLib.dice().roll(1, adjustedLevel(invoker(), 0) / 3, 1);
          CMLib.combat()
              .postDamage(
                  invoker(),
                  M,
                  this,
                  harming,
                  CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy aura <DAMAGE> <T-NAME>!"));
        } else {
          final int harming =
              CMLib.dice().roll(1, CMLib.ableMapper().lowestQualifyingLevel(ID()) / 3, 1);
          CMLib.combat()
              .postDamage(
                  M,
                  M,
                  this,
                  harming,
                  CMMsg.MASK_MALICIOUS | CMMsg.TYP_UNDEAD,
                  Weapon.TYPE_BURSTING,
                  L("The unholy aura <DAMAGE> <T-NAME>!"));
        }
        if ((!M.isInCombat())
            && (M.isMonster())
            && (M != invoker)
            && (invoker != null)
            && (M.location() == invoker.location())
            && (M.location().isInhabitant(invoker))
            && (CMLib.flags().canBeSeenBy(invoker, M)))
          CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem());
      }
    }
    return super.tick(ticking, tickID);
  }
Пример #11
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if (mob != null) {
     if (target instanceof Room) {
       if (!mob.isInCombat())
         return super.castingQuality(mob, target, Ability.QUALITY_INDIFFERENT);
       if (CMLib.flags().isUndead(mob))
         return super.castingQuality(mob, target, Ability.QUALITY_BENEFICIAL_SELF);
       return super.castingQuality(mob, target, Ability.QUALITY_MALICIOUS);
     }
   }
   return super.castingQuality(mob, target);
 }
Пример #12
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if ((mob != null) && (target != null)) {
     final MOB victim = mob.getVictim();
     if (victim == null) return Ability.QUALITY_INDIFFERENT;
     if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT;
     if (mob.fetchWieldedItem() == null) return Ability.QUALITY_INDIFFERENT;
     Item hisWeapon = victim.fetchWieldedItem();
     if (hisWeapon == null) hisWeapon = victim.fetchHeldItem();
     if ((hisWeapon == null)
         || (!(hisWeapon instanceof Weapon))
         || ((((Weapon) hisWeapon).weaponClassification() == Weapon.CLASS_NATURAL)))
       return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
Пример #13
0
  public void tickLycanthropically(MOB mob) {
    if (mob == null) return;
    if (mob.location() == null) return;
    if (mob.isInCombat()) return;

    if ((CMLib.dice().rollPercentage() < 15) && ((mob.location().domainType() & Room.INDOORS) > 0))
      mob.location()
          .show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> howl(s) at the moon! ARROOOOOOOO!!!!"));
    // time to tick lycanthropically
    final MOB M = victimHere(mob.location(), mob);
    if (M != null) {
      deathTrail = null;
      CMLib.combat().postAttack(mob, M, mob.fetchWieldedItem());
      return;
    }
    if ((deathTrail != null) && (!deathTrail.contains(mob.location()))) deathTrail = null;
    if (deathTrail == null) {
      final Vector rooms = new Vector();
      if ((findVictim(mob, mob.location(), rooms, 0)) && (rooms.size() > 0)) {
        TrackingLibrary.TrackingFlags flags;
        flags =
            new TrackingLibrary.TrackingFlags()
                .plus(TrackingLibrary.TrackingFlag.OPENONLY)
                .plus(TrackingLibrary.TrackingFlag.AREAONLY)
                .plus(TrackingLibrary.TrackingFlag.NOEMPTYGRIDS)
                .plus(TrackingLibrary.TrackingFlag.NOAIR)
                .plus(TrackingLibrary.TrackingFlag.NOWATER);
        deathTrail = CMLib.tracking().findBastardTheBestWay(mob.location(), rooms, flags, 50);
        if (deathTrail != null) deathTrail.add(mob.location());
      }
    }
    if (deathTrail != null) {
      final int nextDirection =
          CMLib.tracking().trackNextDirectionFromHere(deathTrail, mob.location(), true);
      if ((nextDirection == 999) || (nextDirection == -1)) deathTrail = null;
      else if (nextDirection >= 0) {
        final Room nextRoom = mob.location().getRoomInDir(nextDirection);
        if ((nextRoom != null) && ((nextRoom.getArea() == mob.location().getArea()))
            || (!mob.isMonster())) {
          if (!CMLib.tracking().walk(mob, nextDirection, false, false)) deathTrail = null;
          else if (CMLib.dice().rollPercentage() < 15)
            mob.location().show(mob, null, CMMsg.MSG_NOISE, L("<S-NAME> sniff(s) at the air."));

        } else deathTrail = null;
      }
    }
  }
Пример #14
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 (!CMLib.flags().isAnimalIntelligence(target)) {
      mob.tell(L("@x1 is not an animal!", target.name(mob)));
      return false;
    }

    if (!target.isInCombat()) {
      mob.tell(L("@x1 doesn't seem particularly enraged at the moment.", target.name(mob)));
      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> become(s) surrounded by a natural light.")
                  : L("^S<S-NAME> chant(s) to <T-NAMESELF> for calm.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 3);
        for (int i = 0; i < mob.location().numInhabitants(); i++) {
          final MOB mob2 = mob.location().fetchInhabitant(i);
          if ((mob2.getVictim() == target) || (mob2 == target)) mob2.makePeace(true);
        }
      }
    } else
      beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but nothing happens."));
    // return whether it worked
    return success;
  }
Пример #15
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if ((mob != null) && (target != null) && (target instanceof MOB)) {
     final Race R = ((MOB) target).charStats().getMyRace();
     if (R.bodyMask()[Race.BODY_HEAD] <= 0) return Ability.QUALITY_INDIFFERENT;
     LegalBehavior B = null;
     if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
     List<LegalWarrant> warrants = new Vector<LegalWarrant>();
     if (B != null)
       warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), (MOB) target);
     if (warrants.size() == 0) return Ability.QUALITY_INDIFFERENT;
     final Item w = mob.fetchWieldedItem();
     Weapon ww = null;
     if ((w == null) || (!(w instanceof Weapon))) return Ability.QUALITY_INDIFFERENT;
     ww = (Weapon) w;
     if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) return Ability.QUALITY_INDIFFERENT;
     if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT;
     if (!CMLib.flags().isBoundOrHeld(target)) return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
Пример #16
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((!target.charStats().getMyRace().racialCategory().equals("Earth Elemental"))
        && (!target.charStats().getMyRace().racialCategory().equals("Stone Golem"))
        && (!target.charStats().getMyRace().racialCategory().equals("Metal Golem"))) {
      mob.tell(L("@x1 is not an stone/metal golem or earth elemental!", target.name(mob)));
      return false;
    }

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

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final String str = auto ? "" : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?");
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          if (success) {
            if (target.isInCombat()) target.makePeace();
            CMLib.commands().postFollow(target, mob, false);
            CMLib.combat().makePeaceInGroup(mob);
            if (target.amFollowing() != mob)
              mob.tell(L("@x1 seems unwilling to follow you.", target.name(mob)));
          }
        }
      }
    }
    if (!success)
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
Пример #17
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();
 }
Пример #18
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (mob.isInCombat() && (mob.rangeToTarget() > 0)) {
      mob.tell(L("You are too far away to touch!"));
      return false;
    }
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

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

    String str = null;
    if (success) {
      str = auto ? "" : L("^S<S-NAME> extend(s) a chilling 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> turn(s) cold!"));
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> extend(s) a chilling hand to <T-NAMESELF>, but fail(s)."));

    return success;
  }
Пример #19
0
 public String builtPrompt(MOB mob) {
   StringBuffer buf = new StringBuffer("\n\r");
   String prompt = mob.playerStats().getPrompt();
   String promptUp = null;
   int c = 0;
   while (c < prompt.length())
     if ((prompt.charAt(c) == '%') && (c < (prompt.length() - 1))) {
       switch (prompt.charAt(++c)) {
         case '-':
           if (c < (prompt.length() - 2)) {
             if (promptUp == null) promptUp = prompt.toUpperCase();
             String promptSub = promptUp.substring(c + 1);
             Wearable.CODES wcodes = Wearable.CODES.instance();
             boolean isFound = false;
             for (long code : wcodes.all())
               if (promptSub.startsWith(wcodes.nameup(code))) {
                 c += 1 + wcodes.nameup(code).length();
                 Item I = mob.fetchFirstWornItem(code);
                 if (I != null) buf.append(I.name());
                 isFound = true;
                 break;
               }
             if (!isFound) {
               CharStats.CODES ccodes = CharStats.CODES.instance();
               for (int code : ccodes.all())
                 if (promptSub.startsWith(ccodes.name(code))) {
                   c += 1 + ccodes.name(code).length();
                   buf.append(mob.charStats().getStat(code));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (int code : ccodes.all())
                   if (promptSub.startsWith("BASE " + ccodes.name(code))) {
                     buf.append(mob.baseCharStats().getStat(code));
                     c += 6 + ccodes.name(code).length();
                     isFound = true;
                     break;
                   }
             }
             if (!isFound) {
               for (String s : mob.envStats().getStatCodes())
                 if (promptSub.startsWith(s)) {
                   c += 1 + s.length();
                   buf.append(mob.envStats().getStat(s));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (String s : mob.baseEnvStats().getStatCodes())
                   if (promptSub.startsWith("BASE " + s)) {
                     c += 6 + s.length();
                     buf.append(mob.baseEnvStats().getStat(s));
                     isFound = true;
                     break;
                   }
             }
             if (!isFound) {
               for (String s : mob.curState().getStatCodes())
                 if (promptSub.startsWith(s)) {
                   c += 1 + s.length();
                   buf.append(mob.curState().getStat(s));
                   isFound = true;
                   break;
                 }
               if (!isFound)
                 for (String s : mob.maxState().getStatCodes())
                   if (promptSub.startsWith("MAX " + s)) {
                     c += 5 + s.length();
                     buf.append(mob.maxState().getStat(s));
                     isFound = true;
                     break;
                   }
               if (!isFound)
                 for (String s : mob.baseState().getStatCodes())
                   if (promptSub.startsWith("BASE " + s)) {
                     c += 6 + s.length();
                     buf.append(mob.baseState().getStat(s));
                     isFound = true;
                     break;
                   }
             }
           }
           break;
         case 'a':
           {
             buf.append(
                 CMLib.factions()
                         .getRangePercent(
                             CMLib.factions().AlignID(),
                             mob.fetchFaction(CMLib.factions().AlignID()))
                     + "%");
             c++;
             break;
           }
         case 'A':
           {
             Faction.FactionRange FR =
                 CMLib.factions()
                     .getRange(
                         CMLib.factions().AlignID(), mob.fetchFaction(CMLib.factions().AlignID()));
             buf.append(
                 (FR != null) ? FR.name() : "" + mob.fetchFaction(CMLib.factions().AlignID()));
             c++;
             break;
           }
         case 'B':
           {
             buf.append("\n\r");
             c++;
             break;
           }
         case 'c':
           {
             buf.append(mob.inventorySize());
             c++;
             break;
           }
         case 'C':
           {
             buf.append(mob.maxItems());
             c++;
             break;
           }
         case 'd':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat()) && (victim != null)) buf.append("" + mob.rangeToTarget());
             c++;
             break;
           }
         case 'e':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat())
                 && (victim != null)
                 && (CMLib.flags().canBeSeenBy(victim, mob))) buf.append(victim.displayName(mob));
             c++;
             break;
           }
         case 'E':
           {
             MOB victim = mob.getVictim();
             if ((mob.isInCombat())
                 && (victim != null)
                 && (!victim.amDead())
                 && (CMLib.flags().canBeSeenBy(victim, mob)))
               buf.append(victim.healthText(mob) + "\n\r");
             c++;
             break;
           }
         case 'g':
           {
             buf.append(
                 (int)
                     Math.round(
                         Math.floor(
                             CMLib.beanCounter().getTotalAbsoluteNativeValue(mob)
                                 / CMLib.beanCounter()
                                     .getLowestDenomination(
                                         CMLib.beanCounter().getCurrency(mob)))));
             c++;
             break;
           }
         case 'G':
           {
             buf.append(
                 CMLib.beanCounter()
                     .nameCurrencyShort(
                         mob, CMLib.beanCounter().getTotalAbsoluteNativeValue(mob)));
             c++;
             break;
           }
         case 'h':
           {
             buf.append("^<Hp^>" + mob.curState().getHitPoints() + "^</Hp^>");
             c++;
             break;
           }
         case 'H':
           {
             buf.append("^<MaxHp^>" + mob.maxState().getHitPoints() + "^</MaxHp^>");
             c++;
             break;
           }
         case 'I':
           {
             if ((CMLib.flags().isCloaked(mob))
                 && (((mob.envStats().disposition() & EnvStats.IS_NOT_SEEN) != 0)))
               buf.append("Wizinvisible");
             else if (CMLib.flags().isCloaked(mob)) buf.append("Cloaked");
             else if (!CMLib.flags().isSeen(mob)) buf.append("Undetectable");
             else if (CMLib.flags().isInvisible(mob) && CMLib.flags().isHidden(mob))
               buf.append("Hidden/Invisible");
             else if (CMLib.flags().isInvisible(mob)) buf.append("Invisible");
             else if (CMLib.flags().isHidden(mob)) buf.append("Hidden");
             c++;
             break;
           }
         case 'K':
         case 'k':
           {
             MOB tank = mob;
             if ((tank.getVictim() != null)
                 && (tank.getVictim().getVictim() != null)
                 && (tank.getVictim().getVictim() != mob)) tank = tank.getVictim().getVictim();
             if (((c + 1) < prompt.length()) && (tank != null))
               switch (prompt.charAt(c + 1)) {
                 case 'h':
                   {
                     buf.append(tank.curState().getHitPoints());
                     c++;
                     break;
                   }
                 case 'H':
                   {
                     buf.append(tank.maxState().getHitPoints());
                     c++;
                     break;
                   }
                 case 'm':
                   {
                     buf.append(tank.curState().getMana());
                     c++;
                     break;
                   }
                 case 'M':
                   {
                     buf.append(tank.maxState().getMana());
                     c++;
                     break;
                   }
                 case 'v':
                   {
                     buf.append(tank.curState().getMovement());
                     c++;
                     break;
                   }
                 case 'V':
                   {
                     buf.append(tank.maxState().getMovement());
                     c++;
                     break;
                   }
                 case 'e':
                   {
                     buf.append(tank.displayName(mob));
                     c++;
                     break;
                   }
                 case 'E':
                   {
                     if ((mob.isInCombat()) && (CMLib.flags().canBeSeenBy(tank, mob)))
                       buf.append(tank.healthText(mob) + "\n\r");
                     c++;
                     break;
                   }
               }
             c++;
             break;
           }
         case 'm':
           {
             buf.append("^<Mana^>" + mob.curState().getMana() + "^</Mana^>");
             c++;
             break;
           }
         case 'M':
           {
             buf.append("^<MaxMana^>" + mob.maxState().getMana() + "^</MaxMana^>");
             c++;
             break;
           }
         case 'r':
           {
             if (mob.location() != null) buf.append(mob.location().displayText());
             c++;
             break;
           }
         case 'R':
           {
             if ((mob.location() != null) && CMSecurity.isAllowed(mob, mob.location(), "SYSMSGS"))
               buf.append(mob.location().roomID());
             c++;
             break;
           }
         case 'v':
           {
             buf.append("^<Move^>" + mob.curState().getMovement() + "^</Move^>");
             c++;
             break;
           }
         case 'V':
           {
             buf.append("^<MaxMove^>" + mob.maxState().getMovement() + "^</MaxMove^>");
             c++;
             break;
           }
         case 'w':
           {
             buf.append(mob.envStats().weight());
             c++;
             break;
           }
         case 'W':
           {
             buf.append(mob.maxCarry());
             c++;
             break;
           }
         case 'x':
           {
             buf.append(mob.getExperience());
             c++;
             break;
           }
         case 'X':
           {
             if (mob.getExpNeededLevel() == Integer.MAX_VALUE) buf.append("N/A");
             else buf.append(mob.getExpNeededLevel());
             c++;
             break;
           }
         case 'z':
           {
             if (mob.location() != null) buf.append(mob.location().getArea().name());
             c++;
             break;
           }
         case 't':
           {
             if (mob.location() != null)
               buf.append(
                   CMStrings.capitalizeAndLower(
                       TimeClock.TOD_DESC[mob.location().getArea().getTimeObj().getTODCode()]
                           .toLowerCase()));
             c++;
             break;
           }
         case 'T':
           {
             if (mob.location() != null)
               buf.append(mob.location().getArea().getTimeObj().getTimeOfDay());
             c++;
             break;
           }
         case '@':
           {
             if (mob.location() != null)
               buf.append(
                   mob.location().getArea().getClimateObj().weatherDescription(mob.location()));
             c++;
             break;
           }
         default:
           {
             buf.append("%" + prompt.charAt(c));
             c++;
             break;
           }
       }
     } else buf.append(prompt.charAt(c++));
   return buf.toString();
 }
Пример #20
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (!mob.clans().iterator().hasNext()) {
      mob.tell(L("You aren't even a member of a clan."));
      return false;
    }
    final Pair<Clan, Integer> clanPair =
        CMLib.clans().findPrivilegedClan(mob, Clan.Function.CLAN_BENEFITS);
    if (clanPair == null) {
      mob.tell(L("You are not authorized to draw from the power of your clan."));
      return false;
    }
    final Clan C = clanPair.first;
    Room clanHomeRoom = null;
    clanHomeRoom = CMLib.map().getRoom(C.getRecall());
    if (clanHomeRoom == null) {
      mob.tell(L("Your clan does not have a clan home."));
      return false;
    }
    if (!CMLib.flags().canAccess(mob, clanHomeRoom)) {
      mob.tell(L("You can't use this magic to get there from here."));
      return false;
    }
    if (!CMLib.law().doesOwnThisProperty(C.clanID(), clanHomeRoom)) {
      mob.tell(L("Your clan no longer owns that room."));
      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,
              null,
              this,
              CMMsg.MASK_MOVE | verbalCastCode(mob, mob, auto),
              L("^S<S-NAME> invoke(s) a teleportation spell.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Set<MOB> h = properTargets(mob, givenTarget, false);
        if (h == null) return false;

        final Room thisRoom = mob.location();
        for (final Object element : h) {
          final MOB follower = (MOB) element;
          final CMMsg enterMsg =
              CMClass.getMsg(
                  follower,
                  clanHomeRoom,
                  this,
                  CMMsg.MSG_ENTER,
                  null,
                  CMMsg.MSG_ENTER,
                  null,
                  CMMsg.MSG_ENTER,
                  L("<S-NAME> appears in a puff of red smoke."));
          final CMMsg leaveMsg =
              CMClass.getMsg(
                  follower,
                  thisRoom,
                  this,
                  CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC,
                  L("<S-NAME> disappear(s) in a puff of red smoke."));
          if (thisRoom.okMessage(follower, leaveMsg)
              && clanHomeRoom.okMessage(follower, enterMsg)) {
            if (follower.isInCombat()) {
              CMLib.commands().postFlee(follower, ("NOWHERE"));
              follower.makePeace(false);
            }
            thisRoom.send(follower, leaveMsg);
            clanHomeRoom.bringMobHere(follower, false);
            clanHomeRoom.send(follower, enterMsg);
            follower.tell(L("\n\r\n\r"));
            CMLib.commands().postLook(follower, true);
          }
        }
      }

    } else
      beneficialWordsFizzle(
          mob, null, L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell."));

    // return whether it worked
    return success;
  }
Пример #21
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Room trapThis = mob.location();

    Item resource =
        CMLib.materials().findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_METAL);
    if (resource == null)
      resource = CMLib.materials().findMostOfMaterial(mob.location(), RawMaterial.MATERIAL_MITHRIL);
    int amount = 0;
    if (resource != null)
      amount = CMLib.materials().findNumberOfResource(mob.location(), resource.material());
    if (amount < 100) {
      mob.tell(L("You need 100 pounds of raw metal to build this trap."));
      return false;
    }
    if (mob.isInCombat()) {
      mob.tell(L("You are too busy to get that done right now."));
      return false;
    }

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

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

    if (resource != null)
      CMLib.materials().destroyResourcesValue(mob.location(), 100, resource.material(), -1, null);

    final CMMsg msg =
        CMClass.getMsg(
            mob,
            trapThis,
            this,
            auto ? CMMsg.MSG_OK_ACTION : CMMsg.MSG_THIEF_ACT,
            CMMsg.MASK_ALWAYS | CMMsg.MSG_DELICATE_HANDS_ACT,
            CMMsg.MSG_OK_ACTION,
            (auto
                ? L("@x1 begins to glow!", trapThis.name())
                : L("<S-NAME> attempt(s) to lay a trap here.")));
    if (mob.location().okMessage(mob, msg)) {
      mob.location().send(mob, msg);
      if (success) {
        mob.tell(L("You have set the trap."));
        setTrap(
            mob,
            trapThis,
            mob.charStats().getClassLevel(mob.charStats().getCurrentClass()),
            (CMLib.ableMapper().qualifyingClassLevel(mob, this)
                    - CMLib.ableMapper().lowestQualifyingLevel(ID()))
                + 1,
            false);
        final Thief_DeathTrap T = (Thief_DeathTrap) trapThis.fetchEffect(ID());
        if (T != null) T.setMiscText(mob.Name());
      } else {
        if (CMLib.dice().rollPercentage() > 50) {
          final Trap T =
              setTrap(
                  mob,
                  trapThis,
                  mob.charStats().getClassLevel(mob.charStats().getCurrentClass()),
                  (CMLib.ableMapper().qualifyingClassLevel(mob, this)
                          - CMLib.ableMapper().lowestQualifyingLevel(ID()))
                      + 1,
                  false);
          mob.location()
              .show(mob, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> trigger(s) the trap on accident!"));
          T.spring(mob);
        } else {
          mob.tell(L("You fail in your attempt to set the death trap."));
        }
      }
    }
    return success;
  }
Пример #22
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = super.getTarget(mob, commands, givenTarget);
    if (target == null) return false;
    final Race R = target.charStats().getMyRace();
    if (R.bodyMask()[Race.BODY_HEAD] <= 0) {
      mob.tell(L("@x1 has no head!", target.name(mob)));
      return false;
    }

    LegalBehavior B = null;
    if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
    List<LegalWarrant> warrants = new Vector<LegalWarrant>();
    if (B != null) warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), target);
    if ((warrants.size() == 0)
        && (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ABOVELAW))) {
      mob.tell(L("You are not allowed to behead @x1 at this time.", target.Name()));
      return false;
    }

    final Item w = mob.fetchWieldedItem();
    Weapon ww = null;
    if ((w == null) || (!(w instanceof Weapon))) {
      mob.tell(L("You cannot behead without a weapon!"));
      return false;
    }
    ww = (Weapon) w;
    if ((!auto) && (!CMSecurity.isASysOp(mob))) {
      if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) {
        mob.tell(L("You cannot behead with a @x1!", ww.name()));
        return false;
      }
      if (mob.isInCombat() && (mob.rangeToTarget() > 0)) {
        mob.tell(L("You are too far away to try that!"));
        return false;
      }
      if (!CMLib.flags().isBoundOrHeld(target)) {
        mob.tell(L("@x1 is not bound and would resist.", target.charStats().HeShe()));
        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 = levelDiff * 3;
    else levelDiff = 0;
    final boolean hit = (auto) || CMLib.combat().rollToHit(mob, target);
    boolean success = proficiencyCheck(mob, 0, auto) && (hit);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MALICIOUS
                  | CMMsg.MASK_MOVE
                  | CMMsg.MASK_SOUND
                  | CMMsg.TYP_JUSTICE
                  | (auto ? CMMsg.MASK_ALWAYS : 0),
              null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        target.curState().setHitPoints(1);
        final Ability A2 = target.fetchEffect("Injury");
        if (A2 != null) A2.setMiscText(mob.Name() + "/head");
        CMLib.combat()
            .postDamage(
                mob,
                target,
                ww,
                Integer.MAX_VALUE / 2,
                CMMsg.MSG_WEAPONATTACK,
                ww.weaponClassification(),
                auto
                    ? ""
                    : L(
                        "^F^<FIGHT^><S-NAME> rear(s) back and behead(s) <T-NAME>!^</FIGHT^>^?@x1",
                        CMLib.protocol().msp("decap.wav", 30)));
        mob.location().recoverRoomStats();
        final Item limb = CMClass.getItem("GenLimb");
        limb.setName(L("@x1`s head", target.Name()));
        limb.basePhyStats().setAbility(1);
        limb.setDisplayText(L("the bloody head of @x1 is sitting here.", target.Name()));
        limb.setSecretIdentity(target.name() + "`s bloody head.");
        int material = RawMaterial.RESOURCE_MEAT;
        for (int r = 0; r < R.myResources().size(); r++) {
          final Item I = R.myResources().get(r);
          final int mat = I.material() & RawMaterial.MATERIAL_MASK;
          if (((mat == RawMaterial.MATERIAL_FLESH)) || (r == R.myResources().size() - 1)) {
            material = I.material();
            break;
          }
        }
        limb.setMaterial(material);
        limb.basePhyStats().setLevel(1);
        limb.basePhyStats().setWeight(5);
        limb.recoverPhyStats();
        mob.location().addItem(limb, ItemPossessor.Expire.Player_Drop);
        for (int i = 0; i < warrants.size(); i++) {
          final LegalWarrant W = warrants.get(i);
          W.setCrime("pardoned");
          W.setOffenses(0);
        }
      } else success = false;
      if (mob.getVictim() == target) mob.makePeace(true);
      if (target.getVictim() == mob) target.makePeace(true);
    } else maliciousFizzle(mob, target, L("<S-NAME> attempt(s) a beheading and fail(s)!"));
    return success;
  }