Fixing generic_find

From: Doppleganger Software (doppsoft@TZC.COM)
Date: 08/30/98

Ok, got the first step done in the fixing of generic find (and one other
procedure as well).  Now, if you want to deal with equipped items and
numbers, you can.  Instead of having to remove 2 rings, just to get the
second one removed, you can now type "remove 2.ring"

However, I am at a bigger stage of the game, the integration into the
generic_find.  What I am working on is to make it so that if you want to
look at the first ring in your inventory.  Unfortunately, you have 2
rings in your eq, and the generic_find will get them first.  So, what I
want to be able to do is either specify where to look first, or go 3.ring
so that it skips the first 2 rings in your eq, and goes to the one in
your inventory.  However, this will mean changing the variable passed to
the find functions at the end of each function.  For example, here is a
preliminary code I have at the end of every find function, just before
the return NULL.

  if (number > 1) {
    sprintf(tmpname, "%d.%s", (number - j), tmp);
    strcpy(name, tmpname);

As you can see, if the number is > 1 (ie. it's a #.something) it will
take the number found, subtract it from the number desired, and add the
name on the end.  So, if you send "3.sword" to the function, and you only
find 2, it will make the name be "1.sword" so that the next function will
find it.  However, I am wondering what kind of problems this may cause.
One I have already seen is that if the function is the only one called,
and it can't find the right number, any message back to the player will
look wrong.  In the example above, it might say "You cannot find 1.sword"
even though the player was looking for 3.sword.  What kind of suggestions
does everyone have on what to do with this.  I am especially interested
in George's & Jeremy's opinions, as I would like to see this kind of
functionality in the stock CircleMUD.

Oh, that reminds me.  Here is the change in the get_object_in_equip_vis
function that allows for numbers.

struct obj_data *get_object_in_equip_vis(struct char_data * ch,
                           char *arg, struct obj_data * equipment[], int
  int number, k = 0;
  char tmpname[MAX_INPUT_LENGTH], *tmp = tmpname;

  strcpy(tmp, arg);
  number = get_number(&tmp);

  for ((*j) = 0; (*j) < NUM_WEARS; (*j)++)
    if (equipment[(*j)])
      if (CAN_SEE_OBJ(ch, equipment[(*j)]))
        if (isname(tmp, equipment[(*j)]->name))
          if (++k == number)
            return (equipment[(*j)]);

  return NULL;

"One hundred years from now, none of this will matter because you and I
will be dead -- unless the Grim Reaper has switched his record-keeping to
a Windows 95-based system, in which case we all might live forever. "
-- Associated Press

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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