Exemple #1
0
 @Override
 public void spring(MOB target) {
   if ((target != invoker()) && (target.location() != null)) {
     if ((doesSaveVsTraps(target))
         || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target)))
       target
           .location()
           .show(
               target,
               null,
               null,
               CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
               L("<S-NAME> avoid(s) setting off a gas trap!"));
     else if (target
         .location()
         .show(
             target,
             target,
             this,
             CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
             L("<S-NAME> set(s) off a trap! The room fills with gas!"))) {
       super.spring(target);
       Ability A = CMClass.getAbility(text());
       if (A == null) A = CMClass.getAbility("Poison");
       for (int i = 0; i < target.location().numInhabitants(); i++) {
         final MOB M = target.location().fetchInhabitant(i);
         if ((M != null) && (M != invoker()) && (A != null))
           if (invoker().mayIFight(M)) A.invoke(invoker(), M, true, 0);
       }
       if ((canBeUninvoked()) && (affected instanceof Item)) disable();
     }
   }
 }
Exemple #2
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.amITarget(this)
           || (msg.targetMinor() == CMMsg.TYP_ADVANCE)
           || (msg.targetMinor() == CMMsg.TYP_RETREAT))
       && (!msg.source().isMonster())
       && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints())
       && (CMLib.dice().rollPercentage() == 1)
       && (CMLib.dice().rollPercentage() == 1)
       && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
     Ability A = null;
     if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia");
     else A = CMClass.getAbility("Disease_Malaria");
     if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
       A.invoke(msg.source(), msg.source(), true, 0);
   }
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
     if (CMLib.dice().rollPercentage() < 10) {
       Ability A = CMClass.getAbility("Disease_Malaria");
       if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
         A.invoke(msg.source(), msg.source(), true, 0);
     }
   }
   super.executeMsg(myHost, msg);
 }
Exemple #3
0
  @Override
  public void grantAbilities(MOB mob, boolean isBorrowedClass) {
    super.grantAbilities(mob, isBorrowedClass);

    if (mob.playerStats() == null) {
      final List<AbilityMapper.AbilityMapping> V =
          CMLib.ableMapper()
              .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
      for (final AbilityMapper.AbilityMapping able : V) {
        final Ability A = CMClass.getAbility(able.abilityID);
        if ((A != null)
            && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
          giveMobAbility(
              mob,
              A,
              CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
              CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
              isBorrowedClass);
      }
      return;
    }

    final Vector grantable = new Vector();

    final int level = mob.charStats().getClassLevel(this);
    int numChants = 2;
    for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) {
      final Ability A = a.nextElement();
      if ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) == level)
          && ((CMLib.ableMapper().getQualifyingLevel(ID(), true, A.ID()) <= 25)
              && (!CMLib.ableMapper().getSecretSkill(ID(), true, A.ID()))
              && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID()))
              && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))) {
        if (!grantable.contains(A.ID())) grantable.addElement(A.ID());
      }
    }
    for (int a = 0; a < mob.numAbilities(); a++) {
      final Ability A = mob.fetchAbility(a);
      if (grantable.contains(A.ID())) {
        grantable.remove(A.ID());
        numChants--;
      }
    }
    for (int i = 0; i < numChants; i++) {
      if (grantable.size() == 0) break;
      final String AID = (String) grantable.elementAt(CMLib.dice().roll(1, grantable.size(), -1));
      if (AID != null) {
        grantable.removeElement(AID);
        giveMobAbility(
            mob,
            CMClass.getAbility(AID),
            CMLib.ableMapper().getDefaultProficiency(ID(), true, AID),
            CMLib.ableMapper().getDefaultParm(ID(), true, AID),
            isBorrowedClass);
      }
    }
  }
Exemple #4
0
 @Override
 public List<Item> getTrapComponents() {
   final Vector V = new Vector();
   final Item I = CMLib.materials().makeItemResource(RawMaterial.RESOURCE_POISON);
   Ability A = CMClass.getAbility(text());
   if (A == null) A = CMClass.getAbility("Poison");
   I.addNonUninvokableEffect(A);
   V.addElement(I);
   return V;
 }
Exemple #5
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_WEAPONATTACK)
       && (weaponClassification() == Weapon.CLASS_THROWN)) return;
   // msg.addTrailerMsg(CMClass.getMsg(msg.source(),this,CMMsg.MSG_DROP,null));
   else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && (msg.target() != null)
       && (msg.target() instanceof MOB)
       && (weaponClassification() == Weapon.CLASS_THROWN)) {
     unWear();
     msg.addTrailerMsg(
         CMClass.getMsg(msg.source(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_DROP, null));
     msg.addTrailerMsg(
         CMClass.getMsg((MOB) msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_GET, null));
     msg.addTrailerMsg(
         CMClass.getMsg(
             msg.source(), msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.TYP_GENERAL, null));
   } else if ((msg.tool() == this)
       && (msg.target() instanceof MOB)
       && (msg.targetMinor() == CMMsg.TYP_GENERAL)
       && (((MOB) msg.target()).isMine(this))
       && (msg.sourceMessage() == null)) {
     final Ability A = CMClass.getAbility("Thief_Bind");
     if (A != null) {
       A.setAffectedOne(this);
       A.invoke(msg.source(), (MOB) msg.target(), true, phyStats().level());
     }
   } else super.executeMsg(myHost, msg);
 }
Exemple #6
0
 @Override
 public void spring(MOB target) {
   if (target.location() != null) {
     if ((!invoker().mayIFight(target))
         || (isLocalExempt(target))
         || (invoker().getGroupMembers(new HashSet<MOB>()).contains(target))
         || (target == invoker())
         || (doesSaveVsTraps(target)))
       target
           .location()
           .show(
               target,
               null,
               null,
               CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
               L("<S-NAME> avoid(s) the water bomb!"));
     else if (target
         .location()
         .show(
             invoker(),
             target,
             this,
             CMMsg.MASK_ALWAYS | CMMsg.MSG_NOISE,
             L("@x1 explodes water all over <T-NAME>!", affected.name()))) {
       super.spring(target);
       final Ability A = CMClass.getAbility("Spell_Irritation");
       if (A != null) A.invoke(target, target, true, invoker().phyStats().level() + abilityCode());
     }
   }
 }
