예제 #1
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   if ((msg.amITarget(this)
           || (msg.targetMinor() == CMMsg.TYP_ADVANCE)
           || (msg.targetMinor() == CMMsg.TYP_RETREAT))
       && (!msg.source().isMonster())
       && (msg.source().curState().getHitPoints() < msg.source().maxState().getHitPoints())
       && (CMLib.dice().rollPercentage() == 1)
       && (CMLib.dice().rollPercentage() == 1)
       && (!CMSecurity.isDisabled(CMSecurity.DisFlag.AUTODISEASE))) {
     Ability A = null;
     if (CMLib.dice().rollPercentage() > 50) A = CMClass.getAbility("Disease_Chlamydia");
     else A = CMClass.getAbility("Disease_Malaria");
     if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
       A.invoke(msg.source(), msg.source(), true, 0);
   }
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
     if (CMLib.dice().rollPercentage() < 10) {
       Ability A = CMClass.getAbility("Disease_Malaria");
       if ((A != null) && (msg.source().fetchEffect(A.ID()) == null))
         A.invoke(msg.source(), msg.source(), true, 0);
     }
   }
   super.executeMsg(myHost, msg);
 }
예제 #2
0
  @Override
  public boolean invoke(MOB mob, Vector commands, Physical givenTarget, boolean auto, int asLevel) {
    final MOB target = getTarget(mob, commands, givenTarget);
    if (target == null) return false;

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;
    final boolean success = proficiencyCheck(mob, 0, auto);

    if (success) {
      invoker = mob;
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              target,
              this,
              verbalCastCode(mob, target, auto),
              auto ? "" : L("^S<S-NAME> incant(s) to <T-NAMESELF>.^?"));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        if (msg.value() <= 0) {
          target
              .curState()
              .adjThirst(
                  -150 - ((mob.phyStats().level() + (2 * getXLEVELLevel(mob))) * 100),
                  target.maxState().maxThirst(target.baseWeight()));
          mob.location()
              .show(target, null, CMMsg.MSG_OK_VISUAL, L("<S-NAME> feel(s) incredibly thirsty!"));
        }
      }
    } else
      return maliciousFizzle(
          mob, target, L("<S-NAME> incant(s) to <T-NAMESELF>, but the spell fades."));
    // return whether it worked
    return success;
  }
예제 #3
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
   } else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_FILL)
       && (msg.target() instanceof Container)
       && (((Container) msg.target()).capacity() > 0)) {
     final Container container = (Container) msg.target();
     final Item I = CMClass.getItem("GenLiquidResource");
     I.setName(L("some milk"));
     I.setDisplayText(L("some milk has been left here."));
     I.setDescription(L("It looks like milk"));
     I.setMaterial(RawMaterial.RESOURCE_MILK);
     I.setBaseValue(RawMaterial.CODES.VALUE(RawMaterial.RESOURCE_MILK));
     I.basePhyStats().setWeight(1);
     CMLib.materials().addEffectsToResource(I);
     I.recoverPhyStats();
     I.setContainer(container);
     if (container.owner() != null)
       if (container.owner() instanceof MOB) ((MOB) container.owner()).addItem(I);
       else if (container.owner() instanceof Room)
         ((Room) container.owner()).addItem(I, ItemPossessor.Expire.Resource);
   }
 }
예제 #4
0
  @Override
  public boolean tick(Tickable ticking, int tickID) {
    if (!super.tick(ticking, tickID)) return false;

    if (tickID != Tickable.TICKID_MOB) return true;

    if (affected == null) return false;
    if (--fallTickDown > 0) return true;
    fallTickDown = 1;

    int direction = Directions.DOWN;
    String addStr = L("down");
    if (reversed()) {
      direction = Directions.UP;
      addStr = L("upwards");
    }
    if (affected instanceof MOB) {
      final MOB mob = (MOB) affected;
      if (mob == null) return false;
      if (mob.location() == null) return false;

      if (CMLib.flags().isInFlight(mob)) {
        damageToTake = 0;
        unInvoke();
        return false;
      } else if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
      else {
        if (mob.phyStats().weight() < 1) {
          mob.tell(L("\n\r\n\rYou are floating gently @x1.\n\r\n\r", addStr));
        } else {
          mob.tell(L("\n\r\n\rYOU ARE FALLING @x1!!\n\r\n\r", addStr.toUpperCase()));
          int damage =
              CMLib.dice()
                  .roll(
                      1,
                      (int)
                          Math.round(
                              CMath.mul(
                                  CMath.mul(mob.maxState().getHitPoints(), 0.1),
                                  CMath.div(mob.baseWeight(), 150.0))),
                      0);
          if (damage > (mob.maxState().getHitPoints() / 3))
            damage = (mob.maxState().getHitPoints() / 3);
          damageToTake = reversed() ? damage : (damageToTake + damage);
        }
        temporarilyDisable = true;
        CMLib.tracking().walk(mob, direction, false, false);
        temporarilyDisable = false;
        if (!canFallFrom(mob.location(), direction)) return stopFalling(mob);
        return true;
      }
    } else if (affected instanceof Item) {
      final Item item = (Item) affected;
      if ((room == null) && (item.owner() != null) && (item.owner() instanceof Room))
        room = (Room) item.owner();

      if ((room == null)
          || ((room != null) && (!room.isContent(item)))
          || (!CMLib.flags().isGettable(item))
          || (item.container() != null)
          || (CMLib.flags().isInFlight(item.ultimateContainer(null)))
          || (room.getRoomInDir(direction) == null)) {
        unInvoke();
        return false;
      }
      if (room.numItems() > 100) {
        fallTickDown = CMLib.dice().roll(1, room.numItems() / 50, 0);
        if ((--fallTickDown) > 0) return true;
      }
      final Room nextRoom = room.getRoomInDir(direction);
      if (canFallFrom(room, direction)) {
        room.show(invoker, null, item, CMMsg.MSG_OK_ACTION, L("<O-NAME> falls @x1.", addStr));
        nextRoom.moveItemTo(item, ItemPossessor.Expire.Player_Drop);
        room = nextRoom;
        nextRoom.show(
            invoker,
            null,
            item,
            CMMsg.MSG_OK_ACTION,
            L("<O-NAME> falls in from @x1.", (reversed() ? "below" : "above")));
        return true;
      }
      if (reversed()) return true;
      unInvoke();
      return false;
    }

    return false;
  }