View Single Post
Old 03-15-2004, 02:03 PM   #2
welcor
Member
 
Join Date: Apr 2002
Location: Aarhus, Denmark, Europe
Posts: 59
welcor is on a distinguished road
Send a message via ICQ to welcor
Though I've not done this myself, What you need to do is something along these lines.
Current setup:
do_cast uses strtok to find the abbreviated spell name between two ''s:
[code] /* get; blank, spell name, target name */
s = strtok(argument, "'");

if (s == NULL) {
send_to_char(ch, "Cast what where?\r\n");
return;
}
s = strtok(NULL, "'");
if (s == NULL) {
send_to_char(ch, "Spell names must be enclosed in the Holy Magic Symbols; '\r\n");
return;
}
t = strtok(NULL, "\0");

/* spellnum = search_block(s, spells, 0); */
spellnum = find_skill_num(s);

if ((spellnum < 1) || (spellnum > MAX_SPELLS)) {
send_to_char(ch, "Cast what?!?\r\n");
return;
}[/quote]

Try this on for size:

[code] skip_spaces(&argument);
if (!*argument) {
send_to_char(ch, "Cast what where?\r\n");
return;
}

spellnum = find_skill_num(argument);

if ((spellnum < 1) || (spellnum > MAX_SPELLS)) {
/*
* if we didn't find it, maybe the last word is a target name
* .. let's split this argument at the last space.
*/
t = strrchr(argument, ' ');
if (!t) {
send_to_char(ch, "Cast what?!?\r\n");
return;
}
t++ = '\0'; /* NULL-terminate argument */
spellnum = find_skill_num(argument);
if ((spellnum < 1) || (spellnum > MAX_SPELLS)) {
send_to_char(ch, "Cast what?!?\r\n");
return;
}
}
[/quote]

I hope this helps.
welcor is offline   Reply With Quote