[CODE SNIP] Locate Object

From: Ryan Stapleton (raal@PENN.COM)
Date: 06/02/98


Here it is.

Ok Here is What I did in my patch, I hope posting this to the list isn't bad.
Its not real pretty what I did but it seems to work, if there are any comments
or anything I would be happy to hear them.
On with the code.

in structs.h add a char field in player_special_data

   void *last_olc_targ;         /* olc control                          */
   int last_olc_mode;           /* olc control                          */
+   char *tmp_text;              /* hold temp text, like for passing in  *
+                                 * locate object                        */
};

This is how I passed the text I was searching for to the spell, without
re-writing the whole thing, not real nice but it works.

in interpreter.c add this:

/*
 * remove hyphans from a string
 */
void strip_hyphan(char *string)
{
  for(; *string; (string)++) {
    if ((*string) == '-' )
      (*string) = ' ';
  }
}
also add it to interpreter.h as a prototype:

in spell_parser.c:  in  do_cast:

/* Find the target */
  if (t != NULL) {
    one_argument(strcpy(arg, t), t);
    skip_spaces(&t);
+    strip_hyphan(t);

in handler.c in *get_obj_vis:

  char *tmp = tmpname;
  char **msg;

+  msg = & ((ch)->player_specials->tmp_text);
+  if ( *msg )
+    free( *msg);

+  if (!*name)
+    *msg = NULL;
+  else
+    *msg = str_dup(name);

in spells.c: in spell_locate_object:

ASPELL(spell_locate_object)
{
  struct obj_data *i;
  char name[MAX_INPUT_LENGTH];
  int j;

  strcpy(name, (ch)->player_specials->tmp_text);

  j = level >> 1;

  for (i = object_list; i && (j > 0); i = i->next) {
    if (!isname2(name, i->name))
      continue;

    if (i->carried_by)
      sprintf(buf, "%s is being carried by %s.\n\r",
              i->short_description, PERS(i->carried_by, ch));
    else if (i->in_room != NOWHERE)
      sprintf(buf, "%s is in %s.\n\r", i->short_description,
              world[i->in_room].name);
    else if (i->in_obj)
      sprintf(buf, "%s is in %s.\n\r", i->short_description,
              i->in_obj->short_description);
    else if (i->worn_by)
      sprintf(buf, "%s is being worn by %s.\n\r",
              i->short_description, PERS(i->worn_by, ch));
    else
      sprintf(buf, "%s's location is uncertain.\n\r",
              i->short_description);

    CAP(buf);
    send_to_char(buf, ch);
    j--;
  }

  if (j == level >> 1)
    send_to_char("You sense nothing.\n\r", ch);
}


I hope this helps someone, I hope I remembered to put everything in here,
if there are any questions please let me know thanks.
again if I shouldnt have put this to this list I appoligize.

Ryan Stapleton
raal@penn.com

---------------------------------------------------------------
- Ryan Stapleton               |   raal@penn.com              -
- 225 West Main Street         |   ryans@cis.clarion.edu      -
- Reynoldsville, Pa            |   ryan@flower.aud.temple.edu -
- 15851                        |                              -
- Amateur Radio Call:  KA3WUT  |  http://users.penn.com/~raal -
---------------------------------------------------------------


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



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