public static void doAnimalFollowerLevelingCheck(CharClass C, Environmental host, CMMsg msg) { if ((msg.sourceMessage() == null) && (msg.sourceMinor() == CMMsg.TYP_LEVEL) && (msg.source().isMonster())) { final MOB druidM = msg.source().amUltimatelyFollowing(); if ((druidM != null) && (!druidM.isMonster()) && (druidM.charStats().getCurrentClass().ID().equals(C.ID())) && (CMLib.flags().isAnimalIntelligence(msg.source()) || msg.source() .charStats() .getMyRace() .racialCategory() .equalsIgnoreCase("Vegetation") || msg.source() .charStats() .getMyRace() .racialCategory() .equalsIgnoreCase("Stone Golem"))) { final int xp = msg.source().phyStats().level() * 5; if (xp > 0) { druidM.tell( CMLib.lang().L("Your stewardship has benefitted @x1.", msg.source().name(druidM))); CMLib.leveler().postExperience(druidM, null, null, xp, false); } } } }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { if ((msg.tool() == this) && (msg.targetMinor() == CMMsg.TYP_WEAPONATTACK) && (weaponClassification() == Weapon.CLASS_THROWN)) return; // msg.addTrailerMsg(CMClass.getMsg(msg.source(),this,CMMsg.MSG_DROP,null)); else if ((msg.tool() == this) && (msg.targetMinor() == CMMsg.TYP_DAMAGE) && (msg.target() != null) && (msg.target() instanceof MOB) && (weaponClassification() == Weapon.CLASS_THROWN)) { unWear(); msg.addTrailerMsg( CMClass.getMsg(msg.source(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_DROP, null)); msg.addTrailerMsg( CMClass.getMsg((MOB) msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.MSG_GET, null)); msg.addTrailerMsg( CMClass.getMsg( msg.source(), msg.target(), this, CMMsg.MASK_ALWAYS | CMMsg.TYP_GENERAL, null)); } else if ((msg.tool() == this) && (msg.target() instanceof MOB) && (msg.targetMinor() == CMMsg.TYP_GENERAL) && (((MOB) msg.target()).isMine(this)) && (msg.sourceMessage() == null)) { final Ability A = CMClass.getAbility("Thief_Bind"); if (A != null) { A.setAffectedOne(this); A.invoke(msg.source(), (MOB) msg.target(), true, phyStats().level()); } } else super.executeMsg(myHost, msg); }
public boolean okMessage(Environmental myHost, CMMsg msg) { if (!super.okMessage(myHost, msg)) return false; if (msg.targetMinor() == CMMsg.TYP_ENTER) { if (msg.target() == this) { MOB mob = msg.source(); if ((mob.location() != null) && (mob.location().roomID().length() > 0)) { int direction = -1; for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) { if (mob.location().getRoomInDir(d) == this) direction = d; } if (direction < 0) { mob.tell("Some great evil is preventing your movement that way."); return false; } msg.modify( msg.source(), getAltRoomFrom(mob.location(), direction), msg.tool(), msg.sourceCode(), msg.sourceMessage(), msg.targetCode(), msg.targetMessage(), msg.othersCode(), msg.othersMessage()); } } } return true; }
@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; } } }
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { final MOB mob = msg.source(); switch (msg.targetMinor()) { case CMMsg.TYP_WAND_USE: if (msg.amITarget(this) && ((msg.tool() == null) || (msg.tool() instanceof Physical))) waveIfAble(mob, (Physical) msg.tool(), msg.targetMessage()); break; case CMMsg.TYP_SPEAK: if ((msg.sourceMinor() == CMMsg.TYP_SPEAK) && (!amWearingAt(Wearable.IN_INVENTORY))) { boolean alreadyWanding = false; final List<CMMsg> trailers = msg.trailerMsgs(); if (trailers != null) for (final CMMsg msg2 : trailers) if (msg2.targetMinor() == CMMsg.TYP_WAND_USE) alreadyWanding = true; final String said = CMStrings.getSayFromMessage(msg.sourceMessage()); if ((!alreadyWanding) && (checkWave(mob, said))) msg.addTrailerMsg( CMClass.getMsg( msg.source(), this, msg.target(), CMMsg.NO_EFFECT, null, CMMsg.MASK_ALWAYS | CMMsg.TYP_WAND_USE, said, CMMsg.NO_EFFECT, null)); } break; default: break; } super.executeMsg(myHost, msg); }
@Override public void executeMsg(Environmental host, CMMsg msg) { super.executeMsg(host, msg); if ((affected instanceof Item) && (text().length() > 0)) { final Item I = (Item) affected; if ((msg.sourceMinor() == CMMsg.TYP_SPEAK) && (msg.target() == I) && ((msg.source() == I.owner()) || (I.owner() instanceof Room)) && (msg.sourceMessage() != null) && (CMLib.english() .containsString( CMStrings.getSayFromMessage(msg.sourceMessage()).toUpperCase(), "REFUGE"))) { final Room newRoom = this.getRefuge(I); if ((newRoom != null) && (newRoom != msg.source().location())) { final Set<MOB> h = properTargets(msg.source(), null, false); if (h == null) return; final Room thisRoom = msg.source().location(); final Ability thisA = this; msg.addTrailerRunnable( new Runnable() { @Override public void run() { for (final Object element : h) { final MOB follower = (MOB) element; final CMMsg enterMsg = CMClass.getMsg( follower, newRoom, thisA, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, L( "<S-NAME> appears in a puff of smoke.@x1", CMLib.protocol().msp("appear.wav", 10))); final CMMsg leaveMsg = CMClass.getMsg( follower, thisRoom, thisA, CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC, L("<S-NAME> disappear(s) in a puff of smoke.")); if (thisRoom.okMessage(follower, leaveMsg) && newRoom.okMessage(follower, enterMsg)) { if (follower.isInCombat()) { CMLib.commands().postFlee(follower, ("NOWHERE")); follower.makePeace(); } thisRoom.send(follower, leaveMsg); newRoom.bringMobHere(follower, false); newRoom.send(follower, enterMsg); follower.tell(L("\n\r\n\r")); CMLib.commands().postLook(follower, true); } } } }); unInvoke(); } } } }