Exemplo n.º 1
0
  public void removeMyAffectsFrom(Physical P) {
    if (P == null) return;

    int x = 0;
    final Vector<Ability> eff = new Vector<Ability>();
    Ability thisAffect = null;
    for (x = 0; x < P.numEffects(); x++) // personal
    {
      thisAffect = P.fetchEffect(x);
      if (thisAffect != null) eff.addElement(thisAffect);
    }
    if (eff.size() > 0) {
      final Map<String, String> h = makeMySpellsH(getMySpellsV());
      if (unrevocableSpells != null) {
        for (int v = unrevocableSpells.size() - 1; v >= 0; v--) {
          thisAffect = unrevocableSpells.get(v);
          if (h.containsKey(thisAffect.ID())) P.delEffect(thisAffect);
        }
      } else
        for (x = 0; x < eff.size(); x++) {
          thisAffect = eff.elementAt(x);
          final String ID = h.get(thisAffect.ID());
          if ((ID != null) && (thisAffect.invoker() == getInvokerMOB(P, P))) {
            thisAffect.unInvoke();
            if ((!uninvocable) && (!thisAffect.canBeUninvoked())) P.delEffect(thisAffect);
          }
        }
      unrevocableSpells = null;
    }
  }
Exemplo n.º 2
0
  public void setTrapped(Environmental myThang, Trap theTrap, boolean isTrapped) {
    for (int a = 0; a < myThang.numEffects(); a++) {
      Ability A = myThang.fetchEffect(a);
      if ((A != null) && (A instanceof Trap)) A.unInvoke();
    }

    if ((isTrapped) && (myThang.fetchEffect(theTrap.ID()) == null)) myThang.addEffect(theTrap);
  }
Exemplo n.º 3
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY);
    if (target == null) return false;

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

    boolean success = proficiencyCheck(mob, 0, auto);
    if ((success) && ((target instanceof MOB) || (target instanceof Item))) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? "<T-NAME> feel(s) somewhat smaller."
                  : "^S<S-NAME> cast(s) a small spell on <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        boolean isJustUnInvoking = false;
        if (target instanceof Item) {
          Ability A = target.fetchEffect("Spell_Shrink");
          if ((A != null) && (A.canBeUninvoked())) {
            A.unInvoke();
            isJustUnInvoking = true;
          }
        } else if (target instanceof MOB) {
          Ability A = target.fetchEffect("Spell_Grow");
          if ((A != null) && (A.canBeUninvoked())) {
            A.unInvoke();
            isJustUnInvoking = true;
          }
        }

        if ((!isJustUnInvoking) && (msg.value() <= 0)) {
          beneficialAffect(mob, target, asLevel, 0);
          if (target instanceof MOB) CMLib.utensils().confirmWearability((MOB) target);
        }
      }
    } else
      beneficialWordsFizzle(mob, target, "<S-NAME> attempt(s) to cast a small spell, but fail(s).");

    return success;
  }
Exemplo n.º 4
0
 public void unAffectAffected(Object[] Os) {
   final CMObject O = (CMObject) Os[0];
   final Physical P = affected;
   if (O instanceof Ability) {
     ((Ability) O).unInvoke();
     ((Ability) O).destroy();
   }
   affects.remove(Os);
   if (P != null) P.recoverPhyStats();
   if (P instanceof MOB) {
     ((MOB) P).recoverCharStats();
     ((MOB) P).recoverMaxState();
   }
 }
Exemplo n.º 5
0
  public void unInvoke() {
    // undo the affects of this spell
    if (!(affected instanceof MOB)) return;
    MOB mob = (MOB) affected;

    super.unInvoke();

    if (canBeUninvoked()) {
      if (buddy != null) {
        mob.tell("Your health is no longer linked with " + buddy.name() + ".");
        Ability A = buddy.fetchEffect(ID());
        if (A != null) A.unInvoke();
      }
    }
  }
