Esempio n. 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);
  }
Esempio n. 2
0
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!super.okMessage(myHost, msg)) return false;
   if (affected == null) return true;
   MOB mob = (MOB) affected;
   if ((msg.amISource(mob))
       && (mob.location() != null)
       && (msg.target() != null)
       && (msg.target() instanceof Room)) {
     if ((msg.sourceMinor() == CMMsg.TYP_ENTER)
         && ((mob.location().domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
             || (mob.location().domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))
         && (msg.target() == mob.location().getRoomInDir(Directions.UP))) {
       msg.source()
           .tell("Your water walking magic prevents you from ascending from the water surface.");
       return false;
     } else if ((msg.sourceMinor() == CMMsg.TYP_LEAVE)
         && (mob.location().domainType() != Room.DOMAIN_OUTDOORS_WATERSURFACE)
         && (mob.location().domainType() != Room.DOMAIN_INDOORS_WATERSURFACE)
         && (msg.tool() != null)
         && (msg.tool() instanceof Exit)) {
       for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) {
         Room R = mob.location().getRoomInDir(d);
         if ((R != null)
             && (mob.location().getReverseExit(d) == msg.tool())
             && ((R.domainType() == Room.DOMAIN_OUTDOORS_WATERSURFACE)
                 || (R.domainType() == Room.DOMAIN_INDOORS_WATERSURFACE))) {
           triggerNow = true;
           msg.source().recoverEnvStats();
           return true;
         }
       }
     }
   }
   return true;
 }
Esempio n. 3
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((myHost != null) && (myHost instanceof MOB) && (msg.amISource((MOB) myHost))) {
     if (((msg.targetMinor() == CMMsg.TYP_LEAVE)
         || (msg.sourceMinor() == CMMsg.TYP_ADVANCE)
         || (msg.sourceMinor() == CMMsg.TYP_RETREAT)
         || (msg.sourceMinor() == CMMsg.TYP_RECALL))) {
       msg.source().tell(L("You can't really go anywhere -- you're a rock!"));
       return false;
     }
   } else if (((msg.targetMajor() & CMMsg.MASK_MALICIOUS) > 0)
       && (myHost instanceof MOB)
       && (msg.amITarget(myHost))
       && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_ALWAYS))) {
     final MOB target = (MOB) msg.target();
     if ((!target.isInCombat())
         && (msg.source().isMonster())
         && (msg.source().location() == target.location())
         && (msg.source().getVictim() != target)) {
       msg.source().tell(L("Attack a rock?!"));
       if (target.getVictim() == msg.source()) {
         target.makePeace();
         target.setVictim(null);
       }
       return false;
     }
   }
   return super.okMessage(myHost, msg);
 }
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((affected instanceof MOB)
        && (msg.amISource((MOB) affected))
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.tool() instanceof Weapon)
        && (msg.value() > 0)
        && (msg.target() instanceof MOB)
        && (((Weapon) msg.tool()).weaponClassification() == Weapon.CLASS_THROWN)) {
      if (CMLib.dice().rollPercentage() < 25) helpProficiency((MOB) affected, 0);
      final CMMsg msg2 =
          CMClass.getMsg(
              (MOB) msg.target(),
              msg.tool(),
              this,
              CMMsg.MSG_OK_VISUAL,
              L("^F^<FIGHT^><T-NAME> fragment(s) in <S-NAME>!^</FIGHT^>^?"));
      CMLib.color().fixSourceFightColor(msg2);
      msg.addTrailerMsg(msg2);
      msg.setValue(
          msg.value()
              + (int)
                  Math.round(
                      CMath.mul(
                          3.0 * msg.value(),
                          CMath.div(proficiency(), 100.0 - (10.0 * getXLEVELLevel(invoker()))))));
    }

    return super.okMessage(myHost, msg);
  }
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((affected instanceof MOB)
       && (msg.amISource((MOB) affected))
       && (msg.sourceMinor() == CMMsg.TYP_QUIT)) unInvoke();
   else if (msg.sourceMinor() == CMMsg.TYP_SHUTDOWN) unInvoke();
   return super.okMessage(myHost, msg);
 }
