コード例 #1
0
ファイル: Spell_Friends.java プロジェクト: kingdavid127/MUD
  @Override
  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;
    Room R = CMLib.map().roomLocation(target);
    if (R == null) R = mob.location();

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

    if ((auto) && (givenTarget != null) && (givenTarget instanceof MOB)) target = (MOB) givenTarget;
    // now see if it worked
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              somanticCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> speak(s) and gesture(s) to <T-NAMESELF>.^?"));
      if (R.okMessage(mob, msg)) {
        R.send(mob, msg);
        R.show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> seem(s) much more likeable!"));
        beneficialAffect(mob, target, asLevel, 0);
      }
    } else
      return beneficialVisualFizzle(
          mob,
          target,
          L("<S-NAME> incant(s) gracefully to <T-NAMESELF>, but nothing more happens."));

    // return whether it worked
    return success;
  }
コード例 #2
0
 protected void clearWarrants(
     final MOB officer, final MOB invoker, final Room R, final Area A, final LegalBehavior B) {
   final List<LegalWarrant> warrants = B.getWarrantsOf(A, invoker);
   if ((warrants != null) && (warrants.size() > 0)) {
     boolean didSomething = false;
     for (LegalWarrant W : warrants) {
       if ((W.arrestingOfficer() == officer)
           && (System.currentTimeMillis() > W.getIgnoreUntilTime())) {
         if (W.state() != Law.STATE_SEEKING) didSomething = true;
         B.release(A, W);
       }
     }
     if (didSomething && (officer.location() == invoker.location())) {
       R.show(officer, invoker, CMMsg.MSG_HANDS, L("<S-NAME> wink(s) at <T-NAME>."));
     }
   }
 }
コード例 #3
0
 @Override
 public void spring(MOB mob) {
   final Room room = mob.location();
   if (room != null) {
     final Set<MOB> friendlySet = new HashSet<MOB>();
     if (invoker() != null) invoker().getGroupMembers(friendlySet);
     room.show(
         mob,
         affected,
         CMMsg.MSG_OK_ACTION,
         L("<T-NAME> explodes, spraying clumps of stomach acid everywhere!"));
     for (final Enumeration<MOB> m = room.inhabitants(); m.hasMoreElements(); ) {
       MOB M = m.nextElement();
       if ((M != null) && (!friendlySet.contains(M))) {
         final MOB invoker = (invoker() != null) ? invoker() : M;
         final int damage = CMLib.dice().roll(4, 5 + invoker.phyStats().level(), 0);
         CMLib.combat()
             .postDamage(
                 invoker,
                 M,
                 this,
                 damage,
                 CMMsg.MASK_MALICIOUS | CMMsg.MASK_ALWAYS | CMMsg.TYP_ACID,
                 Weapon.TYPE_MELTING,
                 L("The acid clumps <DAMAGE> <T-NAME>!"));
         if ((!M.isInCombat())
             && (M.isMonster())
             && (M != invoker)
             && (M.location() == invoker.location())
             && (M.location().isInhabitant(invoker))
             && (CMLib.flags().canBeSeenBy(invoker, M)))
           CMLib.combat().postAttack(M, invoker, M.fetchWieldedItem());
       }
     }
   }
   Physical affected = this.affected;
   unInvoke();
   if (affected instanceof Item) ((Item) affected).destroy();
 }
コード例 #4
0
ファイル: Spell_Slow.java プロジェクト: bozimmerman/CoffeeMud
  @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;
  }
