Re: code writing a mob

From: Daniel A. Koepke (dkoepke@california.com)
Date: 04/10/99


> Ya know, sometimes the spontaneous flaming should be held to a minimum.
> The guy said he was blind, therefore negating the probability that he's
> going to "read through the code".

The ability to read is not predicated by one's ability to see.  That you
normally read by seeing does not mean that one cannot read through some
other means, such as touch by using braile.  Nor is the ability to spell
or code dictated by blindness.  He is just as capable of learning as the
rest of us, though perhaps through different means.  I know many disabled
persons, and they do not like to be treated any more different than is
absolutely necessary due to their condition.  Treating a blind person as
stupid, or somehow inferior, as you have done by indicating that he is not
capable of reading or doing things by himself, is perhaps worse than
directly insulting his disability.  If he can read a mailing list, what
makes you think he cannot read code?

> Once in a while, it wouldn't hurt the "master coders of the circle
> mailing list" to be just a little nice.

I'm not sure exactly who these "Master Coders" are, I doubt their
existence, truthfully, but it seems your message has managed to be far
more insultive than the one to which you are replying.

Having said that, I direct everyone's attention back towards the reason
this exists: he asked a question.  His blindness has nothing to do with
anything (and I don't have the slightest clue why he even mentioned it to
begin with), as you all have seemingly forgotten.  For the wandering
shopkeeper idea, I present this long bit of Mailer Code(tm), written
because I need a break from working on multi-threading stuff,

  SPECIAL(delivery_man)
  {
    struct char_data * man = (struct char_data *) ch;
    struct obj_data * obj;

    if (!AWAKE(man))
      return FALSE;

    if (CMD_IS("steal")) {
      act("$N gives you a sharp smack on the head.", FALSE, ch, 0, man,
          TO_CHAR);
      do_action(man, GET_NAME(ch), find_command("slap"), 0);
      do_say(man, "You ain't that stealthy, m'friend.", 0, 0);
      return (TRUE);
    }

    if (CMD_IS("buy")) {
      one_argument(argument, arg);
      if (!(obj = get_obj_in_list_vis(ch, arg, man->carrying))) {
        sprintf(buf, "%s I don't have that.", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if (GET_OBJ_COST(obj) > GET_GOLD(ch)) {
        sprintf(buf, "%s You don't have enough money.", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if (IS_CARRYING_N(ch) >= CAN_CARRY_N(ch)) {
        sprintf(buf, "%s Your hands are full, you dope.", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if ((CAN_CARRY_W(ch) - IS_CARRYING_W(ch)) <
                 GET_OBJ_WEIGHT(obj)) {
        sprintf(buf, "%s Doesn't look like you can carry all that weight.",
                GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      }

      /* okay, we can buy it */
      GET_GOLD(man) += GET_OBJ_COST(obj);
      GET_GOLD(ch) -= GET_OBJ_COST(obj);

      /* You'll need to add ITEM_STICKY after ITEM_NOSELL */
      if (OBJ_FLAGGED(obj, ITEM_STICKY))
        obj = read_object(GET_OBJ_RNUM(obj), REAL);
      else
        obj_from_char(obj);

      obj_to_char(obj, ch);
      return TRUE;
    }

    if (CMD_IS("sell")) {
      one_argument(argument, arg);
      if (!*arg) {
        send_to_char("Sell what?\r\n", ch);
        return TRUE;
      } else if (!(obj = get_obj_in_list_vis(man, arg, ch->carrying))) {
        sprintf(buf, "%s If you had one to be seen, I might want to"
                "talk business...", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if (GET_OBJ_COST(obj) < 1) {
        sprintf(buf, "%s Why would I buy that?!  It's worthless!",
                GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if (GET_GOLD(man) < GET_OBJ_COST(obj)) {
        sprintf(buf, "%s I don't have the money, sorry.", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if ((GET_OBJ_TYPE(obj) == ITEM_WAND ||
                  GET_OBJ_TYPE(obj) == ITEM_STAFF) &&
                 GET_OBJ_VAL(obj, 2) == 0) {
        sprintf(buf, "%s What do I look like, an idiot?!", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      }

      sprintf(buf, "%s Alright...", GET_NAME(ch));
      do_tell(man, buf, 0, 0);

      GET_GOLD(man) -= GET_OBJ_COST(obj);
      GET_GOLD(ch) += GET_OBJ_COST(obj);

      obj_from_char(obj);
      obj_to_char(obj, man);

      return TRUE;
    }

    if (CMD_IS("list")) {
      /* implementation left up to the individual user */
      return TRUE;
    }

    if (CMD_IS("value")) {
      int cost;
      one_argument(argument, arg);

      if (!*arg) {
        send_to_char("Determine the value of what?\r\n", ch);
        return TRUE;
      } else if (!(obj = obj_in_list_vis(man, arg, ch->carrying))) {
        send_to_char("You don't have that.\r\n", ch);
        return TRUE;
      } else if ((GET_OBJ_TYPE(obj) == ITEM_WAND ||
                  GET_OBJ_TYPE(obj) == ITEM_STAFF) &&
                 GET_OBJ_VAL(obj, 2) == 0) {
        sprintf(buf, "%s It's all used up -- I wouldn't buy it.",
                GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      } else if (GET_OBJ_COST(obj) < 1) {
        sprintf(buf, "%s I could sell dirt for more.", GET_NAME(ch));
        do_tell(man, buf, 0, 0);
        return TRUE;
      }

      cost = (int) (GET_OBJ_COST(obj) * .1)
      cost = GET_OBJ_COST + number(-cost, cost);
      sprintf(buf, "%s Oh, I'd say about...%d gold.", GET_NAME(ch), cost);
      do_tell(man, buf, 0, 0);
      return TRUE;
    }

    return FALSE;
  }

  void give_merchant_default(struct char_data * mob, obj_vnum item, bool
                             sticky)
  {
    struct obj_data * obj = read_object(item, VIRTUAL);

    if (!obj) {
      log("Attempt to give merchant non-existant item %d.", item);
      return;
    }

    if (sticky) SET_BIT(GET_OBJ_EXTRA(obj), ITEM_STICKY);
    obj_to_char(obj, mob);
  }

The only thing you'll need to write is the "list" command handler, and
maybe you'll need to pretty it up to allow for the buy/sell syntax of
shops (like "buy 4 5" or "buy 4 bread" etc.) instead of the very simple
syntax we have now.  The ITEM_STICKY flag, which you'll also have to add
(but that's very straight-forward) is used to allow the wandering merchant
to never run out of a particular object.  The code would be cleaner if the
shop code was more generic, but you can't really expect the *shop* code to
not be specific to shops.

-dak : I'm nice ... A little... Every once in a while.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST