예제 #1
0
파일: Druid.java 프로젝트: kingdavid127/MUD
  @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);
      }
    }
  }
예제 #2
0
 @Override
 public void endCharacter(MOB mob) {
   final Vector<Ability> otherChoices = new Vector<Ability>();
   for (int a = 0; a < mob.numAbilities(); a++) {
     final Ability A2 = mob.fetchAbility(a);
     if ((A2 != null)
         && (!A2.isSavable())
         && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
       otherChoices.addElement(A2);
   }
   for (int a = 0; a < otherChoices.size(); a++) mob.delAbility(otherChoices.elementAt(a));
 }
예제 #3
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((myHost == null) || (!(myHost instanceof MOB))) return;
   final MOB mob = (MOB) myHost;
   if (msg.amISource(mob)) {
     if (((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
         && (msg.target() instanceof Wand)
         && (mob.charStats().getClassLevel(this) >= 30)) {
       final String message =
           "<O-NAME> has " + ((Wand) msg.target()).usesRemaining() + " charges remaining.";
       msg.addTrailerMsg(
           CMClass.getMsg(
               mob,
               null,
               msg.target(),
               CMMsg.MSG_OK_VISUAL,
               CMMsg.NO_EFFECT,
               CMMsg.NO_EFFECT,
               message));
     } else if (msg.tool() != null) {
       if (msg.tool().ID().equals("Skill_Spellcraft")) {
         if ((msg.tool().text().length() > 0) && (msg.target() instanceof MOB)) {
           Ability A = ((MOB) msg.target()).fetchAbility(msg.tool().text());
           if (A == null) return;
           final Ability myA = mob.fetchAbility(A.ID());
           if (myA != null) {
             if ((!A.isSavable())
                 && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
                 && (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30))
               addAbilityToSpellcraftList(mob, A);
           } else if (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30) {
             final Vector<Ability> otherChoices = new Vector<Ability>();
             for (int a = 0; a < mob.numAbilities(); a++) {
               final Ability A2 = mob.fetchAbility(a);
               if ((A2 != null)
                   && (!A2.isSavable())
                   && ((A2.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
                 otherChoices.addElement(A2);
             }
             A = (Ability) A.copyOf();
             A.setProficiency(0);
             A.setSavable(false);
             if (otherChoices.size() > (mob.charStats().getClassLevel(this) / 3)) {
               final Ability A2 =
                   otherChoices.elementAt(CMLib.dice().roll(1, otherChoices.size(), -1));
               clearAbilityFromSpellcraftList(mob, A2);
             }
             addAbilityToSpellcraftList(mob, A);
           }
         }
       } else if (msg.tool().ID().equals("Spell_Scribe")
           || msg.tool().ID().equals("Spell_EnchantWand")
           || msg.tool().ID().equals("Spell_MagicItem")
           || msg.tool().ID().equals("Spell_StoreSpell")
           || msg.tool().ID().equals("Spell_WardArea")) {
         final Ability A = mob.fetchAbility(msg.tool().text());
         if ((A != null) && (!A.isSavable())) clearAbilityFromSpellcraftList(mob, A);
       } else if (msg.tool() instanceof Ability) {
         final Ability A = mob.fetchAbility(msg.tool().ID());
         if ((A != null)
             && (!A.isSavable())
             && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
           clearAbilityFromSpellcraftList(mob, A);
       }
     }
   }
 }