コード例 #5
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if ((msg.target() == affected)
        && msg.isTarget(CMMsg.MASK_MALICIOUS)
        && CMLib.flags().isAPlant(msg.source())
        && (affected instanceof MOB)
        && (pointsRemaining >= 0)) {
      final MOB mob = (MOB) affected;
      final MOB plantMOB = msg.source();
      final Room R = plantMOB.location();
      if ((R != null) && (R == mob.location())) {
        if ((msg.isSource(CMMsg.TYP_ADVANCE)) && (--pointsRemaining >= 0)) {
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> struggle(s) against <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if (plantMOB.getVictim() == null) {
          plantMOB.setVictim(mob);
          if (mob.getVictim() == plantMOB) {
            if (mob.rangeToTarget() > 0) plantMOB.setRangeToTarget(mob.rangeToTarget());
            else {
              plantMOB.setRangeToTarget(R.maxRange());
              mob.setRangeToTarget(R.maxRange());
            }
          } else plantMOB.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if ((plantMOB.getVictim() == affected) && (plantMOB.rangeToTarget() <= 0)) {
          plantMOB.setRangeToTarget(R.maxRange());
          if (mob.getVictim() == plantMOB) mob.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        } else if ((mob.getVictim() == plantMOB) && (mob.rangeToTarget() <= 0)) {
          mob.setRangeToTarget(R.maxRange());
          if ((--pointsRemaining) < 0) {
            unInvoke();
            return true;
          }
          R.show(
              plantMOB,
              affected,
              CMMsg.MSG_OK_ACTION,
              L("<S-NAME> <S-IS-ARE> repelled by <T-YOUPOSS> anti-plant shell."));
          return false;
        }
      }
    } else if (msg.isSource(CMMsg.TYP_ADVANCE)
        && (msg.source() == affected)
        && (msg.source().getVictim() == msg.target())
        && (CMLib.flags().isAPlant((MOB) msg.target()))
        && (pointsRemaining >= 0)
        && (msg.source().rangeToTarget() == 1)) {
      final MOB plantM = msg.source().getVictim();
      if (plantM != null) {
        final Room R = plantM.location();
        if (R != null) {
          final CMMsg msg2 =
              CMClass.getMsg(
                  plantM,
                  msg.source(),
                  CMMsg.MSG_RETREAT,
                  L("<S-NAME> <S-IS-ARE> pushed back by <T-YOUPOSS> anti-plant shell."));
          if (R.okMessage(plantM, msg2)) R.send(plantM, msg2);
        }
      }
    }
    if (pointsRemaining < 0) {
      unInvoke();
      return true;
    }
    return true;
  }
コード例 #6
0
ファイル: Falling.java プロジェクト: bozimmerman/CoffeeMud
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (tickID != Tickable.TICKID_MOB) return true;

    if (affected == null) return false;
    if (--fallTickDown > 0) return true;
    fallTickDown = 1;

    int direction = Directions.DOWN;
    String addStr = L("down");
    if (reversed()) {
      direction = Directions.UP;
      addStr = L("upwards");
    }
    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if (mob == null) return false;
      if (mob.location() == null) return false;

      if (CMLib.flags().isInFlight(mob)) {
        damageToTake = 0;
        unInvoke();
        return false;
      } else if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
      else {
        if (mob.phyStats().weight() < 1) {
          mob.tell(L("\n\r\n\rYou are floating gently @x1.\n\r\n\r", addStr));
        } else {
          mob.tell(L("\n\r\n\rYOU ARE FALLING @x1!!\n\r\n\r", addStr.toUpperCase()));
          int damage =
              CMLib.dice()
                  .roll(
                      1,
                      (int)
                          Math.round(
                              CMath.mul(
                                  CMath.mul(mob.maxState().getHitPoints(), 0.1),
                                  CMath.div(mob.baseWeight(), 150.0))),
                      0);
          if (damage > (mob.maxState().getHitPoints() / 3))
            damage = (mob.maxState().getHitPoints() / 3);
          damageToTake = reversed() ? damage : (damageToTake + damage);
        }
        temporarilyDisable = true;
        CMLib.tracking().walk(mob, direction, false, false);
        temporarilyDisable = false;
        if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
        return true;
      }
    } else if (affected instanceof Item) {
      final Item item = (Item) affected;
      if ((room == null) && (item.owner() != null) && (item.owner() instanceof Room))
        room = (Room) item.owner();

      if ((room == null)
          || ((room != null) && (!room.isContent(item)))
          || (!CMLib.flags().isGettable(item))
          || (item.container() != null)
          || (CMLib.flags().isInFlight(item.ultimateContainer(null)))
          || (room.getRoomInDir(direction) == null)) {
        unInvoke();
        return false;
      }
      if (room.numItems() > 100) {
        fallTickDown = CMLib.dice().roll(1, room.numItems() / 50, 0);
        if ((--fallTickDown) > 0) return true;
      }
      final Room nextRoom = room.getRoomInDir(direction);
      if (canFallFrom(room, direction)) {
        room.show(invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls @x1.", addStr));
        nextRoom.moveItemTo(item, ItemPossessor.Expire.Player_Drop);
        room = nextRoom;
        nextRoom.show(
            invoker,
            null,
            item,
            CMMsg.MSG_OK_ACTION,
            L("<O-NAME> falls in from @x1.", (reversed() ? "below" : "above")));
        return true;
      }
      if (reversed()) return true;
      unInvoke();
      return false;
    }

    return false;
  }
コード例 #7
0
ファイル: Falling.java プロジェクト: bozimmerman/CoffeeMud
 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;
 }
