player.c
src/player.c · 7.9 KB
From the archive cyhawk_mud.tar.gz
Download the archive « Back to the archive contents
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "tables.h"
#include "player.h"
/*
* religion_table()
*
* Conatins master list of all in-game churchs
*/
/*
* birthsign_table[]
*
* Contains all birthsign names.. and bonuses
*/
struct birthsign_type birthsign_table[] =
{
{"No birthsign", "No Month"},
{"The Sun", "Sun's Dusk"},
{"The Snowflake", "Evening Star"},
{"The Mage", "Morning Star"},
{"The Passion", "Sun's Dawn"},
{"The Golem", "First Seed"},
{"The Snake", "Rain's Hand"},
{"The Lion", "Second Seed"},
{"The Twins", "Mid Year"},
{"The Flame", "Sun's Height"},
{"The Moon", "Last Seed"},
{"The Bull", "Hearthfire"},
{"The Goddess", "Frostfall"},
{NULL, NULL},
};
struct trait_v_type voice_table[] =
{
{"normal", ""},
{"Squeeky", "in a squeeky voice"},
{"Raspy", "in a raspy voice"},
{"Low toned", "in a low voice"},
{"High pitched", "in a sharp voice"},
{"Deep voiced", "deeply"},
{"Soft", "softly"},
{"Booming", "boomingly"},
{"Stressed", "in a very streesed voice"},
{"Evil", "in an evilish voice"},
{"Sweetly", "sweetly"},
{"Demanding", "demandingly"},
{"Growling", "growling"},
{"Cheery", "cheerily"},
{NULL}
};
struct trait_type eye_table[] =
{
{"Not set"},
{"Green"},
{"Brown"},
{"Red"},
{"Blue"},
{"White"},
{"Dark Green"},
{"Dark Brown"},
{"Dark Red"},
{"Dark Blue"},
{"Violet"},
{"Black"},
{"Grey"},
{"Amber"},
{"Azure"},
{"Blood-Red"},
{"Crimson"},
{"Cyan"},
{"Golden"},
{"Magenta"},
{"Mercury"},
{"Pale-Blue"},
{"Ruby"},
{"Sapphire"},
{"Sea-Green"},
{"Silver"},
{"Stormy"},
{"Yellow"},
{"Dark Grey"},
{"Emerald"},
{"Topaz"},
{NULL}
};
struct trait_type hair_table[] =
{
{"Not set"},
{"Brunette"},
{"Black"},
{"Blonde"},
{"Grey"},
{"Red"},
{"Dark Brunette"},
{"Purple"},
{"Dark Grey"},
{"White"},
{"Bald"},
{"Salt-Pepper"},
{"Copper"},
{"Sandy-Blonde"},
{"Golden"},
{NULL}
};
struct trait_type weight_table[] =
{
{"Muscular"},
{"Skinny"},
{"Frail"},
{"Normal"},
{"Heavy"},
{"Lanky"},
{"Bulky"},
{"Slender"},
{"Toned"},
{"Stringy"},
{"Massive"},
{"Sickly"},
{"Diminutive"},
{"Delicate"},
{"Petite"},
{"Strapping"},
{"Brawny"},
{"Chubby"},
{"Plump"},
{"Thin"},
{"Scrawny"},
{NULL}
};
struct trait_type height_table[] =
{
{"very short"},
{"shrimp"},
{"munchkin"},
{"short"},
{"average"},
{"tall"},
{"giant"},
{NULL}
};
struct trait_type face_hair_table[] =
{
{"None"},
{"Mustache"},
{"Goatee"},
{"Short Beard"},
{"Sideburns"},
{"Long Beard"},
{"Long Mustache"},
{"Stubble"},
{"Grizzled"},
{"Muttonchops"},
{NULL}
};
/*
* eye_lookup()
*
* Returns table number of eye type
*/
int eye_lookup(const char * name)
{
int i;
for (i = 0; eye_table[i].name != NULL; i++)
{
if (eye_table[i].name == NULL)
break;
if (LOWER (name[0]) == LOWER (eye_table[i].name[0]) && !str_prefix (name, eye_table[i].name))
return i;
}
return -1;
}
/*
* birthsign_lookup()
*
* Returns table number of birthsign type
*/
int birthsign_lookup(const char * name)
{
int i;
for (i = 0; birthsign_table[i].birthsign != NULL; i++)
{
if (birthsign_table[i].birthsign == NULL)
break;
if (LOWER (name[0]) == LOWER (birthsign_table[i].birthsign[0]) && !str_prefix (name, birthsign_table[i].birthsign))
return i;
}
return -1;
}
/*
* hair_lookup()
*
* Returns table number of hair type
*/
int hair_lookup(const char * name)
{
int i;
for (i = 0; hair_table[i].name != NULL; i++)
{
if (hair_table[i].name == NULL)
break;
if (LOWER (name[0]) == LOWER (hair_table[i].name[0]) && !str_prefix (name, hair_table[i].name))
return i;
}
return -1;
}
/*
* face_hair_lookup()
*
* Returns table number of face_hair type
*/
int face_hair_lookup(const char * name)
{
int i;
for (i = 0; face_hair_table[i].name != NULL; i++)
{
if (face_hair_table[i].name == NULL)
break;
if (LOWER (name[0]) == LOWER (face_hair_table[i].name[0]) && !str_prefix (name, face_hair_table[i].name))
return i;
}
return -1;
}
/*
* voice_lookup()
*
* Returns table number of voice type
*/
int voice_lookup(const char * name)
{
int i;
for (i = 0; voice_table[i].name != NULL; i++)
{
if (voice_table[i].name == NULL)
break;
if (LOWER (name[0]) == LOWER (voice_table[i].name[0]) && !str_prefix (name, voice_table[i].name))
return i;
}
return -1;
}
/*
* height_lookup()
*
* Returns table number of height type
*/
int height_lookup(const char * name)
{
int i;
for (i = 0; height_table[i].name != NULL; i++)
{
if (height_table[i].name == NULL)
break;
if (LOWER (name[0]) == LOWER (height_table[i].name[0]) && !str_prefix (name, height_table[i].name))
return i;
}
return -1;
}
/*
* weight_lookup()
*
* Returns table number of weight type
*/
int weight_lookup(const char * name)
{
int i;
for (i = 0; weight_table[i].name != NULL; i++)
{
if (weight_table[i].name == NULL)
break;
if (LOWER (name[0]) == LOWER (weight_table[i].name[0]) && !str_prefix (name, weight_table[i].name))
return i;
}
return -1;
}
/*
* return_height()
*
* Returns player's height in string format,
* Example: height == 75 returns "6'3"
* This is in American Feet ;)
*/
char * return_height_org(int height)
{
static char buf[MAX_BUFFER];
div_t temp;
int x = height;
int y = 12;
temp = div( x, y );
sprintf(buf, "%d'%d", temp.quot, temp.rem );
return buf;
}
/*
* return_skin()
*
* Returns the skin tone of the given type.
*/
char * return_skin(int skin)
{
return "Not Finished";
}
/*
* return_align()
*
* Returns alignment in Long form
*
*/
char * return_align(int law, int good)
{
static char buf[MAX_BUFFER];
static char buf1[MAX_BUFFER];
static char buf2[MAX_BUFFER];
int true_neutral = 0;
/* Handle Law and order first */
if (law >= 66 || law >= 100)
sprintf(buf1, "Lawful ");
else if (law >= 33)
{
sprintf(buf1, "Neutral ");
true_neutral++;
}
else
sprintf(buf1, "Chaotic ");
/* Ok handle Good and Evil */
if (good >= 66 || good >= 100)
sprintf(buf2, "Good");
else if (good >= 33)
{
sprintf(buf2, "Neutral");
true_neutral++;
}
else
sprintf(buf2, "Evil");
if (true_neutral != 2)
sprintf(buf, "%s%s", buf1, buf2);
else
sprintf(buf, "True Neutral");
return buf;
}
/*
* return_birthsign()
*
* Returns the full birthsign of the player.
*/
char * return_birthsign (int birthsign)
{
static char buf[MAX_BUFFER];
sprintf(buf, "%s", birthsign_table[birthsign].birthsign);
return buf;
}
/*
* return_weight()
*
* Returns weight
*/
char * return_weight(int weight)
{
static char buf[MSL];
sprintf(buf, "%d lbs", weight);
return buf;
}