Esempio n. 6
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return true;

    final MOB mob = (MOB) affected;
    if (msg.amISource(mob)
        && ((msg.sourceMinor() == CMMsg.TYP_SIT) || (msg.sourceMinor() == CMMsg.TYP_SLEEP))) {
      mob.tell(L("You're too caffeinated for that!"));
      return false;
    }
    return true;
  }
 @Override
 public boolean okMessage(Environmental host, CMMsg msg) {
   if ((affected instanceof MOB)
       && (msg.amISource((MOB) affected))
       && (msg.sourceMinor() == CMMsg.TYP_REBUKE)
       && (msg.target() != null)
       && ((msg.target() == invoker()) || (msg.target().Name().equals(godName)))) {
     msg.source().tell(L("Your faith is too undeniable."));
     return false;
   }
   return super.okMessage(host, msg);
 }
Esempio n. 8
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((whom != null)
       && (song == null)
       && (msg.amISource(whom))
       && (CMLib.flags().canBeSeenBy(whom, invoker()))) {
     if (trail == null) trail = new StringBuffer("");
     ensureCmds();
     if (cmds.containsKey("" + msg.sourceMinor())) trail.append(msg.sourceMinor() + ";");
   }
   super.executeMsg(myHost, msg);
 }
Esempio n. 9
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((myHost != null) && (myHost instanceof MOB) && (msg.amISource((MOB) myHost))) {
     if (((msg.targetMinor() == CMMsg.TYP_LEAVE)
         || (msg.sourceMinor() == CMMsg.TYP_ADVANCE)
         || (msg.sourceMinor() == CMMsg.TYP_RETREAT))) {
       msg.source().tell(L("You can't really go anywhere -- you are rooted!"));
       return false;
     }
   }
   return super.okMessage(myHost, msg);
 }
Esempio n. 10
0
  @Override
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    super.executeMsg(myHost, msg);
    // the sex rules
    if (!(affected instanceof MOB)) return;

    final MOB myChar = (MOB) affected;
    if (msg.target() instanceof MOB) {
      final MOB mate = (MOB) msg.target();
      if ((msg.amISource(myChar))
          && (msg.tool() instanceof Social)
          && (msg.tool().Name().equals("MATE <T-NAME>") || msg.tool().Name().equals("SEX <T-NAME>"))
          && (msg.sourceMinor() != CMMsg.TYP_CHANNEL)
          && (myChar.charStats().getStat(CharStats.STAT_GENDER)
              != mate.charStats().getStat(CharStats.STAT_GENDER))
          && ((mate.charStats().getStat(CharStats.STAT_GENDER) == ('M'))
              || (mate.charStats().getStat(CharStats.STAT_GENDER) == ('F')))
          && ((myChar.charStats().getStat(CharStats.STAT_GENDER) == ('M'))
              || (myChar.charStats().getStat(CharStats.STAT_GENDER) == ('F')))
          && (!mate.charStats().getMyRace().canBreedWith(myChar.charStats().getMyRace()))
          && (myChar.location() == mate.location())
          && (myChar
                  .fetchWornItems(
                      Wearable.WORN_LEGS | Wearable.WORN_WAIST, (short) -2048, (short) 0)
                  .size()
              == 0)
          && (mate.fetchWornItems(
                      Wearable.WORN_LEGS | Wearable.WORN_WAIST, (short) -2048, (short) 0)
                  .size()
              == 0)
          && ((mate.charStats().getStat(CharStats.STAT_AGE) == 0)
              || ((mate.charStats().ageCategory() > Race.AGE_CHILD)
                  && (mate.charStats().ageCategory() < Race.AGE_OLD)))
          && ((myChar.charStats().getStat(CharStats.STAT_AGE) == 0)
              || ((myChar.charStats().ageCategory() > Race.AGE_CHILD)
                  && (myChar.charStats().ageCategory() < Race.AGE_OLD)))) {
        MOB female = myChar;
        MOB male = mate;
        if ((mate.charStats().getStat(CharStats.STAT_GENDER) == ('F'))) {
          female = mate;
          male = myChar;
        }
        final Ability A = CMClass.getAbility("Pregnancy");
        if ((A != null)
            && (female.fetchAbility(A.ID()) == null)
            && (female.fetchEffect(A.ID()) == null)) {
          A.invoke(male, female, true, 0);
          unInvoke();
        }
      }
    }
  }
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (affected == null) return super.okMessage(myHost, msg);

    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if ((msg.amITarget(mob))
          && (!msg.amISource(mob))
          && (mob.location() != msg.source().location())
          && (msg.tool() instanceof Ability)
          && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING))
          && (!mob.amDead())) {
        final Ability A = (Ability) msg.tool();
        if (((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_CHANT)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_PRAYER)
            || ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SONG))
          msg.source()
              .location()
              .showHappens(
                  CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!"));
        return false;
      }
    } else if (affected instanceof Room) {
      final Room R = (Room) affected;
      if ((msg.tool() instanceof Ability)
          && (msg.source().location() != null)
          && (msg.sourceMinor() != CMMsg.TYP_LEAVE)) {
        final boolean summon = CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_SUMMONING);
        final boolean teleport =
            CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING);
        final boolean shere =
            (msg.source().location() == affected)
                || ((affected instanceof Area)
                    && (((Area) affected).inMyMetroArea(msg.source().location().getArea())));
        if ((!shere)
            && (!summon)
            && (teleport)
            && (!CMLib.law().doesHavePriviledgesHere(msg.source(), R))) {
          if ((msg.source().location() != null) && (msg.source().location() != R))
            msg.source()
                .location()
                .showHappens(
                    CMMsg.MSG_OK_VISUAL, L("Magical energy fizzles and is absorbed into the air!"));
          R.showHappens(
              CMMsg.MSG_OK_VISUAL, L("Magic energy fizzles and is absorbed into the air."));
          return false;
        }
      }
    }
    return super.okMessage(myHost, msg);
  }
