コード例 #1
1
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;

    // when this spell is on a MOBs Affected list,
    // it should consistantly prevent the mob
    // from trying to do ANYTHING except sleep
    if ((msg.amITarget(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.source() == mob.amFollowing())) unInvoke();
    if ((msg.amISource(mob))
        && (CMath.bset(msg.targetMajor(), CMMsg.MASK_MALICIOUS))
        && (msg.target() == mob.amFollowing())) {
      mob.tell(L("You like @x1 too much.", mob.amFollowing().charStats().himher()));
      return false;
    } else if ((msg.amISource(mob))
        && (!mob.isMonster())
        && (msg.target() instanceof Room)
        && ((msg.targetMinor() == CMMsg.TYP_LEAVE) || (msg.sourceMinor() == CMMsg.TYP_RECALL))
        && (mob.amFollowing() != null)
        && (((Room) msg.target()).isInhabitant(mob.amFollowing()))) {
      mob.tell(L("You don't want to leave your friend."));
      return false;
    } else if ((msg.amISource(mob))
        && (mob.amFollowing() != null)
        && (msg.sourceMinor() == CMMsg.TYP_NOFOLLOW)) {
      mob.tell(L("You like @x1 too much.", mob.amFollowing().name()));
      return false;
    }

    return super.okMessage(myHost, msg);
  }
コード例 #2
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   if ((affecting() == null) || (!(affecting() instanceof MOB))) return false;
   final MOB mob = (MOB) affecting();
   if ((affected == mob)
       && (mob != getCharmer())
       && ((mob.amFollowing() == null) || (mob.amFollowing() != getCharmer()))
       && (mob.location() != null)
       && (mob.location().isInhabitant(getCharmer())))
     CMLib.commands().postFollow(mob, getCharmer(), true);
   return super.tick(ticking, tickID);
 }
コード例 #3
0
ファイル: Chant_AnimalSpy.java プロジェクト: Cocanuta/Marble
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (affected == spy)) {
     if (spy.amDead()
         || (spy.amFollowing() != invoker)
         || (!CMLib.flags().isInTheGame(spy, false))) unInvoke();
   }
   return true;
 }
コード例 #4
0
ファイル: Follow.java プロジェクト: Cocanuta/Marble
 public boolean nofollow(MOB mob, boolean errorsOk, boolean quiet) {
   if (mob == null) return false;
   Room R = mob.location();
   if (R == null) return false;
   if (mob.amFollowing() != null) {
     CMMsg msg =
         CMClass.getMsg(
             mob,
             mob.amFollowing(),
             null,
             CMMsg.MSG_NOFOLLOW,
             quiet ? null : "<S-NAME> stop(s) following <T-NAMESELF>.");
     // no room OKaffects, since the damn leader may not be here.
     if (mob.okMessage(mob, msg)) R.send(mob, msg);
     else return false;
   } else if (errorsOk) mob.tell("You aren't following anyone!");
   return true;
 }
コード例 #5
0
ファイル: Chant_AnimalSpy.java プロジェクト: Cocanuta/Marble
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {

    if (commands.size() < 1) {
      mob.tell("Chant to whom?");
      return false;
    }
    String mobName = CMParms.combine(commands, 0).trim().toUpperCase();
    MOB target = getTarget(mob, commands, givenTarget);

    Room newRoom = mob.location();
    if (target != null) {
      newRoom = target.location();
      if ((!CMLib.flags().isAnimalIntelligence(target)) || (target.amFollowing() != mob)) {
        mob.tell("You have no animal follower named '" + mobName + "' here.");
        return false;
      }
    } else {
      mob.tell("You have no animal follower named '" + mobName + "' here.");
      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,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto
                  ? ""
                  : "^S<S-NAME> chant(s) to <T-NAMESELF>, invoking the a mystical connection.^?");
      CMMsg msg2 = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), null);
      if ((mob.location().okMessage(mob, msg))
          && ((newRoom == mob.location()) || (newRoom.okMessage(mob, msg2)))) {
        mob.location().send(mob, msg);
        if (newRoom != mob.location()) newRoom.send(target, msg2);
        spy = target;
        beneficialAffect(mob, spy, asLevel, 0);
        Ability A = spy.fetchEffect(ID());
        if (A != null) {
          mob.addNonUninvokableEffect((Ability) A.copyOf());
          A.setAffectedOne(spy);
        }
      }

    } else
      beneficialVisualFizzle(
          mob, target, "<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades.");

    // return whether it worked
    return success;
  }
