@Override public boolean tick(Tickable ticking, int tickID) { if (!super.tick(ticking, tickID)) return false; if (affected == null) return false; if (!(affected instanceof MOB)) return true; final MOB mob = (MOB) affected; if ((!mob.amDead()) && ((--diseaseTick) <= 0)) { diseaseTick = DISEASE_DELAY(); if (mob.maxState().getFatigue() > Long.MIN_VALUE / 2) mob.curState() .adjFatigue(mob.curState().getFatigue() + CharState.FATIGUED_MILLIS, mob.maxState()); mob.location().show(mob, null, CMMsg.MSG_NOISE, DISEASE_AFFECT()); if (!CMLib.flags().isSleeping(mob)) { final Command C = CMClass.getCommand("Sleep"); try { if (C != null) C.execute(mob, CMParms.parse("Sleep"), Command.METAFLAG_FORCED); } catch (final Exception e) { } } return true; } return true; }
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { if (!mob.isMonster()) { if ((commands != null) && (commands.size() > 1) && (commands.get(1).toUpperCase().equals("OFF"))) { final Command C = CMClass.getCommand("NoSounds"); if (C != null) { return C.execute(mob, commands, metaFlags); } } boolean force = false; if (commands != null) { for (final Object o : commands) { if (o.toString().equalsIgnoreCase("force")) force = true; } } final Session session = mob.session(); if ((!mob.isAttributeSet(MOB.Attrib.SOUND)) || (!session.getClientTelnetMode(Session.TELNET_MSP))) { session.changeTelnetMode(Session.TELNET_MSP, true); for (int i = 0; ((i < 5) && (!session.getClientTelnetMode(Session.TELNET_MSP))); i++) { try { mob.session().prompt("", 500); } catch (final Exception e) { } } if (session.getClientTelnetMode(Session.TELNET_MSP)) { mob.setAttribute(MOB.Attrib.SOUND, true); mob.tell(L("MSP Sound/Music enabled.\n\r")); } else if (force) { session.setClientTelnetMode(Session.TELNET_MSP, true); session.setServerTelnetMode(Session.TELNET_MSP, true); mob.setAttribute(MOB.Attrib.SOUND, true); mob.tell(L("MSP Sound/Music has been forceably enabled.\n\r")); } else mob.tell(L("Your client does not appear to support MSP.")); } else { mob.tell(L("MSP Sound/Music is already enabled.\n\r")); } } return false; }
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { final String str = L("Prop_WizInvis"); final Ability A = mob.fetchEffect(str); boolean didSomething = false; if (A != null) { final Command C = CMClass.getCommand("WizInv"); if ((C != null) && (C.securityCheck(mob))) { didSomething = true; C.execute(mob, new XVector<String>("WIZINV", "OFF"), metaFlags); } } final java.util.List<Ability> V = returnOffensiveAffects(mob); if (V.size() == 0) { if (!didSomething) mob.tell(L("You are not invisible or hidden!")); } else for (int v = 0; v < V.size(); v++) V.get(v).unInvoke(); mob.location().recoverRoomStats(); mob.location().recoverRoomStats(); return false; }
@Override public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { boolean announce = false; if (commands.size() > 0) { if (((String) commands.lastElement()).equals("!")) { commands.removeElementAt(commands.size() - 1); announce = true; } } final MOB target = getTargetAnywhere(mob, commands, givenTarget, true); if (target == null) 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, CMMsg.MASK_MOVE | CMMsg.TYP_JUSTICE | (auto ? CMMsg.MASK_ALWAYS : 0), auto ? L("<T-NAME> <T-IS-ARE> knocked out of <T-HIS-HER> shoes!!!") : L( "^F**<S-NAME> BLAST(S) <T-NAMESELF>**, knocking <T-HIM-HER> out of <T-HIS-HER> shoes!!^?")); CMLib.color().fixSourceFightColor(msg); if (target.location().okMessage(mob, msg)) { target.location().send(mob, msg); if (target.curState().getHitPoints() > 2) target.curState().setHitPoints(target.curState().getHitPoints() / 2); if (target.curState().getMana() > 2) target.curState().setMana(target.curState().getMana() / 2); if (target.curState().getMovement() > 2) target.curState().setMovement(target.curState().getMovement() / 2); final Item I = target.fetchFirstWornItem(Wearable.WORN_FEET); if (I != null) { I.unWear(); I.removeFromOwnerContainer(); target.location().addItem(I, ItemPossessor.Expire.Player_Drop); } Log.sysOut("Banish", mob.Name() + " wrathed " + target.name() + "."); if (announce) { final Command C = CMClass.getCommand("Announce"); try { C.execute( mob, new XVector( "ANNOUNCE", target.name() + " is knocked out of " + target.charStats().hisher() + " shoes!!!"), Command.METAFLAG_FORCED); } catch (final Exception e) { } } } } else return beneficialVisualFizzle( mob, target, L("<S-NAME> attempt(s) to inflict <S-HIS-HER> wrath upon <T-NAMESELF>, but fail(s).")); return success; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { if (mob.location().numInhabitants() == 1) { mob.tell("You will need to find someone to teach you first."); return false; } if (commands.size() == 1) { mob.tell("Learn what? Enter QUALIFY or TRAIN to see what you can learn."); return false; } commands.removeElementAt(0); String teacherName = ""; if (commands.size() > 1) { teacherName = " " + (String) commands.lastElement(); if (teacherName.length() > 1) { commands.removeElementAt(commands.size() - 1); if ((commands.size() > 1) && (((String) commands.lastElement()).equalsIgnoreCase("FROM"))) commands.removeElementAt(commands.size() - 1); } else teacherName = ""; } String what = CMParms.combine(commands, 0); Vector V = Train.getAllPossibleThingsToTrainFor(); if (V.contains(what.toUpperCase().trim())) { Vector CC = CMParms.makeVector("SAY", "I would like to be trained in " + what); mob.doCommand(CC, metaFlags); if (teacherName.length() > 0) commands.addElement(teacherName.trim()); Command C = CMClass.getCommand("TRAIN"); if (C != null) C.execute(mob, commands, metaFlags); return true; } if (CMClass.findAbility(what + teacherName, mob) != null) { Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + what); mob.doCommand(CC, metaFlags); return true; } ExpertiseLibrary.ExpertiseDefinition theExpertise = null; Vector V2 = CMLib.expertises().myListableExpertises(mob); for (Enumeration e = V2.elements(); e.hasMoreElements(); ) { ExpertiseLibrary.ExpertiseDefinition def = (ExpertiseLibrary.ExpertiseDefinition) e.nextElement(); if ((def.name.equalsIgnoreCase(what + teacherName) || def.name.equalsIgnoreCase(what)) || (def.name.toLowerCase().startsWith((what + teacherName).toLowerCase()) && (CMath.isRomanNumeral(def.name.substring((what + teacherName).length()).trim()) || CMath.isNumber(def.name.substring((what + teacherName).length()).trim()))) || (def.name.toLowerCase().startsWith((what).toLowerCase()) && (CMath.isRomanNumeral(def.name.substring((what).length()).trim()) || CMath.isNumber(def.name.substring((what).length()).trim())))) { theExpertise = def; break; } } if (theExpertise == null) for (Enumeration e = CMLib.expertises().definitions(); e.hasMoreElements(); ) { ExpertiseLibrary.ExpertiseDefinition def = (ExpertiseLibrary.ExpertiseDefinition) e.nextElement(); if ((def.name.equalsIgnoreCase(what + teacherName) || def.name.equalsIgnoreCase(what))) { theExpertise = def; break; } } if (theExpertise != null) { Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + theExpertise.name); mob.doCommand(CC, metaFlags); return true; } for (int v = 0; v < V.size(); v++) if (((String) V.elementAt(v)).startsWith(what.toUpperCase().trim())) { Vector CC = CMParms.makeVector("SAY", "I would like to be trained in " + what); mob.doCommand(CC, metaFlags); if (teacherName.length() > 0) commands.addElement(teacherName.trim()); Command C = CMClass.getCommand("TRAIN"); if (C != null) C.execute(mob, commands, metaFlags); return true; } Vector CC = CMParms.makeVector("SAY", "I would like you to teach me " + what + teacherName); mob.doCommand(CC, metaFlags); return false; }
public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { String whatToDrop = null; Environmental target = mob; Vector V = new Vector(); if (commands.size() < 2) { mob.tell("Empty what where?"); return false; } commands.removeElementAt(0); if (commands.size() > 1) { String s = (String) commands.lastElement(); if (s.equalsIgnoreCase("here")) target = mob.location(); else if (s.equalsIgnoreCase("me")) target = mob; else if (s.equalsIgnoreCase("self")) target = mob; else if ("INVENTORY".startsWith(s.toUpperCase())) target = mob; else if (s.equalsIgnoreCase("floor")) target = mob.location(); else if (s.equalsIgnoreCase("ground")) target = mob.location(); else { target = CMLib.english().possibleContainer(mob, commands, false, Wearable.FILTER_UNWORNONLY); if (target == null) target = mob.location().fetchFromRoomFavorItems(null, s); else commands.addElement("delme"); } if (target != null) commands.removeElementAt(commands.size() - 1); } if ((target == null) || (!CMLib.flags().canBeSeenBy(target, mob))) { mob.tell("Empty it where?"); return false; } int maxToDrop = CMLib.english().calculateMaxToGive(mob, commands, true, mob, false); if (maxToDrop < 0) return false; whatToDrop = CMParms.combine(commands, 0); boolean allFlag = (commands.size() > 0) ? ((String) commands.elementAt(0)).equalsIgnoreCase("all") : false; if (whatToDrop.toUpperCase().startsWith("ALL.")) { allFlag = true; whatToDrop = "ALL " + whatToDrop.substring(4); } if (whatToDrop.toUpperCase().endsWith(".ALL")) { allFlag = true; whatToDrop = "ALL " + whatToDrop.substring(0, whatToDrop.length() - 4); } int addendum = 1; String addendumStr = ""; Drink drink = null; boolean doBugFix = true; while (doBugFix || ((allFlag) && (addendum <= maxToDrop))) { doBugFix = false; Item dropThis = mob.fetchCarried(null, whatToDrop + addendumStr); if ((dropThis == null) && (V.size() == 0) && (addendumStr.length() == 0) && (!allFlag)) { dropThis = mob.fetchWornItem(whatToDrop); if ((dropThis != null) && (dropThis instanceof Container)) { if ((!dropThis.amWearingAt(Wearable.WORN_HELD)) && (!dropThis.amWearingAt(Wearable.WORN_WIELD))) { mob.tell("You must remove that first."); return false; } CMMsg newMsg = CMClass.getMsg(mob, dropThis, null, CMMsg.MSG_REMOVE, null); if (mob.location().okMessage(mob, newMsg)) mob.location().send(mob, newMsg); else return false; } } if (dropThis == null) break; if (dropThis instanceof Drink) drink = (Drink) dropThis; if ((CMLib.flags().canBeSeenBy(dropThis, mob)) && (dropThis instanceof Container) && (!V.contains(dropThis))) V.addElement(dropThis); addendumStr = "." + (++addendum); } String str = "<S-NAME> empt(ys) <T-NAME>"; if (target instanceof Room) str += " here."; else if (target instanceof MOB) str += "."; else str += " into " + target.Name() + "."; if ((V.size() == 0) && (drink != null)) { mob.tell(drink.name() + " must be POURed out."); return false; } if (V.size() == 0) mob.tell("You don't seem to be carrying that."); else if ((V.size() == 1) && (V.firstElement() == target)) mob.tell("You can't empty something into itself!"); else if ((V.size() == 1) && (V.firstElement() instanceof Drink) && (!((Drink) V.firstElement()).containsDrink())) mob.tell(mob, (Drink) V.firstElement(), null, "<T-NAME> is already empty."); else for (int v = 0; v < V.size(); v++) { Container C = (Container) V.elementAt(v); if (C == target) continue; List<Item> V2 = C.getContents(); boolean skipMessage = false; if ((C instanceof Drink) && (((Drink) C).containsDrink())) { if (target instanceof Drink) { Command C2 = CMClass.getCommand("Pour"); C2.execute( mob, new XVector("POUR", "$" + C.Name() + "$", "$" + target.Name() + "$"), metaFlags); skipMessage = true; } else { ((Drink) C).setLiquidRemaining(0); if (((Drink) C).disappearsAfterDrinking()) C.destroy(); } } CMMsg msg = CMClass.getMsg(mob, C, CMMsg.MSG_QUIETMOVEMENT, str); Room R = mob.location(); if (skipMessage || (R.okMessage(mob, msg))) { if (!skipMessage) R.send(mob, msg); for (int v2 = 0; v2 < V2.size(); v2++) { Item I = (Item) V2.get(v2); if (I instanceof Coins) ((Coins) I).setContainer(null); if (((I.container() == null) || (Get.get(mob, C, I, true, null, true))) && (I.container() == null)) { if (target instanceof Room) drop(mob, I, true, true); else if (target instanceof Container) { CMMsg putMsg = CMClass.getMsg(mob, target, I, CMMsg.MASK_OPTIMIZE | CMMsg.MSG_PUT, null); if (R.okMessage(mob, putMsg)) R.send(mob, putMsg); } if (I instanceof Coins) ((Coins) I).putCoinsBack(); if (I instanceof RawMaterial) ((RawMaterial) I).rebundle(); } } } } mob.location().recoverRoomStats(); mob.location().recoverRoomStats(); return false; }