Was messing around with imm commands the other day, and I noticed that the
display from the skillset command (no args)(ACMD(do_skillset) in modify.c
stock 30bpl21) leaves a little to be desired. So I cleaned it up a bit.
Figured why not throw it out on the list and see what people think.
Here is what the display from the old code looks like:
500H 100M 82V > skillset
Syntax: skillset <name> '<skill>' <value>
Skill being one of the following:
armor teleport bless blindness
burning hands call lightning charm person chill touch
clone color spray control weather create food
create water cure blind cure critic cure light
curse detect alignmentdetect invisibility detect magic
detect poison dispel evil earthquake enchant weapon
energy drain fireball harm heal
invisibility lightning bolt locate object magic missile
poisonprotection from evil remove curse sanctuary
shocking grasp sleep strength summon
word of recall remove poison sense life animate dead
dispel good group armor group heal infravision
waterwalk backstab bash hide
kick pick lock rescue sneak
steal track identify fire breath
gas breath frost breath acid breath lightning breath
500H 100M 82V >
Heres what the display from the new code looks like:
500H 100M 82V > skillset
Syntax: skillset <name> '<skill>' <value>
Skill being one of the following:
armor teleport bless blindness
burning hands call lightning charm person chill touch
clone color spray control weather create food
create water cure blind cure critic cure light
curse detect alignment detect invisibili~ detect magic
detect poison dispel evil earthquake enchant weapon
energy drain fireball harm heal
invisibility lightning bolt locate object magic missile
poison protection from e~ remove curse sanctuary
shocking grasp sleep strength summon
word of recall remove poison sense life animate dead
dispel good group armor group heal infravision
waterwalk backstab bash hide
kick pick lock rescue sneak
steal track identify fire breath
gas breath frost breath acid breath lightning breath
500H 100M 82V >
As you can see, the spells protection from evil and detect invisibility have
been truncated, and a '~' has been added to the end of each spell.
This was accomplished by using snprintf() to limit (truncate) the length of
each spell name. Then we do a check to see if spell_info[i].name is longer
than 17 chars - if it is we add the '~' to the end of the string and print
it. I'll let the code explain itself.
New code for the display part of the function:
ACMD(do_skillset)
{
struct char_data *vict;
char name[MAX_INPUT_LENGTH], help[MAX_STRING_LENGTH];
char buf[MAX_INPUT_LENGTH], buf1[40], buf2[20];
int skill, value, i, qend;
int max_spellname_length = 18;
argument = one_argument(argument, name);
if (!*name) { /* no arguments. print an informative text */
send_to_char(ch, "Syntax: skillset <name> '<skill>' <value>\r\n"
"Skill being one of the following:\r\n");
for (qend = 0, i = 0; i <= TOP_SPELL_DEFINE; i++) {
if (spell_info[i].name == unused_spellname) /* This is valid. */
continue;
snprintf(buf2, max_spellname_length, "%s", spell_info[i].name);
if (strlen(spell_info[i].name) > 17)
strcat(buf2, "~");
sprintf(buf1, "%-20s", buf2);
send_to_char(ch, buf1);
if (qend++ % 4 == 3)
send_to_char(ch, "\r\n");
}
if (qend % 4 != 0)
send_to_char(ch, "\r\n");
return;
}...
Well I'm sure there are probably more efficient ways of doing this, but this
is what I came up with. Fell free to make comments/suggestions, or point out
any problems. Also feel free to use/change it in any way you like.
Jared
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
| Newbie List: http://groups.yahoo.com/group/circle-newbies/ |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT