~case/dbns

8f2f4d4ca30221d20ca5ca8692504dd89b3bb328 — case 4 years ago b183d6e + 05362f9
Merge branch 'master' of ssh://capsulecorp.org:712/srv/git/db
M src/Makefile => src/Makefile +1 -1
@@ 8,7 8,7 @@ DATA_FOLDERS = ../area ../clans ../classes ../councils ../deity ../doc ../gods \
	../houses ../planets ../races ../space ../system

C_FLAGS = -O2 -g3 -Wall -std=c99 ${DBUGFLG} ${TIME} ${REG}
L_FLAGS = ${MATH_LINK} -lz -lbsd
L_FLAGS = ${MATH_LINK} -lz

O_FILES = act_comm.o act_info.o act_move.o act_obj.o act_wiz.o \
          board.o boards.o bounty.o build.o clans.o colorize.o comm.o \

M src/act_comm.c => src/act_comm.c +2 -3
@@ 15,7 15,6 @@
*			   Player communication module                     *
****************************************************************************/
#include <sys/types.h>
#include <bsd/stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#include <stdio.h>


@@ 225,7 224,7 @@ translate(int percent, const char *in, const char *name)
	for (pbuf = in; *pbuf;) {
		for (cnv = lng->first_precnv; cnv; cnv = cnv->next) {
			if (!str_prefix(cnv->old, pbuf)) {
			  if (percent && (int)(arc4random() % 100) < percent) {
			  if (percent && (int)(random() % 100) < percent) {
					strncpy(pbuf2, pbuf, cnv->olen);
					pbuf2[cnv->olen] = '\0';
					pbuf2 += cnv->olen;


@@ 238,7 237,7 @@ translate(int percent, const char *in, const char *name)
			}
		}
		if (!cnv) {
		  if (isalpha(*pbuf) && (!percent || (int)(arc4random() % 100) > percent)) {
		  if (isalpha(*pbuf) && (!percent || (int)(random() % 100) > percent)) {
				*pbuf2 = lng->alphabet[LOWER(*pbuf) - 'a'];
				if (isupper(*pbuf))
					*pbuf2 = UPPER(*pbuf2);

M src/act_info.c => src/act_info.c +27 -14
@@ 664,11 664,11 @@ show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
	    && IS_AFFECTED(victim, AFF_SSJ4)
	    && !IS_AFFECTED(victim, AFF_SGOD)) {
		pager_printf_color(ch, "  &P*");
		act(AT_RED, "$N's body is covered in thick, red fur.&P",
		act(AT_RED, "$N's body is emitting an indescribable ki.&P",
		    ch, NULL, victim, TO_CHAR);
		pager_printf_color(ch, "  &P*");
		act(AT_RED,
		    "$N is surrounded by a menacing aura of fiery red.&P", ch,
		    "$N is engulfed in a blaze of crimson and gold God Ki.&P", ch,
		    NULL, victim, TO_CHAR);
	}
	if (IS_AFFECTED(victim, AFF_SSJ)


@@ 677,11 677,11 @@ show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
	    && IS_AFFECTED(victim, AFF_SSJ4)
	    && IS_AFFECTED(victim, AFF_SGOD)) {
		pager_printf_color(ch, "  &P*");
		act(AT_PURPLE, "$N's hair and eyes are a shade of purple.&P",
		act(AT_LBLUE, "$N's hair and eyes are a light shade of blue.&P",
		    ch, NULL, victim, TO_CHAR);
		pager_printf_color(ch, "  &P*");
		act(AT_RED,
		    "$N is surrounded by a menacing aura of translucent fire.&P", ch,
		act(AT_LBLUE,
		    "$N is surrounded by a whorl of raging blue God Ki.&P", ch,
		    NULL, victim, TO_CHAR);
	}
	if (IS_AFFECTED(victim, AFF_SSJ)


@@ 693,7 693,11 @@ show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
	}
	if (IS_AFFECTED(victim, AFF_SSJ)
	    && IS_AFFECTED(victim, AFF_USSJ)
	    && IS_AFFECTED(victim, AFF_USSJ2)) {
	    && IS_AFFECTED(victim, AFF_USSJ2)
		&& !IS_AFFECTED(victim, AFF_SSJ2)
		&& !IS_AFFECTED(victim, AFF_SSJ3)
		&& !IS_AFFECTED(victim, AFF_SSJ4)
		&& !IS_AFFECTED(victim, AFF_SGOD)) {
		pager_printf_color(ch, "  &P*");
		act(AT_YELLOW, "$N's muscles are grossly oversized.&P", ch,
		    NULL, victim, TO_CHAR);


@@ 753,7 757,7 @@ show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
	    && IS_AFFECTED(victim, AFF_ICER5)) {
		pager_printf_color(ch, "  &P*");
		act(AT_PURPLE,
		    "$N has armored plating and cruel spikes protecting $S giant, "
		    "$N's once sleek body is swollen with energy, taking on a giant, "
		    "muscle-bound form.&P", ch, NULL, victim, TO_CHAR);
		pager_printf_color(ch,
		    "  &P*&P%s is covered in dark, icy purple flames.&P\n\r",


@@ 764,14 768,11 @@ show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
	    && !IS_AFFECTED(victim, AFF_ICER5)
	    &&  IS_AFFECTED(victim, AFF_GOLDENFORM)) {
		pager_printf_color(ch, "  &P*");
		act(AT_PURPLE,
		    "$N has armored plating and cruel spikes protecting $S giant, "
		    "muscle-bound form.&P", ch, NULL, victim, TO_CHAR);
		pager_printf_color(ch,
		    "  &P*&P%s is covered in dark, icy purple flames.&P\n\r",
		    name);
		act(AT_YELLOW,
		    "$N's sleek, reflective body radiates an intense gold-amber glow.",
			ch, NULL, victim, TO_CHAR);
		pager_printf_color(ch,
		    "  &Y*&Y%s is shimmering in deep, golden aura.&P\n\r",
		    "  &Y*&Y%s is covered in a massive golden aura.&P\n\r",
		    name);
	}
	if (IS_AFFECTED(victim, AFF_HYPER)) {


@@ 779,6 780,18 @@ show_visible_affects_to_char(CHAR_DATA * victim, CHAR_DATA * ch)
		act(z, "$N is covered in bright energy flames.", ch,
		    NULL, victim, TO_CHAR);
	}
	if (IS_AFFECTED(victim, AFF_MYSTIC)) {
		if ((ch->pl / ch->exp) >= 600) {
			pager_printf_color(ch, "  &P*");
			act(z, "$N's body radiates an intense God Ki from within.", ch,
				NULL, victim, TO_CHAR);
		}
		else {
			pager_printf_color(ch, "  &P*");
			act(z, "$N appears normal, if not for an unsettling power lurking within.", ch,
				NULL, victim, TO_CHAR);
		}
	}
	if (IS_AFFECTED(victim, AFF_EXTREME)) {
		pager_printf_color(ch, "  &P*");
		act(z, "$N has a corona of energy lightning.", ch, NULL,

M src/act_move.c => src/act_move.c +9 -0
@@ 1906,6 1906,15 @@ do_sit(CHAR_DATA * ch, char *argument)
void 
do_rest(CHAR_DATA * ch, char *argument)
{
	if (xIS_SET((ch)->affected_by, AFF_PUSHUPS)
		|| xIS_SET((ch)->affected_by, AFF_SHADOWBOXING)
		|| xIS_SET((ch)->affected_by, AFF_ENDURING)
		|| xIS_SET((ch)->affected_by, AFF_MEDITATION)
		|| xIS_SET((ch)->affected_by, AFF_POWERCHANNEL)
		|| xIS_SET((ch)->affected_by, AFF_OVERCHANNEL)) {
			send_to_char("You're a little too busy to do that.\n\r", ch);
			return;
		}
	switch (ch->position) {
	case POS_SLEEPING:
		if (IS_AFFECTED(ch, AFF_SLEEP)) {

M src/act_wiz.c => src/act_wiz.c +14 -14
@@ 450,7 450,7 @@ do_disconnect(CHAR_DATA * ch, char *argument)
	for (d = first_descriptor; d; d = d->next) {
		if (d == victim->desc) {
			log_string("preparing to close socket at act_wiz.c:854\n");
			close_socket(d, true, false);
			close_socket(d, true);
			send_to_char("Ok.\n\r", ch);
			return;
		}


@@ 512,7 512,7 @@ do_forceclose(CHAR_DATA * ch, char *argument)
				return;
			}
			log_string("preparing to close socket at act_wiz.c:916\n");
			close_socket(d, true, false);
			close_socket(d, true);
			send_to_char("Ok.\n\r", ch);
			return;
		}


@@ 5058,7 5058,7 @@ do_destroy(CHAR_DATA * ch, char *argument)
				break;
		if (d)
			log_string("preparing to close socket at comm.c:5520\n");
			close_socket(d, true, true);
		close_socket(d, true);
	} else {
		int 	x , y;



@@ 9639,12 9639,12 @@ do_godset(CHAR_DATA * ch, char *argument)
		send_to_pager_color("&wOk.\n\r", ch);
		return;
	}
	/* Set a PC's train points */
	/* Set a PC's mastery points */
	if (!str_cmp(arg2, "train")) {
		if (!can_mmodify(ch, victim))
			return;
		if (value < 0 || value > 360) {
			send_to_char("Train range is 0 to 360 sessions.\n\r", ch);
		if (value < 0) {
			send_to_char("Mastery range must be greater than 0.\n\r", ch);
			return;
		}
		victim->train = value;


@@ 10091,8 10091,8 @@ do_godstat(CHAR_DATA * ch, char *argument)
	    "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\r");

	pager_printf_color(ch,
	    "PRACT: &G%2d&C/&g%2d&C    &YLifeforce&C: [&Y%3d&C]%c             AutoZeni: (&W%c&C)    AutoExit: (&W%c&C)\n\r",
	    victim->practice, victim->max_prac, victim->hit, '%',
	    "                  &YLifeforce&C: [&Y%3d&C]             AutoZeni: (&W%c&C)    AutoExit: (&W%c&C)\n\r",
	    victim->hit,
	    xIS_SET(victim->act, PLR_AUTOGOLD) ? 'X' : ' ',
	    xIS_SET(victim->act, PLR_AUTOEXIT) ? 'X' : ' ');



@@ 10101,20 10101,20 @@ do_godstat(CHAR_DATA * ch, char *argument)

	if (victim->max_mana < 1000)
		pager_printf_color(ch,
		    "TRAIN: &G%2d&C/&g%2d&C       &YEnergy&C: [&Y%3s&C/&Y%-3s&C]           Sparing: (&W%c&C)    AutoLoot: (&W%c&C)\n\r",
		    victim->train, victim->max_train, buf, buf2,
		    "MASTERY: &G%2d&C       &YEnergy&C: [&Y%3s&C/&Y%-3s&C]           Sparing: (&W%c&C)    AutoLoot: (&W%c&C)\n\r",
		    victim->train, buf, buf2,
		    xIS_SET(victim->act, PLR_SPAR) ? 'X' : ' ',
		    xIS_SET(victim->act, PLR_AUTOLOOT) ? 'X' : ' ');
	else if (victim->max_mana < 10000)
		pager_printf_color(ch,
		    "TRAIN: &G%2d&C/&g%2d&C       &YEnergy&C: [&Y%5s&C/&Y%-5s&C]       Sparing: (&W%c&C)    AutoLoot: (&W%c&C)\n\r",
		    victim->train, victim->max_train, buf, buf2,
		    "MASTERY: &G%2d&C       &YEnergy&C: [&Y%5s&C/&Y%-5s&C]       Sparing: (&W%c&C)    AutoLoot: (&W%c&C)\n\r",
		    victim->train, buf, buf2,
		    xIS_SET(victim->act, PLR_SPAR) ? 'X' : ' ',
		    xIS_SET(victim->act, PLR_AUTOLOOT) ? 'X' : ' ');
	else
		pager_printf_color(ch,
		    "TRAIN: &G%2d&C/&g%2d&C       &YEnergy&C: [&Y%6s&C/&Y%-6s&C]     Sparing: (&W%c&C)    AutoLoot: (&W%c&C)\n\r",
		    victim->train, victim->max_train, buf, buf2,
		    "MASTERY: &G%2d&C       &YEnergy&C: [&Y%6s&C/&Y%-6s&C]     Sparing: (&W%c&C)    AutoLoot: (&W%c&C)\n\r",
		    victim->train, buf, buf2,
		    xIS_SET(victim->act, PLR_SPAR) ? 'X' : ' ',
		    xIS_SET(victim->act, PLR_AUTOLOOT) ? 'X' : ' ');


M src/build.c => src/build.c +2 -1
@@ 176,7 176,8 @@ char   *const a_flags[] =
	"perfect", "ultraperfect", "growth", "giant", "splitform", "triform",	/*- Temp fix --Krillin*/
	"multiform", "ussj", "ussj2", "extreme", "thin", "super", "kid", "mystic",
	"superandroid", "noglobaldrop", "makeostar", "evilboost", "evilsurge",
	"eviloverload", "biojr", "goldenoozaru"
	"eviloverload", "biojr", "goldenoozaru", "pushups", "shadowboxing", "enduring",
	"meditation", "powerchannel", "overchannel", "safemax"
};

char   *const act_flags[] =

M src/comm.c => src/comm.c +1817 -1364
@@ 18,7 18,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <bsd/stdlib.h>
#include <getopt.h>
#include <syslog.h>
#include <ctype.h>


@@ 43,8 42,13 @@
#include <arpa/inet.h>
#include <arpa/telnet.h>
#include <netdb.h>

#define closesocket close
#define ENOSR 63
#define BERR 255
#define	INVALID	1
#define	TOOSMALL 2
#define	TOOLARGE 3

const char echo_off_str[] = {IAC, WILL, TELOPT_ECHO, '\0'};
const char echo_on_str[] = {IAC, WONT, TELOPT_ECHO, '\0'};


@@ 88,10 92,11 @@ void 	new_descriptor(int new_desc);
bool 	read_from_descriptor(DESCRIPTOR_DATA * d);
bool 	write_to_descriptor(int desc, char *txt, int length);
bool 	check_parse_name(char *name, bool newchar);
bool 	check_reconnect(DESCRIPTOR_DATA * d, char *name, bool fConn);
bool 	check_playing(DESCRIPTOR_DATA * d, char *name);
bool    check_reconnect(DESCRIPTOR_DATA *d, char *name, bool f_conn);
bool	check_playing (DESCRIPTOR_DATA *d, char *name, bool kick);
bool 	reconnect(DESCRIPTOR_DATA * d, char *name);
int 	main(int argc, char **argv);
void	stop_idling(CHAR_DATA *ch );
void 	nanny(DESCRIPTOR_DATA * d, char *argument);
bool 	flush_buffer(DESCRIPTOR_DATA * d, bool f_prompt);
void 	read_from_buffer(DESCRIPTOR_DATA * d);


@@ 107,6 112,8 @@ bool 	check_pfile(DESCRIPTOR_DATA * d);
void    p_to_fp(char *p, char *fp);
void    load_from_fp(DESCRIPTOR_DATA * d, bool np);
void 	usage(void);
long long strtonum(const char *numstr, long long minval, long long maxval,
	 const char **errstrp);

/* locals */
unsigned int port;


@@ 265,48 272,62 @@ main(int argc, char **argv)
int
init_socket(int port)
{
	char 	hostname[64];
	struct sockaddr_in sa;
	struct linger ld;
	int 	x = 1;
	int 	fd;

	gethostname(hostname, sizeof(hostname));

	if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		perror("init_socket: socket");
		exit(1);
	}
	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
	    (void *) &x, sizeof(x)) < 0) {
		perror("init_socket: SO_REUSEADDR");
		closesocket(fd);
		exit(1);
	}
	ld.l_onoff = 1;
	ld.l_linger = 1000;

	if (setsockopt(fd, SOL_SOCKET, SO_LINGER,
	    (void *) &ld, sizeof(ld)) < 0) {
		perror("init_socket: SO_DONTLINGER");
		closesocket(fd);
		exit(1);
	}
	memset(&sa, '\0', sizeof(sa));
	sa.sin_family = AF_INET;
	sa.sin_port = htons(port);

	if (bind(fd, (struct sockaddr *) & sa, sizeof(sa)) == -1) {
		perror("init_socket: bind");
		closesocket(fd);
		exit(1);
	}
	if (listen(fd, 50) < 0) {
		perror("init_socket: listen");
		closesocket(fd);
		exit(1);
	}
	return (fd);
  char hostname[64];
  struct sockaddr_in sa;
  int x = 1;
  int fd;

  gethostname(hostname, sizeof(hostname));


  if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    {
      perror("Init_socket: socket");
      exit(1);
    }

  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
		 (void *) &x, sizeof(x)) < 0)
    {
      perror("Init_socket: SO_REUSEADDR");
      closesocket(fd);
      exit(1);
    }

#if defined(SO_DONTLINGER)
  struct linger ld;

  ld.l_onoff  = 1;
  ld.l_linger = 1000;

  if (setsockopt(fd, SOL_SOCKET, SO_DONTLINGER,
		 (void *) &ld, sizeof(ld)) < 0)
    {
      perror("Init_socket: SO_DONTLINGER");
      closesocket(fd);
      exit(1);
    }
#endif

  memset(&sa, '\0', sizeof(sa));
  sa.sin_family   = AF_INET;
  sa.sin_port	    = htons(port);

  if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1)
    {
      perror("Init_socket: bind");
      closesocket(fd);
      exit(1);
    }

  if (listen(fd, 50) < 0)
    {
      perror("Init_socket: listen");
      closesocket(fd);
      exit(1);
    }

  return fd;
}

static void


@@ 466,216 487,275 @@ check_bad_desc(int desc)
void
accept_new(int ctrl)
{
	static struct timeval null_time;
	DESCRIPTOR_DATA *d;

	/*
	 * Poll all active descriptors.
	 */
	FD_ZERO(&in_set);
	FD_ZERO(&out_set);
	FD_ZERO(&exc_set);
	FD_SET(ctrl, &in_set);

	maxdesc = ctrl;
	newdesc = 0;
	for (d = first_descriptor; d; d = d->next) {
		maxdesc = UMAX(maxdesc, d->descriptor);
		FD_SET(d->descriptor, &in_set);
		FD_SET(d->descriptor, &out_set);
		FD_SET(d->descriptor, &exc_set);
		if (d->ifd != -1 && d->ipid != -1) {
			maxdesc = UMAX(maxdesc, d->ifd);
			FD_SET(d->ifd, &in_set);
		}
		if (d == last_descriptor)
			break;
	}
	if (select(maxdesc + 1, &in_set, &out_set, &exc_set, &null_time) < 0) {
		perror("accept_new: select: poll");
		exit(1);
	}
	if (FD_ISSET(ctrl, &exc_set)) {
		bug("Exception raise on controlling descriptor %d", ctrl);
		FD_CLR(ctrl, &in_set);
		FD_CLR(ctrl, &out_set);
	} else {
		if (FD_ISSET(ctrl, &in_set)) {
			newdesc = ctrl;
			new_descriptor(newdesc);
		}
  static struct timeval null_time;
  DESCRIPTOR_DATA *d;

  /*
   * Poll all active descriptors.
   */
  FD_ZERO(&in_set );
  FD_ZERO(&out_set);
  FD_ZERO(&exc_set);
  FD_SET(ctrl, &in_set);

  maxdesc = ctrl;
  newdesc = 0;
  for (d = first_descriptor; d; d = d->next)
    {
      maxdesc = UMAX(maxdesc, d->descriptor);
      FD_SET(d->descriptor, &in_set );
      FD_SET(d->descriptor, &out_set);
      FD_SET(d->descriptor, &exc_set);
      if(d->ifd != -1 && d->ipid != -1)
	{
	  maxdesc = UMAX(maxdesc, d->ifd);
	  FD_SET(d->ifd, &in_set);
	}
      if (d == last_descriptor)
	break;
    }

  if (select(maxdesc+1, &in_set, &out_set, &exc_set, &null_time) < 0)
    {
      perror("accept_new: select: poll");
      exit(1);
    }


  if (FD_ISSET(ctrl, &exc_set))
    {
      bug("Exception raise on controlling descriptor %d", ctrl);
      FD_CLR(ctrl, &in_set);
      FD_CLR(ctrl, &out_set);
    }
  else
    if (FD_ISSET(ctrl, &in_set))
      {
	newdesc = ctrl;
	new_descriptor(newdesc);
      }
}

void
game_loop()
{
	struct timeval last_time;
	char 	cmdline[MAX_INPUT_LENGTH];
	DESCRIPTOR_DATA *d;
  struct timeval last_time;
  char cmdline[MAX_INPUT_LENGTH];
  DESCRIPTOR_DATA *d;

  signal(SIGSEGV, seg_vio);
  signal(SIGKILL, sig_kill);
  signal(SIGTERM, sig_term);
  signal(SIGINT, sig_int);
  signal(SIGHUP, sig_hup);
  signal(SIGQUIT, sig_quit);
  signal(SIGPIPE, SIG_IGN);

  gettimeofday(&last_time, NULL);
  current_time = (time_t) last_time.tv_sec;

  /* Main loop */
  while (!mud_down)
    {
      accept_new(control );

      /*
       * Kick out descriptors with raised exceptions
       * or have been idle, then check for input.
       */
      for (d = first_descriptor; d; d = d_next)
	{
	  if (d == d->next)
	    {
	      bug("descriptor_loop: loop found & fixed");
	      d->next = NULL;
	    }
	  d_next = d->next;

	  d->idle++;	/* make it so a descriptor can idle out */
	  if (d->idle > 2)
	    d->prev_idle = d->idle;

	  if (FD_ISSET(d->descriptor, &exc_set))
	    {
	      FD_CLR(d->descriptor, &in_set );
	      FD_CLR(d->descriptor, &out_set);
	      if (d->character
		  && (d->connected == CON_PLAYING
		      ||   d->connected == CON_EDITING))
		save_char_obj(d->character);
	      d->outtop	= 0;
	      close_socket(d, true);
	      continue;
	    }
	  else
	    if ((!d->character && d->idle > 480)		  /* 2 mins */
		||   (d->connected != CON_PLAYING && d->idle > 1200) /* 5 mins */
		||     d->idle > 28800)				  /* 2 hrs  */
	      {
		write_to_descriptor(d->descriptor,
				    "Idle timeout... disconnecting.\n\r", 0);
		d->outtop	= 0;
		close_socket(d, true);
		continue;
	      }
	    else
	      {
		d->fcommand	= false;

		if (FD_ISSET(d->descriptor, &in_set))
		  {
		    if (d->character)
		      {
			d->character->timer = 0;
			if (d->character->pcdata && d->character->level < 51)
			  {
			    if (d->idle >= 180)
			      {
				if (d->character->pcdata->i_idle < 0)
				  d->character->pcdata->i_idle = 0;
				if (d->character->pcdata->i_idle > 4)
				  d->character->pcdata->i_idle = 0;

				d->character->pcdata->p_idle[d->character->pcdata->i_idle] = (d->idle / 4);
				d->character->pcdata->i_idle++;
			      }
			  }
		      }
		    if (d->prev_idle < 2)
		      d->psuppress_cmdspam = true;
		    else
		      d->psuppress_cmdspam = false;

		    d->psuppress_channel = 0;
		    d->prev_idle = d->idle;
		    d->idle = 0;

		    if (!read_from_descriptor(d))
		      {
			FD_CLR(d->descriptor, &out_set);
			if (d->character
			    && (d->connected == CON_PLAYING
				||   d->connected == CON_EDITING))
			  save_char_obj(d->character);
			d->outtop	= 0;
			close_socket(d, false);
			continue;
		      }
		  }

	signal(SIGSEGV, seg_vio);
	signal(SIGKILL, sig_kill);
	signal(SIGTERM, sig_term);
	signal(SIGINT, sig_int);
	signal(SIGHUP, sig_hup);
	signal(SIGQUIT, sig_quit);
	signal(SIGPIPE, SIG_IGN);
		/* check for input from the dns */
		if((d->connected == CON_PLAYING || d->character != NULL) && d->ifd != -1 && FD_ISSET(d->ifd, &in_set))
		  process_dns(d);

	gettimeofday(&last_time, NULL);
	current_time = (time_t) last_time.tv_sec;
		if (d->character && d->character->wait > 0)
		  {
		    --d->character->wait;
		    continue;
		  }

	/* main loop */
	while (!mud_down) {
		accept_new(control);
		/*
		 * Kick out descriptors with raised exceptions
		 */
		for (d = first_descriptor; d; d = d_next) {
			if (d == d->next) {
				bug("descriptor_loop: loop found & fixed");
				d->next = NULL;
			}
			d_next = d->next;
			if (FD_ISSET(d->descriptor, &exc_set)) {
				FD_CLR(d->descriptor, &in_set);
				FD_CLR(d->descriptor, &out_set);
				/* exceptional state, fquit */
				if (d->character) {
					log_string("preparing to fquit comm.c:652\n");
					close_socket(d, true, true);
					continue;
				}
				d->outtop = 0;
				log_string("preparing to close socket at comm.c:657\n");
				close_socket(d, true, true);
				continue;
			} else {
				d->fcommand = false;
				if (FD_ISSET(d->descriptor, &in_set)) {
					if (!read_from_descriptor(d)) {
						FD_CLR(d->descriptor, &out_set);
						if (d->character
						    && (d->connected == CON_PLAYING
						    || d->connected == CON_EDITING)) {
							log_string("preparing to fquit comm.c:668\n");
							fquit(d->character);
							continue;
						}
						/* new creation EOF catch */
						if (d->character) {
							log_string("preparing to close socket at comm.c:647\n");
							close_socket(d, true, true);
							continue;
							/*
							 * odd state, no
							 * character but
							 * descriptor
							 * remains
							 */
						} else {
							log_string("preparing to close socket at comm.c:652\n");
							close_socket(d, true, true);
							continue;
						}
						log_string("made it to the end without clearing EOF");
					}
				}
				/* check for input from the dns */
				if ((d->connected == CON_PLAYING
				    || d->character != NULL)
				    && d->ifd != -1
				    && FD_ISSET(d->ifd, &in_set))
					process_dns(d);
				if (d->character && d->character->wait > 0) {
					--d->character->wait;
					continue;
				}
				read_from_buffer(d);
				if (d->incomm[0] != '\0') {
					d->fcommand = true;
					utf8cpy(cmdline, d->incomm);
					d->incomm[0] = '\0';

					if (d->character)
						set_cur_char(d->character);
					switch (d->connected) {
					case CON_PLAYING:
						interpret(d->character, cmdline);
						break;
					case CON_EDITING:
						edit_buffer(d->character, cmdline);
						break;
					default:
						nanny(d, cmdline);
						break;
					}
				}
			}
			if (d == last_descriptor)
				break;
		}
		/* autonomous game motion */
		update_handler();

		/* check REQUESTS pipe */
		check_requests();

		/* output */
		for (d = first_descriptor; d; d = d_next) {
			d_next = d->next;
			if ((d->fcommand || d->outtop > 0)
			    && FD_ISSET(d->descriptor, &out_set)) {
				/*
				 * ignore ret value, runtime will clear out
				 * EPIPE or EOF
				 */
				if (!flush_buffer(d, true)) {
					d->outtop = 0;
				}
			}
			if (d == last_descriptor)
				break;
		}

		/*
		 * Synchronize to a clock.
		 * sleep(last_time + 1/PULSE_PER_SECOND - now).
		 */
		struct timeval now_time;
		long 	sec_delta;
		long 	usec_delta;

		gettimeofday(&now_time, NULL);
		usec_delta = ((int) last_time.tv_usec) - ((int) now_time.tv_usec)
		    + 1000000 / PULSE_PER_SECOND;
		sec_delta = ((int) last_time.tv_sec) - ((int) now_time.tv_sec);
		while (usec_delta < 0) {
			usec_delta += 1000000;
			sec_delta -= 1;
		}
		read_from_buffer(d);
		if (d->incomm[0] != '\0')
		  {
		    d->fcommand	= true;
		    stop_idling(d->character);

		while (usec_delta >= 1000000) {
			usec_delta -= 1000000;
			sec_delta += 1;
		}
		    strcpy(cmdline, d->incomm);
		    d->incomm[0] = '\0';

		if (sec_delta > 0 || (sec_delta == 0 && usec_delta > 0)) {
			struct timeval stall_time;
		    if (d->character)
		      set_cur_char(d->character);

			stall_time.tv_usec = usec_delta;
			stall_time.tv_sec = sec_delta;
			if (select(0, NULL, NULL, NULL, &stall_time) < 0 && errno != EINTR) {
				perror("game_loop: select: stall");
				exit(1);
		      switch(d->connected)
			{
			default:
			  nanny(d, cmdline);
			  break;
			case CON_PLAYING:
			  interpret(d->character, cmdline);
			  break;
			case CON_EDITING:
			  edit_buffer(d->character, cmdline);
			  break;
			}
		  }
	      }
	  if (d == last_descriptor)
	    break;
	}
      /*
       * Autonomous game motion.
       */
      update_handler();

      /*
       * Check REQUESTS pipe
       */
      check_requests();

      /*
       * Output.
       */
      for (d = first_descriptor; d; d = d_next)
	{
	  d_next = d->next;

	  if ((d->fcommand || d->outtop > 0)
	      &&   FD_ISSET(d->descriptor, &out_set))
	    {
	      if (!flush_buffer(d, true))
		{
		  if (d->character
		      && (d->connected == CON_PLAYING
			  ||   d->connected == CON_EDITING))
		    save_char_obj(d->character);
		  d->outtop	= 0;
		  close_socket(d, false);
		}
		gettimeofday(&last_time, NULL);
		current_time = (time_t) last_time.tv_sec;
	    }
	  if (d == last_descriptor)
	    break;
	}
      {
	struct timeval now_time;
	long secDelta;
	long usecDelta;

	/* make sure strerr is flushed */
	fflush(stderr);
	gettimeofday(&now_time, NULL);
	usecDelta	= ((int) last_time.tv_usec) - ((int) now_time.tv_usec)
	  + 1000000 / PULSE_PER_SECOND;
	secDelta	= ((int) last_time.tv_sec) - ((int) now_time.tv_sec);
	while (usecDelta < 0)
	  {
	    usecDelta += 1000000;
	    secDelta  -= 1;
	  }

	while (usecDelta >= 1000000)
	  {
	    usecDelta -= 1000000;
	    secDelta  += 1;
	  }

	if (secDelta > 0 || (secDelta == 0 && usecDelta > 0))
	  {
	    struct timeval stall_time;

	    stall_time.tv_usec = usecDelta;
	    stall_time.tv_sec  = secDelta;
	    if (select(0, NULL, NULL, NULL, &stall_time) < 0 && errno != EINTR)
	      {
		perror("game_loop: select: stall");
		exit(1);
	      }
	  }
      }

      gettimeofday(&last_time, NULL);
      current_time = (time_t) last_time.tv_sec;
    }
  /* make sure strerr is flushed */
  fflush(stderr);	
}




@@ 798,120 878,147 @@ free_desc(DESCRIPTOR_DATA * d)
}

void
close_socket(DESCRIPTOR_DATA * dclose, bool force, bool clear)
close_socket(DESCRIPTOR_DATA *dclose, bool force)
{
	CHAR_DATA *ch;
	DESCRIPTOR_DATA *d;
	bool 	do_not_unlink = false;

	if (!dclose) {
		return;
  CHAR_DATA *ch;
  DESCRIPTOR_DATA *d;
  bool do_not_unlink = false;

  if(dclose->ipid != -1)
    {
      int status;

      kill(dclose->ipid, SIGKILL);
      waitpid(dclose->ipid, &status, 0);
    }

  if(dclose->ifd != -1)
    close(dclose->ifd);

  /* flush outbuf */
  if (!force && dclose->outtop > 0)
    flush_buffer(dclose, false);

  /* say bye to whoever's snooping this descriptor */
  if (dclose->snoop_by)
    write_to_buffer(dclose->snoop_by,
		     "Your victim has left the game.\n\r", 0);

  /* stop snooping everyone else */
  for (d = first_descriptor; d; d = d->next)
    if (d->snoop_by == dclose)
      d->snoop_by = NULL;

  /* Check for switched people who go link-dead. -- Altrag */
  if (dclose->original)
    {
      if ((ch = dclose->character) != NULL)
	do_return(ch, "");
      else
	{
	  bug("Close_socket: dclose->original without character %s",
	       (dclose->original->name ? dclose->original->name : "unknown"));
	  dclose->character = dclose->original;
	  dclose->original = NULL;
	}
	if (dclose->ipid != -1) {
		int 	status;

		kill(dclose->ipid, SIGKILL);
		waitpid(dclose->ipid, &status, 0);
	}
	if (dclose->ifd != -1)
		close(dclose->ifd);
	/* flush outbuf */
	if (!force && dclose->outtop > 0)
		flush_buffer(dclose, false);
	/* say bye to whoever's snooping this descriptor */
	if (dclose->snoop_by)
		write_to_buffer(dclose->snoop_by,
		    "Your victim has left the game.\n\r", 0);
	/* stop snooping everyone else */
	for (d = first_descriptor; d; d = d->next)
		if (d->snoop_by == dclose)
			d->snoop_by = NULL;
	/* check for switched people who go link-dead */
	if (dclose->original) {
		if ((ch = dclose->character) != NULL)
			do_return(ch, "");
		else {
			bug("Close_socket: dclose->original without character %s",
			    (dclose->original->name ? dclose->original->name : "unknown"));
			dclose->character = dclose->original;
			dclose->original = NULL;
		}
    }

  ch = dclose->character;

  /* sanity check :(*/
  if (!dclose->prev && dclose != first_descriptor)
    {
      DESCRIPTOR_DATA *dp, *dn;
      bug("Close_socket: %s desc:%p != first_desc:%p and desc->prev = NULL!",
	   ch ? ch->name : d->host, dclose, first_descriptor);
      dp = NULL;
      for (d = first_descriptor; d; d = dn)
	{
	  dn = d->next;
	  if (d == dclose)
	    {
	      bug("Close_socket: %s desc:%p found, prev should be:%p, fixing.",
		   ch ? ch->name : d->host, dclose, dp);
	      dclose->prev = dp;
	      break;
	    }
	  dp = d;
	}
	ch = dclose->character;
	/* sanity check :( */
	if (!dclose->prev && dclose != first_descriptor) {
		DESCRIPTOR_DATA *dp, *dn;

		bug("Close_socket: %s desc:%p != first_desc:%p and desc->prev = NULL!",
		    ch ? ch->name : d->host, dclose, first_descriptor);
		dp = NULL;
		for (d = first_descriptor; d; d = dn) {
			dn = d->next;
			if (d == dclose) {
				bug("Close_socket: %s desc:%p found, prev should be:%p, fixing.",
				    ch ? ch->name : d->host, dclose, dp);
				dclose->prev = dp;
				break;
			}
			dp = d;
		}
		if (!dclose->prev) {
			bug("Close_socket: %s desc:%p could not be found!.",
			    ch ? ch->name : dclose->host, dclose);
			do_not_unlink = true;
		}
      if (!dclose->prev)
	{
	  bug("Close_socket: %s desc:%p could not be found!.",
	       ch ? ch->name : dclose->host, dclose);
	  do_not_unlink = true;
	}
	if (!dclose->next && dclose != last_descriptor) {
		DESCRIPTOR_DATA *dp, *dn;

		bug("Close_socket: %s desc:%p != last_desc:%p and desc->next = NULL!",
		    ch ? ch->name : d->host, dclose, last_descriptor);
		dn = NULL;
		for (d = last_descriptor; d; d = dp) {
			dp = d->prev;
			if (d == dclose) {
				bug("Close_socket: %s desc:%p found, next should be:%p, fixing.",
				    ch ? ch->name : d->host, dclose, dn);
				dclose->next = dn;
				break;
			}
			dn = d;
		}
		if (!dclose->next) {
			bug("Close_socket: %s desc:%p could not be found!.",
			    ch ? ch->name : dclose->host, dclose);
			do_not_unlink = true;
		}
    }
  if (!dclose->next && dclose != last_descriptor)
    {
      DESCRIPTOR_DATA *dp, *dn;
      bug("Close_socket: %s desc:%p != last_desc:%p and desc->next = NULL!",
	   ch ? ch->name : d->host, dclose, last_descriptor);
      dn = NULL;
      for (d = last_descriptor; d; d = dp)
	{
	  dp = d->prev;
	  if (d == dclose)
	    {
	      bug("Close_socket: %s desc:%p found, next should be:%p, fixing.",
		   ch ? ch->name : d->host, dclose, dn);
	      dclose->next = dn;
	      break;
	    }
	  dn = d;
	}
	if (clear) {
		/* sanity check */
		if (ch) {
			dclose->character->desc = NULL;
			free_char(dclose->character);
		} else {
			log_string("bug: calling func thought char descriptor was free");
		}
	} else {
		/*
		 * don't clear, extract_char will take care of it for us,
		 * NULL out the descriptor
		 */
		if (dclose->character) {
			if (dclose->character->desc) {
				dclose->character->desc = NULL;
			}
		}
      if (!dclose->next)
	{
	  bug("Close_socket: %s desc:%p could not be found!.",
	       ch ? ch->name : dclose->host, dclose);
	  do_not_unlink = true;
	}
	if (!do_not_unlink) {
		/* make sure loop doesn't get messed up */
		if (d_next == dclose)
			d_next = d_next->next;
		UNLINK(dclose, first_descriptor, last_descriptor, next, prev);
    }

  if (dclose->character)
    {
      sprintf(log_buf, "Closing link to %s.", ch->pcdata->filename);
      log_string_plus(log_buf, LOG_COMM, UMAX(sysdata.log_level, ch->level));

      if ((dclose->connected == CON_PLAYING
	    || dclose->connected == CON_EDITING)
	   ||(dclose->connected >= CON_NOTE_TO
	      && dclose->connected <= CON_NOTE_FINISH))
	{
	  char ldbuf[MAX_STRING_LENGTH];
	  act(AT_ACTION, "$n has lost $s link.", ch, NULL, NULL, TO_CANSEE);

	  sprintf(ldbuf, "%s has gone linkdead", ch->name);
	  if(!IS_IMMORTAL(ch))
	    do_info(ch, ldbuf);
	  else
	    do_ainfo(ch, ldbuf);

	  ch->desc = NULL;
	}
	if (dclose->descriptor == maxdesc)
		--maxdesc;
	free_desc(dclose);
	--num_descriptors;
      else
	{
	  /* clear descriptor pointer to get rid of bug message in log */
	  dclose->character->desc = NULL;
	  free_char(dclose->character);
	}
    }

  if (!do_not_unlink)
    {
      /* make sure loop doesn't get messed up */
      if (d_next == dclose)
	d_next = d_next->next;
      UNLINK(dclose, first_descriptor, last_descriptor, next, prev);
    }

  if (dclose->descriptor == maxdesc)
    --maxdesc;

  free_desc(dclose);
  --num_descriptors;
}




@@ 1171,7 1278,7 @@ write_to_buffer(DESCRIPTOR_DATA * d, const char *txt, int length)
			d->outtop = 0;
			bug("Buffer overflow. Closing (%s).", d->character ? d->character->name : "???");
			log_string("preparing to close socket at comm.c:1248\n");
			close_socket(d, true, true);
			close_socket(d, true);
			return;
		}
		d->outsize *= 2;


@@ 1234,1041 1341,1253 @@ show_title(DESCRIPTOR_DATA * d)
}

void
nanny(DESCRIPTOR_DATA * d, char *argument)
nanny(DESCRIPTOR_DATA *d, char *argument)
{
	char 	buf[MAX_STRING_LENGTH];
	char 	buf2[MAX_STRING_LENGTH];
	char 	buf3[MAX_STRING_LENGTH];
	char 	buf4[MAX_STRING_LENGTH];
	char 	arg[MAX_STRING_LENGTH];
	CHAR_DATA *ch;
	char   *pwdnew;
	char   *p;
	int 	b = 0;
	int 	i_class;
	bool    p_exists = false;
	bool 	blocked = false;
	NOTE_DATA *catchup_notes;
	int 	i = 0;

	if (d->connected != CON_NOTE_TEXT) {
		while (isspace(*argument))
			argument++;
  char buf[MAX_STRING_LENGTH];
  char buf2[MAX_STRING_LENGTH];
  char buf3[MAX_STRING_LENGTH];
  char buf4[MAX_STRING_LENGTH];
  char arg[MAX_STRING_LENGTH];
  CHAR_DATA *ch;
  char *pwd_new;
  char *p;
  int b = 0;
  int i_class;
  bool f_old, chk;
  NOTE_DATA *catchup_notes;
  int i = 0;

  if(d->connected != CON_NOTE_TEXT)
    {
      while (isspace(*argument))
	argument++;
    }

  ch = d->character;

  switch (d->connected)
    {

    default:
      bug("nanny: bad d->connected %d.", d->connected);
      close_socket(d, true);
      return;

    case CON_GET_NAME:
      if (argument[0] == '\0')
	{
	  close_socket(d, false);
	  return;
	}
	ch = d->character;

	switch (d->connected) {
	default:
		bug("Nanny: bad d->connected %d.", d->connected);
		log_string("preparing to close socket at comm.c:1340\n");
		close_socket(d, true, true);
		return;
	case CON_GET_NAME:
		if (argument[0] == '\0') {
			close_socket(d, false, true);
			return;
		}
		*argument = capitalize_string(argument);
      *argument = capitalize_string(argument);

		if (!check_parse_name(argument, (d->newstate != 0))) {
			send_to_desc_color("&wIllegal name, try another.\n\rName: &D", d);
			return;
		}
		if (!str_cmp(argument, "New") && !blocked) {
			if (d->newstate == 0) {
				/* new player */
				sprintf(buf, "\n\r&wPlease choose a name for your character: &D");
				send_to_desc_color(buf, d);
				d->newstate++;
				d->connected = CON_GET_NAME;
				return;
			} else {
				send_to_desc_color("&wIllegal name, try another.\n\rName: &D", d);
				return;
			}
		}
		if (!str_cmp(argument, "help")) {
			HELP_DATA *p_help;
      /* Old players can keep their characters. -- Alty */
      if (!check_parse_name(argument, (d->newstate != 0)))
	{
	  send_to_desc_color("&wIllegal name, try another.\n\rName: &D", d);
	  return;
	}

			for (p_help = first_help; p_help; p_help = p_help->next) {
				if (!str_cmp(p_help->keyword, "dbznames"))
					break;
			}
			if (!p_help) {
				send_to_desc_color("No help on that word.\n\rName: ", d);
				return;
			}
			send_to_desc_color("\n\r", d);
			send_to_desc_color(p_help->text, d);
			send_to_desc_color("\n\r\n\r&wName: ", d);
			return;
		}
		p_exists  = char_exists(argument);
		if (p_exists && d->newstate == 0) {
			d->user = STRALLOC(argument);
			send_to_desc_color("&wPassword: &D", d);
			write_to_buffer(d, echo_off_str, 0);
			d->connected = CON_GET_OLD_PASSWORD;
			return;
		} else if (p_exists && d->newstate != 0) {
			send_to_desc_color("&wThat name is already taken. Please choose another: &D", d);
			d->connected = CON_GET_NAME;
			return;
		} else if (d->newstate == 0) {
			/* no such player */
			send_to_desc_color("\n\r&wNo such player exists.\n\rPlease check your spelling, or type new to start a new player.\n\r\n\rName: &D", d);
			d->connected = CON_GET_NAME;
			return;
		} else {
			d->user = STRALLOC(argument);
			sprintf(buf, "&wDid I get that right, %s (&WY&w/&WN&w)? &D", argument);
			send_to_desc_color(buf, d);
			d->connected = CON_CONFIRM_NEW_NAME;
			return;
      if (!str_cmp(argument, "New"))
	{
	  if (d->newstate == 0)
	    {
	      /* New player */
	      /* Don't allow new players if DENY_NEW_PLAYERS is true */
	      if (sysdata.DENY_NEW_PLAYERS == true)
		{
		  sprintf(buf, "The mud is currently preparing for a reboot.\n\r");
		  send_to_desc_color(buf, d);
		  sprintf(buf, "New players are not accepted during this time.\n\r");
		  send_to_desc_color(buf, d);
		  sprintf(buf, "Please try again in a few minutes.\n\r");
		  send_to_desc_color(buf, d);
		  close_socket(d, false);
		}
	      sprintf(buf, "\n\r&gChoosing a name is one of the most important parts of this game...\n\r"
		      "Make sure to pick a name appropriate to the character you are going\n\r"
		      "to role play, and be sure that it fits into the DragonBall Z world.\n\r"
		      "Please type '&WHELP&g' to read what restirictions we have for naming your\n\r"
		      "character.\n\r\n\r&wPlease choose a name for your character: &D");
	      send_to_desc_color(buf, d);
	      d->newstate++;
	      d->connected = CON_GET_NAME;
	      return;
	    }
	  else
	    {
	      send_to_desc_color("&wIllegal name, try another.\n\rName: &D", d);
	      return;
	    }
	}

      if (!str_cmp(argument, "help"))
	{
	  HELP_DATA *pHelp;

	  for (pHelp = first_help; pHelp; pHelp = pHelp->next)
	    {
	      if (!str_cmp(pHelp->keyword, "dbznames"))
		break;
	case CON_GET_OLD_PASSWORD:
		/* player exists, load in character */
		load_from_fp(d, false);
		ch = d->character;
		if (!check_pfile(d)) {
			return;
		}
		write_to_buffer(d, "\n\r", 2);
		if (str_cmp(sha256_crypt(argument), ch->pcdata->pwd)) {
			write_to_buffer(d, "Wrong password, disconnecting.\n\r", 0);
			close_socket(d, false, true);
			return;
		}
		write_to_buffer(d, echo_on_str, 0);
		if (check_playing(d, ch->pcdata->filename)) {
			if (!(reconnect(d, ch->pcdata->filename))) {
				write_to_buffer(d, "error, disconnecting.\n\r", 0);
				close_socket(d, false, true);
				return;
			} else {
				write_to_buffer(d, "cleared old connection, please reconnect.\n\r", 0);
				close_socket(d, false, true);
				return;
			}
		}
		strncpy(buf, ch->pcdata->filename, MAX_STRING_LENGTH);
		if (ch->position > POS_SITTING && ch->position < POS_STANDING)
			ch->position = POS_STANDING;
		sprintf(log_buf, "%s@%s(%s) has connected.", ch->pcdata->filename, d->host, d->user);
	    }
	  if (!pHelp)
	    {
	      send_to_desc_color("No help on that word.\n\rName: ", d);
	      return;
	    }
	  send_to_desc_color("\n\r", d);
	  send_to_desc_color(pHelp->text, d);
	  send_to_desc_color("\n\r\n\r&wName: ", d);
	  return;
	}

		log_string_plus(log_buf, LOG_COMM, sysdata.log_level);
		if (ch->level == 2) {
			xSET_BIT(ch->deaf, CHANNEL_FOS);
			ch->level = 1;
		}
		sprintf(buf3, "%s has logged on", ch->name);
		if (!IS_IMMORTAL(ch))
			do_info(ch, buf3);
		else
			do_ainfo(ch, buf3);
      if (check_playing(d, argument, false) == BERR)
	{
	  write_to_buffer(d, "Name: ", 0);
	  return;
	}

		if (!IS_IMMORTAL(ch) && IS_AFFECTED(ch, AFF_DEAD)) {
			sprintf(buf4, "%s has a halo", ch->name);
			log_string_plus(buf4, LOG_HIGH, LEVEL_LESSER);
		}
		/* player data update checks */
		pager_printf(ch, "Checking for player data updates...\n\r");
      f_old = load_char_obj(d, argument, true);
      if (!d->character)
	{
	  sprintf(log_buf, "Bad player file %s@%s.", argument, d->host);
	  log_string(log_buf);
	  send_to_desc_color("Your playerfile is corrupt...Please notify GokuDBS@hotmail.com.\n\r", d);
	  close_socket(d, false);
	  return;
	}
      ch   = d->character;
      if (xIS_SET(ch->act, PLR_DENY))
	{
	  sprintf(log_buf, "Denying access to %s@%s.", argument, d->host);
	  log_string_plus(log_buf, LOG_COMM, sysdata.log_level);
	  if (d->newstate != 0)
	    {
	      send_to_desc_color("That name is already taken.  Please choose another: ", d);
	      d->connected = CON_GET_NAME;
	      d->character->desc = NULL;
	      free_char(d->character); /* Big Memory Leak before --Shaddai */
	      d->character = NULL;
	      return;
	    }
	  send_to_desc_color("You are denied access.\n\r", d);
	  close_socket(d, false);
	  return;
	}
      if (check_total_ip(d))
	{
	  send_to_desc_color (
			      "Your maximum amount of players you can have online has been reached.\n\r", d);
	  close_socket(d, false);
	  return;
	}

		if (ch->pcdata->upgradeL > CURRENT_UPGRADE_LEVEL)
			ch->pcdata->upgradeL = CURRENT_UPGRADE_LEVEL - 1;
      chk = check_reconnect(d, argument, false);
      if (chk == BERR)
	return;

		if (upgrade_player(ch))
			pager_printf(ch, "Updated player data successfully.\n\r");
		else
			pager_printf(ch, "No updates to make.\n\r");
		adjust_hiscore("pkill", ch, ch->pcdata->pkills);
		adjust_hiscore("sparwins", ch, ch->pcdata->spar_wins);
		adjust_hiscore("sparloss", ch, ch->pcdata->spar_loss);
		adjust_hiscore("mkills", ch, ch->pcdata->mkills);
		adjust_hiscore("deaths", ch, (ch->pcdata->pdeaths + ch->pcdata->mdeaths));
		update_plHiscore(ch);
		adjust_hiscore("played", ch, ((get_age(ch) - 4) * 2));
		adjust_hiscore("zeni", ch, ch->gold);
		adjust_hiscore("bounty", ch, ch->pcdata->bkills);
		update_member(ch);
		show_title(d);
		break;
	case CON_CONFIRM_NEW_NAME:
		switch (*argument) {
		case 'y':
		case 'Y':
			load_from_fp(d, true);
			ch = d->character;
			sprintf(buf, "\n\r&wMake sure to use a password that won't be easily guessed by someone else."
			    "\n\rPick a good password for %s: %s&D",
			    ch->name, echo_off_str);
			send_to_desc_color(buf, d);
			xSET_BIT(ch->act, PLR_ANSI);
			d->connected = CON_GET_NEW_PASSWORD;
			break;
		case 'n':
		case 'N':
			send_to_desc_color("&wOk, what IS it, then? &D", d);
			d->connected = CON_GET_NAME;
			break;
		default:
			send_to_desc_color("&wPlease type &WY&wes or &WN&wo. &D", d);
			break;
		}
		break;
	case CON_GET_NEW_PASSWORD:
		send_to_desc_color("\n\r", d);
		if (utf8len(argument) < 5) {
			send_to_desc_color("&wPassword must be at least five characters long.\n\rPassword: &D", d);
			return;
		}
		pwdnew = sha256_crypt(argument);
		for (p = pwdnew; *p != '\0'; p++) {
			if (*p == '~') {
				send_to_desc_color("&wNew password not acceptable, try again.\n\rPassword: &D", d);
				return;
			}
		}
		DISPOSE(ch->pcdata->pwd);
		ch->pcdata->pwd = str_dup(pwdnew);
		send_to_desc_color("\n\r&wPlease retype the password to confirm: &D", d);
		d->connected = CON_CONFIRM_NEW_PASSWORD;
		break;
	case CON_CONFIRM_NEW_PASSWORD:
		send_to_desc_color("\n\r", d);
		if (str_cmp(sha256_crypt(argument), ch->pcdata->pwd)) {
			write_to_buffer(d, "Passwords don't match.\n\rRetype password: ", 0);
			d->connected = CON_GET_NEW_PASSWORD;
			return;
		}
		write_to_buffer(d, echo_on_str, 0);
		send_to_desc_color("\n\r&wWhat do you want your last name to be? [press enter for none] &D\n\r", d);
		d->connected = CON_GET_LAST_NAME;
		break;
	case CON_GET_LAST_NAME:
		if (argument[0] == '\0') {
			write_to_buffer(d, echo_on_str, 0);
			send_to_desc_color("\n\rDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w)\n\rType &WHELP&w for more information.", d);
			d->connected = CON_GET_HC;
			return;
		}
		argument[0] = UPPER(argument[0]);
		*argument = capitalize_string(argument);
		if (!check_parse_name(argument, true)) {
			send_to_desc_color("&wIllegal name, try another.\n\rLast name: &D", d);
			return;
		}
		sprintf(buf, "&wDid I get that right, %s (&WY&w/&WN&w)? &D", argument);
		send_to_desc_color(buf, d);
		DISPOSE(ch->pcdata->last_name);
		ch->pcdata->last_name = str_dup("");
		buf[0] = ' ';
		utf8cpy(buf + 1, argument);
		ch->pcdata->last_name = strdup(buf);
		d->connected = CON_CONFIRM_LAST_NAME;
		return;
		break;
	case CON_CONFIRM_LAST_NAME:
		switch (*argument) {
		case 'y':
		case 'Y':
			write_to_buffer(d, echo_on_str, 0);
			send_to_desc_color("\n\rDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w)\n\rType &WHELP&w for more information.", d);
			d->connected = CON_GET_HC;
			break;
      if (chk)
	{
	  f_old = true;
	}
      else
	{
	  if (wizlock && !IS_IMMORTAL(ch))
	    {
	      send_to_desc_color("The game is wizlocked.  Only immortals can connect now.\n\r", d);
	      send_to_desc_color("Please try back later.\n\r", d);
	      close_socket(d, false);
	      return;
	    }
	}

		case 'n':
		case 'N':
			send_to_desc_color("&wOk, what IS it, then? &D", d);
			d->connected = CON_GET_LAST_NAME;
			break;
      if (f_old)
	{
	  if (d->newstate != 0)
	    {
	      send_to_desc_color("&wThat name is already taken.  Please choose another: &D", d);
	      d->connected = CON_GET_NAME;
	      d->character->desc = NULL;
	      free_char(d->character); /* Big Memory Leak before --Shaddai */
	      d->character = NULL;
	      return;
	    }
	  /* Old player */
	  send_to_desc_color("&wPassword: &D", d);
	  write_to_buffer(d, echo_off_str, 0);
	  d->connected = CON_GET_OLD_PASSWORD;
	  return;
	}
      else
	{
	  if (d->newstate == 0)
	    {
	      /* No such player */
	      send_to_desc_color("\n\r&wNo such player exists.\n\rPlease check your spelling, or type new to start a new player.\n\r\n\rName: &D", d);
	      d->connected = CON_GET_NAME;
	      d->character->desc = NULL;
	      free_char(d->character); /* Big Memory Leak before --Shaddai */
	      d->character = NULL;
	      return;
	    }

	  sprintf(buf, "&wDid I get that right, %s (&WY&w/&WN&w)? &D", argument);
	  send_to_desc_color(buf, d);
	  d->connected = CON_CONFIRM_NEW_NAME;
	  return;
	}
      break;

		default:
			send_to_desc_color("&wPlease type &WY&wes or &WN&wo. &D", d);
			break;
		}
		break;
	case CON_GET_HC:
		if (!str_cmp(argument, "help")) {
			HELP_DATA *p_help;
    case CON_GET_OLD_PASSWORD:
      send_to_desc_color("\n\r", d);

			for (p_help = first_help; p_help; p_help = p_help->next) {
				if (!str_cmp(p_help->keyword, "HC HARDCORE UNKNOWN"))
					break;
			}
			if (!p_help) {
				send_to_desc_color("No help on that word.\n\rDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w): ", d);
				return;
			}
			send_to_desc_color("\n\r", d);
			send_to_desc_color(p_help->text, d);
			send_to_desc_color("&wDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w): ", d);
			return;
		}
		switch (*argument) {
		case 'y':
		case 'Y':
			sprintf(buf, "\n\r&wOkay, you are now &RHARDCORE&w!&D");
			send_to_desc_color(buf, d);
			xSET_BIT(ch->act, PLR_HC);
			write_to_buffer(d, echo_on_str, 0);
			break;
      if (strcmp(sha256_crypt(argument), ch->pcdata->pwd))
	{
	  send_to_desc_color("&wWrong password.&D\n\r", d);
	  sprintf(log_buf, "WRONG PASSWORD: %s@%s.", ch->name, d->host);
	  log_string(log_buf);
	  /* clear descriptor pointer to get rid of bug message in log */
	  d->character->desc = NULL;
	  close_socket(d, false);
	  return;
	}

		case 'n':
		case 'N':
			send_to_desc_color("\n\r&wOkay, you are a normal character.&D", d);
			write_to_buffer(d, echo_on_str, 0);
			break;
      write_to_buffer(d, echo_on_str, 0);

		default:
			send_to_desc_color("&wPlease type Yes or No. &D", d);
			return;
		}
		send_to_desc_color("\n\r&wWhat is your sex (&CM&w/&PF&w/&WN&w)? &D", d);
		d->connected = CON_GET_NEW_SEX;
		break;
	case CON_GET_NEW_SEX:
		switch (argument[0]) {
		case 'm':
		case 'M':
			ch->sex = SEX_MALE;
			break;
		case 'f':
		case 'F':
			ch->sex = SEX_FEMALE;
			break;
		case 'n':
		case 'N':
			ch->sex = SEX_NEUTRAL;
			break;
		default:
			send_to_desc_color("&wThat's not a sex.\n\rWhat IS your sex? &D", d);
			return;
		}
      if (check_playing(d, ch->pcdata->filename, true))
	return;

		send_to_desc_color("\n\r&wThe following Races are Available to You:&D\n\r", d);
		send_to_desc_color("&c==============================================================================&D", d);
		buf[0] = '\0';
      chk = check_reconnect(d, ch->pcdata->filename, true);
      if (chk == BERR)
	{
	  if (d->character && d->character->desc)
	    d->character->desc = NULL;
	  close_socket(d, false);
	  return;
	}
      if (chk == true)
	return;

		/* Take this out SHADDAI */
		i = 0;
		send_to_desc_color("\n\r", d);
		for (i_class = 0; i_class < 31; i_class++) {
			if (i_class == 4) {
				continue;
			}
			if (i_class > 8 && i_class < 28)
				continue;
			char 	letters[14] = "abcdefghijklmn";

			if (class_table[i_class]->who_name &&
			    class_table[i_class]->who_name[0] != '\0') {
				sprintf(buf, "&w   (&W%2d&w)  &c%-12s&w  ('&R%c&w' for help)&D\n\r",
				    i, class_table[i_class]->who_name, letters[i]);
				send_to_desc_color(buf, d);
				i++;
			}
		}
		send_to_desc_color("&c==============================================================================&D", d);
		sprintf(buf, "\n\r&wChoose the number of your race: &D");
		send_to_desc_color(buf, d);
		d->connected = CON_GET_NEW_CLASS;
      sprintf(buf, ch->pcdata->filename);
      d->character->desc = NULL;
      free_char(d->character);
      d->character = NULL;
      f_old = load_char_obj(d, buf, false);
      ch = d->character;
      if (ch->position ==  POS_FIGHTING
	  || ch->position ==  POS_EVASIVE
	  || ch->position ==  POS_DEFENSIVE
	  || ch->position ==  POS_AGGRESSIVE
	  || ch->position ==  POS_BERSERK)
	ch->position = POS_STANDING;

      sprintf(log_buf, "%s@%s(%s) has connected.", ch->pcdata->filename,
	      d->host, d->user);
      if (ch->level == 2)
	{
	  xSET_BIT(ch->deaf, CHANNEL_FOS);
	  ch->level = 1;
	}
      sprintf(buf3, "%s has logged on", ch->name);
      if (!IS_IMMORTAL(ch))
	do_info(ch, buf3);
      else
	do_ainfo(ch, buf3);

      if (!IS_IMMORTAL(ch) && IS_AFFECTED(ch, AFF_DEAD))
	{
	  sprintf(buf4, "%s has a halo", ch->name);
	  log_string_plus(buf4, LOG_HIGH, LEVEL_LESSER);
	}
      /* player data update checks */

      pager_printf(ch, "Checking for player data updates...\n\r");
      if (upgrade_player(ch))
	pager_printf(ch, "Updated player data successfully.\n\r");
      else
	pager_printf(ch, "No updates to make.\n\r");

      adjust_hiscore("pkill", ch, ch->pcdata->pkills); /* cronel hiscore */
      adjust_hiscore("sparwins", ch, ch->pcdata->spar_wins);
      adjust_hiscore("sparloss", ch, ch->pcdata->spar_loss);
      adjust_hiscore("mkills", ch, ch->pcdata->mkills);
      adjust_hiscore("deaths", ch, (ch->pcdata->pdeaths + ch->pcdata->mdeaths));
      update_plHiscore(ch);
      adjust_hiscore("played", ch, ((get_age(ch) - 4) * 2));
      adjust_hiscore("zeni", ch, ch->gold);
      adjust_hiscore("bounty", ch, ch->pcdata->bkills);
      update_member(ch);

      if (ch->level < LEVEL_DEMI)
	{
	  log_string_plus(log_buf, LOG_COMM, sysdata.log_level);
	}
      else
	log_string_plus(log_buf, LOG_COMM, ch->level);
      show_title(d);
      break;

    case CON_CONFIRM_NEW_NAME:
      switch (*argument)
	{
	case 'y': case 'Y':
	  sprintf(buf, "\n\r&wMake sure to use a password that won't be easily guessed by someone else."
		  "\n\rPick a good password for %s: %s&D",
		  ch->name, echo_off_str);
	  send_to_desc_color(buf, d);
	  xSET_BIT(ch->act, PLR_ANSI);
	  d->connected = CON_GET_NEW_PASSWORD;
	  break;

	case 'n': case 'N':
	  send_to_desc_color("&wOk, what IS it, then? &D", d);
	  /* clear descriptor pointer to get rid of bug message in log */
	  d->character->desc = NULL;
	  free_char(d->character);
	  d->character = NULL;
	  d->connected = CON_GET_NAME;
	  break;

	default:
	  send_to_desc_color("&wPlease type &WY&wes or &WN&wo. &D", d);
	  break;
	}
      break;

    case CON_GET_NEW_PASSWORD:
      send_to_desc_color("\n\r", d);

      if (strlen(argument) < 5)
	{
	  send_to_desc_color("&wPassword must be at least five characters long.\n\rPassword: &D", d);
	  return;
	}

      pwd_new = sha256_crypt(argument);
      for (p = pwd_new; *p != '\0'; p++)
	{
	  if (*p == '~')
	    {
	      send_to_desc_color(
				 "&wNew password not acceptable, try again.\n\rPassword: &D",
				 d);
	      return;
	    }
	}

      DISPOSE(ch->pcdata->pwd);
      ch->pcdata->pwd = str_dup(pwd_new);
      send_to_desc_color("\n\r&wPlease retype the password to confirm: &D", d);
      d->connected = CON_CONFIRM_NEW_PASSWORD;
      break;

    case CON_CONFIRM_NEW_PASSWORD:
      send_to_desc_color("\n\r", d);

      if (strcmp(sha256_crypt(argument), ch->pcdata->pwd))
	{
	  send_to_desc_color("&wPasswords don't match.\n\rRetype password: &D",
			     d);
	  d->connected = CON_GET_NEW_PASSWORD;
	  return;
	}

      write_to_buffer(d, echo_on_str, 0);
      send_to_desc_color("\n\r&wWhat do you want your last name to be? [press enter for none] &D\n\r", d);
      d->connected = CON_GET_LAST_NAME;
      break;

    case CON_GET_LAST_NAME:
      if (argument[0] == '\0')
	{
	  write_to_buffer(d, echo_on_str, 0);
	  send_to_desc_color("\n\rDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w)\n\rType &WHELP&w for more information.", d);
	  d->connected = CON_GET_HC;
	  return;
	}

      *argument = capitalize_string(argument);
      /* Old players can keep their characters. -- Alty */
      if (!check_parse_name(argument, true))
	{
	  send_to_desc_color("&wIllegal name, try another.\n\rLast name: &D", d);
	  return;
	}

      sprintf(buf, "&wDid I get that right, %s (&WY&w/&WN&w)? &D", argument);
      send_to_desc_color(buf, d);
      DISPOSE(ch->pcdata->last_name);
      ch->pcdata->last_name = str_dup("");
      buf[0] = ' ';
      strcpy(buf+1, argument);
      ch->pcdata->last_name = strdup(buf);
      d->connected = CON_CONFIRM_LAST_NAME;
      return;
      break;

    case CON_CONFIRM_LAST_NAME:
      switch (*argument)
	{
	case 'y': case 'Y':
	  write_to_buffer(d, echo_on_str, 0);
	  send_to_desc_color("\n\rDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w)\n\rType &WHELP&w for more information.", d);
	  d->connected = CON_GET_HC;
	  break;

	case 'n': case 'N':
	  send_to_desc_color("&wOk, what IS it, then? &D", d);
	  d->connected = CON_GET_LAST_NAME;
	  break;

	default:
	  send_to_desc_color("&wPlease type &WY&wes or &WN&wo. &D", d);
	  break;
	}
      break;


    case CON_GET_HC:
      if (!str_cmp(argument, "help"))
	{
	  HELP_DATA *pHelp;

	  for (pHelp = first_help; pHelp; pHelp = pHelp->next)
	    {
	      if (!str_cmp(pHelp->keyword, "HC HARDCORE UNKNOWN"))
		break;
	case CON_GET_NEW_CLASS:
		/* 1 - saiyan, 2 - human, 3 - halfie, 4 - namek, 5 - icer, 
		 * 6 - bio, 7 - kaio, 8 - demon, 9 - android-h, 
		 * 10 - android-e, 11 - android-fm
		 */
		argument = one_argument(argument, arg);
		if (is_number(arg)) {
			i = atoi(arg);
			int 	c = 0;

			if (i == 0)
				c = 0;
			if (i == 1)
				c = 1;
			if (i == 2)
				c = 2;
			if (i == 3)
				c = 3;
			if (i == 4)
				c = 5;
			if (i == 5)
				c = 6;
			if (i == 6)
				c = 7;
			if (i == 7)
				c = 8;
			if (i == 8)
				c = 28;
			if (i == 9)
				c = 29;
			if (i == 10)
				c = 30;
			for (i_class = 0; i_class < 31; i_class++) {
				if (i_class > 8 && i_class < 28)
					continue;
				if (class_table[i_class]->who_name &&
				    class_table[i_class]->who_name[0] != '\0') {
					if (c == i_class) {
						ch->class = i_class;
						ch->race = i_class;
						break;
					}
				}
			}
		} else {
			char 	letters[14] = "abcdefghijklmn";
			for (i = 0; i < 14; i++) {
				if (arg[0] == letters[i]) {
					int 	c = i;

					if (i == 0)
						c = 0;
					//saian
					if (i == 1)
						c = 1;
					//human
					if (i == 2)
						c = 2;
					//halfbreed
					if (i == 3)
						c = 3;
					//namek
					if (i == 4)
						c = 5;
					//icer
					if (i == 5)
						c = 6;
					//bio
					if (i == 6)
						c = 7;
					//kaio
					if (i == 7)
						c = 8;
					//demon
					if (i == 8)
						c = 28;
					//android - h
					if (i == 9)
						c = 29;
					//android - e
					if (i == 10)
						c = 30;
					//android - fm
					if (!str_cmp(class_table[c]->who_name, "android-h"))
						sprintf(buf, "androidh");
					else if (!str_cmp(class_table[c]->who_name, "android-e"))
						sprintf(buf, "androide");
					else if (!str_cmp(class_table[c]->who_name, "android-fm"))
						sprintf(buf, "androidfm");
					else
						sprintf(buf, "%s", class_table[c]->who_name);
					do_help(ch, buf);
					return;
				}
			}
			i = 0;
			send_to_desc_color("\n\r&c==============================================================================&D", d);
			for (i_class = 0; i_class < 31; i_class++) {
				if (i_class == 4) {
					continue;
				}
				if (i_class > 8 && i_class < 28)
					continue;
				char 	letters[14] = "abcdefghijklmn";

				if (class_table[i_class]->who_name &&
				    class_table[i_class]->who_name[0] != '\0') {
					sprintf(buf, "\n\r&w   (&W%2d&w)  &c%-12s&w  ('&R%c&w' for help)&D",
					    i,
					    class_table[i_class]->who_name, letters[i]);
					send_to_desc_color(buf, d);
					i++;
				}
			}
			send_to_desc_color("\n\r&c==============================================================================&D", d);
			sprintf(buf, "\n\r&wChoose the number of your race: &D");
			send_to_desc_color(buf, d);
			return;
		}
	    }
	  if (!pHelp)
	    {
	      send_to_desc_color("No help on that word.\n\rDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w): ", d);
	      return;
	    }
	  send_to_desc_color("\n\r", d);
	  send_to_desc_color(pHelp->text, d);
	  send_to_desc_color("&wDo you wish to be a &RHARDCORE&w character? (&WY&w/&WN&w): ", d);
	  return;
	}
      switch (*argument)
	{
	case 'y': case 'Y':
	  sprintf(buf, "\n\r&wOkay, you are now &RHARDCORE&w!&D");
	  send_to_desc_color(buf, d);
	  xSET_BIT(ch->act, PLR_HC);
	  write_to_buffer(d, echo_on_str, 0);
	  break;

	case 'n': case 'N':
	  send_to_desc_color("\n\r&wOkay, you are a normal character.&D", d);
	  write_to_buffer(d, echo_on_str, 0);
	  break;

		if (i_class != 28 && i_class != 29 && i_class != 30) {
		    if (i_class > 8
		      || !class_table[i_class]->who_name
		      || class_table[i_class]->who_name[0] == '\0'
		      || !str_cmp(class_table[i_class]->who_name, "unused")) {
			send_to_desc_color("&wThat's not a race.\n\rWhat IS your race? &D", d);
			return;
		    }
		}
		if (!str_cmp(class_table[i_class]->who_name, "bio-android")
		  || !str_cmp(class_table[i_class]->who_name, "demon")
		  || !str_cmp(class_table[i_class]->who_name, "android-e")
		  || !str_cmp(class_table[i_class]->who_name, "android-h")
		  || !str_cmp(class_table[i_class]->who_name, "android-fm")) {
		    send_to_desc_color("&wThat race is currently disabled.\n\rPlease select a different race. &D", d);
                    return;
	default:
	  send_to_desc_color("&wPlease type Yes or No. &D", d);
	  return;
	}
      send_to_desc_color("\n\r&wWhat is your sex (&CM&w/&PF&w/&WN&w)? &D", d);
      d->connected = CON_GET_NEW_SEX;
      break;

    case CON_GET_NEW_SEX:
      switch (argument[0])
	{
	case 'm': case 'M': ch->sex = SEX_MALE;    break;
	case 'f': case 'F': ch->sex = SEX_FEMALE;  break;
	case 'n': case 'N': ch->sex = SEX_NEUTRAL; break;
	default:
	  send_to_desc_color("&wThat's not a sex.\n\rWhat IS your sex? &D", d);
	  return;
	}

      send_to_desc_color("\n\r&wThe following Races are Available to You:&D\n\r", d);
      send_to_desc_color("&c==============================================================================&D",d);
      buf[0] = '\0';

      /*
       * Take this out SHADDAI
       */
      i=0;
      for (i_class = 0; i_class < 31; i_class++)
	{
	  if(i_class == 4) {
	    continue;
	  }
	  if(i_class > 8 && i_class < 28)
	    continue;
	  char letters[14] = "abcdefghijklmn";
	  if (class_table[i_class]->who_name &&
	      class_table[i_class]->who_name[0] != '\0')
	    {
	      sprintf(buf, "\n\r&w   (&W%d&w)  &c%-12s&w  ('&R%c&w' for help)&D", i,
		      class_table[i_class]->who_name, letters[i]);
	      send_to_desc_color(buf, d);
	      i++;
	    }
	}
      send_to_desc_color("&c==============================================================================&D",d);
      sprintf(buf, "\n\r&wChoose the number of your race: &D");
      send_to_desc_color(buf, d);
      d->connected = CON_GET_NEW_CLASS;
      break;

    case CON_GET_NEW_CLASS:
      argument = one_argument(argument, arg);
      if (is_number(arg))
	{
	  i = atoi(arg);

	  // map the argument to the actual race IDs
	  int 	c = 0;
	  if (i == 0)
	    c = 0; // saiyan
	  if (i == 1)
	    c = 1; // human
	  if (i == 2)
	    c = 2; // halfbreed
	  if (i == 3)
	    c = 3; // namek
	  if (i == 4)
	    c = 5; // icer
	  if (i == 5)
	    c = 6; // bio-android
	  if (i == 6)
	    c = 7; // kaio
	  if (i == 7)
	    c = 8; // demon
	  if (i == 8)
	    c = 28; // android-h
	  if (i == 9)
	    c = 29; // android-e
	  if (i == 10)
	    c = 30; // android-fm
	  for (i_class = 0; i_class < 31; i_class++)
	    {
	      if(i_class > 8 && i_class < 28)
		{
		  continue;
		}
		if (ch->race == 3 || ch->race == 5 || ch->race == 6) {
			ch->pcdata->haircolor = 24;
			ch->pcdata->orignalhaircolor = 24;
		} else {
			send_to_desc_color("\n\r&wPlease choose a hair color from the following list:&D\n\r", d);
			buf[0] = '\0';

			for (i_class = 0; i_class < (MAX_HAIR - 2); i_class++) {
				sprintf(buf2, "&w[&W%2d&w] &g%-18.18s  ", i_class, hair_color[i_class]);
				b++;
				strcat(buf, buf2);
				if ((b % 3) == 0)
					strcat(buf, "&D\n\r");
			}
			strcat(buf, "\n\r: ");
			strcat(buf, "\r\r");
			send_to_desc_color(buf, d);
			d->connected = CON_GET_NEW_HAIR;
			break;
	      if (class_table[i_class]->who_name &&
		  class_table[i_class]->who_name[0] != '\0')
		{
		  if (c == i_class)
		    {
		      ch->class =  i_class;
		      ch->race  =  i_class;
		      break;
		    }
		}
	case CON_GET_NEW_HAIR:
		argument = one_argument(argument, arg);
		if (ch->race != 3 && ch->race != 5 && ch->race != 6) {
			if (!str_cmp(arg, "help")) {
				do_help(ch, argument);
				send_to_desc_color("&wPlease choose a hair color: &D", d);
				return;
			}
			for (i_class = 0; i_class < (MAX_HAIR - 2); i_class++) {
				if (toupper(arg[0]) == toupper(hair_color[i_class][0])
				    && !str_prefix(arg, hair_color[i_class])) {
					ch->pcdata->haircolor = i_class;
					ch->pcdata->orignalhaircolor = i_class;
					break;
				}
				if (is_number(arg) && atoi(arg) == i_class) {
					ch->pcdata->haircolor = i_class;
					ch->pcdata->orignalhaircolor = i_class;
					break;
				}
			}
			if (i_class == (MAX_HAIR - 2) || !hair_color[i_class] || hair_color[i_class][0] == '\0') {
				send_to_desc_color("&wThat's not a hair color.\n\rWhat IS it going to be? &D", d);
				return;
			}
	    }
	}
      else
	{
	  char letters[14] = "abcdefghijklmn";
	  for (i = 0; i < 14; i++)
	    {
	      if (arg[0] == letters[i])
		{
		  // map the argument to the actual race IDs
		  int 	c = i;
		  if (i == 0)
		    c = 0; // saiyan
		  if (i == 1)
		    c = 1; // human
		  if (i == 2)
		    c = 2; // halfbreed
		  if (i == 3)
		    c = 3; // namek
		  if (i == 4)
		    c = 5; // icer
		  if (i == 5)
		    c = 6; // bio-android
		  if (i == 6)
		    c = 7; // kaio
		  if (i == 7)
		    c = 8; // demon
		  if (i == 8)
		    c = 28; // android-h
		  if (i == 9)
		    c = 29; // android-e
		  if (i == 10)
		    c = 30; // android-fm
		  if (!str_cmp(class_table[c]->who_name, "android-h"))
		    {
		      sprintf(buf, "androidh");
		    }
		  else if (!str_cmp(class_table[c]->who_name, "android-e"))
		    {
		      sprintf(buf, "androide");
		    }
		  else if (!str_cmp(class_table[c]->who_name, "android-fm"))
		    {
		      sprintf(buf, "androidfm");
		    }
		  else
		    {
		      sprintf(buf, "%s", class_table[c]->who_name);
		    }
		  do_help(ch, buf);
		  return;
		}
		if (ch->race == 3 || ch->race == 6) {
			send_to_desc_color("\n\r&wPlease choose a main body color from the following list:&D\n\r", d);
			buf[0] = '\0';
			buf2[0] = '\0';
			b = 0;
			for (i_class = (MAX_COMPLEXION - 17); i_class < (MAX_COMPLEXION - 14); i_class++) {
				sprintf(buf2, "&w[&W%2d&W] &g%-15s&D", i_class, complexion[i_class]);
				b++;
				strcat(buf, buf2);
				if ((b % 4) == 0)
					strcat(buf, "\n\r");
			}
			strcat(buf, "\n\r: ");
			strcat(buf, "\r\r\r\r");
			send_to_desc_color(buf, d);
			d->connected = CON_GET_NEW_COMPLEXION;
			break;
		} else if (ch->race == 5) {
			send_to_desc_color("\n\r&wPlease choose a main body color from the following list:&D\n\r", d);
			buf[0] = '\0';
			buf2[0] = '\0';
			b = 0;
			for (i_class = (MAX_COMPLEXION - 14); i_class < (MAX_COMPLEXION); i_class++) {
				sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, complexion[i_class]);
				b++;
				strcat(buf, buf2);
				if ((b % 4) == 0)
					strcat(buf, "\n\r");
			}
			strcat(buf, "\n\r: ");
			strcat(buf, "\r\r\r\r");
			send_to_desc_color(buf, d);
			d->connected = CON_GET_NEW_COMPLEXION;
			break;
		} else {
			send_to_desc_color("\n\r&wPlease choose a complexion from the following list:&D\n\r", d);
			buf[0] = '\0';
			buf2[0] = '\0';
			b = 0;
			for (i_class = 0; i_class < (MAX_COMPLEXION - 17); i_class++) {
				sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, complexion[i_class]);
				b++;
				strcat(buf, buf2);
				if ((b % 4) == 0)
					strcat(buf, "\n\r");
			}
			strcat(buf, "\n\r: ");
			strcat(buf, "\r\r\r\r");
			send_to_desc_color(buf, d);
			d->connected = CON_GET_NEW_COMPLEXION;
			break;
	    }
	  i=0;
	  send_to_desc_color("\n\r&c==============================================================================&D",d);
	  for (i_class = 0; i_class < 31; i_class++)
	    {
	      if(i_class == 4)
		{
		  continue;
		}
	case CON_GET_NEW_COMPLEXION:
		argument = one_argument(argument, arg);
		if (ch->race == 5) {
			if (!str_cmp(arg, "help")) {
				do_help(ch, argument);
				send_to_desc_color("&wPlease choose a main body color: &D", d);
				return;
			}
			for (i_class = (MAX_COMPLEXION - 14); i_class < (MAX_COMPLEXION); i_class++) {
				if (toupper(arg[0]) == toupper(complexion[i_class][0])
				    && !str_prefix(arg, complexion[i_class])) {
					ch->pcdata->complexion = i_class;
					break;
				}
				if (is_number(arg) && atoi(arg) == i_class) {
					ch->pcdata->complexion = i_class;
					break;
				}
			}
			if (i_class == (MAX_COMPLEXION) || !complexion[i_class] || complexion[i_class][0] == '\0') {
				send_to_desc_color("&wThat's not a choice.\n\rWhat IS it going to be? &D", d);
				return;
			}
		} else if (ch->race == 3 || ch->race == 6) {
			if (!str_cmp(arg, "help")) {
				do_help(ch, argument);
				send_to_desc_color("&wPlease choose a main body color: &D", d);
				return;
			}
			for (i_class = (MAX_COMPLEXION - 17); i_class < (MAX_COMPLEXION - 13); i_class++) {
				if (toupper(arg[0]) == toupper(complexion[i_class][0])
				    && !str_prefix(arg, complexion[i_class])) {
					ch->pcdata->complexion = i_class;
					break;
				}
				if (is_number(arg) && atoi(arg) == i_class) {
					ch->pcdata->complexion = i_class;
					break;
				}
			}
			if (i_class == (MAX_COMPLEXION - 14) || !complexion[i_class] || complexion[i_class][0] == '\0') {
				send_to_desc_color("&wThat's not a choice.\n\rWhat IS it going to be? &D", d);
				return;
			}
		} else {
			if (!str_cmp(arg, "help")) {
				do_help(ch, argument);
				send_to_desc_color("&wPlease choose complexion: &D", d);
				return;
			}
			for (i_class = 0; i_class < (MAX_COMPLEXION - 17); i_class++) {
				if (toupper(arg[0]) == toupper(complexion[i_class][0])
				    && !str_prefix(arg, complexion[i_class])) {
					ch->pcdata->complexion = i_class;
					break;
				}
				if (is_number(arg) && atoi(arg) == i_class) {
					ch->pcdata->complexion = i_class;
					break;
				}
			}
			if (i_class == (MAX_COMPLEXION - 17) || !complexion[i_class] || complexion[i_class][0] == '\0') {
				send_to_desc_color("&wThat's not a complexion.\n\rWhat IS it going to be? &D", d);
				return;
			}
	      if(i_class > 8 && i_class < 28)
		continue;
	      char letters[14] = "abcdefghijklmn";
	      if (class_table[i_class]->who_name &&
		  class_table[i_class]->who_name[0] != '\0')
		{
		  sprintf(buf, "\n\r&w   (&W%d&w)  &c%-12s&w  ('&R%c&w' for help)&D", i,
			  class_table[i_class]->who_name, letters[i]);
		  send_to_desc_color(buf, d);
		  i++;
		}
		if (ch->race == 5) {
			send_to_desc_color("\n\r&wPlease choose a secondary body color from the following list:&D\n\r", d);
			buf[0] = '\0';
			buf2[0] = '\0';
			b = 0;
			for (i_class = 0; i_class < (MAX_SECONDARYCOLOR - 1); i_class++) {
				sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, secondary_color[i_class]);
				b++;
				strcat(buf, buf2);
				if ((b % 4) == 0)
					strcat(buf, "\n\r");
			}
			strcat(buf, "\n\r: ");
			strcat(buf, "\r\r\r\r");
			send_to_desc_color(buf, d);
			d->connected = CON_GET_NEW_SECONDARYCOLOR;
			break;
	    }
	  send_to_desc_color("\n\r&c==============================================================================&D",d);
	  sprintf(buf, "\n\r&wChoose the number of your race: &D");
	  send_to_desc_color(buf, d);
	  return;
	}
      
      if (i_class != 28 && i_class != 29 && i_class != 30)
	{
	  if (i_class > 8
	      || !class_table[i_class]->who_name
	      || class_table[i_class]->who_name[0] == '\0'
	      || !str_cmp(class_table[i_class]->who_name, "unused"))
	    {
	      send_to_desc_color("&wThat's not a race.\n\rWhat IS your race? &D", d);
	      return;
	    }
	}

		case CON_GET_NEW_SECONDARYCOLOR:
			/*
			 * Black, Brown, Red, Blonde, Strawberry Blonde,
			 * Argent, Golden Blonde, Platinum Blonde, Light
			 * Brown
			 */
			argument = one_argument(argument, arg);
			if (!str_cmp(arg, "help")) {
				do_help(ch, argument);
				send_to_desc_color("&wPlease choose a secondary body color: &D", d);
				return;
			}
			for (i_class = 0; i_class < (MAX_SECONDARYCOLOR - 1); i_class++) {
				if (toupper(arg[0]) == toupper(secondary_color[i_class][0])
				    && !str_prefix(arg, secondary_color[i_class])) {
					ch->pcdata->secondarycolor = i_class;
					break;
				}
				if (is_number(arg) && atoi(arg) == i_class) {
					ch->pcdata->secondarycolor = i_class;
					break;
				}
			}
			if (i_class == (MAX_SECONDARYCOLOR - 1) || !secondary_color[i_class] || secondary_color[i_class][0] == '\0') {
				send_to_desc_color("&wThat's not a choice.\n\rWhat IS it going to be? &D", d);
				return;
			}
      if (!str_cmp(class_table[i_class]->who_name, "bio-android")
	  || !str_cmp(class_table[i_class]->who_name, "demon")
	  || !str_cmp(class_table[i_class]->who_name, "android-e")
	  || !str_cmp(class_table[i_class]->who_name, "android-h")
	  || !str_cmp(class_table[i_class]->who_name, "android-fm"))
        {
	  send_to_desc_color("&wThat race is currently disabled.\n\rPlease select a different race. &D", d);
	  return;
	}

      if (ch->race == 3 || ch->race == 5 || ch->race == 6)
	{
	  ch->pcdata->haircolor = 24;
	  ch->pcdata->orignalhaircolor = 24;
	}
      else
	{
	  send_to_desc_color("\n\r&wPlease choose a hair color from the following list:&D\n\r", d);
	  buf[0] = '\0';

	  for (i_class = 0; i_class < (MAX_HAIR - 2); i_class++)
	    {
	      sprintf(buf2, "&w[&W%2d&w] &g%-18.18s  ", i_class, hair_color[i_class]);
	      b++;
	      strcat(buf,buf2);
	      if ((b % 3) == 0)
		strcat(buf, "&D\n\r");
	    }
	  strcat(buf, "\n\r: ");
	  strcat(buf, "\r\r");
	  send_to_desc_color(buf, d);
	  d->connected = CON_GET_NEW_HAIR;
	  break;
	}
    case CON_GET_NEW_HAIR:
      argument = one_argument(argument, arg);
      if (ch->race != 3 && ch->race != 5 && ch->race != 6)
	{
	  if (!str_cmp(arg, "help"))
	    {
	      do_help(ch, argument);
	      send_to_desc_color("&wPlease choose a hair color: &D", d);
	      return;
	    }
	  for (i_class = 0; i_class < (MAX_HAIR - 2); i_class++)
	    {
	      if (toupper(arg[0]) == toupper(hair_color[i_class][0])
		  &&   !str_prefix(arg, hair_color[i_class]))
		{
		  ch->pcdata->haircolor = i_class;
		  ch->pcdata->orignalhaircolor = i_class;
		  break;
		}
		send_to_desc_color("\n\r&wPlease choose a eye color from the following list:&D\n\r", d);
		buf[0] = '\0';
		buf2[0] = '\0';
		b = 0;

		for (i_class = 0; i_class < (MAX_EYE - 3); i_class++) {
			sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, eye_color[i_class]);
			b++;
			strcat(buf, buf2);
			if ((b % 4) == 0)
				strcat(buf, "\n\r");
	      if (is_number(arg) && atoi(arg) == i_class)
		{
		  ch->pcdata->haircolor = i_class;
		  ch->pcdata->orignalhaircolor = i_class;
		  break;
		}
		strcat(buf, "\n\r: ");
		strcat(buf, "\r\r\r\r");
		send_to_desc_color(buf, d);
		d->connected = CON_GET_NEW_EYE;
	    }
	  if (i_class == (MAX_HAIR - 2) || !hair_color[i_class] || hair_color[i_class][0] == '\0')
	    {
	      send_to_desc_color("&wThat's not a hair color.\n\rWhat IS it going to be? &D", d);
	      return;
	    }
	}
      if (ch->race == 3 || ch->race == 6)
	{
	  send_to_desc_color("\n\r&wPlease choose a main body color from the following list:&D\n\r", d);
	  buf[0] = '\0';
	  buf2[0] = '\0';
	  b = 0;
	  for (i_class = (MAX_COMPLEXION - 17); i_class < (MAX_COMPLEXION - 14); i_class++)
	    {
	      sprintf(buf2, "&w[&W%2d&W] &g%-15s&D", i_class, complexion[i_class]);
	      b++;
	      strcat(buf,buf2);
	      if ((b % 4) == 0)
		strcat(buf, "\n\r");
	    }
	  strcat(buf, "\n\r: ");
	  strcat(buf, "\r\r\r\r");
	  send_to_desc_color(buf, d);
	  d->connected = CON_GET_NEW_COMPLEXION;
	  break;
	}

		break;
	case CON_GET_NEW_EYE:
		/*
		 * Black, Brown, Red, Blonde, Strawberry Blonde, Argent,
		 * Golden Blonde, Platinum Blonde, Light Brown
		 */
		argument = one_argument(argument, arg);
		if (!str_cmp(arg, "help")) {
			do_help(ch, argument);
			send_to_desc_color("&wPlease choose a hair color: &D", d);
			return;
      else if (ch->race == 5)
	{
	  send_to_desc_color("\n\r&wPlease choose a main body color from the following list:&D\n\r", d);
	  buf[0] = '\0';
	  buf2[0] = '\0';
	  b = 0;
	  for (i_class = (MAX_COMPLEXION - 14); i_class < (MAX_COMPLEXION); i_class++)
	    {
	      sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, complexion[i_class]);
	      b++;
	      strcat(buf,buf2);
	      if ((b % 4) == 0)
		strcat(buf, "\n\r");
	    }
	  strcat(buf, "\n\r: ");
	  strcat(buf, "\r\r\r\r");
	  send_to_desc_color(buf, d);
	  d->connected = CON_GET_NEW_COMPLEXION;
	  break;
	}
      else
	{
	  send_to_desc_color("\n\r&wPlease choose a complexion from the following list:&D\n\r", d);
	  buf[0] = '\0';
	  buf2[0] = '\0';
	  b = 0;
	  for (i_class = 0; i_class < (MAX_COMPLEXION - 17); i_class++)
	    {
	      sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, complexion[i_class]);
	      b++;
	      strcat(buf,buf2);
	      if ((b % 4) == 0)
		strcat(buf, "\n\r");
	    }
	  strcat(buf, "\n\r: ");
	  strcat(buf, "\r\r\r\r");
	  send_to_desc_color(buf, d);
	  d->connected = CON_GET_NEW_COMPLEXION;
	  break;
	}
    case CON_GET_NEW_COMPLEXION:

      argument = one_argument(argument, arg);
      if (ch->race == 5)
	{
	  if (!str_cmp(arg, "help"))
	    {
	      do_help(ch, argument);
	      send_to_desc_color("&wPlease choose a main body color: &D", d);
	      return;
	    }
	  for (i_class = (MAX_COMPLEXION - 14); i_class < (MAX_COMPLEXION); i_class++)
	    {
	      if (toupper(arg[0]) == toupper(complexion[i_class][0])
		  &&   !str_prefix(arg, complexion[i_class]))
		{
		  ch->pcdata->complexion = i_class;
		  break;
		}
		for (i_class = 0; i_class < (MAX_EYE - 3); i_class++) {
			if (toupper(arg[0]) == toupper(eye_color[i_class][0])
			    && !str_prefix(arg, eye_color[i_class])) {
				ch->pcdata->eyes = i_class;
				ch->pcdata->orignaleyes = i_class;
				break;
			}
			if (is_number(arg) && atoi(arg) == i_class) {
				ch->pcdata->eyes = i_class;
				ch->pcdata->orignaleyes = i_class;
				break;
			}
	      if (is_number(arg) && atoi(arg) == i_class)
		{
		  ch->pcdata->complexion = i_class;
		  break;
		}
		if (i_class == (MAX_EYE - 3) || !eye_color[i_class] || eye_color[i_class][0] == '\0') {
			send_to_desc_color("&wThat's not a eye color.\n\rWhat IS it going to be? &D", d);
			return;
	    }
	  if (i_class == (MAX_COMPLEXION) || !complexion[i_class] || complexion[i_class][0] == '\0')
	    {
	      send_to_desc_color("&wThat's not a choice.\n\rWhat IS it going to be? &D", d);
	      return;
	    }
	}
      else if (ch->race == 3 || ch->race == 6)
	{
	  if (!str_cmp(arg, "help"))
	    {
	      do_help(ch, argument);
	      send_to_desc_color("&wPlease choose a main body color: &D", d);
	      return;
	    }
	  for (i_class = (MAX_COMPLEXION - 17); i_class < (MAX_COMPLEXION - 13); i_class++)
	    {
	      if (toupper(arg[0]) == toupper(complexion[i_class][0])
		  &&   !str_prefix(arg, complexion[i_class]))
		{
		  ch->pcdata->complexion = i_class;
		  break;
		}
		send_to_desc_color("\n\r&wPlease choose a build type from the following list:&D\n\r", d);
		buf[0] = '\0';
		buf2[0] = '\0';
		b = 0;

		for (i_class = 0; i_class < (MAX_BUILD); i_class++) {
			sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, build_type[i_class]);
			b++;
			strcat(buf, buf2);
			if ((b % 4) == 0)
				strcat(buf, "\n\r");
	      if (is_number(arg) && atoi(arg) == i_class)
		{
		  ch->pcdata->complexion = i_class;
		  break;
		}
		strcat(buf, "\n\r: ");
		strcat(buf, "\r\r\r\r");
		send_to_desc_color(buf, d);
		d->connected = CON_GET_NEW_BUILD;

		break;
	case CON_GET_NEW_BUILD:
		argument = one_argument(argument, arg);
		if (!str_cmp(arg, "help")) {
			do_help(ch, argument);
			send_to_desc_color("&wPlease choose a build type: &D", d);
			return;
	    }
	  if (i_class == (MAX_COMPLEXION - 14) || !complexion[i_class] || complexion[i_class][0] == '\0')
	    {
	      send_to_desc_color("&wThat's not a choice.\n\rWhat IS it going to be? &D", d);
	      return;
	    }
	}
      else
	{
	  if (!str_cmp(arg, "help"))
	    {
	      do_help(ch, argument);
	      send_to_desc_color("&wPlease choose complexion: &D", d);
	      return;
	    }
	  for (i_class = 0; i_class < (MAX_COMPLEXION - 17); i_class++)
	    {
	      if (toupper(arg[0]) == toupper(complexion[i_class][0])
		  &&   !str_prefix(arg, complexion[i_class]))
		{
		  ch->pcdata->complexion = i_class;
		  break;
		}
		for (i_class = 0; i_class < (MAX_BUILD); i_class++) {
			if (toupper(arg[0]) == toupper(build_type[i_class][0])
			    && !str_prefix(arg, build_type[i_class])) {
				ch->pcdata->build = i_class;
				break;
			}
			if (is_number(arg) && atoi(arg) == i_class) {
				ch->pcdata->build = i_class;
				break;
			}
	      if (is_number(arg) && atoi(arg) == i_class)
		{
		  ch->pcdata->complexion = i_class;
		  break;
		}
		if (i_class == (MAX_BUILD) || !build_type[i_class] || build_type[i_class][0] == '\0') {
			send_to_desc_color("&wThat's not a build type.\n\rWhat IS it going to be? &D", d);
			return;
	    }
	  if (i_class == (MAX_COMPLEXION - 17) || !complexion[i_class] || complexion[i_class][0] == '\0')
	    {
	      send_to_desc_color("&wThat's not a complexion.\n\rWhat IS it going to be? &D", d);
	      return;
	    }
	}
      if (ch->race == 5)
	{
	  send_to_desc_color("\n\r&wPlease choose a secondary body color from the following list:&D\n\r", d);
	  buf[0] = '\0';
	  buf2[0] = '\0';
	  b = 0;
	  for (i_class = 0; i_class < (MAX_SECONDARYCOLOR - 1); i_class++)
	    {
	      sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, secondary_color[i_class]);
	      b++;
	      strcat(buf,buf2);
	      if ((b % 4) == 0)
		strcat(buf, "\n\r");
	    }
	  strcat(buf, "\n\r: ");
	  strcat(buf, "\r\r\r\r");
	  send_to_desc_color(buf, d);
	  d->connected = CON_GET_NEW_SECONDARYCOLOR;
	  break;

	case CON_GET_NEW_SECONDARYCOLOR:
	  /* Black, Brown, Red, Blonde, Strawberry Blonde, Argent, Golden Blonde, Platinum Blonde, Light Brown*/
	  argument = one_argument(argument, arg);
	  if (!str_cmp(arg, "help"))
	    {
	      do_help(ch, argument);
	      send_to_desc_color("&wPlease choose a secondary body color: &D", d);
	      return;
	    }
	  for (i_class = 0; i_class < (MAX_SECONDARYCOLOR - 1); i_class++)
	    {
	      if (toupper(arg[0]) == toupper(secondary_color[i_class][0])
		  &&   !str_prefix(arg, secondary_color[i_class]))
		{
		  ch->pcdata->secondarycolor = i_class;
		  break;
		}
		sprintf(log_buf, "%s@%s new %s %s.", ch->name, d->host,
		    race_table[ch->race]->race_name,
		    class_table[ch->class]->who_name);
		log_string_plus(log_buf, LOG_COMM, sysdata.log_level);
		to_channel(log_buf, CHANNEL_MONITOR, "Monitor", LEVEL_IMMORTAL);
		send_to_desc_color("&wPress [&RENTER&w] &D", d);
		show_title(d);
		ch->level = 0;
		ch->position = POS_STANDING;
		d->connected = CON_PRESS_ENTER;
		set_pager_color(AT_PLAIN, ch);
		adjust_hiscore("pkill", ch, ch->pcdata->pkills);	/* cronel hiscore */
		adjust_hiscore("sparwins", ch, ch->pcdata->spar_wins);
		adjust_hiscore("sparloss", ch, ch->pcdata->spar_loss);
		adjust_hiscore("mkills", ch, ch->pcdata->mkills);
		adjust_hiscore("deaths", ch, (ch->pcdata->pdeaths + ch->pcdata->mdeaths));
		update_plHiscore(ch);
		adjust_hiscore("played", ch, ((get_age(ch) - 4) * 2));
		adjust_hiscore("zeni", ch, ch->gold);
		return;
		break;
	case CON_PRESS_ENTER:
		/* todo: remove this */
		REMOVE_BIT(ch->pcdata->flags, PCFLAG_WATCH);
		if (ch->position == POS_MOUNTED)
			ch->position = POS_STANDING;
		set_pager_color(AT_PLAIN, ch);
		if (xIS_SET(ch->act, PLR_RIP))
			send_rip_screen(ch);
		if (xIS_SET(ch->act, PLR_ANSI))
			send_to_pager("\033[2J", ch);
		else
			send_to_pager("\014", ch);
		if (IS_IMMORTAL(ch))
			do_help(ch, "imotd");
		if (ch->level == 50)
			do_help(ch, "amotd");
		if (ch->level < 50 && ch->level > 0)
			do_help(ch, "motd");
		if (ch->level == 0)
			do_help(ch, "nmotd");
		send_to_pager("\n\rPress [ENTER] ", ch);
		d->connected = CON_READ_MOTD;
		break;
	case CON_READ_MOTD:
	      if (is_number(arg) && atoi(arg) == i_class)
		{
			char 	motdbuf[MAX_STRING_LENGTH];
			sprintf(motdbuf, "\n\rWelcome to %s...\n\r", sysdata.mud_name);
			send_to_desc_color(motdbuf, d);
		  ch->pcdata->secondarycolor = i_class;
		  break;
		}
		add_char(ch);
		d->connected = CON_PLAYING;
		set_char_color(AT_DGREEN, ch);
		if (!xIS_SET(ch->act, PLR_ANSI) && d->ansi == true)
			d->ansi = false;
		else if (xIS_SET(ch->act, PLR_ANSI) && d->ansi == false)
			d->ansi = true;
		if (ch->level == 0) {
			int 	i_lang;
	    }
	  if (i_class == (MAX_SECONDARYCOLOR - 1) || !secondary_color[i_class] || secondary_color[i_class][0] == '\0')
	    {
	      send_to_desc_color("&wThat's not a choice.\n\rWhat IS it going to be? &D", d);
	      return;
	    }
	}
      send_to_desc_color("\n\r&wPlease choose a eye color from the following list:&D\n\r", d);
      buf[0] = '\0';
      buf2[0] = '\0';
      b = 0;

			ch->pcdata->upgradeL = CURRENT_UPGRADE_LEVEL;
      for (i_class = 0; i_class < (MAX_EYE - 3); i_class++)
	{
	  sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, eye_color[i_class]);
	  b++;
	  strcat(buf,buf2);
	  if ((b % 4) == 0)
	    strcat(buf, "\n\r");
	}
      strcat(buf, "\n\r: ");
      strcat(buf, "\r\r\r\r");
      send_to_desc_color(buf, d);
      d->connected = CON_GET_NEW_EYE;

      break;
    case CON_GET_NEW_EYE:
      /* Black, Brown, Red, Blonde, Strawberry Blonde, Argent, Golden Blonde, Platinum Blonde, Light Brown*/
      argument = one_argument(argument, arg);
      if (!str_cmp(arg, "help"))
	{
	  do_help(ch, argument);
	  send_to_desc_color("&wPlease choose a hair color: &D", d);
	  return;
	}
      for (i_class = 0; i_class < (MAX_EYE - 3); i_class++)
	{
	  if (toupper(arg[0]) == toupper(eye_color[i_class][0])
	      &&   !str_prefix(arg, eye_color[i_class]))
	    {
	      ch->pcdata->eyes = i_class;
	      ch->pcdata->orignaleyes = i_class;
	      break;
	    }
	  if (is_number(arg) && atoi(arg) == i_class)
	    {
	      ch->pcdata->eyes = i_class;
	      ch->pcdata->orignaleyes = i_class;
	      break;
	    }
	}
      if (i_class == (MAX_EYE - 3) || !eye_color[i_class] || eye_color[i_class][0] == '\0')
	{
	  send_to_desc_color("&wThat's not a eye color.\n\rWhat IS it going to be? &D", d);
	  return;
	}

			ch->pcdata->clan_name = STRALLOC("");
			ch->pcdata->clan = NULL;
			switch (class_table[ch->class]->attr_prime) {
			case APPLY_STR:
				ch->perm_str = 10;
				break;
			case APPLY_INT:
				ch->perm_int = 10;
				break;
			case APPLY_DEX:
				ch->perm_dex = 10;
				break;
			case APPLY_CON:
				ch->perm_con = 10;
				break;
			case APPLY_LCK:
				ch->perm_lck = 10;
				break;
			}
      send_to_desc_color("\n\r&wPlease choose a build type from the following list:&D\n\r", d);
      buf[0] = '\0';
      buf2[0] = '\0';
      b = 0;

			ch->perm_str += race_table[ch->race]->str_plus;
			ch->perm_int += race_table[ch->race]->int_plus;
			ch->perm_dex += race_table[ch->race]->dex_plus;
			ch->perm_con += race_table[ch->race]->con_plus;
			ch->affected_by = race_table[ch->race]->affected;
			ch->perm_lck = number_range(0, 30);

			ch->pcdata->permTstr = ch->perm_str;
			ch->pcdata->permTspd = ch->perm_dex;
			ch->pcdata->permTint = ch->perm_int;
			ch->pcdata->permTcon = ch->perm_con;

			ch->armor += race_table[ch->race]->ac_plus;
			ch->alignment += race_table[ch->race]->alignment;
			ch->attacks = race_table[ch->race]->attacks;
			ch->defenses = race_table[ch->race]->defenses;
			ch->saving_poison_death = race_table[ch->race]->saving_poison_death;
			ch->saving_wand = race_table[ch->race]->saving_wand;
			ch->saving_para_petri = race_table[ch->race]->saving_para_petri;
			ch->saving_breath = race_table[ch->race]->saving_breath;
			ch->saving_spell_staff = race_table[ch->race]->saving_spell_staff;

			ch->height = number_range(race_table[ch->race]->height * .9, race_table[ch->race]->height * 1.1);
			ch->weight = number_range(race_table[ch->race]->weight * .9, race_table[ch->race]->weight * 1.1);

			if ((i_lang = skill_lookup("common")) < 0)
				bug("Nanny: cannot find common language.");
			else
				ch->pcdata->learned[i_lang] = 100;
      for (i_class = 0; i_class < (MAX_BUILD); i_class++)
	{
	  sprintf(buf2, "&w[&W%2d&w] &g%-15s&D", i_class, build_type[i_class]);
	  b++;
	  strcat(buf,buf2);
	  if ((b % 4) == 0)
	    strcat(buf, "\n\r");
	}
      strcat(buf, "\n\r: ");
      strcat(buf, "\r\r\r\r");
      send_to_desc_color(buf, d);
      d->connected = CON_GET_NEW_BUILD;

      break;
    case CON_GET_NEW_BUILD:
      /* Black, Brown, Red, Blonde, Strawberry Blonde, Argent, Golden Blonde, Platinum Blonde, Light Brown*/
      argument = one_argument(argument, arg);
      if (!str_cmp(arg, "help"))
	{
	  do_help(ch, argument);
	  send_to_desc_color("&wPlease choose a build type: &D", d);
	  return;
	}
      for (i_class = 0; i_class < (MAX_BUILD); i_class++)
	{
	  if (toupper(arg[0]) == toupper(build_type[i_class][0])
	      &&   !str_prefix(arg, build_type[i_class]))
	    {
	      ch->pcdata->build = i_class;
	      break;
	    }
	  if (is_number(arg) && atoi(arg) == i_class)
	    {
	      ch->pcdata->build = i_class;
	      break;
	    }
	}
      if (i_class == (MAX_BUILD) || !build_type[i_class] || build_type[i_class][0] == '\0')
	{
	  send_to_desc_color("&wThat's not a build type.\n\rWhat IS it going to be? &D", d);
	  return;
	}

			for (i_lang = 0; lang_array[i_lang] != LANG_UNKNOWN; i_lang++)
				if (lang_array[i_lang] == race_table[ch->race]->language)
					break;
			if (lang_array[i_lang] == LANG_UNKNOWN);
			else {
				if ((i_lang = skill_lookup(lang_names[i_lang])) < 0)
					bug("Nanny: cannot find racial language.");
				else
					ch->pcdata->learned[i_lang] = 100;
			}
      sprintf(log_buf, "%s@%s new %s %s.", ch->name, d->host,
	      race_table[ch->race]->race_name,
	      class_table[ch->class]->who_name);
      log_string_plus(log_buf, LOG_COMM, sysdata.log_level);
      to_channel(log_buf, CHANNEL_MONITOR, "Monitor", LEVEL_IMMORTAL);
      send_to_desc_color("&wPress [&RENTER&w] &D", d);
      show_title(d);
      ch->level = 0;
      ch->position = POS_STANDING;
      d->connected = CON_PRESS_ENTER;
      set_pager_color(AT_PLAIN, ch);
      adjust_hiscore("pkill", ch, ch->pcdata->pkills); /* cronel hiscore */
      adjust_hiscore("sparwins", ch, ch->pcdata->spar_wins);
      adjust_hiscore("sparloss", ch, ch->pcdata->spar_loss);
      adjust_hiscore("mkills", ch, ch->pcdata->mkills);
      adjust_hiscore("deaths", ch, (ch->pcdata->pdeaths + ch->pcdata->mdeaths));
      update_plHiscore(ch);
      adjust_hiscore("played", ch, ((get_age(ch) - 4) * 2));
      adjust_hiscore("zeni", ch, ch->gold);
      return;
      break;

    case CON_PRESS_ENTER:
      if (ch->position == POS_MOUNTED)
	ch->position = POS_STANDING;
      set_pager_color(AT_PLAIN, ch);
      if (xIS_SET(ch->act, PLR_RIP))
	send_rip_screen(ch);
      if (xIS_SET(ch->act, PLR_ANSI))
	send_to_pager("\033[2J", ch);
      else
	send_to_pager("\014", ch);
      if (IS_IMMORTAL(ch))
	do_help(ch, "imotd");
      if (ch->level == 50)
	do_help(ch, "amotd");
      if (ch->level < 50 && ch->level > 0)
	do_help(ch, "motd");
      if (ch->level == 0)
	do_help(ch, "nmotd");
      send_to_pager("\n\rPress [ENTER] ", ch);
      d->connected = CON_READ_MOTD;
      break;

    case CON_READ_MOTD:
      {
	char 	motdbuf[MAX_STRING_LENGTH];
	sprintf(motdbuf, "\n\rWelcome to %s...\n\r", sysdata.mud_name);
	send_to_desc_color(motdbuf, d);
      }
      add_char(ch);
      d->connected = CON_PLAYING;
      set_char_color(AT_DGREEN, ch);
      if (!xIS_SET(ch->act, PLR_ANSI) && d->ansi == true)
	d->ansi = false;
      else if (xIS_SET(ch->act, PLR_ANSI) && d->ansi == false)
	d->ansi = true;
      if (ch->level == 0) {
	int 	i_lang;

	ch->pcdata->upgradeL = CURRENT_UPGRADE_LEVEL;

	ch->pcdata->clan_name = STRALLOC("");
	ch->pcdata->clan = NULL;
	switch (class_table[ch->class]->attr_prime) {
	case APPLY_STR:
	  ch->perm_str = 10;
	  break;
	case APPLY_INT:
	  ch->perm_int = 10;
	  break;
	case APPLY_DEX:
	  ch->perm_dex = 10;
	  break;
	case APPLY_CON:
	  ch->perm_con = 10;
	  break;
	case APPLY_LCK:
	  ch->perm_lck = 10;
	  break;
	}

			name_stamp_stats(ch);

			ch->level = 1;
			ch->exp = 5;
			ch->pl = 5;
			ch->heart_pl = 5;
			ch->max_hit += race_table[ch->race]->hit;
			ch->max_mana += race_table[ch->race]->mana;
			ch->max_move = 100;
			ch->hit = UMAX(1, ch->max_hit);
			ch->mana = UMAX(1, ch->max_mana);
			ch->move = UMAX(1, ch->max_move);
			ch->train = 5;
			ch->max_train = 1;
			ch->pcdata->xTrain = 0;
			ch->pcdata->total_xTrain = 0;
			ch->practice = 0;
			ch->max_prac = 0;
			ch->max_energy = 1;
			ch->pcdata->admintalk = 0;
			ch->pcdata->age = 18;
			ch->pcdata->sparcount = 0;
			if (is_saiyan(ch) || is_hb(ch) || is_icer(ch) || is_bio(ch))
				ch->pcdata->tail = true;
			else
				ch->pcdata->tail = false;
			if (is_android(ch))
				ch->pcdata->natural_ac_max = 500;
			if (is_bio(ch))
				ch->pcdata->absorb_pl_mod = 6;
			if (is_saiyan(ch) || is_hb(ch))
				ch->pcdata->learned[gsn_monkey_gun] = 95;

			sprintf(buf, "the %s",
			    title_table[ch->class][ch->level]
			    [ch->sex == SEX_FEMALE ? 1 : 0]);
			set_title(ch, buf);
			ch->pcdata->creation_date = current_time;

			xSET_BIT(ch->act, PLR_AUTOGOLD);
			xSET_BIT(ch->act, PLR_AUTOEXIT);
			xSET_BIT(ch->act, PLR_AUTO_COMPASS);
			xSET_BIT(ch->act, PLR_SPAR);
			SET_BIT(ch->pcdata->flags, PCFLAG_DEADLY);
			xSET_BIT(ch->deaf, CHANNEL_FOS);

			for (i = 1; i < MAX_BOARD; i++) {
				for (catchup_notes = ch->pcdata->board->note_first; catchup_notes && catchup_notes->next; catchup_notes = catchup_notes->next);

				if (!catchup_notes);
				else {
					ch->pcdata->last_note[i] = catchup_notes->date_stamp;
				}
			}
	ch->perm_str += race_table[ch->race]->str_plus;
	ch->perm_int += race_table[ch->race]->int_plus;
	ch->perm_dex += race_table[ch->race]->dex_plus;
	ch->perm_con += race_table[ch->race]->con_plus;
	ch->affected_by = race_table[ch->race]->affected;
	ch->perm_lck = number_range(0, 30);

	ch->pcdata->permTstr = ch->perm_str;
	ch->pcdata->permTspd = ch->perm_dex;
	ch->pcdata->permTint = ch->perm_int;
	ch->pcdata->permTcon = ch->perm_con;

	ch->armor += race_table[ch->race]->ac_plus;
	ch->alignment += race_table[ch->race]->alignment;
	ch->attacks = race_table[ch->race]->attacks;
	ch->defenses = race_table[ch->race]->defenses;
	ch->saving_poison_death = race_table[ch->race]->saving_poison_death;
	ch->saving_wand = race_table[ch->race]->saving_wand;
	ch->saving_para_petri = race_table[ch->race]->saving_para_petri;
	ch->saving_breath = race_table[ch->race]->saving_breath;
	ch->saving_spell_staff = race_table[ch->race]->saving_spell_staff;

	ch->height = number_range(race_table[ch->race]->height * .9, race_table[ch->race]->height * 1.1);
	ch->weight = number_range(race_table[ch->race]->weight * .9, race_table[ch->race]->weight * 1.1);

	if ((i_lang = skill_lookup("common")) < 0)
	  bug("Nanny: cannot find common language.");
	else
	  ch->pcdata->learned[i_lang] = 100;

			char_to_room(ch, get_room_index(ROOM_VNUM_SCHOOL));
			ch->pcdata->prompt = STRALLOC("");
		} else if (!IS_IMMORTAL(ch) && ch->pcdata->release_date > 0 &&
		    ch->pcdata->release_date > current_time) {
			if (ch->in_room->vnum == 6
			    || ch->in_room->vnum == 8
			    || ch->in_room->vnum == 1206)
				char_to_room(ch, ch->in_room);
			else
				char_to_room(ch, get_room_index(8));
		} else if (!IS_IMMORTAL(ch) && ch->in_room
		    && ch->in_room->vnum == 2060) {
			act(AT_GREEN, "A Strange Force rips you from the Hyperbolic Time Chamber.", ch, NULL, NULL, TO_CHAR);
			char_to_room(ch, get_room_index(2059));
		} else if (ch->in_room && (IS_IMMORTAL(ch)
		    || !xIS_SET(ch->in_room->room_flags, ROOM_PROTOTYPE))) {
			char_to_room(ch, ch->in_room);
		} else if (IS_IMMORTAL(ch)) {
			char_to_room(ch, get_room_index(ROOM_VNUM_CHAT));
		} else {
			char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
		}
	for (i_lang = 0; lang_array[i_lang] != LANG_UNKNOWN; i_lang++)
	  if (lang_array[i_lang] == race_table[ch->race]->language)
	    break;
	if (lang_array[i_lang] == LANG_UNKNOWN);
	else {
	  if ((i_lang = skill_lookup(lang_names[i_lang])) < 0)
	    bug("Nanny: cannot find racial language.");
	  else
	    ch->pcdata->learned[i_lang] = 100;
	}

		act(AT_ACTION, "$n has entered the game.", ch, NULL, NULL, TO_CANSEE);
		if (ch->pcdata->pet) {
			act(AT_ACTION, "$n returns to $s master from the Void.",
			    ch->pcdata->pet, NULL, ch, TO_NOTVICT);
			act(AT_ACTION, "$N returns with you to the realms.",
			    ch, NULL, ch->pcdata->pet, TO_CHAR);
		}
		ch->tmystic = 0;
		ch->mysticlearn = 0;
		ch->teaching = NULL;
		if (is_kaio(ch) && ch->alignment < 0)
			ch->alignment = 0;
		if (is_demon(ch) && ch->alignment > 0)
			ch->alignment = 0;

		remove_member(ch);
		if (ch->pcdata->clan)
			update_member(ch);

		/* For the logon pl tracker */
		ch->logon_start = ch->exp;
		do_global_boards(ch, "");

		ch->dodge = false;
		ch->block = false;
		ch->ki_dodge = false;
		ch->ki_cancel = false;
		ch->ki_deflect = false;

		do_look(ch, "auto");
		tax_player(ch);
		mccp_interest(ch);
		mail_count(ch);
		check_loginmsg(ch);

		if (!ch->was_in_room && ch->in_room == get_room_index(ROOM_VNUM_TEMPLE))
			ch->was_in_room = get_room_index(ROOM_VNUM_TEMPLE);
		else if (ch->was_in_room == get_room_index(ROOM_VNUM_TEMPLE))
			ch->was_in_room = get_room_index(ROOM_VNUM_TEMPLE);
		else if (!ch->was_in_room)
			ch->was_in_room = ch->in_room;
		break;
	case CON_NOTE_TO:
		handle_con_note_to(d, argument);
		break;
	case CON_NOTE_SUBJECT:
		handle_con_note_subject(d, argument);
		break;			
	case CON_NOTE_EXPIRE:
		handle_con_note_expire(d, argument);
		break;
	case CON_NOTE_TEXT:
		handle_con_note_text(d, argument);
		break;
	case CON_NOTE_FINISH:
		handle_con_note_finish(d, argument);
		break;
	name_stamp_stats(ch);

	ch->level = 1;
	ch->exp = 5;
	ch->pl = 5;
	ch->heart_pl = 5;
	ch->max_hit += race_table[ch->race]->hit;
	ch->max_mana += race_table[ch->race]->mana;
	ch->max_move = 100;
	ch->hit = UMAX(1, ch->max_hit);
	ch->mana = UMAX(1, ch->max_mana);
	ch->move = UMAX(1, ch->max_move);
	ch->train = 5;
	ch->max_train = 1;
	ch->pcdata->xTrain = 0;
	ch->pcdata->total_xTrain = 0;
	ch->practice = 0;
	ch->max_prac = 0;
	ch->max_energy = 1;
	ch->pcdata->admintalk = 0;
	ch->pcdata->age = 18;
	ch->pcdata->sparcount = 0;
	if (is_saiyan(ch) || is_hb(ch) || is_icer(ch) || is_bio(ch))
	  ch->pcdata->tail = true;
	else
	  ch->pcdata->tail = false;
	if (is_android(ch))
	  ch->pcdata->natural_ac_max = 500;
	if (is_bio(ch))
	  ch->pcdata->absorb_pl_mod = 6;
	if (is_saiyan(ch) || is_hb(ch))
	  ch->pcdata->learned[gsn_monkey_gun] = 95;

	sprintf(buf, "the %s",
		title_table[ch->class][ch->level]
		[ch->sex == SEX_FEMALE ? 1 : 0]);
	set_title(ch, buf);
	ch->pcdata->creation_date = current_time;

	xSET_BIT(ch->act, PLR_AUTOGOLD);
	xSET_BIT(ch->act, PLR_AUTOEXIT);
	xSET_BIT(ch->act, PLR_AUTO_COMPASS);
	xSET_BIT(ch->act, PLR_SPAR);
	SET_BIT(ch->pcdata->flags, PCFLAG_DEADLY);
	xSET_BIT(ch->deaf, CHANNEL_FOS);

	for (i = 1; i < MAX_BOARD; i++) {
	  for (catchup_notes = ch->pcdata->board->note_first; catchup_notes && catchup_notes->next; catchup_notes = catchup_notes->next);

	  if (!catchup_notes);
	  else {
	    ch->pcdata->last_note[i] = catchup_notes->date_stamp;
	  }
	}

	return;
	char_to_room(ch, get_room_index(ROOM_VNUM_SCHOOL));
	ch->pcdata->prompt = STRALLOC("");
      } else if (!IS_IMMORTAL(ch) && ch->pcdata->release_date > 0 &&
		 ch->pcdata->release_date > current_time) {
	if (ch->in_room->vnum == 6
	    || ch->in_room->vnum == 8
	    || ch->in_room->vnum == 1206)
	  char_to_room(ch, ch->in_room);
	else
	  char_to_room(ch, get_room_index(8));
      } else if (!IS_IMMORTAL(ch) && ch->in_room
		 && ch->in_room->vnum == 2060) {
	act(AT_GREEN, "A Strange Force rips you from the Hyperbolic Time Chamber.", ch, NULL, NULL, TO_CHAR);
	char_to_room(ch, get_room_index(2059));
      } else if (ch->in_room && (IS_IMMORTAL(ch)
				 || !xIS_SET(ch->in_room->room_flags, ROOM_PROTOTYPE))) {
	char_to_room(ch, ch->in_room);
      } else if (IS_IMMORTAL(ch)) {
	char_to_room(ch, get_room_index(ROOM_VNUM_CHAT));
      } else {
	char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
      }

      act(AT_ACTION, "$n has entered the game.", ch, NULL, NULL, TO_CANSEE);
      if (ch->pcdata->pet) {
	act(AT_ACTION, "$n returns to $s master from the Void.",
	    ch->pcdata->pet, NULL, ch, TO_NOTVICT);
	act(AT_ACTION, "$N returns with you to the realms.",
	    ch, NULL, ch->pcdata->pet, TO_CHAR);
      }
      ch->tmystic = 0;
      ch->mysticlearn = 0;
      ch->teaching = NULL;
      if (is_kaio(ch) && ch->alignment < 0)
	ch->alignment = 0;
      if (is_demon(ch) && ch->alignment > 0)
	ch->alignment = 0;

      remove_member(ch);
      if (ch->pcdata->clan)
	update_member(ch);

      /* For the logon pl tracker */
      ch->logon_start = ch->exp;
      do_global_boards(ch, "");

      ch->dodge = false;
      ch->block = false;
      ch->ki_dodge = false;
      ch->ki_cancel = false;
      ch->ki_deflect = false;

      do_look(ch, "auto");
      tax_player(ch);
      mccp_interest(ch);
      mail_count(ch);
      check_loginmsg(ch);

      if (!ch->was_in_room && ch->in_room == get_room_index(ROOM_VNUM_TEMPLE))
	ch->was_in_room = get_room_index(ROOM_VNUM_TEMPLE);
      else if (ch->was_in_room == get_room_index(ROOM_VNUM_TEMPLE))
	ch->was_in_room = get_room_index(ROOM_VNUM_TEMPLE);
      else if (!ch->was_in_room)
	ch->was_in_room = ch->in_room;
      break;
    case CON_NOTE_TO:
      handle_con_note_to (d, argument);
      break;
    case CON_NOTE_SUBJECT:
      handle_con_note_subject (d, argument);
      break; /* subject */
    case CON_NOTE_EXPIRE:
      handle_con_note_expire (d, argument);
      break;
    case CON_NOTE_TEXT:
      handle_con_note_text (d, argument);
      break;
    case CON_NOTE_FINISH:
      handle_con_note_finish (d, argument);
      break;
    }
}

bool


@@ 2329,45 2648,139 @@ check_parse_name(char *name, bool newchar)
	return (true);
}

/*
 * Look for link-dead player to reconnect.
 */
bool
check_playing(DESCRIPTOR_DATA * d, char *name)
check_reconnect(DESCRIPTOR_DATA *d, char *name, bool f_conn)
{
	DESCRIPTOR_DATA *d_old;

	for (d_old = first_descriptor; d_old; d_old = d_old->next) {
		if (d_old != d
		    && (d_old->character || d_old->original)
		    && !str_cmp(name, d_old->original
		    ? d_old->original->pcdata->filename :
		    d_old->character->pcdata->filename)) {
			return (true);
  CHAR_DATA *ch;

  for (ch = first_char; ch; ch = ch->next)
    {
      if (!IS_NPC(ch)
	  && (!f_conn || !ch->desc)
	  &&    ch->pcdata->filename
	  &&   !str_cmp(name, ch->pcdata->filename))
	{
	  if (f_conn && ch->switched)
	    {
	      write_to_buffer(d, "Already playing.\n\rName: ", 0);
	      d->connected = CON_GET_NAME;
	      if (d->character)
		{
		  /* clear descriptor pointer to get rid of bug message in log */
		  d->character->desc = NULL;
		  free_char(d->character);
		  d->character = NULL;
		}
	      return BERR;
	    }
	  if (f_conn == false)
	    {
	      DISPOSE(d->character->pcdata->pwd);
	      d->character->pcdata->pwd = str_dup(ch->pcdata->pwd);
	    }
	  else
	    {
	      /* clear descriptor pointer to get rid of bug message in log */
	      d->character->desc = NULL;
	      free_char(d->character);
	      d->character = ch;
	      ch->desc	 = d;
	      ch->timer	 = 0;
	      send_to_char("Reconnecting.\n\r", ch);
	      do_look(ch, "auto");
	      act(AT_ACTION, "$n has reconnected.", ch, NULL, NULL, TO_CANSEE);
	      sprintf(log_buf, "%s@%s(%s) reconnected.",
		      ch->pcdata->filename, d->host, d->user);
	      log_string_plus(log_buf, LOG_COMM, UMAX(sysdata.log_level, ch->level));
	      d->connected = CON_PLAYING;
	      if (ch->pcdata->in_progress)
		send_to_char ("You have a note in progress. Type \"note write\" to continue it.\n\r",ch);

	    }
	  return true;
	}
    }

	return (false);
  return false;
}

bool
reconnect(DESCRIPTOR_DATA * d, char *name)
check_playing(DESCRIPTOR_DATA *d, char *name, bool kick)
{
	CHAR_DATA *ch;
	DESCRIPTOR_DATA *d_old;
	int 	conn_state;

	for (d_old = first_descriptor; d_old; d_old = d_old->next) {
		if (d_old != d
		    && (d_old->character || d_old->original)
		    && !str_cmp(name, d_old->original
		    ? d_old->original->pcdata->filename :
		    d_old->character->pcdata->filename)) {
			log_string("preparing to close socket at comm.c:2824\n");
			//fquit(d->character);
			close_socket(d_old, true, true);
			return (true);
		}
  CHAR_DATA *ch;

  DESCRIPTOR_DATA *dold;
  int	cstate;

  for (dold = first_descriptor; dold; dold = dold->next)
    {
      if (dold != d
	   && ( dold->character || dold->original)
	   &&   !str_cmp(name, dold->original
			  ? dold->original->pcdata->filename :
			  dold->character->pcdata->filename))
	{
	  cstate = dold->connected;
	  ch = dold->original ? dold->original : dold->character;
	  if (!ch->name
	       || (cstate != CON_PLAYING && cstate != CON_EDITING))
	    {
	      write_to_buffer(d, "Already connected - try again.\n\r", 0);
	      sprintf(log_buf, "%s already connected.",
		       ch->pcdata->filename);
	      log_string_plus(log_buf, LOG_COMM, sysdata.log_level);
	      return BERR;
	    }
	  if (!kick)
	    return true;
	  write_to_buffer(d, "Already playing... Kicking off old connection.\n\r", 0);
	  write_to_buffer(dold, "Kicking off old connection... bye!\n\r", 0);
	  close_socket(dold, false);
	  /* clear descriptor pointer to get rid of bug message in log */
	  d->character->desc = NULL;
	  free_char(d->character);
	  d->character = ch;
	  ch->desc	 = d;
	  ch->timer	 = 0;
	  if (ch->switched)
	    do_return(ch->switched, "");
	  ch->switched = NULL;
	  send_to_char("Reconnecting.\n\r", ch);
	  do_look(ch, "auto");
	  act(AT_ACTION, "$n has reconnected, kicking off old link.",
	       ch, NULL, NULL, TO_CANSEE);
	  sprintf(log_buf, "%s@%s reconnected, kicking off old link.",
		   ch->pcdata->filename, d->host);
	  log_string_plus(log_buf, LOG_COMM, UMAX(sysdata.log_level, ch->level));
	  d->connected = cstate;
	  return true;
	}
    }

	return (false);
  return false;
}

void
stop_idling(CHAR_DATA *ch)
{
  ROOM_INDEX_DATA *was_in_room;

  if (!ch
       ||   !ch->desc
       ||   ch->desc->connected != CON_PLAYING
       ||   !IS_IDLE(ch))
    return;

  ch->timer = 0;
  was_in_room = ch->was_in_room;
  char_from_room(ch);
  char_to_room(ch, was_in_room);
  ch->was_in_room = ch->in_room;
  REMOVE_BIT(ch->pcdata->flags, PCFLAG_IDLE);
  act(AT_ACTION, "$n has returned from the void.", ch, NULL, NULL, TO_ROOM);
}

void


@@ 4069,7 4482,7 @@ check_pfile(DESCRIPTOR_DATA * d) {
		sprintf(log_buf, "Bad player file %s", d->user);
		log_string(log_buf);
		send_to_desc_color("Your playerfile is corrupt... please notify case@capsulecorp.org\n\r", d);
		close_socket(d, true, false);
		close_socket(d, true);
		return (false);
	} else {
		return(true);


@@ 4088,3 4501,43 @@ load_from_fp(DESCRIPTOR_DATA * d, bool np) {
	else
	    load_char_obj(d, d->user, false);
}


long long
strtonum(const char *numstr, long long minval, long long maxval,
    const char **errstrp)
{
	long long ll = 0;
	int error = 0;
	char *ep;
	struct errval {
		const char *errstr;
		int err;
	} ev[4] = {
		{ NULL,		0 },
		{ "invalid",	EINVAL },
		{ "too small",	ERANGE },
		{ "too large",	ERANGE },
	};

	ev[0].err = errno;
	errno = 0;
	if (minval > maxval) {
		error = INVALID;
	} else {
		ll = strtoll(numstr, &ep, 10);
		if (numstr == ep || *ep != '\0')
			error = INVALID;
		else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
			error = TOOSMALL;
		else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
			error = TOOLARGE;
	}
	if (errstrp != NULL)
		*errstrp = ev[error].errstr;
	errno = ev[error].err;
	if (error)
		ll = 0;

	return (ll);
}

M src/db.c => src/db.c +12 -11
@@ 19,7 19,6 @@
 ****************************************************************************/

#include <sys/types.h>
#include <bsd/stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>


@@ 2656,9 2655,12 @@ create_mobile(MOB_INDEX_DATA * pMobIndex)
	else
		mob->armor = 100;

	if (!pMobIndex->hitnodice)
		mob->max_hit = (mob->perm_con + 100);
	mob->hit = mob->max_hit;
	mob->hitplus = pMobIndex->hitplus;
	
	if (mob->hitplus < 1)
	  mob->hitplus = 1;
	
	mob->max_hit = mob->hitplus;
	/* lets put things back the way they used to be! -Thoric */
	mob->gold = pMobIndex->gold;
	if (mob->gold > -1)


@@ 2719,7 2721,6 @@ create_mobile(MOB_INDEX_DATA * pMobIndex)
	mob->barenumdie = pMobIndex->damnodice;
	mob->baresizedie = pMobIndex->damsizedice;
	mob->mobthac0 = pMobIndex->mobthac0;
	mob->hitplus = pMobIndex->hitplus;
	mob->damplus = pMobIndex->damplus;

	mob->perm_str = pMobIndex->perm_str;


@@ 4116,24 4117,24 @@ number_fuzzy(int number)

/*
 * Generate a random number.
 * Ooops was (arc4random() % to) + from which doesn't work -Shaddai
 * Ooops was (random() % to) + from which doesn't work -Shaddai
 */
int
number_range(int from, int to)
{
	if ((to - from) < 1)
		return from;
	return ((arc4random() % (to - from + 1)) + from);
	return ((random() % (to - from + 1)) + from);
}

/*
 * Generate a percentile roll.
 * arc4random() % 100 only does 0-99, changed to do 1-100 -Shaddai
 * random() % 100 only does 0-99, changed to do 1-100 -Shaddai
 */
int
number_percent(void)
{
	return (arc4random() % 100) + 1;
	return (random() % 100) + 1;
}




@@ 4145,7 4146,7 @@ number_door(void)
{
	int 	door;

	while ((door = arc4random() & (16 - 1)) > 9);
	while ((door = random() & (16 - 1)) > 9);

	return door;
}


@@ 4155,7 4156,7 @@ number_door(void)
int
number_bits(int width)
{
	return arc4random() & ((1 << width) - 1);
	return random() & ((1 << width) - 1);
}

/*

M src/fight.c => src/fight.c +1599 -1
@@ 531,6 531,1604 @@ violence_update(void)
				affect_remove(ch, paf);
			}
		}
		/* Transformation Update */
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SNAMEK)) {
				int form_drain = 0;
				int form_mastery = 0;
				double plmod = 0;
				
				form_mastery = (ch->train / 45000);
				plmod = (ch->pl / ch->exp);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SNAMEK);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					ch->mana = 0;
					transStatRemove(ch);
					act( AT_WHITE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_WHITE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				if (plmod > 600)
					form_drain = (800 - (form_mastery * 6));
				else if (plmod > 500)
					form_drain = (400 - (form_mastery * 6));
				else if (plmod > 350)
					form_drain = (400 - (form_mastery * 6));
				else if (plmod > 250)
					form_drain = (275 - (form_mastery * 6));
				else if (plmod > 150)
					form_drain = (200 - (form_mastery * 6));
				else if (plmod > 75)
					form_drain = (150 - (form_mastery * 6));
				else if (plmod > 50)
					form_drain = (100 - (form_mastery * 6));
				else if (plmod > 35)
					form_drain = (75 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_drain <= 1)
					ch->train += 1;
				else if (form_drain > 1)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_MYSTIC)) {
				int form_drain = 0;
				int form_mastery = 0;
				double plmod = 0;
				
				form_mastery = (ch->train / 45000);
				plmod = (ch->pl / ch->exp);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_MYSTIC);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					act( AT_WHITE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_WHITE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				if (plmod > 600)
					form_drain = (800 - (form_mastery * 6));
				else if (plmod > 500)
					form_drain = (400 - (form_mastery * 6));
				else if (plmod > 350)
					form_drain = (400 - (form_mastery * 6));
				else if (plmod > 250)
					form_drain = (275 - (form_mastery * 6));
				else if (plmod > 150)
					form_drain = (200 - (form_mastery * 6));
				else if (plmod > 75)
					form_drain = (150 - (form_mastery * 6));
				else if (plmod > 50)
					form_drain = (100 - (form_mastery * 6));
				else if (plmod > 35)
					form_drain = (75 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_drain <= 1)
					ch->train += 1;
				else if (form_drain > 1)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_ICER2)) {
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_ICER2);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					act( AT_PURPLE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_PURPLE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				if (form_mastery >= 6)
					ch->train += 1;
				else if (form_mastery < 6)
					ch->train += 15;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_ICER3)) {
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_ICER3);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					act( AT_PURPLE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_PURPLE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				if (form_mastery >= 20)
					ch->train += 1;
				else if (form_mastery < 20)
					ch->train += 15;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_ICER4)) {
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_ICER4);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					act( AT_PURPLE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_PURPLE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				if (form_mastery >= 44)
					ch->train += 1;
				else if (form_mastery < 44)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_ICER5)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_ICER5);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					act( AT_PURPLE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_PURPLE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (600 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_mastery >= 64)
					ch->train += 1;
				else if (form_mastery < 64)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_GOLDENFORM)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_GOLDENFORM);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					act( AT_PURPLE, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_PURPLE, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (800 - (form_mastery * 6));
				if (form_drain < 400)
					form_drain = 400;
				ch->mana -= form_drain;
				if (form_drain > 400)
					ch->train += 3;
				else if (form_drain <= 400)
					ch->train += 1;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& !xIS_SET((ch)->affected_by, AFF_USSJ)
			&& !xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_YELLOW, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (100 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_mastery >= 9)
					ch->train += 1;
				else if (form_mastery < 9)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ)
			&& !xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_YELLOW, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (150 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_mastery >= 19)
					ch->train += 1;
				else if (form_mastery < 19)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_YELLOW, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (300 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_mastery >= 29)
					ch->train += 1;
				else if (form_mastery < 29)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ2);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_YELLOW, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (275 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_drain >= 39)
					ch->train += 1;
				else if (form_drain < 39)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ3);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_YELLOW, "You lose control of your ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n loses control of $s ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (500 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_mastery >= 52)
					ch->train += 1;
				else if (form_mastery < 52)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ3);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ4);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_RED, "You lose control of your God Ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_RED, "$n loses control of $s God Ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (400 - (form_mastery * 6));
				if (form_drain < 1)
					form_drain = 1;
				ch->mana -= form_drain;
				if (form_mastery >= 62)
					ch->train += 1;
				else if (form_mastery < 62)
					ch->train += 3;
		}
		if (!IS_NPC(ch)
			&& xIS_SET((ch)->affected_by, AFF_SSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ)
			&& xIS_SET((ch)->affected_by, AFF_USSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ2)
			&& xIS_SET((ch)->affected_by, AFF_SSJ3)
			&& xIS_SET((ch)->affected_by, AFF_SSJ4)
			&& xIS_SET((ch)->affected_by, AFF_SGOD)) {
				int form_drain = 0;
				int form_mastery = 0;
				
				form_mastery = (ch->train / 45000);
				if (ch->mana <= 0) {
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
					xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ2);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ3);
					xREMOVE_BIT((ch)->affected_by, AFF_SSJ4);
					xREMOVE_BIT((ch)->affected_by, AFF_SGOD);
					if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL))
						xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
					if (xIS_SET((ch)->affected_by, AFF_SAFEMAX))
						xREMOVE_BIT((ch)->affected_by, AFF_SAFEMAX);
					ch->pl = ch->exp;
					ch->powerup = 0;
					transStatRemove(ch);
					ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
					ch->pcdata->eyes = ch->pcdata->orignaleyes;
					act( AT_LBLUE, "You lose control of your God Ki and return to normal!", ch, NULL, NULL, TO_CHAR );
					act( AT_LBLUE, "$n loses control of $s God Ki and returns to normal!", ch, NULL, NULL, TO_NOTVICT );
				}
				if (form_mastery < 1)
					form_mastery = 1;
				form_drain = (500 - (form_mastery * 6));
				if (form_drain < 250)
					form_drain = 250;
				ch->mana -= form_drain;
				if (form_drain <= 250)
					ch->train += 1;
				else if (form_drain > 250)
					ch->train += 3;
		}
		/* Bug Guard */
		if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL)
			&& xIS_SET((ch)->affected_by, AFF_SAFEMAX)) {
				xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
				bug( "POWERCHANNEL AND SAFEMAX ACTIVE TOGETHER, REMOVED POWERCHANNEL", 0 );
				send_to_char("DEBUG: POWERUP AND SAFEMAX CAUGHT TOGETHER, REMOVED POWERCHANNEL\n\r", ch);
			}
		/* New Time-based Powerup */
		if (xIS_SET((ch)->affected_by, AFF_POWERCHANNEL)
			&& !xIS_SET((ch)->affected_by, AFF_KAIOKEN)
			&& !xIS_SET((ch)->affected_by, AFF_SAFEMAX)
			&& ch->position >= POS_STANDING) {
			double safemaximum = 0;
			int form_mastery = 0;
			double plmod = 0;
			int auraColor = AT_WHITE;
			int powerupstr = 0;
			int powerupspd = 0;
			int powerupint = 0;
			int powerupcon = 0;
			
			powerupstr = ch->perm_str * 0.05;
			powerupspd = ch->perm_dex * 0.05;
			powerupint = ch->perm_int * 0.05;
			powerupcon = ch->perm_con * 0.05;
			
			safemaximum = ((get_curr_int(ch) * 0.03) + 1);
			form_mastery = (ch->train / 45000);
			plmod = (ch->pl / ch->exp);
			if( !IS_NPC( ch ) && ch->pcdata->auraColorPowerUp > 0 )
				auraColor = ch->pcdata->auraColorPowerUp;
			if (form_mastery < 1)
				form_mastery = 1;
			if (ch->position < POS_STANDING) {
				xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
				send_to_char("You must stand if you wish to power up.\n\r", ch);
			}
			if (xIS_SET((ch)->affected_by, AFF_KAIOKEN)) {
				xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
				send_to_char("Your energy is too unstable while using Kaioken.\n\r", ch);
			}
			if (is_saiyan(ch) || is_hb(ch)) {
				int onestr = 0; 
				int twostr = 0;
				int threestr = 0;
				int fourstr = 0;
				int fivestr = 0;
				int sixstr = 0;
				int sevenstr = 0;
				int onespd = 0;
				int twospd = 0;
				int threespd = 0;
				int fourspd = 0;
				int fivespd = 0;
				int sixspd = 0;
				int sevenspd = 0;
				int oneint = 0;
				int twoint = 0;
				int threeint = 0;
				int fourint = 0;
				int fiveint = 0;
				int sixint = 0;
				int sevenint = 0;
				int onecon = 0;
				int twocon = 0;
				int threecon = 0;
				int fourcon = 0;
				int fivecon = 0;
				int sixcon = 0;
				int sevencon = 0;
					
				onestr = ch->perm_str * 0.20; 
				twostr = ch->perm_str * 0.30;
				threestr = ch->perm_str * 0.50;
				fourstr = ch->perm_str * 0.50;
				fivestr = ch->perm_str * 0.60;
				sixstr = ch->perm_str;
				sevenstr = ch->perm_str * 1.25;
				onespd = ch->perm_dex * 0.20;
				twospd = ch->perm_dex * 0.25;
				threespd = -250;
				fourspd = ch->perm_dex * 0.50;
				fivespd = ch->perm_dex * 0.60;
				sixspd = ch->perm_dex;
				sevenspd = ch->perm_dex * 1.25;
				oneint = ch->perm_int * 0.10;
				twoint = ch->perm_int * 0.10;
				threeint = ch->perm_int * 0.10;
				fourint = ch->perm_int * 0.25;
				fiveint = ch->perm_int * 0.30;
				sixint = ch->perm_int * 0.50;
				sevenint = ch->perm_int;
				onecon = ch->perm_con * 0.20;
				twocon = ch->perm_con * 0.30;
				threecon = ch->perm_con * 0.50;
				fourcon = ch->perm_con * 0.40;
				fivecon = ch->perm_con * 0.50;
				sixcon = ch->perm_con;
				sevencon = ch->perm_con * 1.25;
				if (!xIS_SET((ch)->affected_by, AFF_SSJ)) {
					safemaximum = ((get_curr_int(ch) * 0.03) + 1);
					if (ch->powerup < safemaximum) {
						
						ch->pl *= 1.15;
						ch->powerup += 1;
						transStatApply(ch, powerupstr, powerupspd, powerupint, powerupcon);
						if (plmod >= 30
							&& ch->pcdata->learned[gsn_ssj] > 0) {
							xSET_BIT((ch)->affected_by, AFF_SSJ);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_YELLOW, "Your eyes turn blue, your hair flashes blonde and a fiery golden aura erupts around you!", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n's hair suddenly flashes blonde, transcending beyond $s normal limits in a fiery display of golden ki!", ch, NULL, NULL, TO_NOTVICT );
							ch->powerup = 0;
							ch->pl = ch->exp * 50;
							transStatApply(ch, onestr, onespd, oneint, onecon);
							if (!IS_NPC(ch)) {
								ch->pcdata->eyes = 0;
								ch->pcdata->haircolor = 3;
							}
						}
						if (plmod >= 30
							&& ch->pcdata->learned[gsn_ssj] <= 0) {
							ch->pl = (ch->exp * 30);
							act( auraColor, "The raging torrent of ki fades but your power remains.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's raging torrent of ki fades away but $s power remains.", ch, NULL, NULL, TO_NOTVICT );
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							ch->powerup = safemaximum;
							xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						}
						if (plmod >= 20 && plmod < 27) {
							act( auraColor, "Your body is barely visible amidst your vortex of ki.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's body is barely visible amidst $s vortex of ki!", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 15 && plmod < 20) {
							act( auraColor, "Your aura spirals upward, nearly licking the clouds.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura spirals upward, nearly licking the clouds.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 10 && plmod < 15) {
							act( auraColor, "Your inner potential explodes into a display of roaring ki.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's inner potential explodes into a display of roaring ki.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 5 && plmod < 10) {
							act( auraColor, "Your aura flickers around you, only faintly visible.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura flickers around $m, only faintly visible.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod > 1 && plmod < 5) {
							act( auraColor, "Your body glows faintly.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's body glows faintly.", ch, NULL, NULL, TO_NOTVICT );
						}
						if ((ch->pl / ch->exp) >= 30
							&& ch->pcdata->learned[gsn_ssj] <= 0) {
							ch->pl = (ch->exp * 30);
							act( auraColor, "The raging torrent of ki fades, but your power remains.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's raging torrent of ki fades away, but $s power remains.", ch, NULL, NULL, TO_NOTVICT );
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( auraColor, "Having reached your limit, you stop powering up. Going any further would be dangerous.", ch, NULL, NULL, TO_CHAR );
						act( auraColor, "$n reaches $s limit and stops powering up.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& !xIS_SET((ch)->affected_by, AFF_USSJ)
					&& !xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 52) {
							act( AT_YELLOW, "Your golden aura churns with scattering rays of light.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n's golden aura churns with scattering rays of light.", ch, NULL, NULL, TO_NOTVICT );
						}
						if ((ch->pl / ch->exp) >= 65) {
							xSET_BIT((ch)->affected_by, AFF_USSJ);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_YELLOW, "Your muscles bulge, and with a sudden burst of power you ascend beyond the reaches of any mere Super Saiyan.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n's muscles bulge, drawing on a power beyond that of any mere Super Saiyan.", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 75;
							transStatApply(ch, twostr, twospd, twoint, twocon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "Having reached your limit, your burning aura recedes to a gentle blaze.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n's burning, golden aura recedes into a gentle blaze.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ)
					&& !xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 78) {
							act( AT_YELLOW, "Crackling bolts of energy build in your aura, impure, but powerful as your muscles swell.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "Crackling bolts of impure energy dance in $n's raging aura, $s muscles swelling to incredible sizes.", ch, NULL, NULL, TO_NOTVICT );
						}
						if ((ch->pl / ch->exp) >= 100) {
							xSET_BIT((ch)->affected_by, AFF_USSJ2);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_YELLOW, "Your muscles expand to inhuman sizes, engorging yourself with energy!", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n's muscles expand to inhuman sizes, engorging $mself with energy!", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 150;
							transStatApply(ch, threestr, threespd, threeint, threecon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "You let out a deep breath, your bulging muscles retracting only slightly.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n lets out a deep breath, $s bulging muscles retracting only slightly.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 156) {
							act( AT_YELLOW, "Your giant muscles tremble, emitting waves of tumultuous energy.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n's giant muscles tremble, emitting waves of tumultuous energy.", ch, NULL, NULL, TO_NOTVICT );
						}
						if ((ch->pl / ch->exp) >= 200
							&& ch->pcdata->learned[gsn_ssj2] > 0) {
							xSET_BIT((ch)->affected_by, AFF_SSJ2);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_YELLOW, "Your muscles shrink, but in an intense explosion of rage your power grows nonetheless, sending arcing bolts of energy from your body.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "Your hair stands further on end as you ascend to the true next level.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n's muscles shrink amidst a storm of golden ki. In a sea of crackling, pure energy, $e truly ascends to the next level.", ch, NULL, NULL, TO_NOTVICT );
							act( AT_YELLOW, "$n stares straight ahead with absolute confidence.", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 225;
							transStatApply(ch, fourstr, fourspd, fourint, fourcon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "Your giant muscles tense and flex, but no further power comes from it.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n's grossly oversized muscles tense and flex, but $e seems unable to progress any further.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 234) {
							act( AT_YELLOW, "You howl with fury as your energy builds, constant strikes of crackling energy suffusing the air.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "$n howls with fury, constant strikes of crackling energy suffusing the air.", ch, NULL, NULL, TO_NOTVICT );
						}
						if ((ch->pl / ch->exp) >= 300
							&& ch->pcdata->learned[gsn_ssj3] > 0) {
							xSET_BIT((ch)->affected_by, AFF_SSJ3);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act(AT_YELLOW, "An earth-shattering burst of energy expands your aura. Your eyebrows disappear and your hair lengthens, flowing down your back.", ch, NULL, NULL, TO_CHAR);
							act(AT_YELLOW, "Only the stench of ozone accompanies the countless bolts of energy wreathing your body.", ch, NULL, NULL, TO_CHAR);
							act(AT_YELLOW, "The world feel as though it could pull apart as $n's aura expands! $s eyebrows disappear slowly and $s hair lengthens, flowing down $s back.", ch, NULL, NULL, TO_NOTVICT);
							act(AT_YELLOW, "When the bright light fades, $n stands within a wreath of countless bolts of energy, unleashing the primal rage of the Saiyan race.", ch, NULL, NULL, TO_NOTVICT);
							ch->pl = ch->exp * 350;
							transStatApply(ch, fivestr, fivespd, fiveint, fivecon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "Your aura shrinks as you relax, only occasional bursts of energy crackling around you.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n's aura shrinks as $e relaxes, only occasional bursts of energy crackling around $m.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& !xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.02;
						ch->powerup += 1;
						if (plmod > 358) {
							act( AT_YELLOW, "The colours of the world seem to fade away against the brilliant light of your aura.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "The colours of the world seem to fade away against the brilliant light of $n's aura.", ch, NULL, NULL, TO_NOTVICT );
						}
						if ((ch->pl / ch->exp) >= 450
							&& ch->pcdata->learned[gsn_ssj4] > 0) {
							xSET_BIT((ch)->affected_by, AFF_SSJ4);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_RED, "Your aura fades and your hair and eyes return to normal. However, in the next instant something inside you changes.", ch, NULL, NULL, TO_CHAR );
							act( AT_RED, "Godly Ki radiates from deep within, and with a mighty shout that pierces the heavens, a brilliant red and gold aura encompasses you.", ch, NULL, NULL, TO_CHAR );
							act( AT_RED, "Your hair and eyes flash red, tinted subtly with violet as you ascend beyond your mortal restrictions.", ch, NULL, NULL, TO_CHAR );
							act( AT_RED, "$n's hair and eyes return to normal. However, in the next instant something feels very different.", ch, NULL, NULL, TO_NOTVICT );
							act( AT_RED, "$n is encompassed in a massive aura of crimson and gold, $s hair and eyes shifting red with a subtle violet tint.", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 500;
							transStatApply(ch, sixstr, sixspd, sixint, sixcon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "Your aura shrinks as you establish control over your primal energy, unable to take it any further.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n's aura shrinks as $e establishes control over $s primal energy.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& !xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.02;
						ch->powerup += 1;
						if (plmod > 511) {
							act( AT_RED, "You stand perfectly calm, your power increasing by the second.", ch, NULL, NULL, TO_CHAR );
							act( AT_RED, "$n stands perfectly calm, and yet with every second $s power grows.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 600
							&& ch->pcdata->learned[gsn_sgod] > 0) {
							xSET_BIT((ch)->affected_by, AFF_SGOD);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_LBLUE, "Harnessing the secrets of your God Ki, you kindle the flame deep within and surge with newfound power.", ch, NULL, NULL, TO_CHAR );
							act( AT_LBLUE, "Your hair and eyes flash blue, and a brilliant cyan aura erupts around you!", ch, NULL, NULL, TO_CHAR );
							act( AT_LBLUE, "$n's body is swallowed in an intense blue light. What emerges is no mere Super Saiyan.", ch, NULL, NULL, TO_NOTVICT );
							act( AT_LBLUE, "$n's hair and eyes shimmer a deep cyan hue, merging fully with a power beyond mortal ki.", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 625;
							transStatApply(ch, sevenstr, sevenspd, sevenint, sevencon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "You shut your eyes, your whole body relaxing.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n relaxes further, emitting subtle pulses of God Ki.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ)
					&& xIS_SET((ch)->affected_by, AFF_USSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ2)
					&& xIS_SET((ch)->affected_by, AFF_SSJ3)
					&& xIS_SET((ch)->affected_by, AFF_SSJ4)
					&& xIS_SET((ch)->affected_by, AFF_SGOD)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 644) {
							act( AT_LBLUE, "Countless particles of white light merge with your aura, sending scattering rays of energy in all directions.", ch, NULL, NULL, TO_CHAR );
							act( AT_LBLUE, "Countless particles of white light merge with $n's aura, sending scattering rays of energy in all directions.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_LBLUE, "Your blue aura of God Ki recedes but your incredible power remains, waiting just beneath the surface.", ch, NULL, NULL, TO_CHAR );
						act( AT_LBLUE, "$n's intense God Ki recedes.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
			}
			else if (is_icer(ch)) {
				int onestr = 0; 
				int twostr = 0;
				int threestr = 0;
				int fourstr = 0;
				int fivestr = 0;
				int onespd = 0;
				int twospd = 0;
				int threespd = 0;
				int fourspd = 0;
				int fivespd = 0;
				int oneint = 0;
				int twoint = 0;
				int threeint = 0;
				int fourint = 0;
				int fiveint = 0;
				int onecon = 0;
				int twocon = 0;
				int threecon = 0;
				int fourcon = 0;
				int fivecon = 0;
					
				onestr = ch->perm_str * 0.10; 
				twostr = ch->perm_str * 0.15;
				threestr = ch->perm_str * 0.20;
				fourstr = ch->perm_str * 0.50;
				fivestr = ch->perm_str;
				onespd = ch->perm_dex * 0.10;
				twospd = ch->perm_dex * 0.15;
				threespd = ch->perm_dex * 0.20;
				fourspd = ch->perm_dex * 0.50;
				fivespd = ch->perm_dex;
				oneint = ch->perm_int * 0.10;
				twoint = ch->perm_int * 0.10;
				threeint = ch->perm_int * 0.15;
				fourint = ch->perm_int * 0.25;
				fiveint = ch->perm_int;
				onecon = ch->perm_con * 0.15;
				twocon = ch->perm_con * 0.20;
				threecon = ch->perm_con * 0.30;
				fourcon = ch->perm_con * 0.75;
				fivecon = ch->perm_con * 1.50;
				if (!xIS_SET((ch)->affected_by, AFF_ICER2)
					&& !xIS_SET((ch)->affected_by, AFF_ICER3)
					&& !xIS_SET((ch)->affected_by, AFF_ICER4)
					&& !xIS_SET((ch)->affected_by, AFF_ICER5)
					&& !xIS_SET((ch)->affected_by, AFF_GOLDENFORM)) {
					safemaximum = ((get_curr_int(ch) * 0.03) + 1);
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.15;
						ch->powerup += 1;
						transStatApply(ch, powerupstr, powerupspd, powerupint, powerupcon);
						if (plmod >= 2) {
							xSET_BIT((ch)->affected_by, AFF_ICER2);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_PURPLE, "Your entire body expands monstrously in size, wicked horns sprouting from your head!", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n's entire body expands monstrously in size, wicked horns sprouting from $s head!", ch, NULL, NULL, TO_NOTVICT );
							ch->powerup = 0;
							ch->pl = ch->exp * 4;
							transStatApply(ch, onestr, onespd, oneint, onecon);
						}
						if (plmod > 1 && plmod < 2) {
							act( auraColor, "You glow brightly, hairline fractures appearing across your body.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n glows brightly, hairline fractures appearing across $s body.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( auraColor, "The tiny fractures in your body seal as you stop powering up. Going any further would be dangerous.", ch, NULL, NULL, TO_CHAR );
						act( auraColor, "$n reaches $s limit and stops powering up, the tiny fractures in $s body closing.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_ICER2)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.15;
						ch->powerup += 1;
						if (plmod > 4.8) {
							act( AT_PURPLE, "Your giant body glows brilliantly, debris scattering in all directions.", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n's giant body glows brilliantly, debris flying past you.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 8) {
							xREMOVE_BIT((ch)->affected_by, AFF_ICER2);
							xSET_BIT((ch)->affected_by, AFF_ICER3);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_PURPLE, "You double forward, chitinous chunks stripping away.", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "Spikes protrude from your back and shoulders as your head elongates, transforming you into a deformed monstrosity!", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n doubles forward, chitinous chunks stripping away from $m as $e transforms into a deformed monstrosity!", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 12;
							transStatApply(ch, twostr, twospd, twoint, twocon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_PURPLE, "You relax, your prehensile tail coiling nonchalantly behind you.", ch, NULL, NULL, TO_CHAR );
						act( AT_PURPLE, "$n relaxes, his tail coiling nonchalantly behind $m.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_ICER3)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.15;
						ch->powerup += 1;
						if (plmod > 14) {
							act( AT_PURPLE, "Your chitinous body creaks ominously beneath your raging aura.", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n's chitinous body creaks ominously beneath $s raging aura.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 30) {
							xREMOVE_BIT((ch)->affected_by, AFF_ICER3);
							xSET_BIT((ch)->affected_by, AFF_ICER4);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_PURPLE, "In an explosion of ki your body fades away, emerging from the dust in a new form!", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "Your body shrinks to normal size, wicked spikes replaced with smooth skin and patches as reflective as glass.", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n emerges from an explosion of ki, $s body shrinking into a sleek, smooth form.", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 50;
							transStatApply(ch, threestr, threespd, threeint, threecon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_PURPLE, "You hunch forward, unable to increase your power any further.", ch, NULL, NULL, TO_CHAR );
						act( AT_PURPLE, "$n hunches forward, unable to increase $s power further.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_ICER4)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 52) {
							act( AT_PURPLE, "Your arms extend at your sides, a vicious purple aura courses around you.", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n extends $s arms to the side, a vicious purple aura coursing around $m.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 100) {
							xREMOVE_BIT((ch)->affected_by, AFF_ICER4);
							xSET_BIT((ch)->affected_by, AFF_ICER5);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_PURPLE, "Your muscles expand massively in size, swelling with incredible energy!", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n's muscles expand massively in size, swelling with incredible energy!", ch, NULL, NULL, TO_NOTVICT );
							ch->pl = ch->exp * 150;
							transStatApply(ch, fourstr, fourspd, fourint, fourcon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_PURPLE, "Chunks of landscape fall back into place as you stop powering up.", ch, NULL, NULL, TO_CHAR );
						act( AT_PURPLE, "Chunks of landscape fall back into place as $n stops powering up.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_ICER5)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.03;
						ch->powerup += 1;
						if (plmod > 156) {
							act( AT_PURPLE, "Your vicious aura rages uncontrolled, devastating the landscape.", ch, NULL, NULL, TO_CHAR );
							act( AT_PURPLE, "$n's vicious aura rages out of control, devastating the landscape.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 275) {
							xREMOVE_BIT((ch)->affected_by, AFF_ICER5);
							xSET_BIT((ch)->affected_by, AFF_GOLDENFORM);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act(AT_YELLOW, "A brilliant golden light overtakes you, traveling up the length of your body.", ch, NULL, NULL, TO_CHAR);
							act(AT_YELLOW, "Your skin takes on a reflective golden sheen as you ascend into the realm of God Ki.", ch, NULL, NULL, TO_CHAR);
							act(AT_YELLOW, "A brilliant golden light overtakes $n, traveling up the length of $s body.", ch, NULL, NULL, TO_NOTVICT);
							act(AT_YELLOW, "$s skin takes on a reflective golden sheen as $e ascends into the realm of God Ki!", ch, NULL, NULL, TO_NOTVICT);
							ch->pl = ch->exp * 380;
							transStatApply(ch, fivestr, fivespd, fiveint, fivecon);
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "You try to relax, but your bulging muscles ignore the command.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n tries to relax, but $s bulging muscles ignore the command.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_GOLDENFORM)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						if (plmod >= 600) {
							ch->pl *= 1.03;
						}
						else {
							ch->pl *= 1.04;
						}
						ch->powerup += 1;
						if (plmod > 395) {
							act( AT_YELLOW, "The air roils, an intense pressure building from your glorious golden sheen.", ch, NULL, NULL, TO_CHAR );
							act( AT_YELLOW, "The air roils, an intense pressure building from $n's glorious golden sheen.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_YELLOW, "Your massive golden aura recedes into your body, leaving only a lustrous glow.", ch, NULL, NULL, TO_CHAR );
						act( AT_YELLOW, "$n's massive golden aura recedes into $s body, leaving only a lustrous glow.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
			}
			if (is_kaio(ch) || is_human(ch)) {
				int onestr = 0; 
				int twostr = 0;
				int threestr = 0;
				int fourstr = 0;
				int fivestr = 0;
				int sixstr = 0;
				int sevenstr = 0;
				int onespd = 0;
				int twospd = 0;
				int threespd = 0;
				int fourspd = 0;
				int fivespd = 0;
				int sixspd = 0;
				int sevenspd = 0;
				int oneint = 0;
				int twoint = 0;
				int threeint = 0;
				int fourint = 0;
				int fiveint = 0;
				int sixint = 0;
				int sevenint = 0;
				int onecon = 0;
				int twocon = 0;
				int threecon = 0;
				int fourcon = 0;
				int fivecon = 0;
				int sixcon = 0;
				int sevencon = 0;
					
				onestr = ch->perm_str * 0.10; 
				twostr = ch->perm_str * 0.15;
				threestr = ch->perm_str * 0.15;
				fourstr = ch->perm_str * 0.30;
				fivestr = ch->perm_str * 0.60;
				sixstr = ch->perm_str;
				sevenstr = ch->perm_str * 1.20;
				onespd = ch->perm_dex * 0.10;
				twospd = ch->perm_dex * 0.15;
				threespd = ch->perm_dex * 0.15;
				fourspd = ch->perm_dex * 0.30;
				fivespd = ch->perm_dex * 0.70;
				sixspd = ch->perm_dex;
				sevenspd = ch->perm_dex * 1.20;
				oneint = ch->perm_int * 0.15;
				twoint = ch->perm_int * 0.20;
				threeint = ch->perm_int * 0.20;
				fourint = ch->perm_int * 0.40;
				fiveint = ch->perm_int * 0.70;
				sixint = ch->perm_int * 1.10;
				sevenint = ch->perm_int * 1.30;
				onecon = ch->perm_con * 0.15;
				twocon = ch->perm_con * 0.20;
				threecon = ch->perm_con * 0.20;
				fourcon = ch->perm_con * 0.40;
				fivecon = ch->perm_con * 0.60;
				sixcon = ch->perm_con;
				sevencon = ch->perm_con * 1.25;
				if (!xIS_SET((ch)->affected_by, AFF_MYSTIC)) {
					int mysticTotal = 0;
					
					mysticTotal = ((ch->perm_str + ch->perm_dex) + (ch->perm_int * 2) + (ch->perm_con * 3));
					safemaximum = ((get_curr_int(ch) * 0.03) + 1);
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.15;
						ch->powerup += 1;
						transStatApply(ch, powerupstr, powerupspd, powerupint, powerupcon);
						if (plmod >= 30
							&& mysticTotal >= 4000) {
							xSET_BIT((ch)->affected_by, AFF_MYSTIC);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( auraColor, "You cry out as your aura expands, pushing beyond your latent potential!", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n cries out, $s inner potential exploding to the surface!", ch, NULL, NULL, TO_NOTVICT );
							ch->powerup = 0;
							ch->pl = ch->exp * 35;
							transStatApply(ch, onestr, onespd, oneint, onecon);
						}
						if (plmod >= 30 && mysticTotal < 4000) {
							ch->pl = (ch->exp * 30);
							act( auraColor, "Having reached your limit, you stop powering up. Going any further would be dangerous.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n reaches $s limit and stops powering up.", ch, NULL, NULL, TO_NOTVICT );
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							ch->powerup = safemaximum;
							xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						}
						if (plmod >= 20 && plmod < 27) {
							act( auraColor, "Your body is barely visible amidst your vortex of ki.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's body is barely visible amidst $s vortex of ki!", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 15 && plmod < 20) {
							act( auraColor, "Your aura spirals upward, nearly licking the clouds.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura spirals upward, nearly licking the clouds.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 10 && plmod < 15) {
							act( auraColor, "Your gentle aura explodes into a display of roaring ki.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's gentle aura explodes into a display of roaring ki.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 5 && plmod < 10) {
							act( auraColor, "Your aura flickers around you, only faintly visible.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura flickers around $m, only faintly visible.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod > 1 && plmod < 5) {
							act( auraColor, "Your body glows faintly.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's body glows faintly.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( auraColor, "Having reached your limit, you stop powering up. Going any further would be dangerous.", ch, NULL, NULL, TO_CHAR );
						act( auraColor, "$n reaches $s limit and stops powering up.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_MYSTIC)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						if (plmod < 600) {
							ch->pl *= 1.05;
						}
						else if (plmod >= 600) {
							ch->pl *= 1.03;
						}
						ch->powerup += 1;
						if (plmod > 600) {
							act( auraColor, "Radiant light suffuses your entire body, cloaking you entirely.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "Radiant light suffuses $n's entire body, cloaking $m completely.", ch, NULL, NULL, TO_NOTVICT );
						}
						else if (plmod > 500) {
							act( auraColor, "Pulses of God Ki emanate deep from within your core!", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "Pulses of God Ki emanate deep from within $n's core!", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, sevenstr, sevenspd, sevenint, sevencon);
						}
						else if (plmod > 350) {
							act( auraColor, "Your aura churns violently, a mysterious ki building deep within.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura engulfs $m, churning violently while a mysterious ki seeps from within.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, sixstr, sixspd, sixint, sixcon);
						}
						else if (plmod > 250) {
							act( auraColor, "Bolts of pure white energy crackle through your body, striking random locations.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "Bolts of pure white energy crackle through $n's body, striking random locations.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, fivestr, fivespd, fiveint, fivecon);
						}
						else if (plmod > 150) {
							act( auraColor, "Your muscles swell with energy, containing power without growing in size.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's muscles swell with energy, containing power without growing in size.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, fourstr, fourspd, fourint, fourcon);
						}
						else if (plmod > 75) {
							act( auraColor, "Your aura swells to twice its normal size but quickly dies back down.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura swells to twice its normal size but quickly dies back down.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, threestr, threespd, threeint, threecon);
						}
						else if (plmod > 50) {
							act( auraColor, "Massive chunks of rock and debris crumble beneath your aura.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "Massive chunks of rock and debris crumble beneath $n's aura.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, twostr, twospd, twoint, twocon);
						}
						else if (plmod > 37) {
							act( auraColor, "Dust and debris swirl ominously around you.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "Dust and debris swirl ominously around $n.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( auraColor, "You reach your limit, tiny bolts of energy dancing between your fingertips.", ch, NULL, NULL, TO_CHAR );
						act( auraColor, "$n reaches the limits of $s potential, tiny bolts of energy dancing between $s fingertips.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
			}
			if (is_namek(ch)) {
				int onestr = 0; 
				int twostr = 0;
				int threestr = 0;
				int fourstr = 0;
				int fivestr = 0;
				int sixstr = 0;
				int sevenstr = 0;
				int onespd = 0;
				int twospd = 0;
				int threespd = 0;
				int fourspd = 0;
				int fivespd = 0;
				int sixspd = 0;
				int sevenspd = 0;
				int oneint = 0;
				int twoint = 0;
				int threeint = 0;
				int fourint = 0;
				int fiveint = 0;
				int sixint = 0;
				int sevenint = 0;
				int onecon = 0;
				int twocon = 0;
				int threecon = 0;
				int fourcon = 0;
				int fivecon = 0;
				int sixcon = 0;
				int sevencon = 0;
					
				onestr = ch->perm_str * 0.10; 
				twostr = ch->perm_str * 0.15;
				threestr = ch->perm_str * 0.20;
				fourstr = ch->perm_str * 0.30;
				fivestr = ch->perm_str * 0.50;
				sixstr = ch->perm_str * 0.60;
				sevenstr = ch->perm_str * 0.75;
				onespd = ch->perm_dex * 0.10;
				twospd = ch->perm_dex * 0.15;
				threespd = ch->perm_dex * 0.25;
				fourspd = ch->perm_dex * 0.35;
				fivespd = ch->perm_dex * 0.60;
				sixspd = ch->perm_dex * 0.80;
				sevenspd = ch->perm_dex;
				oneint = ch->perm_int * 0.15;
				twoint = ch->perm_int * 0.25;
				threeint = ch->perm_int * 0.50;
				fourint = ch->perm_int * 0.75;
				fiveint = ch->perm_int;
				sixint = ch->perm_int * 1.25;
				sevenint = ch->perm_int * 1.75;
				onecon = ch->perm_con * 0.15;
				twocon = ch->perm_con * 0.15;
				threecon = ch->perm_con * 0.25;
				fourcon = ch->perm_con * 0.35;
				fivecon = ch->perm_con * 0.60;
				sixcon = ch->perm_con * 0.80;
				sevencon = ch->perm_con * 1.10;
				if (!xIS_SET((ch)->affected_by, AFF_SNAMEK)) {
					int namekTotal = 0;
					
					namekTotal = ((ch->perm_str + ch->perm_dex) + (ch->perm_int * 3) + (ch->perm_con * 2));
					safemaximum = ((get_curr_int(ch) * 0.03) + 1);
					if (ch->powerup < safemaximum) {
						ch->pl *= 1.15;
						ch->powerup += 1;
						transStatApply(ch, powerupstr, powerupspd, powerupint, powerupcon);
						if (plmod >= 40
							&& namekTotal >= 5000) {
							xSET_BIT((ch)->affected_by, AFF_SNAMEK);
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							act( AT_WHITE, "Your mind opens to the secrets of the ancient Namekians, flooding you with incredible power.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "$n's mind opens to the secrets of the ancient Namekians, flooding $m with incredible power.'", ch, NULL, NULL, TO_NOTVICT );
							ch->powerup = 0;
							ch->pl = ch->exp * 50;
							transStatApply(ch, onestr, onespd, oneint, onecon);
						}
						if (plmod >= 40
							&& namekTotal < 4000) {
							ch->pl = (ch->exp * 40);
							act( auraColor, "You stop abruptly, unable to concentrate any further.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n stops abruptly, unable to concentrate any further.", ch, NULL, NULL, TO_NOTVICT );
							xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
							ch->powerup = safemaximum;
							xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						}
						if (plmod >= 20 && plmod < 27) {
							act( auraColor, "Your body is barely visible amidst your vortex of ki.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's body is barely visible amidst $s vortex of ki!", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 15 && plmod < 20) {
							act( auraColor, "Your aura spirals upward, nearly licking the clouds.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura spirals upward, nearly licking the clouds.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 10 && plmod < 15) {
							act( auraColor, "Your gentle aura explodes into a display of roaring ki.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's gentle aura explodes into a display of roaring ki.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod >= 5 && plmod < 10) {
							act( auraColor, "Your aura flickers around you, only faintly visible.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's aura flickers around $m, only faintly visible.", ch, NULL, NULL, TO_NOTVICT );
						}
						if (plmod > 1 && plmod < 5) {
							act( auraColor, "Your body glows faintly.", ch, NULL, NULL, TO_CHAR );
							act( auraColor, "$n's body glows faintly.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( auraColor, "Having reached your limit, you stop powering up. Going any further would be dangerous.", ch, NULL, NULL, TO_CHAR );
						act( auraColor, "$n reaches $s limit and stops powering up.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
				if (xIS_SET((ch)->affected_by, AFF_SNAMEK)) {
					safemaximum = form_mastery;
					if (ch->powerup < safemaximum) {
						if (plmod >= 600) {
							ch->pl *= 1.03;
						}
						else if (plmod >= 400) {
							ch->pl *= 1.02;
						}
						else if (plmod < 400) {
							ch->pl *= 1.06;
						}
						ch->powerup += 1;
						if (plmod > 600) {
							act( AT_WHITE, "Vague images of your ancestors flash before you, conjured by your brilliant divine aura.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "Vague images of $n's ancestors flash randomly within $s blinding God Ki.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, sevenstr, sevenspd, sevenint, sevencon);
						}
						else if (plmod > 500) {
							act( AT_WHITE, "A burst of God Ki erupts from deep within your body.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "A burst of God Ki erupts from deep within $n's body.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, sixstr, sixspd, sixint, sixcon);
						}
						else if (plmod > 350) {
							act( AT_WHITE, "The heavens shake and the earth trembles at your feet.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "The heavens shake and the earth trembles at $n's feet.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, fivestr, fivespd, fiveint, fivecon);
						}
						else if (plmod > 250) {
							act( AT_WHITE, "Bolts of energy crackle through your blinding aura.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "Bolts of energy crackle through $n's blinding aura.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, fourstr, fourspd, fourint, fourcon);
						}
						else if (plmod > 150) {
							act( AT_WHITE, "Your aura swirls, constant beams of light radiating from within.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "$n's aura swirls with constant beams of echoing light.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, threestr, threespd, threeint, threecon);
						}
						else if (plmod > 75) {
							act( AT_WHITE, "Blinding flashes escape your body, echoing through the air.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "Blinding flashes escape $n's body, echoing through the air.", ch, NULL, NULL, TO_NOTVICT );
							transStatApply(ch, twostr, twospd, twoint, twocon);
						}
						else if (plmod > 50) {
							act( AT_WHITE, "Brilliant white light shrouds the contours of your body.", ch, NULL, NULL, TO_CHAR );
							act( AT_WHITE, "Brilliant white light shrouds the contours of $n's body.", ch, NULL, NULL, TO_NOTVICT );
						}
					}
					if (ch->powerup >= safemaximum) {
						ch->powerup = safemaximum;
						xREMOVE_BIT((ch)->affected_by, AFF_POWERCHANNEL);
						xSET_BIT((ch)->affected_by, AFF_SAFEMAX);
						act( AT_WHITE, "Having reached your limits, your ancestors can afford you no more power.", ch, NULL, NULL, TO_CHAR );
						act( AT_WHITE, "Having reached $s limits, $n takes a deep breath and stops channeling his ancestors' wisdom.", ch, NULL, NULL, TO_NOTVICT );
					}
				}
			}
			if (!is_saiyan(ch) && !is_hb(ch)
				&& !is_icer(ch) && !is_namek(ch)
				&& !is_human(ch) && !is_kaio(ch)) {
				send_to_char("DEBUG: You should only be testing the non-locked races.\n\r", ch);
			}
		}
		if (xIS_SET((ch)->affected_by, AFF_OVERCHANNEL)
			&& !xIS_SET((ch)->affected_by, AFF_KAIOKEN)
			&& xIS_SET((ch)->affected_by, AFF_SAFEMAX)) {
			double safemaximum = 0;
			int danger = 0;
			int form_mastery = 0;
			
			if (ch->position < POS_STANDING && ch->position > POS_DEAD) {
				xREMOVE_BIT((ch)->affected_by, AFF_OVERCHANNEL);
				send_to_char("You must stand if you wish to power up.\n\r", ch);
			}
			form_mastery = (ch->train / 45000);
			if (xIS_SET((ch)->affected_by, AFF_SSJ)
				|| xIS_SET((ch)->affected_by, AFF_SSJ2)
				|| xIS_SET((ch)->affected_by, AFF_SSJ3)
				|| xIS_SET((ch)->affected_by, AFF_SSJ4)
				|| xIS_SET((ch)->affected_by, AFF_SGOD)
				|| xIS_SET((ch)->affected_by, AFF_HYPER)
				|| xIS_SET((ch)->affected_by, AFF_SNAMEK)
				|| xIS_SET((ch)->affected_by, AFF_ICER2)
				|| xIS_SET((ch)->affected_by, AFF_ICER3)
				|| xIS_SET((ch)->affected_by, AFF_ICER4)
				|| xIS_SET((ch)->affected_by, AFF_ICER5)
				|| xIS_SET((ch)->affected_by, AFF_GOLDENFORM)
				|| xIS_SET((ch)->affected_by, AFF_SEMIPERFECT)
				|| xIS_SET((ch)->affected_by, AFF_PERFECT)
				|| xIS_SET((ch)->affected_by, AFF_ULTRAPERFECT)
				|| xIS_SET((ch)->affected_by, AFF_OOZARU)
				|| xIS_SET((ch)->affected_by, AFF_GOLDEN_OOZARU)
				|| xIS_SET((ch)->affected_by, AFF_EXTREME)
				|| xIS_SET((ch)->affected_by, AFF_MYSTIC)
				|| xIS_SET((ch)->affected_by, AFF_SUPERANDROID)
				|| xIS_SET((ch)->affected_by, AFF_MAKEOSTAR)
				|| xIS_SET((ch)->affected_by, AFF_EVILBOOST)
				|| xIS_SET((ch)->affected_by, AFF_EVILSURGE)
				|| xIS_SET((ch)->affected_by, AFF_EVILOVERLOAD)) {
				safemaximum = form_mastery;
				if (form_mastery < 1)
					form_mastery = 1;
				danger = ((ch->powerup - safemaximum) * (ch->powerup * 100));
				/* Just in case. */
				if (danger < 1) {
					danger = 1;
				}
				ch->pl *= 1.01;
				ch->powerup += 1;
				if ((ch->mana - danger) < 0)
					ch->mana = 0;
				else {
					ch->mana -= danger;
				}
				
				if (danger != 0 && ch->mana == 0) {
					ch->hit -= (danger / 10);
					act( AT_RED, "Your body is ripping itself apart!", ch, NULL, NULL, TO_CHAR );
					act( AT_RED, "$n's body is ripping itself apart!'", ch, NULL, NULL, TO_NOTVICT );
					if (ch->hit - (danger / 10) < 0) {
						ch->hit -= (danger / 10);
						update_pos(ch);
						if ( ch->position == POS_DEAD) {
							act( AT_RED, "Your body gives out under the intense strain. All must succumb to their limits in the end.", ch, NULL, NULL, TO_CHAR );
							act( AT_RED, "$n collapses, DEAD, $s body completely spent.", ch, NULL, NULL, TO_NOTVICT );
							sprintf( buf, "%s withers away, succumbing to their limits", ch->name );
							do_info(ch, buf);
							raw_kill(ch, ch);
						}
					}
				}
				else {
					act( AT_YELLOW, "You struggle against the will of your own body, increasing your power at incredible risk.", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n struggles against the will of $s own body, increasing $s power at incredible risk.", ch, NULL, NULL, TO_NOTVICT );
				}
			}
			else {
				safemaximum = ((get_curr_int(ch) * 0.03) + 1);
				danger = ((ch->powerup - safemaximum) * (ch->powerup * 100));
				/* Just in case. */
				if (danger < 1) {
					danger = 1;
				}
				ch->pl *= 1.01;
				ch->powerup += 1;
				if ((ch->mana - danger) < 0)
					ch->mana = 0;
					
				else
					ch->mana -= danger;
				
				if (danger != 0 && ch->mana == 0) {
					ch->hit -= (danger / 10);
					act( AT_RED, "Your body is ripping itself apart!", ch, NULL, NULL, TO_CHAR );
					act( AT_RED, "$n's body is ripping itself apart!'", ch, NULL, NULL, TO_NOTVICT );
					if (ch->hit - (danger / 10) < 0) {
						ch->hit -= (danger / 10);
						update_pos(ch);
						if (ch->position == POS_DEAD) {
							act( AT_RED, "Your body gives out under the intense strain. All must succumb to their limits in the end.", ch, NULL, NULL, TO_CHAR );
							act( AT_RED, "$n collapses, DEAD, $s body completely spent.", ch, NULL, NULL, TO_NOTVICT );
							sprintf( buf, "%s withers away, succumbing to their limits", ch->name );
							do_info(ch, buf);
							raw_kill(ch, ch);
						}
					}
				}
				else {
					act( AT_YELLOW, "You struggle against the will of your own body, increasing your power at incredible risk.", ch, NULL, NULL, TO_CHAR );
					act( AT_YELLOW, "$n struggles against the will of $s own body, increasing $s power at incredible risk.", ch, NULL, NULL, TO_NOTVICT );
				}
			}
		}
		/* New Gravity Training */
		if (xIS_SET((ch)->affected_by, AFF_PUSHUPS) && !xIS_SET((ch)->in_room->room_flags, ROOM_GRAV)) {
			


@@ 2718,7 4316,7 @@ damage(CHAR_DATA * ch, CHAR_DATA * victim, int dam, int dt)

	if (!is_android_h(victim))
		victim->mana -=
		    URANGE(0, ((double)dam / 100 * 0.5 * victim->mana),
		    URANGE(0, ((double)dam / 1000 * 0.25 * victim->mana),
		    victim->max_mana);

	heart_calc(victim, "");

M src/handler.c => src/handler.c +43 -3
@@ 941,6 941,8 @@ update_aris(CHAR_DATA * ch)
	int 	aff_w, aff_x, aff_y, aff_z, aff_aa;
	int 	aff_ab, aff_ac, aff_ad, aff_ae, aff_af, aff_ag, aff_ah;
	int 	aff_ai, aff_aj, aff_ak, aff_al, aff_am, aff_an;
	int		aff_ao, aff_ap, aff_aq, aff_ar, aff_as, aff_at, aff_au;
	int		aff_av;

	if (IS_NPC(ch) || IS_IMMORTAL(ch))
		return;


@@ 989,6 991,14 @@ update_aris(CHAR_DATA * ch)
	aff_al = IS_AFFECTED(ch, AFF_SANCTUARY);
	aff_am = IS_AFFECTED(ch, AFF_GOLDEN_OOZARU);
	aff_an = IS_AFFECTED(ch, AFF_SGOD);
	aff_ao = IS_AFFECTED(ch, AFF_PUSHUPS);
	aff_ap = IS_AFFECTED(ch, AFF_SHADOWBOXING);
	aff_aq = IS_AFFECTED(ch, AFF_ENDURING);
	aff_ar = IS_AFFECTED(ch, AFF_MEDITATION);
	aff_as = IS_AFFECTED(ch, AFF_POWERCHANNEL);
	aff_at = IS_AFFECTED(ch, AFF_OVERCHANNEL);
	aff_au = IS_AFFECTED(ch, AFF_SAFEMAX);
	aff_av = IS_AFFECTED(ch, AFF_GOLDENFORM);

	xCLEAR_BITS(ch->affected_by);
	ch->resistant = 0;


@@ 1063,8 1073,6 @@ update_aris(CHAR_DATA * ch)
		xSET_BIT(ch->affected_by, AFF_SSJ3);
	if (aff_e)
		xSET_BIT(ch->affected_by, AFF_SSJ4);
	if (aff_an)
		xSET_BIT(ch->affected_by, AFF_SGOD);
	if (aff_f)
		xSET_BIT(ch->affected_by, AFF_SNAMEK);
	if (aff_g)


@@ 1133,6 1141,24 @@ update_aris(CHAR_DATA * ch)
		xSET_BIT(ch->affected_by, AFF_SANCTUARY);
	if (aff_am)
		xSET_BIT(ch->affected_by, AFF_GOLDEN_OOZARU);
	if (aff_an)
		xSET_BIT(ch->affected_by, AFF_SGOD);
	if (aff_ao)
		xSET_BIT(ch->affected_by, AFF_PUSHUPS);
	if (aff_ap)
		xSET_BIT(ch->affected_by, AFF_SHADOWBOXING);
	if (aff_aq)
		xSET_BIT(ch->affected_by, AFF_ENDURING);
	if (aff_ar)
		xSET_BIT(ch->affected_by, AFF_MEDITATION);
	if (aff_as)
		xSET_BIT(ch->affected_by, AFF_POWERCHANNEL);
	if (aff_at)
		xSET_BIT(ch->affected_by, AFF_OVERCHANNEL);
	if (aff_au)
		xSET_BIT(ch->affected_by, AFF_SAFEMAX);
	if (aff_av)
		xSET_BIT(ch->affected_by, AFF_GOLDENFORM);
	return;
}



@@ 1980,7 2006,7 @@ extract_char(CHAR_DATA * ch, bool fPull, bool death)
			bug("Extract_char: char's descriptor points to another char", 0);
		else {
			log_string("preparing to close socket at handler.c:1983\n");
			close_socket(ch->desc, false, false);
			close_socket(ch->desc, false);
		}
	}
}


@@ 3213,6 3239,20 @@ affect_bit_name(EXT_BV * vector)
	buf[0] = '\0';
	if (xIS_SET(*vector, AFF_BLIND))
		strcat(buf, " blind");
	if (xIS_SET(*vector, AFF_PUSHUPS))
		strcat(buf, " pushups");
	if (xIS_SET(*vector, AFF_SHADOWBOXING))
		strcat(buf, " shadowboxing");
	if (xIS_SET(*vector, AFF_ENDURING))
		strcat(buf, " enduring");
	if (xIS_SET(*vector, AFF_MEDITATION))
		strcat(buf, " meditation");
	if (xIS_SET(*vector, AFF_POWERCHANNEL))
		strcat(buf, " powerchannel");
	if (xIS_SET(*vector, AFF_SAFEMAX))
		strcat(buf, " safemax");
	if (xIS_SET(*vector, AFF_OVERCHANNEL))
		strcat(buf, " overchannel");
	if (xIS_SET(*vector, AFF_INVISIBLE))
		strcat(buf, " invisible");
	if (xIS_SET(*vector, AFF_DETECT_EVIL))

M src/mud.h => src/mud.h +9 -7
@@ 1729,8 1729,7 @@ typedef enum {
	AFF_NO_GLOBAL_DROP, AFF_MAKEOSTAR, AFF_EVILBOOST, AFF_EVILSURGE,
	AFF_EVILOVERLOAD, AFF_BIOJR, AFF_GOLDEN_OOZARU,
	AFF_PUSHUPS, AFF_SHADOWBOXING, AFF_ENDURING, AFF_MEDITATION,

	MAX_AFFECTED_BY
	AFF_POWERCHANNEL, AFF_OVERCHANNEL, AFF_SAFEMAX, MAX_AFFECTED_BY
} 	affected_by_types;

/*


@@ 2654,9 2653,9 @@ struct char_data {
	sh_int 	max_move;
	sh_int 	practice;
	sh_int 	max_prac;
	sh_int 	powerup;
	sh_int 	train;
	sh_int 	max_train;
	int 	powerup;
	int 	train;
	int 	max_train;
	sh_int 	numattacks;
	int 	gold;
	long double exp;


@@ 2690,7 2689,7 @@ struct char_data {
	sh_int 	mobthac0;
	sh_int 	hitroll;
	sh_int 	damroll;
	sh_int 	hitplus;
	int 	hitplus;
	sh_int 	damplus;
	sh_int 	position;
	sh_int 	defposition;


@@ 2814,6 2813,8 @@ struct pc_data {
	COUNCIL_DATA *council;
	AREA_DATA *area;
	DEITY_DATA *deity;
	int i_idle;
	int p_idle[5];
	char   *homepage;
	char   *clan_name;
	char   *council_name;


@@ 5417,7 5418,8 @@ args((const char *argument, int channel,
/* comm.c */
/* logging */
	void 	logmsg(int, const char *,...);
	void 	close_socket(DESCRIPTOR_DATA * dclose, bool force, bool clear);

	void close_socket args((DESCRIPTOR_DATA *dclose, bool force));
	void write_to_buffer args((DESCRIPTOR_DATA * d, const char *txt,
		int 	length));
	void send_to_char args((const char *txt, CHAR_DATA * ch));

M src/player.c => src/player.c +10 -2
@@ 411,6 411,12 @@ do_score(CHAR_DATA * ch, char *argument)
	pager_printf_color(ch, "ZENI : &Y%-13s&C           AutoSac: (&W%c&C)\n\r",
	    num_punct(ch->gold), xIS_SET(ch->act, PLR_AUTOSAC) ? 'X' : ' ');

	int form_mastery = (ch->train / 45000);

	if(form_mastery < 1) {
	  form_mastery = 1;
	}
	
	if (is_android(ch) || is_superandroid(ch)) {
		pager_printf(ch, "BASE TECHLEVEL: %-16s\n\r", num_punct_ld(ch->exp));



@@ 420,11 426,13 @@ do_score(CHAR_DATA * ch, char *argument)
			pager_printf(ch, "CURR TECHLEVEL: %-16s\n\r", num_punct_ld(ch->pl));
	} else {
		pager_printf(ch, "BASE POWERLEVEL: %-16s\n\r", num_punct_ld(ch->exp));

		
		if (ch->pl != ch->exp) {
			pager_printf(ch, "&YCURR POWERLEVEL: %-16s&C\n\r", num_punct_ld(ch->pl));
		} else
		} else {
			pager_printf(ch, "CURR POWERLEVEL: %-16s\n\r", num_punct_ld(ch->pl));
		}
		pager_printf_color(ch, "&GFORM MASTERY: &Y%-3d\n\r", form_mastery);
	}
	long double pltrack = 0;


M src/save.c => src/save.c +7 -0
@@ 957,6 957,13 @@ load_char_obj (DESCRIPTOR_DATA * d, char *name, bool preload)
     ch->pcdata->absorb_sn = 0;
     ch->pcdata->absorb_learn = 0;

    ch->pcdata->p_idle[0] = 0;
    ch->pcdata->p_idle[1] = 0;
    ch->pcdata->p_idle[2] = 0;
    ch->pcdata->p_idle[3] = 0;
    ch->pcdata->p_idle[4] = 0;
    ch->pcdata->i_idle = 0;

     ch->pcdata->tStr = 0;
     ch->pcdata->tInt = 0;
     ch->pcdata->tSpd = 0;

M src/skills_dbs.c => src/skills_dbs.c +225 -531
@@ 463,16 463,10 @@ rage(CHAR_DATA * ch, CHAR_DATA * victim)
		if (ch->rage < 500)
			return;
			
		if (get_curr_str(ch) < 500 )
			return;
			
		if (get_curr_dex(ch) < 100 )
			return;
		int saiyanTotal = 0;
		saiyanTotal = ((ch->perm_str * 2) + (ch->perm_dex * 2) + (ch->perm_int) + (ch->perm_con * 2));
			
		if (get_curr_int(ch) < 500 )
			return;
			
		if (get_curr_con(ch) < 500 )
		if (saiyanTotal < 4000)
			return;
			



@@ 708,19 702,7 @@ rage2(CHAR_DATA * ch, CHAR_DATA * victim)
		if (ch->rage < 800)
			return;
			
		if (get_curr_str(ch) < 1000 )
			return;
			
		if (get_curr_dex(ch) < 500 )
			return;
			
		if (get_curr_int(ch) < 1000 )
			return;
			
		if (get_curr_con(ch) < 1000 )
			return;

		if (ch->pcdata->learned[gsn_ssj2] > 0)
		if (ch->train < 1305000)
			return;

		switch (number_range(1, 5)) {


@@ 941,16 923,7 @@ rage3(CHAR_DATA * ch, CHAR_DATA * victim)
		if (ch->rage < 1000)
			return;
			
		if (get_curr_str(ch) < 2000 )
			return;
			
		if (get_curr_dex(ch) < 1000 )
			return;
			
		if (get_curr_int(ch) < 2000 )
			return;
			
		if (get_curr_con(ch) < 2000 )
		if (ch->train < 1755000)
			return;

		if (ch->pcdata->learned[gsn_ssj3] > 0)


@@ 1125,22 1098,13 @@ rage4(CHAR_DATA * ch, CHAR_DATA * victim)
		return;
		
	if (ch->delay <= 0) {
		if (!is_saiyan(ch))
		if (!is_saiyan(ch) && !is_hb(ch))
			return;

		if (ch->rage < 1500)
			return;
			
		if (get_curr_str(ch) < 4000 )
			return;
			
		if (get_curr_dex(ch) < 2000 )
			return;
			
		if (get_curr_int(ch) < 4000 )
			return;
			
		if (get_curr_con(ch) < 4000 )
		if (ch->train < 2340000)
			return;

		if (ch->pcdata->learned[gsn_ssj4] > 0)


@@ 1201,11 1165,11 @@ rage4(CHAR_DATA * ch, CHAR_DATA * victim)
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_CHAR);
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_VICT);
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_NOTVICT);
		act(AT_RED, "Red fur begins to sprout all over your body.", ch,
		act(AT_RED, "Your eyes flash red momentarily.", ch,
		    NULL, victim, TO_CHAR);
		act(AT_RED, "Red fur begins to sprout all over $n's body.", ch,
		act(AT_RED, "$n's eyes flash red.", ch,
		    NULL, victim, TO_VICT);
		act(AT_RED, "Red fur begins to sprout all over $n's body.", ch,
		act(AT_RED, "$n's eyes flash red.", ch,
		    NULL, victim, TO_NOTVICT);
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_CHAR);
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_VICT);


@@ 1218,11 1182,11 @@ rage4(CHAR_DATA * ch, CHAR_DATA * victim)
		act(AT_RED, "=-", ch, NULL, victim, TO_CHAR);
		act(AT_RED, "=-", ch, NULL, victim, TO_VICT);
		act(AT_RED, "=-", ch, NULL, victim, TO_NOTVICT);
		act(AT_YELLOW, "Your hair flashes black.", ch, NULL, victim,
		act(AT_YELLOW, "Your hair flashes red.", ch, NULL, victim,
		    TO_CHAR);
		act(AT_YELLOW, "$n's hair flashes black.", ch, NULL, victim,
		act(AT_YELLOW, "$n's hair flashes red.", ch, NULL, victim,
		    TO_VICT);
		act(AT_YELLOW, "$n's hair flashes black.", ch, NULL, victim,
		act(AT_YELLOW, "$n's hair flashes red.", ch, NULL, victim,
		    TO_NOTVICT);
		act(AT_RED, "=-", ch, NULL, victim, TO_CHAR);
		act(AT_RED, "=-", ch, NULL, victim, TO_VICT);


@@ 1236,13 1200,13 @@ rage4(CHAR_DATA * ch, CHAR_DATA * victim)
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_VICT);
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_NOTVICT);
		act(AT_RED,
		    "Your voice bellows out through the area, with a deep angry howl.",
		    "Your voice bellows out through the area with a deep angry howl.",
		    ch, NULL, victim, TO_CHAR);
		act(AT_RED,
		    "$n's voice bellows out through the area, with a deep angry howl.",
		    "$n's voice bellows out through the area with a deep angry howl.",
		    ch, NULL, victim, TO_VICT);
		act(AT_RED,
		    "$n's voice bellows out through the area, with a deep angry howl.",
		    "$n's voice bellows out through the area with a deep angry howl.",
		    ch, NULL, victim, TO_NOTVICT);
		do_yell(ch, "rrrrrRRRRRRRRAAAAAAAAAAAAHHHHHHHHHH!!!");
		act(AT_YELLOW, "=-", ch, NULL, victim, TO_CHAR);


@@ 1257,31 1221,31 @@ rage4(CHAR_DATA * ch, CHAR_DATA * victim)
		act(AT_RED, "=-", ch, NULL, victim, TO_VICT);
		act(AT_RED, "=-", ch, NULL, victim, TO_NOTVICT);
		act(AT_RED,
		    "You howl with anger as your hair turns black again and grow",
		    "You howl with anger as your hair turns red. A giant golden",
		    ch, NULL, NULL, TO_CHAR);
		act(AT_RED,
		    "thick red fur all over your body, finally you sprout a",
		    "aura envelopes you, intertwined with a menacing crimson hue.",
		    ch, NULL, NULL, TO_CHAR);
		act(AT_RED,
		    "tail and look up with glaring eyes inset within a red outline.",
		    "You've tasted what it truly means to become a God.",
		    ch, NULL, NULL, TO_CHAR);
		act(AT_RED,
		    "$n howls with anger as $s hair turns black again and grows",
		    "$n howls with anger as $s hair turns red. A giant golden",
		    ch, NULL, NULL, TO_NOTVICT);
		act(AT_RED,
		    "thick red fur all over $s body, finally $e sprouts a", ch,
		    "aura envelopes $m, intertwined with a menacing crimson hue.", ch,
		    NULL, NULL, TO_NOTVICT);
		act(AT_RED,
		    "tail and looks up at you with glaring eyes inset within a red outline.",
		    "$n has tasted what it truly means to become a God...",
		    ch, NULL, NULL, TO_NOTVICT);
		act(AT_RED,
		    "You look up at $N, with rage filled eyes, ready to kill...",
		    "You look up at $N with rage filled eyes, ready to kill...",
		    ch, NULL, victim, TO_CHAR);
		act(AT_RED,
		    "$n looks up at you, with rage filled eyes, ready to kill...",
		    "$n looks up at you with rage filled eyes, ready to kill...",
		    ch, NULL, victim, TO_VICT);
		act(AT_RED,
		    "$n looks up at $N, with rage filled eyes, ready to kill...",
		    "$n looks up at $N with rage filled eyes, ready to kill...",
		    ch, NULL, victim, TO_NOTVICT);
		act(AT_RED, "=-", ch, NULL, victim, TO_CHAR);
		act(AT_RED, "=-", ch, NULL, victim, TO_VICT);


@@ 1335,22 1299,13 @@ rage5(CHAR_DATA * ch, CHAR_DATA * victim)
		return;

	if (ch->delay <= 0) {
		if (!is_saiyan(ch))
		if (!is_saiyan(ch) && !is_hb(ch))
			return;

		if (ch->rage < 1500)
			return;