コード例 #8
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    if ((auto || mob.isMonster())
        && ((commands.size() < 1) || (((String) commands.firstElement()).equals(mob.name())))) {
      commands.clear();
      if (mob.numItems() > 0) commands.addElement(mob.getRandomItem());
      commands.addElement(CMLib.map().getRandomArea().Name());
    }
    final Room oldRoom = mob.location();
    if (commands.size() < 2) {
      mob.tell(L("Teleport what object to what place or person?"));
      return false;
    }
    final String objectName = (String) commands.firstElement();
    final Item target = mob.findItem(null, objectName);
    if (target == null) {
      mob.tell(L("You don't seem to have an item '@x1'.", objectName));
      return false;
    }
    if (target.amWearingAt(Wearable.IN_INVENTORY)) {
      mob.tell(L("You seem to be wearing or holding the item '@x1'.", objectName));
      return false;
    }
    String searchWhat = null;
    if (commands.size() > 2) {
      final String s = (String) commands.elementAt(1);
      if (s.equalsIgnoreCase("room")) searchWhat = "R";
      if (s.equalsIgnoreCase("area")) searchWhat = "E";
      if (s.equalsIgnoreCase("mob")) searchWhat = "M";
      if (s.equalsIgnoreCase("monster")) searchWhat = "M";
      if (s.equalsIgnoreCase("player")) searchWhat = "P";
      if (s.equalsIgnoreCase("user")) searchWhat = "P";
      if (s.equalsIgnoreCase("item")) searchWhat = "I";
      if (s.equalsIgnoreCase("object")) searchWhat = "I";
      if (searchWhat != null) commands.removeElementAt(1);
    }
    if (searchWhat == null) searchWhat = "ERIPM";
    final String destinationString = CMParms.combine(commands, 1).trim().toUpperCase();
    final List<Room> candidates =
        CMLib.map().findWorldRoomsLiberally(mob, destinationString, searchWhat, 10, 600000);
    if (candidates.size() == 0) {
      mob.tell(L("You don't know of a place called '@x1'.", destinationString.toLowerCase()));
      return false;
    }

    if (CMLib.flags().isSitting(mob) || CMLib.flags().isSleeping(mob)) {
      mob.tell(L("You need to stand up!"));
      return false;
    }

    Room newRoom = null;
    int tries = 0;
    while ((tries < 20) && (newRoom == null)) {
      newRoom = candidates.get(CMLib.dice().roll(1, candidates.size(), -1));
      if (((newRoom.roomID().length() == 0) && (CMLib.dice().rollPercentage() > 50))
          || ((newRoom.domainType() == Room.DOMAIN_OUTDOORS_AIR)
              && (CMLib.dice().rollPercentage() > 10))) {
        newRoom = null;
        continue;
      }
      final CMMsg enterMsg =
          CMClass.getMsg(
              mob,
              newRoom,
              null,
              CMMsg.MSG_ENTER,
              null,
              CMMsg.MSG_ENTER,
              null,
              CMMsg.MSG_ENTER,
              null);
      if (!newRoom.okMessage(mob, enterMsg)) newRoom = null;
      tries++;
    }

    if ((newRoom == null) || (newRoom == oldRoom)) {
      mob.tell(L("Your magic seems unable to send anything there."));
      return false;
    }

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

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

    final CMMsg msg =
        CMClass.getMsg(
            mob,
            target,
            this,
            somanticCastCode(mob, target, auto),
            L("^S<S-NAME> invoke(s) a teleportation spell upon <T-NAME>.^?"));
    if (oldRoom.okMessage(mob, msg)) {
      oldRoom.send(mob, msg);
      newRoom.bringMobHere(mob, false);
      target.unWear();
      success = CMLib.commands().postDrop(mob, target, true, false, false) && (!mob.isMine(target));
      oldRoom.bringMobHere(mob, false);
      if (success) {
        oldRoom.show(mob, target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> vanishes!"));
        newRoom.showOthers(
            mob, target, null, CMMsg.MSG_OK_VISUAL, L("<T-NAME> appear(s) out of nowhere!"));
      } else mob.tell(L("Nothing happens."));
    }
    // return whether it worked
    return success;
  }