Exemple #7
0
 @Override
 protected Ability getSpell() {
   if (theSpell != null) return theSpell;
   if (mimicSpell().length() == 0) return null;
   theSpell = CMClass.getAbility(mimicSpell());
   return theSpell;
 }
 @Override
 public CMObject copyOf() {
   final ClimbableSurface R = (ClimbableSurface) super.copyOf();
   R.climbA = CMClass.getAbility("Prop_Climbable");
   R.climbA.setAffectedOne(R);
   R.climbA.makeNonUninvokable();
   return R;
 }
 public ClimbableSurface() {
   super();
   name = "the surface";
   basePhyStats.setWeight(4);
   climbA = CMClass.getAbility("Prop_Climbable");
   if (climbA != null) {
     climbA.setAffectedOne(this);
     climbA.makeNonUninvokable();
   }
   recoverPhyStats();
 }
  @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();
        }
      }
    }
  }
  @Override
  public void setMiscText(String txt) {
    super.setMiscText("");
    if (txt.startsWith("-")) {
      txt = txt.substring(1).toLowerCase().trim();
      for (final Object[] A : affects)
        if (((CMObject) A[0]).ID().toLowerCase().equals(txt)) {
          unAffectAffected(A);
          return;
        }
      for (final Object[] A : affects)
        if ((A[0] instanceof Ability)
            && (((Environmental) A[0]).name().toLowerCase().startsWith(txt))) {
          unAffectAffected(A);
          return;
        }
      for (final Object[] A : affects)
        if ((A[0] instanceof Behavior)
            && (((Behavior) A[0]).name().toLowerCase().startsWith(txt))) {
          unAffectAffected(A);
          return;
        }
    } else if (txt.trim().length() > 0) {
      if (txt.startsWith("+")) txt = txt.substring(1);
      else for (final Object[] A : affects) unAffectAffected(A);

      int x = txt.indexOf(' ');
      if (x < 0) return;
      final String abilityStr = txt.substring(0, x).trim();
      String numTicksStr = txt.substring(x + 1).trim();
      String parms = "";
      x = numTicksStr.indexOf(' ');
      if (x > 0) {
        parms = numTicksStr.substring(x + 1).trim();
        numTicksStr = numTicksStr.substring(0, x);
      }
      CMObject A = CMClass.getAbility(abilityStr);
      if (A == null) A = CMClass.getBehavior(abilityStr);
      if (A == null) A = CMClass.findAbility(abilityStr);
      if (A == null) A = CMClass.findBehavior(abilityStr);
      if (A != null) {
        affects.addElement(new Object[] {A, new int[] {CMath.s_int(numTicksStr)}});
        if (A instanceof Ability) ((Ability) A).setMiscText(parms);
        if ((A instanceof Behavior) && (affected instanceof PhysicalAgent))
          ((Behavior) A).setParms(parms);
        finishInit(A);
      }
    }
  }
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 3) {
      mob.tell(
          L("Specify a target, a property, number of ticks, and (optionally) some misc text!"));
      return false;
    }
    final Vector V = new XVector(commands.firstElement());
    final Physical target = getAnyTarget(mob, V, givenTarget, Wearable.FILTER_ANY);
    if (target == null) return false;
    commands.removeElementAt(0);

    final String abilityStr = (String) commands.firstElement();
    CMObject A = CMClass.getAbility(abilityStr);
    if (A == null) A = CMClass.getBehavior(abilityStr);
    if (A == null) A = CMClass.findAbility(abilityStr);
    if (A == null) A = CMClass.findBehavior(abilityStr);
    if (A == null) {
      mob.tell(L("No such ability or behavior as @x1!", abilityStr));
      return false;
    }
    final String numTicks = ((String) commands.elementAt(1)).trim();
    if ((!CMath.isInteger(numTicks)) || (CMath.s_int(numTicks) <= 0)) {
      mob.tell(L("'@x1' is not a number of ticks!", numTicks));
      return false;
    }
    final String parms = CMParms.combine(commands, 2);

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

    TemporaryAffects T = (TemporaryAffects) target.fetchEffect(ID());
    if (T == null) {
      T = (TemporaryAffects) this.newInstance();
      T.affects = new SVector<Object[]>();
      T.startTickDown(mob, target, 10);
      T = (TemporaryAffects) target.fetchEffect(ID());
    }
    if (T != null) {
      T.setMiscText("+" + A.ID() + " " + numTicks.trim() + " " + parms.trim());
      T.makeLongLasting();
    }
    return true;
  }
  public List<Ability> getMySpellsV() {
    if (spellV != null) return spellV;
    spellV = new Vector<Ability>();
    final String names = getParmString(text());
    final List<String> set = CMParms.parseSemicolons(names, true);
    String thisOne = null;
    for (int s = 0; s < set.size(); s++) {
      thisOne = set.get(s);
      if (thisOne.equalsIgnoreCase("NOUNINVOKE")) {
        this.uninvocable = false;
        continue;
      }
      if (thisOne.toUpperCase().startsWith("LEVEL")) {
        level = (short) CMParms.getParmInt(thisOne, "LEVEL", -1);
        if (level >= 0) continue;
      }
      if (thisOne.toUpperCase().startsWith("MAXTICKS")) {
        maxTicks = (short) CMParms.getParmInt(thisOne, "MAXTICKS", -1);
        if (maxTicks != -1) continue;
      }
      final int pctDex = thisOne.indexOf("% ");
      if ((pctDex > 0) && (thisOne.substring(pctDex + 1).trim().length() > 0))
        thisOne = thisOne.substring(pctDex + 1).trim();
      String parm = "";
      if ((thisOne != null) && (thisOne.endsWith(")"))) {
        final int x = thisOne.indexOf('(');
        if (x > 0) {
          parm = thisOne.substring(x + 1, thisOne.length() - 1);
          thisOne = thisOne.substring(0, x).trim();
        }
      }

      Ability A = CMClass.getAbility(thisOne);
      if ((A != null)
          && ((A.classificationCode() & Ability.ALL_DOMAINS) != Ability.DOMAIN_ARCHON)) {
        A = (Ability) A.copyOf();
        A.setMiscText(parm);
        spellV.add(A);
      }
    }
    return spellV;
  }
