|
Locate Object Spell [by Ryan Stapleton] |
|
|
|
Posted Wednesday, August 12th @ 11:30:27 PM, by George Greer in the Skills dept.
Added Jul 6, 1998. Click the link below to read it or download it.
From: Ryan Stapleton <raal@PENN.COM>
Subject: Locate Object
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.
Ryan Stapleton
raal@penn.com
<< Load Linkdead Players [by Frollo] | Reply | View as text | Threaded | Locate Target Spell [by David Klasinc] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|