Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Removal of the Holy Magic Symbols (http://www.topmudsites.com/forums/showthread.php?t=320)

xanthic 03-15-2004 11:10 AM

I am trying to remove the need of the Holy Magic Symbols from my circle mud. But how can i make so that regardless if the spell has 1, 2, 3 or more words it should know where to end and find the "target"

Many thanks ierodules /GoaX Mud

welcor 03-15-2004 02:03 PM

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.


All times are GMT -4. The time now is 06:13 AM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022