@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); }
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.amITarget(myChar)) && (msg.targetMinor() == CMMsg.TYP_DAMAGE) && (msg.sourceMinor() == CMMsg.TYP_ACID)) { int recovery = myChar.charStats().getClassLevel(this); msg.setValue(msg.value() - recovery); } else if ((msg.amITarget(myChar)) && (msg.targetMinor() == CMMsg.TYP_DAMAGE) && (msg.sourceMinor() == CMMsg.TYP_ELECTRIC)) { int recovery = msg.value(); msg.setValue(msg.value() + recovery); } return true; }
public boolean okMessage(final Environmental myHost, final CMMsg msg) { if (!super.okMessage(myHost, msg)) return false; if ((affected == null) || (!(affected instanceof MOB))) return true; MOB mob = (MOB) affected; if (msg.amISource(mob) && (msg.targetMinor() == CMMsg.TYP_DAMAGE) && (msg.tool() instanceof Weapon) && (msg.tool() == naturalWeapon)) msg.setValue(msg.value() + naturalWeapon.basePhyStats().damage() + super.getXLEVELLevel(mob)); return true; }
@Override public boolean okMessage(Environmental host, CMMsg msg) { if (msg.amITarget(this)) { switch (msg.targetMinor()) { case CMMsg.TYP_ACTIVATE: if (!isInstalled()) { if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)) msg.source().tell(L("@x1 is not installed or connected.", name())); return false; } else if (!isAllWiringHot(this)) { if (!CMath.bset(msg.targetMajor(), CMMsg.MASK_CNTRLMSG)) msg.source() .tell(L("The panel containing @x1 is not activated or connected.", name())); return false; } break; case CMMsg.TYP_DEACTIVATE: break; case CMMsg.TYP_LOOK: break; case CMMsg.TYP_POWERCURRENT: if ((!(this instanceof FuelConsumer)) && (!(this instanceof PowerGenerator)) && activated() && (powerNeeds() > 0) && (msg.value() > 0)) { double amtToTake = Math.min((double) powerNeeds(), (double) msg.value()); msg.setValue(msg.value() - (int) Math.round(amtToTake)); amtToTake *= getFinalManufacturer().getEfficiencyPct(); if (subjectToWearAndTear() && (usesRemaining() <= 200)) amtToTake *= CMath.div(usesRemaining(), 100.0); setPowerRemaining(Math.min(powerCapacity(), Math.round(amtToTake) + powerRemaining())); } break; } } return super.okMessage(host, msg); }
public boolean wear(MOB mob, Item item, int locationIndex, boolean quiet) { String str = "<S-NAME> put(s) on <T-NAME>."; int msgType = CMMsg.MSG_WEAR; if (item.rawProperLocationBitmap() == Wearable.WORN_HELD) { str = "<S-NAME> hold(s) <T-NAME>."; msgType = CMMsg.MSG_HOLD; } else if ((item.rawProperLocationBitmap() == Wearable.WORN_WIELD) || (item.rawProperLocationBitmap() == (Wearable.WORN_HELD | Wearable.WORN_WIELD))) { str = "<S-NAME> wield(s) <T-NAME>."; msgType = CMMsg.MSG_WIELD; } else if (locationIndex != 0) str = "<S-NAME> put(s) <T-NAME> on <S-HIS-HER> " + Wearable.CODES.NAME(locationIndex).toLowerCase() + "."; CMMsg newMsg = CMClass.getMsg(mob, item, null, msgType, quiet ? null : str); newMsg.setValue(locationIndex); if (mob.location().okMessage(mob, newMsg)) { mob.location().send(mob, newMsg); return true; } return false; }
@Override public boolean execute(MOB mob, Vector commands, int metaFlags) throws java.io.IOException { final Room R = mob.location(); boolean quiet = false; if ((commands != null) && (commands.size() > 1) && (((String) commands.lastElement()).equalsIgnoreCase("UNOBTRUSIVELY"))) { commands.remove(commands.size() - 1); quiet = true; } final String textMsg = "<S-NAME> look(s) "; if (R == null) return false; if ((commands != null) && (commands.size() > 1)) { Environmental thisThang = null; if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("at"))) commands.remove(1); else if ((commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("to"))) commands.remove(1); final String ID = CMParms.combine(commands, 1); if ((ID.toUpperCase().startsWith("EXIT") && (commands.size() == 2)) && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) { final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null); if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF)) exitMsg.setValue(CMMsg.MASK_OPTIMIZE); if (R.okMessage(mob, exitMsg)) R.send(mob, exitMsg); return false; } if (ID.equalsIgnoreCase("SELF") || ID.equalsIgnoreCase("ME")) thisThang = mob; if (thisThang == null) thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, noCoinFilter); if (thisThang == null) thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID, Wearable.FILTER_ANY); if ((thisThang == null) && (commands.size() > 2) && (((String) commands.get(1)).equalsIgnoreCase("in"))) { commands.remove(1); final String ID2 = CMParms.combine(commands, 1); thisThang = R.fetchFromMOBRoomFavorsItems(mob, null, ID2, Wearable.FILTER_ANY); if ((thisThang != null) && ((!(thisThang instanceof Container)) || (((Container) thisThang).capacity() == 0))) { mob.tell(L("That's not a container.")); return false; } } int dirCode = -1; Environmental lookingTool = null; if (thisThang == null) { dirCode = Directions.getGoodDirectionCode(ID); if (dirCode >= 0) { final Room room = R.getRoomInDir(dirCode); final Exit exit = R.getExitInDir(dirCode); if ((room != null) && (exit != null)) { thisThang = exit; lookingTool = room; } else { mob.tell(L("You don't see anything that way.")); return false; } } } if (thisThang != null) { String name = "at <T-NAMESELF>"; if ((thisThang instanceof Room) || (thisThang instanceof Exit)) { if (thisThang == R) name = "around"; else if (dirCode >= 0) name = ((R instanceof BoardableShip) || (R.getArea() instanceof BoardableShip)) ? Directions.getShipDirectionName(dirCode) : Directions.getDirectionName(dirCode); } final CMMsg msg = CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK, textMsg + name + "."); if ((thisThang instanceof Room) && (mob.isAttribute(MOB.Attrib.AUTOEXITS)) && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1)) { final CMMsg exitMsg = CMClass.getMsg(mob, thisThang, lookingTool, CMMsg.MSG_LOOK_EXITS, null); if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF)) exitMsg.setValue(CMMsg.MASK_OPTIMIZE); msg.addTrailerMsg(exitMsg); } if (R.okMessage(mob, msg)) R.send(mob, msg); } else mob.tell(L("You don't see that here!")); } else { if ((commands != null) && (commands.size() > 0)) if (((String) commands.get(0)).toUpperCase().startsWith("E")) { mob.tell(L("Examine what?")); return false; } final CMMsg msg = CMClass.getMsg( mob, R, null, CMMsg.MSG_LOOK, (quiet ? null : textMsg + "around."), CMMsg.MSG_LOOK, (quiet ? null : textMsg + "at you."), CMMsg.MSG_LOOK, (quiet ? null : textMsg + "around.")); if ((mob.isAttribute(MOB.Attrib.AUTOEXITS)) && (CMProps.getIntVar(CMProps.Int.EXVIEW) != 1) && (CMLib.flags().canBeSeenBy(R, mob))) { final CMMsg exitMsg = CMClass.getMsg(mob, R, null, CMMsg.MSG_LOOK_EXITS, null); if ((CMProps.getIntVar(CMProps.Int.EXVIEW) >= 2) != mob.isAttribute(MOB.Attrib.BRIEF)) exitMsg.setValue(CMMsg.MASK_OPTIMIZE); msg.addTrailerMsg(exitMsg); } if (R.okMessage(mob, msg)) R.send(mob, msg); } return false; }
public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) { boolean saveTheTrap = false; if ((commands.size() > 0) && (commands.lastElement() instanceof Boolean)) { saveTheTrap = ((Boolean) commands.lastElement()).booleanValue(); commands.removeElementAt(commands.size() - 1); } String whatTounlock = CMParms.combine(commands, 0); Physical unlockThis = null; int dirCode = Directions.getGoodDirectionCode(whatTounlock); Room R = mob.location(); Room nextRoom = null; if (dirCode >= 0) { nextRoom = R.getRoomInDir(dirCode); unlockThis = R.getExitInDir(dirCode); } if ((unlockThis == null) && (whatTounlock.equalsIgnoreCase("room") || whatTounlock.equalsIgnoreCase("here"))) unlockThis = R; if (unlockThis == null) unlockThis = getAnyTarget(mob, commands, givenTarget, Wearable.FILTER_UNWORNONLY); if (unlockThis == null) return false; int oldProficiency = proficiency(); if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false; boolean success = proficiencyCheck( mob, +(((mob.phyStats().level() + (getXLEVELLevel(mob) * 2)) - unlockThis.phyStats().level()) * 3), auto); Vector<Physical> permSetV = new Vector<Physical>(); Trap theTrap = CMLib.utensils().fetchMyTrap(unlockThis); if (theTrap != null) permSetV.addElement(unlockThis); Trap opTrap = null; boolean permanent = false; if ((unlockThis instanceof Room) && (CMLib.law().doesOwnThisProperty(mob, ((Room) unlockThis)))) permanent = true; else if (unlockThis instanceof Exit) { Room R2 = null; if (dirCode < 0) for (int d = Directions.NUM_DIRECTIONS() - 1; d >= 0; d--) if (R.getExitInDir(d) == unlockThis) { dirCode = d; R2 = R.getRoomInDir(d); break; } if ((CMLib.law().doesOwnThisProperty(mob, R)) || ((R2 != null) && (CMLib.law().doesOwnThisProperty(mob, R2)))) permanent = true; if (dirCode >= 0) { Exit exit = R.getReverseExit(dirCode); if (exit != null) opTrap = CMLib.utensils().fetchMyTrap(exit); if (opTrap != null) permSetV.addElement(exit); Trap roomTrap = null; if (nextRoom != null) roomTrap = CMLib.utensils().fetchMyTrap(nextRoom); if (roomTrap != null) permSetV.addElement(nextRoom); if ((theTrap != null) && (theTrap.disabled()) && (roomTrap != null)) { opTrap = null; unlockThis = nextRoom; theTrap = roomTrap; } } } if (unlockThis == null) { mob.tell("You can't seem to remember how this works."); return false; } CMMsg msg = CMClass.getMsg( mob, unlockThis, this, auto ? CMMsg.MSG_OK_ACTION : CMMsg.MSG_DELICATE_HANDS_ACT, CMMsg.MSG_DELICATE_HANDS_ACT, CMMsg.MSG_OK_ACTION, auto ? unlockThis.name() + " begins to glow." : "<S-NAME> attempt(s) to safely deactivate a trap on " + unlockThis.name() + "."); if ((success) && (!lastDone.contains("" + unlockThis))) { while (lastDone.size() > 40) lastDone.removeElementAt(0); lastDone.addElement("" + unlockThis); msg.setValue(1); } else msg.setValue(0); if (R.okMessage(mob, msg)) { R.send(mob, msg); if ((unlockThis == lastChecked) && ((theTrap == null) || (theTrap.disabled()))) setProficiency(oldProficiency); if (success) { if (theTrap != null) { theTrap.disable(); if (saveTheTrap) commands.addElement(theTrap); } if (opTrap != null) { opTrap.disable(); if (saveTheTrap) commands.addElement(opTrap); } if (permanent) { for (int i = 0; i < permSetV.size(); i++) { if (theTrap != null) { theTrap.unInvoke(); ((Physical) permSetV.elementAt(i)).delEffect(theTrap); } if (opTrap != null) { opTrap.unInvoke(); ((Physical) permSetV.elementAt(i)).delEffect(opTrap); } } CMLib.database().DBUpdateRoom(R); CMLib.database().DBUpdateExits(R); } } if ((!auto) && (!saveTheTrap)) mob.tell("You have completed your attempt."); lastChecked = unlockThis; } return success; }