Esempio n. 12
0
  @Override
  public void executeMsg(final Environmental myHost, final CMMsg msg) {
    super.executeMsg(myHost, msg);
    if (!(affected instanceof MOB)) return;
    final MOB mob = (MOB) affected;

    if ((msg.amISource(mob))
        && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_CHANNEL))
        && ((CMath.bset(msg.sourceMajor(), CMMsg.MASK_MOVE))
            || (CMath.bset(msg.sourceMajor(), CMMsg.MASK_HANDS))
            || (CMath.bset(msg.sourceMajor(), CMMsg.MASK_MOUTH)))) unInvoke();
    return;
  }
Esempio n. 13
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((affected != null) && (affected instanceof MOB) && (msg.amISource((MOB) affected))) {
     if (msg.sourceMinor() == CMMsg.TYP_RECALL) {
       damageToTake = 0;
       unInvoke();
     } else if ((msg.tool() instanceof Ability)
         && (CMath.bset(((Ability) msg.tool()).flags(), Ability.FLAG_TRANSPORTING))) {
       damageToTake = 0;
       unInvoke();
     }
   }
 }
Esempio n. 14
0
 @Override
 public void executeMsg(Environmental host, CMMsg msg) {
   if (host instanceof MOB) {
     final MOB myChar = (MOB) host;
     if (msg.amISource(myChar)
         && (msg.tool() instanceof Ability)
         && (!myChar.isMonster())
         && (msg.sourceMinor() == CMMsg.TYP_PREINVOKE)
         && (myChar.isMine(msg.tool()))
         && (myChar.charStats().getClassLevel(this) >= 30)
         && (CMLib.ableMapper().getQualifyingLevel(ID(), true, msg.tool().ID()) < 1))
       invokable = new WeakReference(msg.tool());
   }
   super.executeMsg(host, msg);
   Bard.visitationBonusMessage(host, msg);
 }