コード例 #6
0
 @Override
 public boolean tick(Tickable ticking, int tickID) {
   int tickSet = super.tickDown;
   if (!super.tick(ticking, tickID)) return false;
   if (ticking instanceof MOB) {
     final MOB mob = (MOB) ticking;
     if (mob.amFollowing() != null) super.tickDown = tickSet;
   }
   return true;
 }
コード例 #7
0
ファイル: Chant_AnimalSpy.java プロジェクト: Cocanuta/Marble
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    try {
      super.executeMsg(myHost, msg);
      if (spy == null) return;
      if (invoker == null) return;

      if ((msg.amISource(spy))
          && ((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
          && (msg.target() != null)
          && ((invoker.location() != spy.location()) || (!(msg.target() instanceof Room)))) {
        disable = true;
        CMMsg newAffect = CMClass.getMsg(invoker, msg.target(), msg.sourceMinor(), null);
        msg.target().executeMsg(invoker, newAffect);
      } else if ((!msg.amISource(invoker))
          && (invoker.location() != spy.location())
          && (msg.source().location() == spy.location())
          && (msg.othersCode() != CMMsg.NO_EFFECT)
          && (msg.othersMessage() != null)
          && (!disable)) {
        disable = true;
        invoker.executeMsg(invoker, msg);
      } else if (msg.amISource(invoker)
          && (!disable)
          && (msg.sourceMinor() == CMMsg.TYP_SPEAK)
          && (msg.sourceMessage() != null)
          && ((msg.sourceMajor() & CMMsg.MASK_MAGIC) == 0)) {
        int start = msg.sourceMessage().indexOf("\'");
        int end = msg.sourceMessage().lastIndexOf("\'");
        if ((start > 0) && (end > start)) {
          String msg2 = msg.sourceMessage().substring(start + 1, end).trim();
          if (msg2.length() > 0)
            spy.enqueCommand(CMParms.parse(msg2.trim()), Command.METAFLAG_FORCED, 0);
        }
      }
    } finally {
      disable = false;
      if ((spy != null)
          && ((spy.amFollowing() != invoker)
              || (spy.amDead())
              || (!CMLib.flags().isInTheGame(spy, false))
              || (!CMLib.flags().isInTheGame(invoker, true)))) unInvoke();
    }
  }
コード例 #8
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = this.getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if ((!target.charStats().getMyRace().racialCategory().equals("Earth Elemental"))
        && (!target.charStats().getMyRace().racialCategory().equals("Stone Golem"))
        && (!target.charStats().getMyRace().racialCategory().equals("Metal Golem"))) {
      mob.tell(L("@x1 is not an stone/metal golem or earth elemental!", target.name(mob)));
      return false;
    }

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

    // now see if it worked
    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final String str = auto ? "" : L("^S<S-NAME> chant(s) at <T-NAMESELF>.^?");
      final CMMsg msg = CMClass.getMsg(mob, target, this, verbalCastCode(mob, target, auto), str);
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          success = maliciousAffect(mob, target, asLevel, 0, -1) != null;
          if (success) {
            if (target.isInCombat()) target.makePeace();
            CMLib.commands().postFollow(target, mob, false);
            CMLib.combat().makePeaceInGroup(mob);
            if (target.amFollowing() != mob)
              mob.tell(L("@x1 seems unwilling to follow you.", target.name(mob)));
          }
        }
      }
    }
    if (!success)
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) at <T-NAMESELF>, but nothing happens."));

    // return whether it worked
    return success;
  }