コード例 #9
0
ファイル: StdClanFlag.java プロジェクト: kingdavid127/MUD
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((clanID().length() > 0) && (msg.amITarget(this))) {
      if (msg.source().getClanRole(clanID()) == null) {
        if ((msg.targetMinor() == CMMsg.TYP_GET)
            || (msg.targetMinor() == CMMsg.TYP_PUSH)
            || (msg.targetMinor() == CMMsg.TYP_PULL)
            || (msg.targetMinor() == CMMsg.TYP_CAST_SPELL)) {
          final Room R = CMLib.map().roomLocation(this);
          if (CMLib.clans().findRivalrousClan(msg.source()) == null) {
            msg.source().tell(L("You must belong to an elligible clan to take a clan item."));
            return false;
          } else if (R != null) {
            for (int i = 0; i < R.numInhabitants(); i++) {
              final MOB M = R.fetchInhabitant(i);
              if ((M != null)
                  && (M.isMonster())
                  && (M.getClanRole(clanID()) != null)
                  && (CMLib.flags().aliveAwakeMobileUnbound(M, true))
                  && (CMLib.flags().canBeSeenBy(this, M))
                  && (!CMLib.flags().isAnimalIntelligence(M))) {
                R.show(
                    M, null, CMMsg.MSG_QUIETMOVEMENT, L("<S-NAME> guard(s) @x1 closely.", name()));
                return false;
              }
            }
            String rulingClan = "";
            final LegalBehavior B = CMLib.law().getLegalBehavior(R);
            if (B != null) rulingClan = B.rulingOrganization();
            if (msg.source().getClanRole(rulingClan) == null) {
              msg.source()
                  .tell(L("You must conquer and fully control this area to take the clan flag."));
              return false;
            }
            if ((B != null) && (!B.isFullyControlled())) {
              msg.source().tell(L("Your clan does not yet fully control the area."));
              return false;
            }
          }
        } else if ((msg.targetMinor() == CMMsg.TYP_DROP)
            && (!CMath.bset(msg.targetMajor(), CMMsg.MASK_INTERMSG))) {
          final Room R = msg.source().location();
          LandTitle T = null;
          Area A = null;
          LegalBehavior B = null;
          if (R != null) {
            A = R.getArea();
            T = CMLib.law().getLandTitle(R);
          }
          if ((T == null)
              || ((!T.getOwnerName().equals(clanID()))
                  && ((!T.getOwnerName().equals(msg.source().getLiegeID()))
                      || (!msg.source().isMarriedToLiege()))
                  && (!T.getOwnerName().equals(msg.source().Name())))) {
            boolean ok = false;
            if (A != null) {
              B = CMLib.law().getLegalBehavior(R);
              if (B != null) ok = B.controlPoints() > 0;
            }
            if (!ok) {
              msg.source()
                  .tell(
                      L("You can not place a flag here, this place is controlled by the Archons."));
              return false;
            }
          }
        }
      } else if ((msg.targetMinor() == CMMsg.TYP_GET)
          && (msg.source().location() != null)
          && (msg.source().isMonster())) {
        boolean foundOne = false;
        for (int i = 0; i < msg.source().location().numInhabitants(); i++) {
          final MOB M = msg.source().location().fetchInhabitant(i);
          if ((M != null) && (!M.isMonster()) && (M.getClanRole(clanID()) != null)) {
            foundOne = true;
            break;
          }
        }
        if (!foundOne) {
          msg.source().tell(L("You are guarding @x1 too closely.", name()));
          return false;
        }
      }
    }

    if (StdClanItem.stdOkMessage(this, msg)) {
      if ((clanID().length() > 0)
          && (msg.amITarget(this))
          && (msg.targetMinor() == CMMsg.TYP_DROP)) {
        final LegalBehavior B = CMLib.law().getLegalBehavior(msg.source().location());
        final String rulingClan = (B != null) ? B.rulingOrganization() : "";
        if (rulingClan.length() == 0)
          msg.source()
              .tell(
                  L("Area '@x1' is presently neutral.", msg.source().location().getArea().name()));
        else {
          msg.source()
              .tell(
                  L(
                      "Area '@x1' is presently controlled by @x2.",
                      msg.source().location().getArea().name(),
                      rulingClan));
          if (!rulingClan.equals(clanID())) {
            int relation = Clan.REL_WAR;
            final Clan C = CMLib.clans().getClan(clanID());
            if (C == null) {
              msg.source().tell(L("This ancient relic from a lost clan fades out of existence."));
              this.destroy();
              return false;
            }
            relation = C.getClanRelations(rulingClan);
            if (relation != Clan.REL_WAR) {
              msg.source()
                  .tell(
                      L("You must be at war with this clan to put down your flag on their area."));
              return false;
            }
          }
        }
      }
      return super.okMessage(myHost, msg);
    }
    return false;
  }