Esempio n. 15
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);

    final MOB myChar = (MOB) myHost;
    if (msg.tool() instanceof Ability) {
      if (msg.amISource(myChar)
          && (!myChar.isMonster())
          && (msg.sourceMinor() != CMMsg.TYP_PREINVOKE)) {
        final WeakReference<Ability> curRef = invokable;
        if ((curRef != null) && (msg.tool() == curRef.get())) {
          curRef.clear();
          final Ability A = ((Ability) msg.tool());
          final int[] usageCost = A.usageCost(myChar, false);
          if (CMath.bset(A.usageType(), Ability.USAGE_MANA))
            myChar.curState().adjMana(usageCost[Ability.USAGEINDEX_MANA] / 4, myChar.maxState());
          if (CMath.bset(A.usageType(), Ability.USAGE_MOVEMENT))
            myChar
                .curState()
                .adjMovement(usageCost[Ability.USAGEINDEX_MOVEMENT] / 4, myChar.maxState());
          if (CMath.bset(A.usageType(), Ability.USAGE_HITPOINTS))
            myChar
                .curState()
                .adjHitPoints(usageCost[Ability.USAGEINDEX_HITPOINTS] / 4, myChar.maxState());
        }
      } else if (msg.amITarget(myChar)) {
        if (((((Ability) msg.tool()).classificationCode() & Ability.ALL_ACODES)
                == Ability.ACODE_SPELL)
            && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_DOMAINS)
                == Ability.DOMAIN_DIVINATION)
            && (CMLib.dice().roll(1, 100, 0) < (myChar.charStats().getClassLevel(this) * 4))) {
          myChar
              .location()
              .show(
                  msg.source(),
                  myChar,
                  CMMsg.MSG_OK_ACTION,
                  L(
                      "<T-NAME> fool(s) <S-NAMESELF>, causing <S-HIM-HER> to fizzle @x1.",
                      msg.tool().name()));
          return false;
        }
      }
    }
    return super.okMessage(myHost, msg);
  }
Esempio n. 16
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!(affected instanceof MOB)) return super.okMessage(myHost, msg);
    final MOB mob = (MOB) affected;

    if ((msg.amISource(mob)
        && (!msg.sourceMajor(CMMsg.MASK_ALWAYS))
        && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_CHANNEL))
        && (msg.sourceMajor() > 0))) {
      if (roundsHibernating < 10) {
        mob.tell(L("You can't withdraw from hibernation just yet."));
        return false;
      }
      unInvoke();
    }
    return super.okMessage(myHost, msg);
  }
Esempio n. 17
0
 public boolean okMessage(Environmental myHost, CMMsg msg) {
   if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);
   MOB myChar = (MOB) myHost;
   if ((msg.tool() == null) || (!(msg.tool() instanceof Ability)))
     return super.okMessage(myChar, msg);
   if (msg.amISource(myChar) && (myChar.isMine(msg.tool()))) {
     if ((msg.sourceMinor() == CMMsg.TYP_CAST_SPELL)
         && (!CMLib.ableMapper().getDefaultGain(ID(), true, msg.tool().ID()))) {
       if (CMLib.dice().rollPercentage()
           > (myChar.charStats().getStat(CharStats.STAT_INTELLIGENCE)
               * ((myChar.charStats().getCurrentClass().ID().equals(ID())) ? 1 : 2))) {
         myChar.location().show(myChar, null, CMMsg.MSG_OK_VISUAL, "<S-NAME> fizzle(s) a spell.");
         return false;
       }
     }
   }
   return super.okMessage(myChar, msg);
 }
Esempio n. 18
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")) {

      }
    }
  }
Esempio n. 19
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if ((myHost == null) || (!(myHost instanceof MOB))) return super.okMessage(myHost, msg);

    final MOB mob = (MOB) myHost;
    if ((msg.amISource(mob)) && (mob.charStats().getClassLevel(this) > 4)) {
      if (((msg.sourceMinor() == CMMsg.TYP_BUY) || (msg.sourceMinor() == CMMsg.TYP_LIST))
          && (msg.tool() instanceof Potion)) {
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() | PhyStats.IS_BONUS);
        mob.recoverPhyStats();
        mob.recoverCharStats();
      } else if ((mob.basePhyStats().disposition() & PhyStats.IS_BONUS) == PhyStats.IS_BONUS) {
        mob.basePhyStats().setDisposition(mob.basePhyStats().disposition() - PhyStats.IS_BONUS);
        mob.recoverPhyStats();
        mob.recoverCharStats();
      }
    }
    return super.okMessage(myHost, msg);
  }