コード例 #9
0
  @Override
  public void unInvoke() {
    // undo the affects of this spell
    if (!(affected instanceof MOB)) return;
    final MOB mob = (MOB) affected;

    super.unInvoke();

    if ((canBeUninvoked()) && (!mob.amDead())) {
      mob.location().show(mob, null, CMMsg.MSG_OK_VISUAL, L("<S-YOUPOSS> free-will returns."));
      if (mob.amFollowing() != null) CMLib.commands().postFollow(mob, null, false);
      CMLib.commands().postStand(mob, true);
      if (mob.isMonster()) {
        if ((CMLib.dice().rollPercentage() > 50)
            || ((mob.getStartRoom() != null)
                && (mob.getStartRoom().getArea() != mob.location().getArea())
                && (CMLib.flags().isAggressiveTo(mob, null)
                    || (invoker == null)
                    || (!mob.location().isInhabitant(invoker)))))
          CMLib.tracking().wanderAway(mob, true, true);
        else if ((invoker != null) && (invoker != mob)) mob.setVictim(invoker);
      }
    }
  }
コード例 #10
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    final Physical target = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_ANY, true);
    if (target == null) return false;

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

    int type = verbalCastCode(mob, target, auto);
    if ((target instanceof MOB)
        && (CMath.bset(type, CMMsg.MASK_MALICIOUS))
        && (((MOB) target).charStats().getStat(CharStats.STAT_AGE) > 0)) {
      final MOB mobt = (MOB) target;
      if (mobt.charStats().ageCategory() <= Race.AGE_CHILD)
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.getLiegeID().equals(mob.Name())) || (mobt.amFollowing() == mob))
        type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
      else if ((mobt.charStats().ageCategory() <= Race.AGE_MATURE)
          && (mobt.getLiegeID().length() > 0)) type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    if ((target instanceof Item)
        || ((target instanceof MOB)
            && (((MOB) target).isMonster())
            && (CMLib.flags().isAnimalIntelligence((MOB) target))
            && (CMLib.law().doesHavePriviledgesHere(mob, mob.location())))) {
      type = CMath.unsetb(type, CMMsg.MASK_MALICIOUS);
    }

    boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob, target, this, type, auto ? "" : L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        final Ability A = target.fetchEffect("Age");
        if ((!(target instanceof MOB)) && (!(target instanceof CagedAnimal)) && (A == null)) {
          if (target instanceof Food) {
            mob.tell(L("@x1 rots away!", target.name(mob)));
            ((Item) target).destroy();
          } else if (target instanceof Item) {
            switch (((Item) target).material() & RawMaterial.MATERIAL_MASK) {
              case RawMaterial.MATERIAL_CLOTH:
              case RawMaterial.MATERIAL_FLESH:
              case RawMaterial.MATERIAL_LEATHER:
              case RawMaterial.MATERIAL_PAPER:
              case RawMaterial.MATERIAL_VEGETATION:
              case RawMaterial.MATERIAL_WOODEN:
                {
                  mob.location()
                      .showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 rots away!", target.name()));
                  if (target instanceof Container) ((Container) target).emptyPlease(false);
                  ((Item) target).destroy();
                  break;
                }
              default:
                mob.location()
                    .showHappens(
                        CMMsg.MSG_OK_VISUAL,
                        L("@x1 ages, but nothing happens to it.", target.name()));
                break;
            }
          } else
            mob.location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("@x1 ages, but nothing happens to it.", target.name()));
          success = false;
        } else if ((target instanceof MOB) && ((A == null) || (A.displayText().length() == 0))) {
          final MOB M = (MOB) target;
          mob.location().show(M, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          if (M.baseCharStats().getStat(CharStats.STAT_AGE) <= 0)
            M.setAgeMinutes(M.getAgeMinutes() + (M.getAgeMinutes() / 10));
          else if ((M.playerStats() != null) && (M.playerStats().getBirthday() != null)) {
            final TimeClock C = CMLib.time().localClock(M.getStartRoom());
            final double aging = CMath.mul(M.baseCharStats().getStat(CharStats.STAT_AGE), .10);
            int years = (int) Math.round(Math.floor(aging));
            final int monthsInYear = C.getMonthsInYear();
            int months = (int) Math.round(CMath.mul(aging - Math.floor(aging), monthsInYear));
            if ((years <= 0) && (months == 0)) months++;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR] -= years;
            M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] -= months;
            if (M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] < 1) {
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_YEAR]--;
              years++;
              M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH] =
                  monthsInYear + M.playerStats().getBirthday()[PlayerStats.BIRTHDEX_MONTH];
            }
            M.baseCharStats()
                .setStat(CharStats.STAT_AGE, M.baseCharStats().getStat(CharStats.STAT_AGE) + years);
          }
          M.recoverPhyStats();
          M.recoverCharStats();
        } else if (A != null) {
          final long start = CMath.s_long(A.text());
          long age = System.currentTimeMillis() - start;
          final long millisPerMudday =
              CMProps.getIntVar(CMProps.Int.TICKSPERMUDDAY) * CMProps.getTickMillis();
          if (age < millisPerMudday) age = millisPerMudday;
          final long millisPerMonth = CMLib.time().globalClock().getDaysInMonth() * millisPerMudday;
          final long millisPerYear = CMLib.time().globalClock().getMonthsInYear() * millisPerMonth;
          long ageBy = age / 10;
          if (ageBy < millisPerMonth) ageBy = millisPerMonth + 1;
          else if (ageBy < millisPerYear) ageBy = millisPerYear + 1;
          A.setMiscText("" + (start - ageBy));
          if (target instanceof MOB)
            mob.location()
                .show((MOB) target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> age(s) a bit."));
          else mob.location().showHappens(CMMsg.MSG_OK_VISUAL, L("@x1 ages a bit.", target.name()));
          target.recoverPhyStats();
        } else
          return beneficialWordsFizzle(
              mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
      }
    } else if (CMath.bset(type, CMMsg.MASK_MALICIOUS))
      return maliciousFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
    else
      return beneficialWordsFizzle(
          mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));

    // return whether it worked
    return success;
  }
