# Include file for character appearance generation.

# Arrays used in generating the description.

array hair[26] = 3,'Blue-Black',5,'Black',6,'Blond',7,'Bald',8,'Red-Brown',9,'Light Brown',
	11,'Brown',13,'Dark Brown',14,'Gray',15,'Strawberry Blond',16,'Bright Red',
	17,'Golden Blond',18,'Pure white';
array eyes[22] = 3,'Purple', 4,'Black', 5,'Ice-blue', 6,'Gray', 8,'Blue', 11,'Brown',
	12,'Hazel', 13,'Green', 14,'Dark Blue', 16,'Dark Green', 17,'Golden';
array skin[18] = 3,'Blue-black', 6,'Black', 7,'White with Freckles', 8,'White, Tanned',
	10,'White', 12,'Brown', 15,'Light Golden', 16,'Golden', 18,'Red-Bronze';
	
array weightmods[18] = 0,0,-40,-30,-20,-10,-5,-5,0,0,0,5,5,10,20,30,40,50;
array heightweight[14] = 120,130,130,135,135,140,145,150,155,160,165,170,180,190;
array heightmods[18] = 0,0,-6,-5,-4,-3,-2,-1,0,0,0,1,2,3,4,5,6,6;

true = 1;
false = 0;

func weightfunc(st) {
	if (st<=5)
		return 130;
	elseif (st < 8)
		return 135;
	elseif (st <15)
		return 140+(st-8)*5;
	endif
	return 150 + (st-15)*10;
}

func d3(add) {
	local sum;
	sum = rand(6)+rand(6)+rand(6)+add;
	if (sum < 0)
		sum = 0;
	endif
	return sum;
}


sub GenerateAppearance
{
	# If the user indicated it, generate random appearance, etc.
	if (rand(2) = 1)
		sex = 'Male';
	else
		sex = 'Female';
	endif

	# Set the eye color.

	eyecolor = d3(0);
	if (eyecolor = 18)
		left = min(d3(0),17);
		right = min(d3(0),17);
		if (left = right)
			left = right+1;
			if (left >= 18)
				left = 16;
			endif
		endif
		eye = format("left %d, right %d", lookup(eyes,left), lookup(eyes,right));
	else
		eye = format("%d", lookup(eyes,eyecolor));
	endif

	# Set appearance.

	Information.sex = sex;
	Information.appearance = format("Hair: %d, Eyes: %d, Skin: %d",
		lookup(hair,d3(0)), eye, lookup(skin,d3(0)));

	# Set height and weight.

	baseheight = min($@st+59,75)+heightmods[d3(0)]-(tl<6?3:0);
	baseweight = heightweight[baseheight-61]+weightmods[d3(0)];

	adj = sex = 'Male' ? 0 : 1;

	height = baseheight - adj*2;
	weight = baseweight - adj*10;
	Information.height = height;
	Information.bodyweight = weight;
}

