New Spell Abbreviation Function

From: Jeff (jfink@csugrad.cs.vt.edu)
Date: 02/08/94


Has anybody ever noticed how inadequate the abbreviation system is
when casting spells?  When you type "cast 'det' self" you get the
first spell that starts with "det". Since there are 4 - 5 detect
spells, this means you have to type the entire word out for all the
other spells... which is pretty easy for "detect"... but users
don't seem to feel the same way when they have to type 
"protectiom from good".

So I wrote this little function. It allows you to abbreviate each word
of a spell. Hence, "protection from good" is recognized when you type 
"prot from good", or "prot from g", or even "p f g".  (Note that the old 
abbreviation scheme still works as well)

Here's how to install it:

1)	Add the following function to spell_parser.c. Try to put it
	somewhere near the top. (Right after the saving throw arrays
	is a good spot)

 
int find_skill_num(char *name)
{
	int index;
	int found, ok;
	char *temp, *temp2;
	char first[256], first2[256];

	found = 0;
	index = 0;
	while (!found && (*spells[index] != '\n')) {
		if (is_abbrev(name, spells[index]))
			found = 1;
		else {
			ok = 1;
			temp = spells[index];
			temp2 = name;
			while (*temp && *temp2 && ok) {
				temp = one_arg(temp, first);
				temp2 = one_arg(temp2, first2);
				if (!is_abbrev(first2, first))
					ok = 0;
			}

			if (ok && !*temp2) 
				found = 1;
		}
		index++;
	}

	if (found)
		return(index);
	else
		return(-1);
}


2)	To use this function, go further down into spell_parser.c and
	find the line which reads:

	spl = old_search_block(argument, 1, qend - 1, spells, 0);

	And change it to the following:

	strcpy(name, (argument + 1));
	name[quend - 1] = 0;
	spl = find_skill_num(name);

3)	To use the same convention while practicing, go into spec_procs.c
	and go to SPECIAL(guild). Next search for the following line:
	(There are two occurances of this line, you'll want to change both)

	number = old_search_block(arg, 0, strlen(arg), spells, FALSE);

	Change this to:

	number = find_skill_num(arg);

4)	If you have a skillset() function, you'll probably want to also
	use it there. (This exercise is left to the reader ;-)


I'll see if I can dig up my do_skillset() for those who don't have a 
working copy.

-Jeff

PS - Jeremy, are you rewriting the SPECIAL(guild) code? If I recall,
     this was the most awful part of adding new skills and spells.
     



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