Esempio n. 20
0
  public boolean okMessage(Environmental myHost, CMMsg msg) {
    if (!(myHost instanceof MOB)) return super.okMessage(myHost, msg);
    MOB myChar = (MOB) myHost;
    if (!super.okMessage(myChar, msg)) return false;

    if (msg.amISource(myChar)
        && (!myChar.isMonster())
        && (msg.sourceMinor() == CMMsg.TYP_CAST_SPELL)
        && (msg.tool() instanceof Ability)
        && ((((Ability) msg.tool()).classificationCode() & Ability.ALL_ACODES)
            == Ability.ACODE_CHANT)
        && (myChar.isMine(msg.tool()))
        && (isQualifyingAuthority(myChar, (Ability) msg.tool()))
        && (CMLib.dice().rollPercentage() < 50)) {
      if (((Ability) msg.tool()).appropriateToMyFactions(myChar)) return true;
      myChar.tell("Extreme emotions disrupt your chant.");
      return false;
    }
    return true;
  }
Esempio n. 21
0
  public void executeMsg(Environmental myHost, CMMsg msg) {
    if ((affected == null) || (!(affected instanceof MOB))) return;

    MOB mob = (MOB) affected;

    if (msg.amISource(mob)) {

      if (((!CMath.bset(msg.sourceMajor(), CMMsg.MASK_SOUND)
              || (msg.sourceMinor() == CMMsg.TYP_SPEAK)
              || (msg.sourceMinor() == CMMsg.TYP_ENTER)
              || (msg.sourceMinor() == CMMsg.TYP_LEAVE)
              || (msg.sourceMinor() == CMMsg.TYP_RECALL)))
          && (!CMath.bset(msg.sourceMajor(), CMMsg.MASK_ALWAYS))
          && (msg.sourceMinor() != CMMsg.TYP_LOOK)
          && (msg.sourceMinor() != CMMsg.TYP_EXAMINE)
          && (msg.sourceMajor() > 0)) {
        ticksSinceLoss = 0;
        mob.recoverEnvStats();
      }
    }
    return;
  }
Esempio n. 22
0
  @Override
  public void executeMsg(Environmental host, CMMsg msg) {
    super.executeMsg(host, msg);
    if ((affected instanceof MOB) && (msg.amISource((MOB) affected))) {
      if (!DATA.containsKey(msg.source())) DATA.put(msg.source(), new int[DATA_TOTAL]);
      final int[] data = DATA.get(msg.source());

      if (data == null) return;
      if (msg.tool() instanceof Social) {
        if (nonIPnonMonsterWithMe(msg.source())) data[DATA_GOODSOCIAL]++;
        if ((msg.target() instanceof MOB) && (!((MOB) msg.target()).isMonster()))
          data[DATA_DIRSOCIAL]++;
        data[DATA_ANYSOCIAL]++;
      } else
        switch (msg.sourceMinor()) {
          case CMMsg.TYP_SPEAK:
            if ((msg.othersMessage() != null)
                && (msg.sourceMessage() != null)
                && (msg.othersMinor() == msg.sourceMinor())
                && (msg.source().location() != null)
                && (msg.source().session() != null)) {
              if (msg.sourceMessage().indexOf("order(s)") > 0) {
                if ((msg.target() instanceof MOB)
                    && (((MOB) msg.target()).session() != null)
                    && (((MOB) msg.target())
                        .session()
                        .getAddress()
                        .equals(msg.source().session().getAddress()))) data[DATA_ORDER]++;
              } else {
                if (nonIPnonMonsterWithMe(msg.source())) data[DATA_GOODSPEECH]++;
                if ((msg.target() instanceof MOB) && (!((MOB) msg.target()).isMonster()))
                  data[DATA_DIRSPEECH]++;
                data[DATA_ANYSPEECH]++;
              }
            }
            break;
        }
    }
  }