Exemple #14
0
 public void grantAbilities(MOB mob, boolean isBorrowedClass) {
   super.grantAbilities(mob, isBorrowedClass);
   if (mob.playerStats() == null) {
     DVector V =
         CMLib.ableMapper()
             .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
     for (Enumeration a = V.getDimensionVector(1).elements(); a.hasMoreElements(); ) {
       Ability A = CMClass.getAbility((String) a.nextElement());
       if ((A != null)
           && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
           && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
         giveMobAbility(
             mob,
             A,
             CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
             CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
             isBorrowedClass);
     }
   }
 }
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!(affected instanceof MOB)) return super.tick(ticking, tickID);

    if (!super.tick(ticking, tickID)) return false;
    if ((--plagueDown) <= 0) {
      final MOB mob = (MOB) affected;
      plagueDown = 10;
      if (invoker == null) invoker = mob;
      drawups += .1;
      if (drawups >= 3.1) {
        if ((mob.location() != null) && (CMLib.flags().isInTheGame(mob, false))) {
          mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-YOU-POSS> feet rot off!"));
          final Ability A = CMClass.getAbility("Amputation");
          if (A != null) {
            int x = 100;
            while (((--x) > 0) && A.invoke(mob, CMParms.parse("foot"), mob, true, 0)) {
              /*do nothing */
            }
            mob.recoverCharStats();
            mob.recoverPhyStats();
            mob.recoverMaxState();
          }
          unInvoke();
        }
      } else {
        final MOB invoker = (invoker() != null) ? invoker() : mob;
        CMLib.combat()
            .postDamage(
                invoker,
                mob,
                this,
                1,
                CMMsg.TYP_DISEASE,
                -1,
                L(
                    "<T-NAME> feel(s) the fungus between <T-HIS-HER> toes eating <T-HIS-HER> feet away!"));
      }
    }
    return true;
  }
Exemple #16
0
 @Override
 public void grantAbilities(MOB mob, boolean isBorrowedClass) {
   super.grantAbilities(mob, isBorrowedClass);
   if (mob.playerStats() == null) {
     final List<AbilityMapper.AbilityMapping> V =
         CMLib.ableMapper()
             .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
     for (final AbilityMapper.AbilityMapping able : V) {
       final Ability A = CMClass.getAbility(able.abilityID);
       if ((A != null)
           && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)
           && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
         giveMobAbility(
             mob,
             A,
             CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
             CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
             isBorrowedClass);
     }
   }
 }
Exemple #17
0
 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;
 }
