Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

setskill.c

Go to the documentation of this file.
00001 /*  Concept by Erwin Anderson */
00002 
00003 #if defined( macintosh )
00004 #include <types.h>
00005 #include <time.h>
00006 #else
00007 #include <sys/types.h>
00008 #include <errno.h>      
00009 #include <unistd.h>     
00010 #include <sys/time.h>
00011 #endif
00012 #include <ctype.h>      
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <string.h>
00016 #include "merc.h"
00017 #include "interp.h"
00018 #include "recycle.h"
00019 #include "tables.h"
00020 #include "lookup.h"
00021 
00022 
00023 
00024 void do_setskill (CHAR_DATA *ch ,char * argument)
00025 {
00026     char class_name[MAX_INPUT_LENGTH], skill_name[MAX_INPUT_LENGTH];
00027     int sn, level, class_no;
00028     char hard[MAX_INPUT_LENGTH];
00029     
00030     argument = one_argument (argument, class_name);
00031     argument = one_argument (argument, skill_name);
00032     argument = one_argument (argument, hard);
00033     if (!argument[0])
00034     {
00035         send_to_char ("Syntax: SETSKILL <class> <skill> <CP> <level>\n\rCP: how much CreationPoints it will cost.\n\r",ch);
00036         return;
00037     }
00038 
00039     level = atoi(argument);
00040 
00041     if(!is_number(argument) || level < 0 || level > LEVEL_IMMORTAL)
00042     {
00043         printf_to_char (ch, "Level range is from 0 to %d.\n\r", LEVEL_IMMORTAL);
00044         return;
00045     }
00046     if (!is_number(hard))
00047     {
00048         send_to_char("Hardness must be a number\n\r",ch);
00049         return;
00050     }
00051     
00052     if (atoi (hard) < 0 || atoi (hard) > 9)
00053     {
00054         send_to_char("Hardness cannot be below zero, or above nine.\n\r",ch);
00055         printf_to_char(ch, "%d -- hard", atoi(hard));
00056         return;
00057     }
00058     
00059 
00060     if ( (sn = skill_lookup (skill_name)) == -1)
00061         
00062     {
00063         printf_to_char (ch, "There is no such spell/skill as '%s'.\n\r", skill_name);
00064         return;
00065     }
00066     
00067     for (class_no = 0; class_no < MAX_CLASS; class_no++)
00068         if (!str_cmp(class_name, class_table[class_no].who_name))
00069                 break;      
00070     if(class_no == MAX_CLASS)
00071     {
00072         printf_to_char (ch, "No class named '%s' exists. Use the 3-letter WHO names (Psi, Mag etc.)\n\r", class_name);
00073         return;
00074     }
00075     skill_table[sn].skill_level[class_no] = level;
00076     skill_table[sn].rating[class_no] = atoi (hard);
00077     
00078     printf_to_char (ch, "OK, %ss will now gain %s at level %d%s, and will learn with a %d rating.\n\r", class_table[class_no].name,
00079         skill_table[sn].name, level, level == LEVEL_IMMORTAL ? " (i.e. never)" : "", skill_table[sn].rating[class_no]);
00080     do_function(ch,do_save_class,"");
00081     return;
00082 }
00083         
00084         
00085             
00086             

Generated on Thu Jan 13 21:48:14 2005 for Beyond the Shadows by  doxygen 1.4.0