/* ************************************************************************ * Skill and Spell listing Part of NirvanaMUD * * Usage: skill [class] or spell [class] * * * * It lists skills and spells that a class will learn. * * + = add this line. * * * * Rodrigo Jose Affonso Magalhaes * * Rio de Janeiro - Brazil * * nirvanamud@hotmail.com * * UIN 24161456 * * * * NirvanaMUD: mud.nlink.com.br 4000 * ************************************************************************ */ file act.informative.c add this at the end of file: +ACMD(do_spell) +{ + extern char *pc_class_types[]; + extern char *spells[]; + extern struct spell_info_type spell_info[]; + int i, j, class; + bool flag = FALSE; + + *buf = '\0'; + *buf2 = '\0'; + + one_argument(argument, arg); + + if (!*arg) { + class = GET_CLASS(ch); + strcpy(buf, "These are the spells that your class will learn:\r\n" + "spell level\r\n"); + strcpy(buf2, buf); + } else { + class = search_block_case(arg, pc_class_types, FALSE); + send_to_char(buf, ch); /* ROD WAS HERE!!! 09/04/1999 */ + if (class < 0 || class >= NUM_CLASSES) { + send_to_char("Not a valid class.\n\r", ch); + return; + } + sprintf(buf, "These are the spells that %s %s will learn:\r\n" + "spell level\r\n" + , AN(pc_class_types[class]), pc_class_types[class]); + strcpy(buf2, buf); + } + + for (j = 1; j < LVL_IMMORT; j++) { + for (i = 1; i < MAX_SPELLS+1; i++) + { + if (spell_info[i].min_level[class] == j) + { + sprintf(buf, "%-20s %d\r\n", spells[i], spell_info[i].min_level[class]); + strcat(buf2, buf); + flag = TRUE; + } + } + } + + if (flag == FALSE) { + if (!*arg) + sprintf(buf2, "You will not learn spells in this class.\r\n"); + else + sprintf(buf2, "The %s class will not learn spells.\r\n", pc_class_types[class]); + } + + page_string(ch->desc, buf2, 1); +} + +ACMD(do_skill) +{ + extern char *pc_class_types[]; + extern char *spells[]; + extern struct spell_info_type spell_info[]; + int i, j, class; + bool flag = FALSE; + + *buf = '\0'; + *buf2 = '\0'; + + one_argument(argument, arg); + + if (!*arg) { + class = GET_CLASS(ch); + strcpy(buf, "These are the skills that your class will learn:\r\n" + "skill level\r\n"); + strcpy(buf2, buf); + } else { + class = search_block_case(arg, pc_class_types, FALSE); + send_to_char(buf, ch); /* ROD WAS HERE!!! 09/04/1999 */ + if (class < 0 || class >= NUM_CLASSES) { + send_to_char("Not a valid class.\n\r", ch); + return; + } + sprintf(buf, "These are the skills that %s %s will learn:\r\n" + "skill level\r\n" + , AN(pc_class_types[class]), pc_class_types[class]); + strcpy(buf2, buf); + } + + for (j = 1; j < LVL_IMMORT; j++) { + for (i = MAX_SPELLS +1; i < MAX_SKILLS+1; i++) + { + if (spell_info[i].min_level[class] == j) + { + sprintf(buf, "%-20s %d\r\n", spells[i], spell_info[i].min_level[class]); + strcat(buf2, buf); + flag = TRUE; + } + } + } + + if (flag == FALSE) { + if (!*arg) + sprintf(buf2, "You will not learn skills in this class.\r\n"); + else + sprintf(buf2, "The %s class will not learn skills.\r\n", pc_class_types[class]); + } + + page_string(ch->desc, buf2, 1); +} + file interpreter.c look at this: ACMD(do_set); ACMD(do_show); ACMD(do_shutdown); ACMD(do_sit); +ACMD(do_skill); ACMD(do_skillset); ACMD(do_sleep); ACMD(do_sneak); ACMD(do_snoop); ACMD(do_spec_comm); +ACMD(do_spell); look at this: { "sip" , POS_RESTING , do_drink , 0, SCMD_SIP }, { "sit" , POS_RESTING , do_sit , 0, 0 }, + { "skill" , POS_RESTING , do_skill , 0, 0 }, { "skillset" , POS_SLEEPING, do_skillset , LVL_GRGOD, 0 }, { "sleep" , POS_SLEEPING, do_sleep , 0, 0 }, { "slap" , POS_RESTING , do_action , 0, 0 }, { "slowns" , POS_DEAD , do_gen_tog , LVL_IMPL, SCMD_SLOWNS }, { "smile" , POS_RESTING , do_action , 0, 0 }, + { "spell" , POS_RESTING , do_spell , 0, 0 }, look at this: /* * searches an array of strings for a target string. "exact" can be * 0 or non-0, depending on whether or not the match must be exact for * it to be returned. Returns -1 if not found; 0..n otherwise. Array * must be terminated with a '\n' so it knows to stop searching. */ int search_block(char *arg, char **list, bool exact) { register int i, l; /* Make into lower case, and get length of string */ for (l = 0; *(arg + l); l++) *(arg + l) = LOWER(*(arg + l)); if (exact) { for (i = 0; **(list + i) != '\n'; i++) if (!strcmp(arg, *(list + i))) return (i); } else { if (!l) l = 1; /* Avoid "" to match the first available * string */ for (i = 0; **(list + i) != '\n'; i++) if (!strncmp(arg, *(list + i), l)) return (i); } return -1; } + +/* + * This function does the same thing as search_block, but it + * uses strcasecmp. by ROD 09/04/1999 + */ +int search_block_case(char *arg, char **list, bool exact) +{ + register int i, l; + + /* Make into lower case, and get length of string */ + for (l = 0; *(arg + l); l++) + *(arg + l) = LOWER(*(arg + l)); + + if (exact) { + for (i = 0; **(list + i) != '\n'; i++) + if (!strcasecmp(arg, *(list + i))) + return (i); + } else { + if (!l) + l = 1; /* Avoid "" to match the first available + * string */ + for (i = 0; **(list + i) != '\n'; i++) + if (!strncasecmp(arg, *(list + i), l)) + return (i); + } + + return -1; +} + file interpreter.h look at this: /* necessary for CMD_IS macro */ #ifndef __INTERPRETER_C__ extern struct command_info cmd_info[]; #endif void command_interpreter(struct char_data *ch, char *argument); int search_block(char *arg, char **list, bool exact); +int search_block_case(char *arg, char **list, bool exact); char lower( char c ); char *one_argument(char *argument, char *first_arg); char *one_word(char *argument, char *first_arg); GOOD LUCK! 8^) **************************************************************************