Re: isname() improvement

From: Patrick Dughi (dughi@imaxx.net)
Date: 06/20/00


> on some muds I have seen you can add a '-' to the argument to make it more
> exact. lets say want to look for a bronze plate mail, if you do a "cast
> 'locate'bronze" you will probably get lots of hits on a variety of bronze
> objects. instead you can do a "cast 'locate'bronze-mail" or even "cast
> 'locate'bronze-mail-plate" to look more exactly for the object you want to
> search for.
>
> since I want this to work on each and every command possible on my mud,
> both for mobs and objects, I figured so far that I have to change the
> isname() in handler.c, but I have no idea how to proceed next. can
> someone out here help me out?  -- /Damian/

        I think that this is probaly a very simple procedure;

        tokenize the spell argument
        for(obj=list of all objs; obj;obj= next object) {
          found=1;
          for(i=0;i < # of tokens;i++) {
            if(!isname(obj_name(obj),token[i]))
              found=0;
          }
          if(found) {
            add to list
          }
        }

        However, what george said was true - using a hyphen as a field
delimiter is a bad choice.  What if you make an item named "ring-mail" or
"great-axe".  Why don't you just do this;

        After checks for mana/spell success/etc, but before the actual
cast_spell(), strdup the argument of the spell to the character.  You
don't have to edit the pfile structure - just add it in one of the unsaved
positions, like last_tell.  That way, if you need to use it in your spell,
you can.  I use it for spells like locate object (so I can actually match
on the word, instead of generating a target object), and a few other
places.

        Don't forget to free the memory when you're done with it.


                                                        PjD


     +------------------------------------------------------------+
     | 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 : 04/10/01 PDT