Re: Abbreviations for objects, mobs and players.

From: icarus (icarus@berkshire.net)
Date: 07/06/96


In <199607062307.BAA23440@worf.cse>, on 07/07/96 
   at 01:07 AM, di4sig@cse.hks.se (J÷rgen "Zigge" Sigvardsson) said:

>If someone is interested I have a piece of code that will allow
>everything to be abbreviated. Instead of typing 'kill
>mobwithaverylongandcomplicatedname' you could type 'kill mob'. It's VERY
>appreciated by players.

Try mine, too.  It's much shorter and doesn't do any of the strange stuff
here.

>Here it is:

>in handler.c, change isname() to this:

>#define WHITESPACE " \t"

>int isname(char *str, char *namelist)
>{
>  char *newlist;
>  char *curtok;

>  newlist = strdup(namelist); /* make a copy since strtok 'modifies'
>strings */

Yeah, you can get around this by using strchr().  Of course, you seem to
use strtok() for a multicharacter token, but you can work around that.

>  for(curtok = strtok(newlist, WHITESPACE); 
>      curtok; curtok = strtok(NULL, WHITSPACE))
>     if(curtok && is_abbrev(str, curtok))

is_abbrev()?

>     {
>        free(newlist); 
>        return 1;
>     }

>  free(newlist);
>  return 0;
>}

>This will check for an abbreviation on every word in the namelist.

I'll take your word for it.  But what if there are two mobs in the room,
mobwithaverylongname and mobwithanevenlongername?  Both match "kill mob"
precisely according to your function.  I guess you just automatically kill
the first one?  I don't think your players would appreciate it if they
killed the wrong mob because your function refused to admit there were two
possibilities.

Even better:  two mobs in the room, one named "thisismob1" and the other
named "thisismob1.5".  A player types "kill thisismob1".  Again, it
depends on the ordering; otherwise, it's impossible to kill that mob.

Of course, you could be handling this in is_abbrev().  I can't tell,
though.  (Is that function shipped with Circle?  I'd check, but it's on my
Linux partition...)

>// Zigg


---------------------------------------------------------------------------
Barid Bel Medar                                       
icarus@berkshire.net Knights of the Cosmos                     Shayol Ghul
Resort and Health Spa
---------------------------------------------------------------------------
"I  am  returning  this  otherwise good typing paper to you because
someone has printed  gibberish  all  over  it  and  put  your  name  at 
the  top."
 - English Professor, Ohio University
---------------------------------------------------------------------------



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