From: Tyrone Watt <tyrone@whoever.com>
Subject: Training up Stats

Hi,

kinda late & probably been answered, but anyway.....
here is the code i used to train up stats.
prob is buggy and a few things may need to be changed
but here goes.

In structs.h
-----------------
In the structure player_special_data_saved
change one of the ubyte spares --> ubyte trains
Use an int rather if a character can get more than 255 training sessions.

In class.c -> These are the maximum that can be trained / class
----------------
int train_params[6][NUM_CLASSES] = {
  /* MAG	CLE	THE	WAR    RAN    SUN*/ 
  {  16,    17,   17,   18,    18,    16 },   /* Strength */
  {  16,    16,   16,   18,    18,    16 },   /* Constitution */
  {  18,    18,   16,   16,    16,    18 },   /* Wisdom */
  {  18,    17,   17,   16,    17,    18 },   /* Intelligence */
  {  17,    16,   18,   17,    17,    17 },   /* Dexterity */
  {  16,    17,   18,   16,    16,    16 }    /* Charisma */
};

In spec_procs.c
------------------------
extern int train_params[6][NUM_CLASSES];

SPECIAL(trainer)
{
  if (IS_NPC(ch) || !CMD_IS("train"))
    return 0;

  skip_spaces(&argument);

  if (!*argument) 
  {
    sprintf(buf,"Hit:%d Mana:%d Str:%d Con:%d Wis:%d Int:%d Dex:%d
Cha:%d\r\n",
      GET_MAX_HIT(ch), GET_MAX_MANA(ch), GET_STR(ch), GET_CON(ch),
GET_WIS(ch),
      GET_INT(ch), GET_DEX(ch), GET_CHA(ch));
    sprintf(buf,"%sYou have %d training session",buf, GET_TRAINING(ch));
    if (GET_TRAINING(ch) == 1)
       sprintf(buf,"%s.\r\n",buf);
    else
       sprintf(buf,"%ss.\r\n",buf);
    send_to_char(buf,ch);
    return 1;
  }

  if (GET_TRAINING(ch) <= 0) {
    send_to_char("You do not seem to be able to train now.\r\n", ch);
    return 1;
  }

  if (strcmp(argument,"hit")==0)
    {
      GET_TRAINING(ch) -=1;
      GET_MAX_HIT(ch) +=5;
    } else
  if (strcmp(argument,"mana")==0)
    {
      GET_TRAINING(ch) -=1;
      GET_MAX_MANA(ch) +=5;
    } else
  if (strcmp(argument,"str")==0)
    {
      if (GET_STR(ch) >= train_params[0][(int)GET_CLASS(ch)])
       { send_to_char("Your are already fully trained there!\r\n",ch); return 1; }
      GET_TRAINING(ch) -=1;
      ch->real_abils.str+=1;
    } else
  if (strcmp(argument,"con")==0)
    {
      if (GET_CON(ch) >= train_params[1][(int)GET_CLASS(ch)])
       { send_to_char("Your are already fully trained there!\r\n",ch); return 1; }
      GET_TRAINING(ch) -=1;
      ch->real_abils.con+=1;
    } else
  if (strcmp(argument,"wis")==0)
    {
      if (GET_WIS(ch) >= train_params[2][(int)GET_CLASS(ch)])
       { send_to_char("Your are already fully trained there!\r\n",ch); return 1; }
      GET_TRAINING(ch) -=1;
      ch->real_abils.wis+=1;
    } else
  if (strcmp(argument,"int")==0)
    {
      if (GET_INT(ch) >= train_params[3][(int)GET_CLASS(ch)])
       { send_to_char("Your are already fully trained there!\r\n",ch); return 1; }
      GET_TRAINING(ch) -=1;
      ch->real_abils.intel+=1;
    } else
  if (strcmp(argument,"dex")==0)
    {
      if (GET_DEX(ch) >= train_params[4][(int)GET_CLASS(ch)])
       { send_to_char("Your are already fully trained there!\r\n",ch); return 1; }
      GET_TRAINING(ch) -=1;
      ch->real_abils.dex+=1;
    } else
  if (strcmp(argument,"cha")==0)
    {
      if (GET_CHA(ch) >= train_params[5][(int)GET_CLASS(ch)])
       { send_to_char("Your are already fully trained there!\r\n",ch); return 1; }
      GET_TRAINING(ch) -=1;
      ch->real_abils.cha+=1;
    } else
    {
      send_to_char("Train what?\r\n",ch);
      return 1;
    }
  send_to_char("You train for a while...\r\n",ch);
  return 1;
}

Other things you'll have to do is declare GET_TRAINING macro in util.h and
assign the special to
a mob in assign_spec.c.
Me thinks thats about it.

Cheers
Riff.
