@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 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; if (!CMLib.flags().isAnimalIntelligence(target)) { mob.tell(L("@x1 is not an animal!", target.name(mob))); return false; } if (!target.isInCombat()) { mob.tell(L("@x1 doesn't seem particularly enraged at the moment.", target.name(mob))); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), auto ? L("<T-NAME> become(s) surrounded by a natural light.") : L("^S<S-NAME> chant(s) to <T-NAMESELF> for calm.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); beneficialAffect(mob, target, asLevel, 3); for (int i = 0; i < mob.location().numInhabitants(); i++) { final MOB mob2 = mob.location().fetchInhabitant(i); if ((mob2.getVictim() == target) || (mob2 == target)) mob2.makePeace(true); } } } else beneficialWordsFizzle( mob, target, L("<S-NAME> chant(s) to <T-NAMESELF>, but nothing happens.")); // return whether it worked return success; }
@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; }
@Override public boolean invoke( MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { if (!mob.clans().iterator().hasNext()) { mob.tell(L("You aren't even a member of a clan.")); return false; } final Pair<Clan, Integer> clanPair = CMLib.clans().findPrivilegedClan(mob, Clan.Function.CLAN_BENEFITS); if (clanPair == null) { mob.tell(L("You are not authorized to draw from the power of your clan.")); return false; } final Clan C = clanPair.first; Room clanHomeRoom = null; clanHomeRoom = CMLib.map().getRoom(C.getRecall()); if (clanHomeRoom == null) { mob.tell(L("Your clan does not have a clan home.")); return false; } if (!CMLib.flags().canAccess(mob, clanHomeRoom)) { mob.tell(L("You can't use this magic to get there from here.")); return false; } if (!CMLib.law().doesOwnThisProperty(C.clanID(), clanHomeRoom)) { mob.tell(L("Your clan no longer owns that room.")); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, null, this, CMMsg.MASK_MOVE | verbalCastCode(mob, mob, auto), L("^S<S-NAME> invoke(s) a teleportation spell.^?")); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); final Set<MOB> h = properTargets(mob, givenTarget, false); if (h == null) return false; final Room thisRoom = mob.location(); for (final Object element : h) { final MOB follower = (MOB) element; final CMMsg enterMsg = CMClass.getMsg( follower, clanHomeRoom, this, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, null, CMMsg.MSG_ENTER, L("<S-NAME> appears in a puff of red smoke.")); final CMMsg leaveMsg = CMClass.getMsg( follower, thisRoom, this, CMMsg.MSG_LEAVE | CMMsg.MASK_MAGIC, L("<S-NAME> disappear(s) in a puff of red smoke.")); if (thisRoom.okMessage(follower, leaveMsg) && clanHomeRoom.okMessage(follower, enterMsg)) { if (follower.isInCombat()) { CMLib.commands().postFlee(follower, ("NOWHERE")); follower.makePeace(false); } thisRoom.send(follower, leaveMsg); clanHomeRoom.bringMobHere(follower, false); clanHomeRoom.send(follower, enterMsg); follower.tell(L("\n\r\n\r")); CMLib.commands().postLook(follower, true); } } } } else beneficialWordsFizzle( mob, null, L("<S-NAME> attempt(s) to invoke transportation, but fizzle(s) the spell.")); // return whether it worked return success; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { if ((!auto) && (!(CMLib.flags().isGood(mob)))) { mob.tell(L("Your alignment has alienated you from your god.")); return false; } final List<String> V = new Vector<String>(); if (commands.size() > 0) { V.add((String) commands.elementAt(0)); commands.removeElementAt(0); } final MOB target = getTarget(mob, V, givenTarget); if (target == null) return false; if (commands.size() == 0) { if (mob.isMonster()) commands.addElement("FLEE"); else { if (V.size() > 0) mob.tell(L("Command @x1 to do what?", V.get(0))); return false; } } if (!target.charStats().getMyRace().racialCategory().equals("Equine")) { mob.tell(L("@x1 is not a horse!", target.name(mob))); return false; } if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; final boolean success = proficiencyCheck(mob, 0, auto); if (success) { final CMMsg msg = CMClass.getMsg( mob, target, this, verbalSpeakCode(mob, target, auto), auto ? "" : L( "^S<S-NAME> command(s) <T-NAMESELF> to '@x1'.^?", CMParms.combine(commands, 0))); final CMMsg msg2 = CMClass.getMsg( mob, target, this, CMMsg.MASK_MALICIOUS | CMMsg.MASK_SOUND | CMMsg.TYP_MIND | (auto ? CMMsg.MASK_ALWAYS : 0), null); final CMMsg omsg = CMClass.getMsg(mob, target, null, CMMsg.MSG_ORDER, null); if ((mob.location().okMessage(mob, msg)) && ((mob.location().okMessage(mob, msg2))) && (mob.location().okMessage(mob, omsg))) { mob.location().send(mob, msg); if (msg.value() <= 0) { mob.location().send(mob, msg2); mob.location().send(mob, omsg); if ((msg2.value() <= 0) && (omsg.sourceMinor() == CMMsg.TYP_ORDER)) { invoker = mob; target.makePeace(); target.enqueCommand(commands, Command.METAFLAG_FORCED | Command.METAFLAG_ORDER, 0); } } } } else return maliciousFizzle( mob, target, L("<S-NAME> attempt(s) to command <T-NAMESELF>, but it definitely didn't work.")); // return whether it worked return success; }
@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; }