Exemplo n.º 6
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    try {
      for (Enumeration r = CMLib.map().rooms(); r.hasMoreElements(); ) {
        Room R = (Room) r.nextElement();
        if (CMLib.flags().canAccess(mob, R))
          for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) {
            final Ability A = a.nextElement();
            if ((A != null) && (A.ID().equals(ID())) && (A.invoker() == mob)) {
              A.unInvoke();
              break;
            }
          }
      }
    } catch (NoSuchElementException nse) {
    }
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

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

    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              mob.location(),
              this,
              verbalCastCode(mob, null, auto),
              auto ? "" : "^S<S-NAME> summon(s) <S-HIS-HER> marker energy to this place!^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(
                mob,
                mob.location(),
                CMMsg.MSG_OK_VISUAL,
                "The spot <S-NAME> pointed to glows for brief moment.");
        beneficialAffect(mob, mob.location(), 0, (adjustedLevel(mob, asLevel) * 240) + 450);
      }

    } else
      beneficialWordsFizzle(
          mob, null, "<S-NAME> attempt(s) to summon <S-HIS-HER> marker energy, but fail(s).");

    // return whether it worked
    return success;
  }
Exemplo n.º 7
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

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

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

    if (success) {
      // it worked, so build a copy of this ability,
      // and add it to the affects list of the
      // affected MOB. Then tell everyone else
      // what happened.
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : "^S<S-NAME> "
                      + prayWord(mob)
                      + " that <T-NAME> be protected in an unholy fortress.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location()
            .show(target, null, CMMsg.MSG_OK_VISUAL, "A dark protective aura surrounds <S-NAME>.");
        beneficialAffect(mob, target, asLevel, 0);
        Ability A = target.fetchEffect("Prayer_Sanctuary");
        if (A != null) A.unInvoke();
      }
    } else
      return beneficialWordsFizzle(
          mob,
          target,
          "<S-NAME> " + prayWord(mob) + " for protection, but <S-HIS-HER> plea is not answered.");

    // return whether it worked
    return success;
  }
Exemplo n.º 8
0
 public void extinguish(MOB source, Environmental target, boolean mundane) {
   if (target instanceof Room) {
     Room R = (Room) target;
     for (int m = 0; m < R.numInhabitants(); m++) {
       MOB M = R.fetchInhabitant(m);
       if (M != null) extinguish(source, M, mundane);
     }
     for (int i = 0; i < R.numItems(); i++) {
       Item I = R.fetchItem(i);
       if (I != null) extinguish(source, I, mundane);
     }
     return;
   }
   for (int a = target.numEffects() - 1; a >= 0; a--) {
     Ability A = target.fetchEffect(a);
     if ((A != null)
         && ((!mundane)
             || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PROPERTY))) {
       if ((CMath.bset(A.flags(), Ability.FLAG_HEATING) && (!mundane))
           || (CMath.bset(A.flags(), Ability.FLAG_FIREBASED))
           || ((A.ID().equalsIgnoreCase("Spell_SummonElemental")
               && A.text().toUpperCase().indexOf("FIRE") >= 0))) A.unInvoke();
     }
   }
   if ((target instanceof MOB) && (!mundane)) {
     MOB tmob = (MOB) target;
     if (tmob.charStats().getMyRace().ID().equals("FireElemental"))
       CMLib.combat().postDeath(source, (MOB) target, null);
     for (int i = 0; i < tmob.inventorySize(); i++) {
       Item I = tmob.fetchInventory(i);
       if (I != null) extinguish(tmob, I, mundane);
     }
   }
   if ((target instanceof Light) && (((Light) target).isLit())) {
     ((Light) target).tick(target, Tickable.TICKID_LIGHT_FLICKERS);
     ((Light) target).light(false);
   }
 }
Exemplo n.º 9
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;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

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

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

    if (success) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> cast(s) a spell on <T-NAMESELF>.^?"));
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        if (msg.value() <= 0) {
          R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> slow(s) down!"));
          final Ability A = target.fetchEffect("Spell_MassSlow");
          if (A != null) A.unInvoke();
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> incant(s) at <T-NAMESELF>, but the spell fizzles."));

    // return whether it worked
    return success;
  }
Exemplo n.º 10
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTargetAnywhere(mob, commands, givenTarget, false, true, false);
    if (target == null) return false;

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

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

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

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0),
              auto ? L("Silence falls upon <T-NAME>!") : L("^F<S-NAME> hush(es) <T-NAMESELF>.^?"));
      CMLib.color().fixSourceFightColor(msg);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        mob.location().show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> <S-IS-ARE> hushed!"));
        beneficialAffect(mob, target, asLevel, Ability.TICKS_ALMOST_FOREVER);
        Log.sysOut("Banish", mob.Name() + " hushed " + target.name() + ".");
      }
    } else
      return beneficialVisualFizzle(
          mob, target, L("<S-NAME> attempt(s) to hush <T-NAMESELF>, but fail(s)."));
    return success;
  }
