Beispiel #1
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));
 }
Beispiel #2
0
 private void clearAbilityFromSpellcraftList(MOB mob, Ability A) {
   final Ability enabledA = mob.fetchAbility("Skill_Spellcraft");
   if (enabledA != null) {
     final List<String> ables = CMParms.parseCommas(enabledA.text(), true);
     if (ables.contains(A.ID())) {
       if (!CMSecurity.isAllowed(mob, mob.location(), CMSecurity.SecFlag.ALLSKILLS)) {
         ables.remove(A.ID());
         enabledA.setMiscText(CMParms.toListString(ables));
         mob.delAbility(A);
       }
     }
   }
 }
Beispiel #3
0
  public void executeMsg(Environmental myHost, CMMsg msg) {
    super.executeMsg(myHost, msg);
    if ((myHost == null) || (!(myHost instanceof MOB))) return;
    MOB mob = (MOB) myHost;
    if (msg.amISource(mob) && (msg.tool() != null)) {
      if (msg.tool() instanceof Ability) {
        Ability A = mob.fetchAbility(msg.tool().ID());
        if ((A != null)
            && (!CMLib.ableMapper().getDefaultGain(ID(), false, A.ID()))
            && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)) {
          mob.delAbility(A);
          mob.recoverMaxState();
        }
      } else if (msg.tool().ID().equalsIgnoreCase("Skill_ScrollCopy")) {

      }
    }
  }
Beispiel #4
0
 public void affectCharState(MOB mob, CharState state) {
   super.affectCharState(mob, state);
   if (mob.baseCharStats().getCurrentClass().ID().equals(ID())) {
     Ability A = null;
     for (int a = 0; a < mob.numLearnedAbilities(); a++) {
       A = mob.fetchAbility(a);
       if ((A != null)
           && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
           && (!CMLib.ableMapper().getDefaultGain(ID(), false, A.ID()))) {
         int[] cost = A.usageCost(mob, true);
         int manaCost = cost[Ability.USAGEINDEX_MANA];
         if (manaCost > 0) {
           if (state.getMana() < manaCost) {
             mob.delAbility(A);
             a--;
           } else state.setMana(state.getMana() - manaCost);
         }
       }
     }
     if (mob.curState().getMana() > state.getMana()) mob.curState().setMana(state.getMana());
   }
 }
Beispiel #5
0
  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;
  }