Esempio n. 23
0
  @Override
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if (temporarilyDisable) return true;
    final MOB mob = msg.source();
    if (affected instanceof MOB) {
      if (msg.amISource((MOB) affected)) {
        if (CMLib.flags().isInFlight(mob)) {
          damageToTake = 0;
          unInvoke();
          return true;
        }
        if (msg.targetMajor(CMMsg.MASK_MOVE)
            && (!hitTheCeiling)
            && (msg.sourceMinor() != CMMsg.TYP_FLEE)) {
          msg.source().tell(L("You are too busy falling to do that right now."));
          return false;
        }
      }
    }
    return true;
  }
Esempio n. 24
0
 @Override
 public boolean okMessage(final Environmental myHost, final CMMsg msg) {
   if ((affected != null)
       && (affected instanceof MOB)
       && (msg.amITarget(affected))
       && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
       && (!msg.amISource((MOB) affected))
       && (CMLib.flags().aliveAwakeMobile((MOB) affected, true))
       && (msg.tool() instanceof Weapon)) {
     final MOB mob = (MOB) affected;
     if (mob.location()
         .show(
             mob,
             msg.source(),
             this,
             CMMsg.MSG_OK_ACTION,
             L("<S-NAME> shrug(s) off the attack from <T-NAME>."))) {
       unInvoke();
       return false;
     }
   }
   return super.okMessage(myHost, msg);
 }
Esempio n. 25
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((myHost == null) || (!(myHost instanceof MOB))) return;
   final MOB mob = (MOB) myHost;
   if (msg.amISource(mob)) {
     if (((msg.sourceMinor() == CMMsg.TYP_LOOK) || (msg.sourceMinor() == CMMsg.TYP_EXAMINE))
         && (msg.target() instanceof Wand)
         && (mob.charStats().getClassLevel(this) >= 30)) {
       final String message =
           "<O-NAME> has " + ((Wand) msg.target()).usesRemaining() + " charges remaining.";
       msg.addTrailerMsg(
           CMClass.getMsg(
               mob,
               null,
               msg.target(),
               CMMsg.MSG_OK_VISUAL,
               CMMsg.NO_EFFECT,
               CMMsg.NO_EFFECT,
               message));
     } else if (msg.tool() != null) {
       if (msg.tool().ID().equals("Skill_Spellcraft")) {
         if ((msg.tool().text().length() > 0) && (msg.target() instanceof MOB)) {
           Ability A = ((MOB) msg.target()).fetchAbility(msg.tool().text());
           if (A == null) return;
           final Ability myA = mob.fetchAbility(A.ID());
           if (myA != null) {
             if ((!A.isSavable())
                 && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL)
                 && (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30))
               addAbilityToSpellcraftList(mob, A);
           } else if (CMLib.ableMapper().lowestQualifyingLevel(A.ID()) < 30) {
             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);
             }
             A = (Ability) A.copyOf();
             A.setProficiency(0);
             A.setSavable(false);
             if (otherChoices.size() > (mob.charStats().getClassLevel(this) / 3)) {
               final Ability A2 =
                   otherChoices.elementAt(CMLib.dice().roll(1, otherChoices.size(), -1));
               clearAbilityFromSpellcraftList(mob, A2);
             }
             addAbilityToSpellcraftList(mob, A);
           }
         }
       } else if (msg.tool().ID().equals("Spell_Scribe")
           || msg.tool().ID().equals("Spell_EnchantWand")
           || msg.tool().ID().equals("Spell_MagicItem")
           || msg.tool().ID().equals("Spell_StoreSpell")
           || msg.tool().ID().equals("Spell_WardArea")) {
         final Ability A = mob.fetchAbility(msg.tool().text());
         if ((A != null) && (!A.isSavable())) clearAbilityFromSpellcraftList(mob, A);
       } else if (msg.tool() instanceof Ability) {
         final Ability A = mob.fetchAbility(msg.tool().ID());
         if ((A != null)
             && (!A.isSavable())
             && ((A.classificationCode() & Ability.ALL_ACODES) == Ability.ACODE_SPELL))
           clearAbilityFromSpellcraftList(mob, A);
       }
     }
   }
 }