Ejemplo n.º 1
0
 public void confirmWearability(MOB mob) {
   if (mob == null) return;
   Race R = mob.charStats().getMyRace();
   DVector reWearSet = new DVector(2);
   Item item = null;
   for (int i = 0; i < mob.inventorySize(); i++) {
     item = mob.fetchInventory(i);
     if ((item != null) && (!item.amWearingAt(Wearable.IN_INVENTORY))) {
       Long oldCode = Long.valueOf(item.rawWornCode());
       item.unWear();
       if (reWearSet.size() == 0) reWearSet.addElement(item, oldCode);
       else {
         short layer = (item instanceof Armor) ? ((Armor) item).getClothingLayer() : 0;
         int d = 0;
         for (; d < reWearSet.size(); d++)
           if (reWearSet.elementAt(d, 1) instanceof Armor) {
             if (((Armor) reWearSet.elementAt(d, 1)).getClothingLayer() > layer) break;
           } else if (0 > layer) break;
         if (d >= reWearSet.size()) reWearSet.addElement(item, oldCode);
         else reWearSet.insertElementAt(d, item, oldCode);
       }
     }
   }
   for (int r = 0; r < reWearSet.size(); r++) {
     item = (Item) reWearSet.elementAt(r, 1);
     long oldCode = ((Long) reWearSet.elementAt(r, 2)).longValue();
     int msgCode = CMMsg.MSG_WEAR;
     if ((oldCode & Wearable.WORN_WIELD) > 0) msgCode = CMMsg.MSG_WIELD;
     else if ((oldCode & Wearable.WORN_HELD) > 0) msgCode = CMMsg.MSG_HOLD;
     CMMsg msg =
         CMClass.getMsg(
             mob, item, null, CMMsg.NO_EFFECT, null, msgCode, null, CMMsg.NO_EFFECT, null);
     if ((R.okMessage(mob, msg))
         && (item.okMessage(item, msg))
         && ((mob.charStats().getWearableRestrictionsBitmap() & oldCode) == 0)
         && (item.canWear(mob, oldCode))) item.wearAt(oldCode);
   }
   // why wasn't that here before?
   mob.recoverEnvStats();
   mob.recoverCharStats();
   mob.recoverMaxState();
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
 @Override
 public int[] getBreathables() {
   return (breathables != null) ? breathables : myRace.getBreathables();
 }
Ejemplo n.º 4
0
 @Override
 public String raceName() {
   if (raceName != null) return raceName;
   if (myRace != null) return myRace.name();
   return "MOB";
 }
Ejemplo n.º 5
0
 @Override
 public String getLeaveStr() {
   if (leaveStr == null) return myRace.leaveStr();
   return leaveStr;
 }
Ejemplo n.º 6
0
 @Override
 public String getArriveStr() {
   if (arriveStr == null) return myRace.arriveStr();
   return arriveStr;
 }
Ejemplo n.º 7
0
  public String runMacro(ExternalHTTPRequests httpReq, String parm) {
    if (!CMProps.getBoolVar(CMProps.SYSTEMB_MUDSTARTED))
      return CMProps.getVar(CMProps.SYSTEM_MUDSTATUS);

    Hashtable parms = parseParms(parm);
    String last = httpReq.getRequestParameter("PLAYER");
    if (last == null) return " @break@";
    if (last.length() > 0) {
      MOB M = CMLib.players().getLoadPlayer(last);
      if (M == null) {
        MOB authM = Authenticate.getAuthenticatedMob(httpReq);
        if ((authM != null) && (authM.Name().equalsIgnoreCase(last))) M = authM;
        else return " @break@";
      }

      boolean firstTime =
          (!httpReq.isRequestParameter("ACTION"))
              || (httpReq.getRequestParameter("ACTION")).equals("FIRSTTIME");
      StringBuffer str = new StringBuffer("");
      for (int i = 0; i < MOB.AUTODESC.length; i++) {
        if (parms.containsKey(MOB.AUTODESC[i])) {
          boolean set = CMath.isSet(M.getBitmap(), i);
          if (MOB.AUTOREV[i]) set = !set;
          str.append((set ? "ON" : "OFF") + ",");
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.charStats();
          if (parms.containsKey(stat)) {
            String old = httpReq.getRequestParameter(stat);
            if ((firstTime) || (old.length() == 0)) {
              if ((!CharStats.CODES.isBASE(i)) && (i != CharStats.STAT_GENDER))
                old = "" + C.getSave(i);
              else old = "" + C.getStat(i);
            }
            str.append(old + ", ");
          }
        }
      }
      for (int i : CharStats.CODES.ALL()) {
        String stat = CharStats.CODES.NAME(i);
        if (!stat.equalsIgnoreCase("GENDER")) {
          CharStats C = M.baseCharStats();
          if (parms.containsKey("BASE" + stat)) {
            String old = httpReq.getRequestParameter("BASE" + stat);
            if ((firstTime) || (old.length() == 0)) old = "" + C.getStat(i);
            str.append(old + ", ");
          }
        }
      }
      for (int i = 0; i < BASICS.length; i++) {
        if (parms.containsKey(BASICS[i])) {
          if (httpReq.isRequestParameter(BASICS[i]))
            str.append(httpReq.getRequestParameter(BASICS[i]) + ", ");
          else str.append(getBasic(M, i));
        }
      }
      if (parms.containsKey("RACE")) {
        String old = httpReq.getRequestParameter("RACE");
        if ((firstTime) || (old.length() == 0)) old = "" + M.baseCharStats().getMyRace().ID();
        for (Enumeration r = CMClass.races(); r.hasMoreElements(); ) {
          Race R2 = (Race) r.nextElement();
          str.append("<OPTION VALUE=\"" + R2.ID() + "\"");
          if (R2.ID().equals(old)) str.append(" SELECTED");
          str.append(">" + R2.name());
        }
      }
      if (parms.containsKey("DEITY")) {
        String old = httpReq.getRequestParameter("DEITY");
        if (firstTime) old = M.getWorshipCharID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Godless");
        for (Enumeration e = CMLib.map().deities(); e.hasMoreElements(); ) {
          Deity E = (Deity) e.nextElement();
          str.append("<OPTION VALUE=\"" + E.Name() + "\"");
          if (E.Name().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + E.Name());
        }
      }
      if (parms.containsKey("TITLELIST")) {
        if (M.playerStats() != null) {
          int b = 0;
          Vector titles = new Vector();
          if (firstTime) CMParms.addToVector(M.playerStats().getTitles(), titles);
          else
            while (httpReq.isRequestParameter("TITLE" + b)) {
              String B = httpReq.getRequestParameter("TITLE" + b);
              if ((B != null) && (B.trim().length() > 0)) titles.addElement(B);
              b++;
            }
          for (b = 0; b < titles.size(); b++) {
            String B = (String) titles.elementAt(b);
            if (B != null)
              str.append(
                  "<INPUT TYPE=TEXT NAME=TITLE"
                      + b
                      + " SIZE="
                      + B.length()
                      + " VALUE=\""
                      + CMStrings.replaceAll(B, "\"", "&quot;")
                      + "\"><BR>");
          }
          str.append("<INPUT TYPE=TEXT NAME=TITLE" + titles.size() + " SIZE=60 VALUE=\"\">");
        }
      }
      if (parms.containsKey("CLAN")) {
        String old = httpReq.getRequestParameter("CLAN");
        if (firstTime) old = M.getClanID();
        str.append("<OPTION " + ((old.length() == 0) ? "SELECTED" : "") + " VALUE=\"\">Clanless");
        for (Enumeration e = CMLib.clans().allClans(); e.hasMoreElements(); ) {
          Clan C = (Clan) e.nextElement();
          str.append("<OPTION VALUE=\"" + C.clanID() + "\"");
          if (C.clanID().equalsIgnoreCase(old)) str.append(" SELECTED");
          str.append(">" + C.getName());
        }
      }
      if (parms.containsKey("ALIGNMENT")) {
        String old = httpReq.getRequestParameter("ALIGNMENT");
        if ((firstTime) || (old.length() == 0))
          old = "" + M.fetchFaction(CMLib.factions().AlignID());
        if (CMLib.factions().getFaction(CMLib.factions().AlignID()) != null) {
          for (int v = 1; v < Faction.ALIGN_NAMES.length; v++) {
            str.append("<OPTION VALUE=" + Faction.ALIGN_NAMES[v]);
            if (old.equalsIgnoreCase(Faction.ALIGN_NAMES[v])) str.append(" SELECTED");
            str.append(">" + CMStrings.capitalizeAndLower(Faction.ALIGN_NAMES[v].toLowerCase()));
          }
        }
      }
      if (parms.containsKey("BASEGENDER")) {
        String old = httpReq.getRequestParameter("BASEGENDER");
        if (firstTime) old = "" + M.baseCharStats().getStat(CharStats.STAT_GENDER);
        str.append("<OPTION VALUE=M " + ((old.equalsIgnoreCase("M")) ? "SELECTED" : "") + ">M");
        str.append("<OPTION VALUE=F " + ((old.equalsIgnoreCase("F")) ? "SELECTED" : "") + ">F");
        str.append("<OPTION VALUE=N " + ((old.equalsIgnoreCase("N")) ? "SELECTED" : "") + ">N");
      }
      str.append(MobData.expertiseList(M, httpReq, parms));
      str.append(MobData.classList(M, httpReq, parms));
      str.append(MobData.itemList(M, M, httpReq, parms, 0));
      str.append(MobData.abilities(M, httpReq, parms, 0));
      str.append(MobData.factions(M, httpReq, parms, 0));
      str.append(AreaData.affectsNBehaves(M, httpReq, parms, 0));
      str.append(ExitData.dispositions(M, firstTime, httpReq, parms));
      str.append(MobData.senses(M, firstTime, httpReq, parms));
      String strstr = str.toString();
      if (strstr.endsWith(", ")) strstr = strstr.substring(0, strstr.length() - 2);
      return clearWebMacros(strstr);
    }
    return "";
  }
Ejemplo n.º 8
0
  public boolean invoke(
      MOB mob, Vector commands, Environmental 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
                  ? ""
                  : (mob == target)
                      ? "^S<S-NAME> close(s) <T-HIS-HER> eyes and peer(s) into <T-HIS-HER> own nostrils.^?"
                      : "^S<S-NAME> peer(s) into the nostrils of <T-NAMESELF>.^?");
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        Ability A = target.fetchEffect("Allergies");
        if (A == null)
          mob.tell(
              mob, target, null, "<T-NAME> seem(s) like <T-HE-SHE> is not allergic to anything.");
        else {

          Vector allergies = new Vector();
          Vector V = CMParms.parse(A.text().toUpperCase().trim());
          for (int i = 0; i < V.size(); i++) {
            if (CMParms.contains(RawMaterial.RESOURCE_DESCS, (String) V.elementAt(i)))
              allergies.addElement(((String) V.elementAt(i)).toLowerCase());
            else {
              Race R = CMClass.getRace((String) V.elementAt(i));
              if (R != null) allergies.addElement(R.name());
            }
          }
          mob.tell(
              mob,
              target,
              null,
              "<T-NAME> seem(s) like <T-HE-SHE> is allergic to " + CMParms.toStringList(V) + ".");
        }
      }
    } else if (mob == target)
      beneficialWordsFizzle(
          mob,
          target,
          auto
              ? ""
              : "<S-NAME> close(s) <T-HIS-HER> eyes and peer(s) into <T-HIS-HER> own nostrils, but then blink(s).");
    else
      beneficialWordsFizzle(
          mob,
          target,
          auto ? "" : "<S-NAME> peer(s) into the nostrils of <T-NAMESELF>, but then blink(s).");

    // return whether it worked
    return success;
  }
Ejemplo n.º 9
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;
  }