コード例 #11
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    tickStatus = Tickable.STATUS_MISC + 0;
    super.tick(ticking, tickID);

    tickStatus = Tickable.STATUS_MISC + 1;
    if (tickID != Tickable.TICKID_MOB) {
      tickStatus = Tickable.STATUS_NOT;
      return true;
    }
    if (!canFreelyBehaveNormal(ticking)) {
      tickStatus = Tickable.STATUS_NOT;
      return true;
    }
    final MOB mob = (MOB) ticking;

    // ridden things dont wander!
    if (ticking instanceof Rideable)
      if (((Rideable) ticking).numRiders() > 0) {
        tickStatus = Tickable.STATUS_NOT;
        return true;
      }
    tickStatus = Tickable.STATUS_MISC + 2;
    if (((mob.amFollowing() != null) && (mob.location() == mob.amFollowing().location()))
        || (!CMLib.flags().canTaste(mob))) {
      tickStatus = Tickable.STATUS_NOT;
      return true;
    }

    tickStatus = Tickable.STATUS_MISC + 3;
    final Room thisRoom = mob.location();
    MOB victim = GoodGuardian.anyPeaceToMake(mob.location(), mob);
    GoodGuardian.keepPeace(mob, victim);
    victim = null;
    int dirCode = -1;
    tickStatus = Tickable.STATUS_MISC + 4;
    for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
      tickStatus = Tickable.STATUS_MISC + 5 + d;
      final Room room = thisRoom.getRoomInDir(d);
      final Exit exit = thisRoom.getExitInDir(d);
      if ((room != null) && (exit != null) && (okRoomForMe(mob, thisRoom, room, false))) {
        tickStatus = Tickable.STATUS_MISC + 20 + d;
        if (exit.isOpen()) {
          tickStatus = Tickable.STATUS_MISC + 40 + d;
          victim = GoodGuardian.anyPeaceToMake(room, mob);
          if (victim != null) {
            dirCode = d;
            break;
          }
          tickStatus = Tickable.STATUS_MISC + 60 + d;
        }
        tickStatus = Tickable.STATUS_MISC + 80 + d;
      }
      if (dirCode >= 0) break;
      tickStatus = Tickable.STATUS_MISC + 100 + d;
    }
    tickStatus = Tickable.STATUS_MISC + 120;
    if ((dirCode >= 0) && (!CMSecurity.isDisabled(CMSecurity.DisFlag.MOBILITY))) {
      tickStatus = Tickable.STATUS_MISC + 121;
      CMLib.tracking().walk(mob, dirCode, false, false);
      tickStatus = Tickable.STATUS_MISC + 122;
      GoodGuardian.keepPeace(mob, victim);
      tickStatus = Tickable.STATUS_MISC + 123;
    }
    tickStatus = Tickable.STATUS_NOT;
    return true;
  }