Re: [Extreme Newbie] [Question]

From: Shane P. Lee (tacodog21@yahoo.com)
Date: 03/02/01


Well, I doubt if you'll find anyone willing to write code for you,
especially since you have given us no indication of its use. If you
can tell us what you are attempting to accomplish, you'll find most
of us more than willing to point you in the right direction.
Having seen quite a few questions with objects, players and mobs in
the subject, I surmise you are attempting to do some sort of corpse
(looting/saving?) comparison.
Trust me, there are much easier ways of doing this than just comparing
names. If that isn't what you are planning to do, at least that gives
you an idea of how little you gave us to work with.
Now, here's some code:P

struct obj_data *o;
struct char_data *ch;
 if(str_cmp(o->name, ch->name))
   return; /* Return if object's name != char's name */

 if(!str_cmp(o->name, ch->name))
   return; /* Return if object's name == char's name */

Now here's your problem if you are looking to add this to comparing
corpses: In fight.c (void make_corpse) the object's name is longer and
contains more words than any PC's name, so even if it contains _some_
of the PC's name. In this instance, it would be smarter to use
'is_abbrev' instead of 'str_cmp'. The problem you would run into there,
is that if you have a player named Bob, and an object named Bobby,
is_abbrev will return true, always.
The way I would limit corpse looting is to simple add the player's
id_num to the object, and then check for that. Something like:
GET_OBJ_VAL(corpse, 2) = IDNUM(ch);
Not sure if that would even work, but I'd try it anyway, since it's the
Hard Way(tm) :P

Now look at me, I started a lecture and couldn't even finish it without
trying to help as much as possible anyway :-(

-FIRE

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST