public boolean invoke( MOB mob, Vector commands, Environmental givenTarget, boolean auto, int asLevel) { if (type.length() == 0) return false; if ((mob.getClanID() == null) || (mob.getClanID().equalsIgnoreCase("")) || (mob.getClanRole() == 0)) { mob.tell("You aren't even a member of a clan."); return false; } Clan C = CMLib.clans().getClan(mob.getClanID()); if (C == null) { mob.tell("You aren't even a member of a clan."); return false; } if (C.allowedToDoThis(mob, Clan.FUNC_CLANENCHANT) != 1) { mob.tell("You are not authorized to draw from the power of your " + C.typeName() + "."); return false; } String ClanName = C.clanID(); String ClanType = C.typeName(); // Invoking will be like: // CAST [CLANEQSPELL] ITEM QUANTITY // -2 -1 0 1 if (commands.size() < 1) { mob.tell("Enchant which spell onto what?"); return false; } if (commands.size() < 2) { mob.tell("Use how much clan enchantment power?"); return false; } Environmental target = mob.location() .fetchFromMOBRoomFavorsItems( mob, null, (String) commands.elementAt(0), Item.WORNREQ_UNWORNONLY); if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) { mob.tell("You don't see '" + ((String) commands.elementAt(0)) + "' here."); return false; } // Add clan power check start int points = CMath.s_int((String) commands.elementAt(1)); if (points <= 0) { mob.tell("You need to use at least 1 enchantment point."); return false; } long exp = points * CMProps.getIntVar(CMProps.SYSTEMI_CLANENCHCOST); if ((C.getExp() < exp) || (exp < 0)) { mob.tell( "You need " + exp + " to do that, but your " + C.typeName() + " has only " + C.getExp() + " experience points."); return false; } // Add clan power check end if (target.fetchEffect("Prop_ClanEquipment") != null) { mob.tell(target.name() + " is already clan enchanted."); return false; } // lose all the mana! if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck(mob, 0, auto); C.setExp(C.getExp() - exp); C.update(); if (success) { CMMsg msg = CMClass.getMsg( mob, target, this, verbalCastCode(mob, target, auto), "^S<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely.^?"); if (mob.location().okMessage(mob, msg)) { mob.location().send(mob, msg); Ability A = CMClass.getAbility("Prop_ClanEquipment"); StringBuffer str = new StringBuffer(""); str.append(type); // Type of Enchantment str.append(" "); str.append("" + points); // Power of Enchantment str.append(" \""); str.append(ClanName); // Clan Name str.append("\" \""); str.append(ClanType); // Clan Type str.append("\""); A.setMiscText(str.toString()); target.addEffect(A); } } else beneficialWordsFizzle( mob, target, "<S-NAME> move(s) <S-HIS-HER> fingers around <T-NAMESELF>, encanting intensely, and looking very frustrated."); return success; }
@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; }