Exemplo n.º 11
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    String whatToRevoke = CMParms.combine(commands, 0);

    Physical target = null;
    if ((whatToRevoke.length() == 0) && (mob.location().numEffects() > 0)) target = mob.location();
    else if (whatToRevoke.equalsIgnoreCase("room")) target = mob.location();
    else if (whatToRevoke.equalsIgnoreCase("self")) target = mob;
    else {
      int dir = Directions.getGoodDirectionCode(whatToRevoke);
      if (dir >= 0) target = mob.location().getExitInDir(dir);
      else {
        target = mob.location().fetchFromRoomFavorMOBs(null, whatToRevoke);
        if (target == null) target = mob.findItem(null, whatToRevoke);
      }
    }

    if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) {
      mob.tell("Revoke from what?  You don't see '" + whatToRevoke + "' here.");
      return false;
    }

    Ability revokeThis = null;
    for (int a = 0; a < target.numEffects(); a++) {
      Ability A = target.fetchEffect(a);
      if ((A != null)
          && (A.invoker() == mob)
          && (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
              || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT))
          && (A.canBeUninvoked())) revokeThis = A;
    }

    if (revokeThis == null) {
      if (target instanceof Room) mob.tell("Revoke your magic from what?");
      else
        mob.tell(
            mob,
            target,
            null,
            "<T-NAME> do(es) not appear to be affected by anything you can revoke.");
      return false;
    }

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

    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              null,
              this,
              CMMsg.MSG_HANDS,
              "<S-NAME> revoke(s) " + revokeThis.name() + " from " + target.name());
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        revokeThis.unInvoke();
      }
    } else
      beneficialVisualFizzle(
          mob,
          target,
          "<S-NAME> attempt(s) to revoke "
              + revokeThis.name()
              + " from "
              + target.name()
              + ", but flub(s) it.");
    return success;
  }
Exemplo n.º 12
0
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell("Commit espionage through whom?");
      return false;
    }
    MOB target = this.getTarget(mob, commands, givenTarget, false, true);
    if (target == null) return false;
    if (target == mob) {
      mob.tell("You cannot do that with yourself?!");
      return false;
    }
    Ability A = target.fetchEffect(ID());
    if (A != null) {
      if (A.invoker() == mob) {
        A.unInvoke();
        return false;
      } else {
        mob.tell(mob, target, null, "It is too crowded to commit espionage with <T-NAME>.");
        return false;
      }
    }
    if (mob.isInCombat()) {
      mob.tell("Not while you are fighting!");
      return false;
    }
    if (CMLib.flags().canBeSeenBy(mob, target)) {
      mob.tell(target.name(mob) + " is watching you too closely.");
      return false;
    }
    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    int levelDiff =
        target.phyStats().level()
            - (mob.phyStats().level() + abilityCode() + (getXLEVELLevel(mob) * 2));

    boolean success = proficiencyCheck(mob, -(levelDiff * 10), auto);

    if (!success) {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              null,
              CMMsg.MSG_OK_VISUAL,
              auto
                  ? ""
                  : "Your attempt to commit espionage using <T-NAMESELF> fails; <T-NAME> spots you!",
              CMMsg.MSG_OK_VISUAL,
              auto ? "" : "You spot <S-NAME> trying to commit espionage through you.",
              CMMsg.NO_EFFECT,
              null);
      if (mob.location().okMessage(mob, msg)) mob.location().send(mob, msg);
    } else {
      CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              auto ? CMMsg.MSG_OK_VISUAL : CMMsg.MSG_THIEF_ACT,
              "You are now committing espionage with <T-NAME>.  Enter 'espionage <targetname>' again to disengage.",
              CMMsg.NO_EFFECT,
              null,
              CMMsg.NO_EFFECT,
              null);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        beneficialAffect(mob, target, asLevel, 0);
      }
    }
    return success;
  }
