Skillset function

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


Ok, here's the skillset we use at DisasterMud. (Plug, Plug, 
128.173.20.37 4000)  This does use the find_skill_num() function that I 
posted earlier. (See the comment in the code, on how to install it without 
the find_skill_num() function) This function should work whether or not you 
give skills to mobiles.  (Default Circle does not, Silly varieties do, etc)

At any rate, just find the do_skillset in modify.c, rip it out, and
add this one instead.

ACMD(do_skillset)
{
   char *skip_spaces(char *string);

   extern char *spells[];
   extern struct char_data *mob_proto;
   struct char_data *vict;
   char name[100], buf2[100], buf[100], help[MAX_STRING_LENGTH];
   int skill, field, value, i, qend, index;

   argument = one_argument(argument, name);

   if (!*name) {      /* no arguments. print an informative text */
      send_to_char("Syntax: skillset <name> '<skill>' <value>\n\n\r", ch);
      strcpy(help, "Skill being one of the following:\n\r");
      for (i = 0; *spells[i] != '\n'; i++) {
	 sprintf(help + strlen(help), "%18s", spells[i]);
	 if (i % 4 == 3) {
	    strcat(help, "\n\r");
	    send_to_char(help, ch);
	    *help = '\0';
	 }
      }
      if (*help)
	 send_to_char(help, ch);
      send_to_char("\n\r", ch);
      return;
   }

   if (!(vict = get_char_vis(ch, name))) {
      send_to_char("No living thing by that name.\n\r",ch);
      return;
   }
 
   argument = skip_spaces(argument);
 
   /* If there is no chars in argument */
   if (!(*argument)) {
      send_to_char("Skill name expected.\n\r",ch);
      return;
   }
 
   if (*argument != '\'') {
      send_to_char("Skill must be enclosed in: ''\n\r",ch);
      return;
   }
 
   /* Locate the last quote && lowercase the magic words (if any) */
 
   for (qend=1; *(argument+qend) && (*(argument+qend) != '\'') ; qend++)
      *(argument+qend) = LOWER(*(argument+qend));
 
   if (*(argument+qend) != '\'') {
      send_to_char("Skill must be enclosed in: ''\n\r",ch);
      return;
   }
 
/*   if ((skill = old_search_block(argument, 1, qend - 1, spells, 0)) < 1) { */

/*	If you don't have find_skill_num() uncomment the line above
	and then comment out the next three lines of code.		*/

   strcpy(help, (argument + 1));
   help[qend - 1] = 0;
   if ((skill = find_skill_num(help)) <= 0) {
      send_to_char("Unrecognized skill.\n\r",ch);
      return;
   } 

   argument += qend+1; /* skip to next parameter */
   argument = one_argument(argument, buf);

   if (!*buf) {
      send_to_char("Learned value expected.\n\r",ch);
      return;
   }

   value = atoi(buf);
   if (value < 0) {
      send_to_char("Minimum value for learned is 0.\n\r",ch);
      return;
   }

   if (value > 100) {
      send_to_char("Max value for learned is 100.\n\r",ch);
      return;
   }
        
   if (!vict->skills) {
      send_to_char("You can't set NPC skills.\n\r", ch);
      return;
   }

   sprintf(buf2,"%s changes %s's %s to %d.",GET_NAME(ch),GET_NAME(vict),
     spells[skill - 1],value);
   syslog(buf2, BRF, -1, TRUE);
   if (IS_NPC(vict) && (vict->nr > -1) && 
      (vict->skills == mob_proto[vict->nr].skills)) {
      CREATE(vict->skills, char, MAX_SKILLS);
      for (index = 0; index < MAX_SKILLS; index++)
	 SET_SKILL(vict, index, GET_SKILL(&mob_proto[vict->nr], index));
   }
	
   SET_SKILL(vict, skill, value);
	
   sprintf(buf2,"You change %s's %s to %d.\n\r" , GET_NAME(vict),
     spells[skill - 1], value); 
   send_to_char(buf2, ch);
}


I'd appreciate getting feedback about this function as to how it works.
(Hopefully, you'll say "Perfectly!" ;-)

-Jeff



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