Exemple #18
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) {
    if (type.length() == 0) return false;
    if ((mob.getClanID() == null)
        || (mob.getClanID().equalsIgnoreCase(""))
        || (mob.getClanRole() == 0)) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    Clan C = CMLib.clans().getClan(mob.getClanID());
    if (C == null) {
      mob.tell("You aren't even a member of a clan.");
      return false;
    }
    if (C.allowedToDoThis(mob, Clan.FUNC_CLANENCHANT) != 1) {
      mob.tell("You are not authorized to draw from the power of your " + C.typeName() + ".");
      return false;
    }
    String ClanName = C.clanID();
    String ClanType = C.typeName();

    // Invoking will be like:
    //   CAST [CLANEQSPELL] ITEM QUANTITY
    //   -2   -1            0    1
    if (commands.size() < 1) {
      mob.tell("Enchant which spell onto what?");
      return false;
    }
    if (commands.size() < 2) {
      mob.tell("Use how much clan enchantment power?");
      return false;
    }
    Environmental target =
        mob.location()
            .fetchFromMOBRoomFavorsItems(
                mob, null, (String) commands.elementAt(0), Item.WORNREQ_UNWORNONLY);
    if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) {
      mob.tell("You don't see '" + ((String) commands.elementAt(0)) + "' here.");
      return false;
    }
    // Add clan power check start
    int points = CMath.s_int((String) commands.elementAt(1));
    if (points <= 0) {
      mob.tell("You need to use at least 1 enchantment point.");
      return false;
    }
    long exp = points * CMProps.getIntVar(CMProps.SYSTEMI_CLANENCHCOST);
    if ((C.getExp() < exp) || (exp < 0)) {
      mob.tell(
          "You need "
              + exp
              + " to do that, but your "
              + C.typeName()
              + " has only "
              + C.getExp()
              + " experience points.");
      return false;
    }

    // Add clan power check end
    if (target.fetchEffect("Prop_ClanEquipment") != null) {
      mob.tell(target.name() + " is already clan enchanted.");
      return false;
    }

    // lose all the mana!
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    C.setExp(C.getExp() - exp);
    C.update();

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              "^S<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = CMClass.getAbility("Prop_ClanEquipment");
        StringBuffer str = new StringBuffer("");
        str.append(type); // Type of Enchantment
        str.append(" ");
        str.append("" + points); // Power of Enchantment
        str.append(" \"");
        str.append(ClanName); // Clan Name
        str.append("\" \"");
        str.append(ClanType); // Clan Type
        str.append("\"");
        A.setMiscText(str.toString());
        target.addEffect(A);
      }
    } else
      beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely, and looking very frustrated.");
    return success;
  }
Exemple #19
0
 @Override
 public Ability getSpell() {
   return CMClass.getAbility(text());
 }
Exemple #20
0
 public Trap makeADeprecatedTrap(Environmental unlockThis) {
   Trap theTrap = null;
   int roll = (int) Math.round(Math.random() * 100.0);
   if (unlockThis instanceof Exit) {
     if (((Exit) unlockThis).hasADoor()) {
       if (((Exit) unlockThis).hasALock()) {
         if (roll < 20) theTrap = (Trap) CMClass.getAbility("Trap_Open");
         else if (roll < 80) theTrap = (Trap) CMClass.getAbility("Trap_Unlock");
         else theTrap = (Trap) CMClass.getAbility("Trap_Enter");
       } else {
         if (roll < 50) theTrap = (Trap) CMClass.getAbility("Trap_Open");
         else theTrap = (Trap) CMClass.getAbility("Trap_Enter");
       }
     } else theTrap = (Trap) CMClass.getAbility("Trap_Enter");
   } else if (unlockThis instanceof Container) {
     if (((Container) unlockThis).hasALid()) {
       if (((Container) unlockThis).hasALock()) {
         if (roll < 20) theTrap = (Trap) CMClass.getAbility("Trap_Open");
         else if (roll < 80) theTrap = (Trap) CMClass.getAbility("Trap_Unlock");
         else theTrap = (Trap) CMClass.getAbility("Trap_Get");
       } else {
         if (roll < 50) theTrap = (Trap) CMClass.getAbility("Trap_Open");
         else theTrap = (Trap) CMClass.getAbility("Trap_Get");
       }
     } else theTrap = (Trap) CMClass.getAbility("Trap_Get");
   } else if (unlockThis instanceof Item) theTrap = (Trap) CMClass.getAbility("Trap_Get");
   return theTrap;
 }
Exemple #21
0
  @Override
  public void grantAbilities(MOB mob, boolean isBorrowedClass) {
    super.grantAbilities(mob, isBorrowedClass);

    // if he already has one, don't give another!
    if (mob.playerStats() != null) {
      final int classLevel = mob.baseCharStats().getClassLevel(this);
      if (classLevel < 2) return;
      if ((classLevel % 2) != 0) return;

      int maxSkills = classLevel / 2;

      // now only give one, for current level, respecting alignment!
      // first, get a list of all skills you don't qualify for that you MIGHT have gained or will
      // gain
      final List<Ability> choices = new Vector<Ability>();
      for (final Enumeration<Ability> a = CMClass.abilities(); a.hasMoreElements(); ) {
        final Ability A = a.nextElement();
        final int lql = CMLib.ableMapper().lowestQualifyingLevel(A.ID());
        if ((CMLib.ableMapper().qualifyingLevel(mob, A) <= 0)
            && (lql < 25)
            && (lql > 0)
            && (!CMLib.ableMapper().getSecretSkill(A.ID()))
            && (CMLib.ableMapper().qualifiesByAnyCharClass(A.ID()))
            && (CMLib.ableMapper().availableToTheme(A.ID(), Area.THEME_FANTASY, true))
            && (!CMLib.ableMapper().qualifiesOnlyByClan(mob, A))
            && (!CMLib.ableMapper().qualifiesOnlyByRace(mob, A))
            && (A.isAutoInvoked()
                || ((A.triggerStrings() != null) && (A.triggerStrings().length > 0))))
          choices.add(A);
      }

      // now count those you already have
      for (int a = choices.size() - 1; a >= 0; a--) {
        final Ability A = choices.get(a);
        if (mob.fetchAbility(A.ID()) != null) maxSkills--;
      }
      if (maxSkills < 1) // if that reduced you to 0, you are done.
      return;
      // now eliminate those you already have, and those that are
      // above your level, if you are <25
      for (int a = choices.size() - 1; a >= 0; a--) {
        final Ability A = choices.get(a);
        final int lql = CMLib.ableMapper().lowestQualifyingLevel(A.ID());
        if ((mob.fetchAbility(ID()) != null)
            || ((lql != classLevel) && (lql != classLevel - 1) && (classLevel < 25)))
          choices.remove(a);
      }
      if (choices.size() == 0) return;
      final Ability A = choices.get(CMLib.dice().roll(1, choices.size(), -1));
      if (A != null) giveMobAbility(mob, A, 0, "", isBorrowedClass);
    } else {
      final List<AbilityMapper.AbilityMapping> V =
          CMLib.ableMapper()
              .getUpToLevelListings(ID(), mob.charStats().getClassLevel(ID()), false, false);
      for (final AbilityMapper.AbilityMapping able : V) {
        final Ability A = CMClass.getAbility(able.abilityID);
        if ((A != null)
            && (!CMLib.ableMapper().getAllQualified(ID(), true, A.ID()))
            && (!CMLib.ableMapper().getDefaultGain(ID(), true, A.ID())))
          giveMobAbility(
              mob,
              A,
              CMLib.ableMapper().getDefaultProficiency(ID(), true, A.ID()),
              CMLib.ableMapper().getDefaultParm(ID(), true, A.ID()),
              isBorrowedClass);
      }
    }
  }
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

    if (target == mob) {
      mob.tell(L("@x1 doesn't look dead yet.", target.name(mob)));
      return false;
    }
    if (!(target instanceof DeadBody)) {
      mob.tell(L("You can't animate that."));
      return false;
    }

    final DeadBody body = (DeadBody) target;
    if (body.isPlayerCorpse()
        || (body.getMobName().length() == 0)
        || ((body.charStats() != null)
            && (body.charStats().getMyRace() != null)
            && (body.charStats().getMyRace().racialCategory().equalsIgnoreCase("Undead")))) {
      mob.tell(L("You can't animate that."));
      return false;
    }
    String race = "a";
    if ((body.charStats() != null) && (body.charStats().getMyRace() != null))
      race = CMLib.english().startWithAorAn(body.charStats().getMyRace().name()).toLowerCase();

    String description = body.getMobDescription();
    if (description.trim().length() == 0) description = "It looks dead.";
    else description += "\n\rIt also looks dead.";

    if (body.basePhyStats().level() < 7) {
      mob.tell(L("This creature is too weak to create a ghast from."));
      return false;
    }

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : L("^S<S-NAME> @x1 to animate <T-NAMESELF> as a ghast.^?", prayForWord(mob)));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        int undeadLevel = this.getUndeadLevel(mob, 6, body.phyStats().level());
        final MOB newMOB = CMClass.getMOB("GenUndead");
        newMOB.setName(L("@x1 ghast", race));
        newMOB.setDescription(description);
        newMOB.setDisplayText(L("@x1 ghast is here", race));
        newMOB.basePhyStats().setLevel(undeadLevel);
        newMOB
            .baseCharStats()
            .setStat(CharStats.STAT_GENDER, body.charStats().getStat(CharStats.STAT_GENDER));
        newMOB.baseCharStats().setMyRace(CMClass.getRace("Undead"));
        newMOB
            .baseCharStats()
            .setBodyPartsFromStringAfterRace(body.charStats().getBodyPartsAsString());
        final Ability P = CMClass.getAbility("Prop_StatTrainer");
        if (P != null) {
          P.setMiscText("NOTEACH STR=20 INT=10 WIS=10 CON=10 DEX=15 CHA=2");
          newMOB.addNonUninvokableEffect(P);
        }
        newMOB.recoverCharStats();
        newMOB.basePhyStats().setAttackAdjustment(CMLib.leveler().getLevelAttack(newMOB));
        newMOB.basePhyStats().setDamage(CMLib.leveler().getLevelMOBDamage(newMOB));
        newMOB.basePhyStats().setSensesMask(PhyStats.CAN_SEE_DARK);
        CMLib.factions().setAlignment(newMOB, Faction.Align.EVIL);
        newMOB.baseState().setHitPoints(25 * newMOB.basePhyStats().level());
        newMOB.baseState().setMovement(CMLib.leveler().getLevelMove(newMOB));
        newMOB.basePhyStats().setArmor(CMLib.leveler().getLevelMOBArmor(newMOB));
        newMOB.baseState().setMana(100);
        newMOB.recoverCharStats();
        newMOB.recoverPhyStats();
        newMOB.recoverMaxState();
        newMOB.resetToMaxState();
        newMOB.addAbility(CMClass.getAbility("Paralysis"));
        Behavior B = CMClass.getBehavior("CombatAbilities");
        if (B != null) newMOB.addBehavior(B);
        B = CMClass.getBehavior("Aggressive");
        if (B != null) {
          B.setParms("+NAMES \"-" + mob.Name() + "\" -LEVEL +>" + newMOB.basePhyStats().level());
          newMOB.addBehavior(B);
        }
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Spell_CauseStink"));
        newMOB.addNonUninvokableEffect(CMClass.getAbility("Prop_ModExperience"));
        newMOB.text();
        newMOB.bringToLife(mob.location(), true);
        CMLib.beanCounter().clearZeroMoney(newMOB, null);
        // newMOB.location().showOthers(newMOB,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> appears!"));
        int it = 0;
        while (it < newMOB.location().numItems()) {
          final Item item = newMOB.location().getItem(it);
          if ((item != null) && (item.container() == body)) {
            final CMMsg msg2 = CMClass.getMsg(newMOB, body, item, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg2);
            final CMMsg msg4 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_GET, null);
            newMOB.location().send(newMOB, msg4);
            final CMMsg msg3 = CMClass.getMsg(newMOB, item, null, CMMsg.MSG_WEAR, null);
            newMOB.location().send(newMOB, msg3);
            if (!newMOB.isMine(item)) it++;
            else it = 0;
          } else it++;
        }
        body.destroy();
        mob.location().show(newMOB, null, CMMsg.MSG_OK_ACTION, L("<S-NAME> begin(s) to rise!"));
        newMOB.setStartRoom(null);
        beneficialAffect(mob, newMOB, 0, 0);
        mob.location().recoverRoomStats();
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          L("<S-NAME> @x1 to animate <T-NAMESELF>, but fail(s) miserably.", prayForWord(mob)));

    // return whether it worked
    return success;
  }