Exemplo n.º 13
0
  public static int updateLotWithThisData(
      Room R,
      LandTitle T,
      boolean resetRoomName,
      boolean clearAllItems,
      List optPlayerList,
      int lastNumItems) {
    boolean updateItems = false;
    boolean updateExits = false;
    boolean updateRoom = false;
    synchronized (("SYNC" + R.roomID()).intern()) {
      R = CMLib.map().getRoom(R);
      if (T.getOwnerName().length() == 0) {
        Item I = null;
        for (int i = R.numItems() - 1; i >= 0; i--) {
          I = R.getItem(i);
          if ((I == null) || (I.Name().equalsIgnoreCase("id"))) continue;
          CMLib.catalog().updateCatalogIntegrity(I);
          if (clearAllItems) {
            I.destroy();
            updateItems = true;
          } else {
            if (I.expirationDate() == 0) {
              long now = System.currentTimeMillis();
              now += (TimeManager.MILI_MINUTE * CMProps.getIntVar(CMProps.Int.EXPIRE_PLAYER_DROP));
              I.setExpirationDate(now);
            }
            if ((I.phyStats().rejuv() != PhyStats.NO_REJUV) && (I.phyStats().rejuv() != 0)) {
              I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
              I.recoverPhyStats();
            }
          }
        }
        Ability A = null;
        if (clearAllItems)
          for (final Enumeration<Ability> a = R.effects(); a.hasMoreElements(); ) {
            A = a.nextElement();
            if (((A != null)
                && ((A.classificationCode() & Ability.ALL_ACODES) != Ability.ACODE_PROPERTY))) {
              A.unInvoke();
              R.delEffect(A);
              updateRoom = true;
            }
          }
        for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
          final Room R2 = R.rawDoors()[d];
          Exit E = R.getRawExit(d);
          if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
            E.setKeyName("");
            E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
            updateExits = true;
            if (R2 != null) {
              E = R2.getRawExit(Directions.getOpDirectionCode(d));
              if ((E != null) && (E.hasALock()) && (E.isGeneric())) {
                E.setKeyName("");
                E.setDoorsNLocks(E.hasADoor(), E.isOpen(), E.defaultsClosed(), false, false, false);
                CMLib.database().DBUpdateExits(R2);
                R2.getArea().fillInAreaRoom(R2);
              }
            }
          }
        }
        if (updateExits) {
          CMLib.database().DBUpdateExits(R);
          R.getArea().fillInAreaRoom(R);
        }
        if (updateItems) CMLib.database().DBUpdateItems(R);
        if (updateRoom) CMLib.database().DBUpdateRoom(R);
        colorForSale(R, T.rentalProperty(), resetRoomName);
        return -1;
      }

      if ((lastNumItems < 0)
          && (!CMSecurity.isDisabled(CMSecurity.DisFlag.PROPERTYOWNERCHECKS))
          && (optPlayerList != null)) {
        boolean playerExists = (CMLib.players().getPlayer(T.getOwnerName()) != null);
        if (!playerExists) playerExists = (CMLib.clans().getClan(T.getOwnerName()) != null);
        if (!playerExists) playerExists = optPlayerList.contains(T.getOwnerName());
        if (!playerExists)
          for (int i = 0; i < optPlayerList.size(); i++)
            if (((String) optPlayerList.get(i)).equalsIgnoreCase(T.getOwnerName())) {
              playerExists = true;
              break;
            }
        if (!playerExists) {
          T.setOwnerName("");
          T.updateLot(null);
          return -1;
        }
      }

      int x = R.description().indexOf(SALESTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }
      x = R.description().indexOf(RENTSTR);
      if (x >= 0) {
        R.setDescription(R.description().substring(0, x));
        CMLib.database().DBUpdateRoom(R);
      }

      // this works on the priciple that
      // 1. if an item has ONLY been removed, the lastNumItems will be != current # items
      // 2. if an item has ONLY been added, the dispossessiontime will be != null
      // 3. if an item has been added AND removed, the dispossession time will be != null on the
      // added
      if ((lastNumItems >= 0) && (R.numItems() != lastNumItems)) updateItems = true;

      for (int i = 0; i < R.numItems(); i++) {
        final Item I = R.getItem(i);
        if ((I.expirationDate() != 0)
            && ((I.isSavable()) || (I.Name().equalsIgnoreCase("id")))
            && ((!(I instanceof DeadBody)) || (((DeadBody) I).isPlayerCorpse()))) {
          I.setExpirationDate(0);
          updateItems = true;
        }

        if ((I.phyStats().rejuv() != Integer.MAX_VALUE) && (I.phyStats().rejuv() != 0)) {
          I.basePhyStats().setRejuv(PhyStats.NO_REJUV);
          I.recoverPhyStats();
          updateItems = true;
        }
      }
      lastNumItems = R.numItems();
      if ((!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYITEMS)) && (updateItems))
        CMLib.database().DBUpdateItems(R);
    }
    return lastNumItems;
  }