////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Markshire's Nomenclature                                                  //
//  ms_name_inc.nss															  //
//                                                                            //
//  By Thrym of Markshire  5/21/06                                            //
// 	Updated by: Jaysyn 2021/12/03											  //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
/*
//  FUNCTION:
//  The Nomenclature is an include file placed in the spawn script
//  nw_c2_default9 designed to assign a name to a generic NPC who may
//  wander towns, roads, shops, etc.
//
//  Utilizing both SetName and RandomName the system will name the NPC in
//  one of two ways ...
//
//  "SET_NAME":  By setting the variable "SET_NAME" on the NPC and
//  assigning it a string the creature will rename itself upon spawning.
//  This is handy for DM's and builders to create more precisely named
//  creatures for the palette and then generize them upon spawn.
//
//  eg. Ancient White Dragon in the Creator becomes White Dragon on Spawn.
//
//  "SET_NAME" = "RANDOM":  By setting the same variable to the name "RANDOM"
//  the NPC then is given a random name generated by RACE and GENDER using
//  the RandomName function.
//
//  eg.  Male Dwarven Villager in the Aurora Toolset becomes Gloigan on spawn
//  this time and perhaps Rufus on the next spawned Villager.
//
//  "NAME_TYPE":  Setting this int variable to "1" will cause a Full Name
//  to be generated if the "SET_NAME" is set to "RANDOM".
//
//  eg.  Male Dwarven Villager becomes Gloigan Stonecutter or Rufus Mason.
//
//  "TITLE": Prepends the defined string to the NPCs name.
//
//      eg. "Lord" Brown
//
//  "POSTFIX": Appends the defind string after the NPC's name.
//
//      eg. Ralph "the Guard"
//


    "RND_ROGUE"
    "RND_BARBARIAN"
    "RND_FIGHTER"
    "RND_CLERIC"    : Setting these to "1" will give the NPC a randomized class
    "RND_MAGE"      : appropriate postfix
    "RND_DRUID"
    "RND_RANGER"


//
//
//////////////////////////////////////////////////////////////////////////////*/

#include "prc_inc_racial"



///// FUNCTION DECLARATIONS ////////////////////////////////////////////////////

//:: Function to get the class type with the highest level
int GetHighestClassType(object oCreature);

//:: Returns class level based NPC titles
string GetClassLevelTitle(int nClassType, object oNPC = OBJECT_SELF);

// Generates a Random First Name
// based on Race and Gender
// For all Standard PC Races and Animals
string ms_RandomFirstName(object oNPC = OBJECT_SELF);

// Generates a Random Last Name
// based on Race For all
// Standard PC Races and Animals
string ms_RandomLastName(object oNPC = OBJECT_SELF);

// Function designed to read the variable
// "SET_NAME" and assign a new name to the NPC
// If the variable is set to "RANDOM" a
// random name is assigned.
// A second variable can be assigned to
// have the random name be a random Full Name.
void ms_Nomenclature(object oNPC = OBJECT_SELF);


///// FUNCTIONS ////////////////////////////////////////////////////////////////

void ms_Nomenclature(object oNPC = OBJECT_SELF)
{
    string sRandomName 	= GetLocalString(oNPC, "SET_NAME");
    string sTitle 		= GetLocalString(oNPC, "TITLE");
    string sPostfix 	= GetLocalString(oNPC, "POSTFIX");
	string sBaseRace 	= GetLocalString(oNPC, "BASE_RACE");
	string sClassTitle;
	
	int bClassTitle		= GetLocalInt(oNPC,"CLASS_TITLE");
	
			
//:: Handles class level based NPC titles
	if (bClassTitle)
	{
		    int nClassType = GetHighestClassType(oNPC);
			sClassTitle  = GetClassLevelTitle(nClassType, oNPC);

			FloatingTextStringOnCreature("Title: " + sClassTitle, oNPC);
	}

//:: Handles class based Henchman titles    
	int nRndPaladin = GetLocalInt(OBJECT_SELF, "RND_PALADIN");
	if (nRndPaladin == 1)
	{
		int nResult = Random(30) + 1; // Generate a random number between 1 and 30
		switch (nResult)
		{
			case 1:  sPostfix = "the Righteous"; break;
			case 2:  sPostfix = "the Just"; break;
			case 3:  sPostfix = "the Defender"; break;
			case 4:  sPostfix = "the Virtuous"; break;
			case 5:  sPostfix = "the Crusader"; break;
			case 6:  sPostfix = "the Lightbringer"; break;
			case 7:  sPostfix = "the Faithful"; break;
			case 8:  sPostfix = "the Zealous"; break;
			case 9:  sPostfix = "the Beacon"; break;
			case 10: sPostfix = "the Redeemer"; break;
			case 11: sPostfix = "the Shield of Faith"; break;
			case 12: sPostfix = "of the Sacred Flame"; break;
			case 13: sPostfix = "the Lawful"; break;
			case 14: sPostfix = "the Blessed"; break;
			case 15: sPostfix = "the Chosen"; break;
			case 16: sPostfix = "of the Holy Vow"; break;
			case 17: sPostfix = "the Avenger"; break;
			case 18: sPostfix = "the Purifier"; break;
			case 19: sPostfix = "the Divine Hand"; break;
			case 20: sPostfix = "the Sacred Blade"; break;
			case 21: sPostfix = "the Lightforged"; break;
			case 22: sPostfix = "the Protector"; break;
			case 23: sPostfix = "the Illuminated"; break;
			case 24: sPostfix = "of the Silver Oath"; break;
			case 25: sPostfix = "the Guardian"; break;
			case 26: sPostfix = "the Oathbound"; break;
			case 27: sPostfix = "the Valiant"; break;
			case 28: sPostfix = "the Seraphic"; break;
			case 29: sPostfix = "the Golden Knight"; break;
			case 30: sPostfix = "the True"; break;
		}
	}

	int nRndMonk = GetLocalInt(OBJECT_SELF, "RND_MONK");
	if (nRndMonk == 1)
	{
		int nResult = Random(30) + 1;
		switch (nResult)
		{
			case 1:  sPostfix = "the Disciplined"; break;
			case 2:  sPostfix = "the Enlightened"; break;
			case 3:  sPostfix = "of the Open Palm"; break;
			case 4:  sPostfix = "of the Empty Hand"; break;
			case 5:  sPostfix = "the Ascetic"; break;
			case 6:  sPostfix = "the Calm"; break;
			case 7:  sPostfix = "the Wayfarer"; break;
			case 8:  sPostfix = "the Iron Fist"; break;
			case 9:  sPostfix = "the Centered"; break;
			case 10: sPostfix = "of the Quiet Mind"; break;
			case 11: sPostfix = "the Humble"; break;
			case 12: sPostfix = "the Swift Palm"; break;
			case 13: sPostfix = "the Inner Flame"; break;
			case 14: sPostfix = "the Master"; break;
			case 15: sPostfix = "of the Lotus Path"; break;
			case 16: sPostfix = "the Patient"; break;
			case 17: sPostfix = "the Balanced"; break;
			case 18: sPostfix = "the Serene"; break;
			case 19: sPostfix = "the Watchful"; break;
			case 20: sPostfix = "the Disciple"; break;
			case 21: sPostfix = "the Harmonious"; break;
			case 22: sPostfix = "the Seeker"; break;
			case 23: sPostfix = "the Breathless"; break;
			case 24: sPostfix = "the Stilled Hand"; break;
			case 25: sPostfix = "of Perfect Form"; break;
			case 26: sPostfix = "the Tranquil"; break;
			case 27: sPostfix = "the Unbound"; break;
			case 28: sPostfix = "the Silent Step"; break;
			case 29: sPostfix = "the Mindful"; break;
			case 30: sPostfix = "the Flowing One"; break;
		}
	}
    
	int nRndRogue = GetLocalInt(OBJECT_SELF,"RND_ROGUE");
	if (nRndRogue == 1)
	{
		int nResult = Random(30) + 1; // Generate a random number between 1 and 30
		switch (nResult)
		{
			case 1:
				sPostfix = "the Quick";
				break;
			case 2:
				sPostfix = "the Quiet";
				break;
			case 3:
				sPostfix = "the Sharp";
				break;
			case 4:
				sPostfix = "the Sneak";
				break;
			case 5:
				sPostfix = "the Rogue";
				break;
			case 6:
				sPostfix = "the Footpad";
				break;
			case 7:
				sPostfix = "the Shadow";
				break;
			case 8:
				sPostfix = "the Nimble";
				break;
			case 9:
				sPostfix = "the Swift";
				break;
			case 10:
				sPostfix = "the Silent";
				break;
			case 11:
				sPostfix = "the Sly";
				break;
			case 12:
				sPostfix = "the Crafty";
				break;
			case 13:
				sPostfix = "the Cunning";
				break;
			case 14:
				sPostfix = "the Elusive";
				break;
			case 15:
				sPostfix = "the Deft";
				break;
			case 16:
				sPostfix = "the Guileful";
				break;
			case 17:
				sPostfix = "the Lurker";
				break;
			case 18:
				sPostfix = "the Trickster";
				break;
			case 19:
				sPostfix = "the Prowler";
				break;
			case 20:
				sPostfix = "the Skulker";
				break;
			case 21:
				sPostfix = "the Phantom";
				break;
			case 22:
				sPostfix = "the Wily";
				break;
			case 23:
				sPostfix = "the Mysterious";
				break;
			case 24:
				sPostfix = "the Furtive";
				break;
			case 25:
				sPostfix = "the Discreet";
				break;
			case 26:
				sPostfix = "the Spy";
				break;
			case 27:
				sPostfix = "the Veiled";
				break;
			case 28:
				sPostfix = "the Artful";
				break;
			case 29:
				sPostfix = "the Sleuth";
				break;
			case 30:
				sPostfix = "the Masked";
				break;
		}
	}

	int nRndBarb = GetLocalInt(OBJECT_SELF,"RND_BARBARIAN");
	if (nRndBarb == 1)
	{
		int nResult = Random(30) + 1; // Generate a random number between 1 and 30
		switch (nResult)
		{
			case 1:
				sPostfix = "the Barbarian";
				break;
			case 2:
				sPostfix = "the Destroyer";
				break;
			case 3:
				sPostfix = "of the Plains";
				break;
			case 4:
				sPostfix = "of Bear Clan";
				break;
			case 5:
				sPostfix = "the Rampager";
				break;
			case 6:
				sPostfix = "the Reaver";
				break;
			case 7:
				sPostfix = "the Savage";
				break;
			case 8:
				sPostfix = "the Berserker";
				break;
			case 9:
				sPostfix = "the Untamed";
				break;
			case 10:
				sPostfix = "the Fierce";
				break;
			case 11:
				sPostfix = "the Warbringer";
				break;
			case 12:
				sPostfix = "the Wild";
				break;
			case 13:
				sPostfix = "the Raider";
				break;
			case 14:
				sPostfix = "the Vicious";
				break;
			case 15:
				sPostfix = "the Ruthless";
				break;
			case 16:
				sPostfix = "the Savage";
				break;
			case 17:
				sPostfix = "the Bloodthirsty";
				break;
			case 18:
				sPostfix = "the Warlord";
				break;
			case 19:
				sPostfix = "the Brute";
				break;
			case 20:
				sPostfix = "the Fierce";
				break;
			case 21:
				sPostfix = "the Marauder";
				break;
			case 22:
				sPostfix = "the Howler";
				break;
			case 23:
				sPostfix = "the Ravager";
				break;
			case 24:
				sPostfix = "the Crusher";
				break;
			case 25:
				sPostfix = "the Frenzied";
				break;
			case 26:
				sPostfix = "the Beast";
				break;
			case 27:
				sPostfix = "the Juggernaut";
				break;
			case 28:
				sPostfix = "the Slayer";
				break;
			case 29:
				sPostfix = "the Rager";
				break;
			case 30:
				sPostfix = "the Conqueror";
				break;
		}
	}

	int nRndFight = GetLocalInt(OBJECT_SELF,"RND_FIGHTER");
	if (nRndFight == 1)
	{
		int nResult = Random(30) + 1; // Generate a random number between 1 and 30
		switch (nResult)
		{
			case 1:
				sPostfix = "the Strong";
				break;
			case 2:
				sPostfix = "the Stout";
				break;
			case 3:
				sPostfix = "of Harrowdale";
				break;
			case 4:
				sPostfix = "of Tyr";
				break;
			case 5:
				sPostfix = "of Neverwinter";
				break;
			case 6:
				sPostfix = "the Swordhand";
				break;
			case 7:
				sPostfix = "the Valiant";
				break;
			case 8:
				sPostfix = "the Brave";
				break;
			case 9:
				sPostfix = "the Defender";
				break;
			case 10:
				sPostfix = "the Just";
				break;
			case 11:
				sPostfix = "the Noble";
				break;
			case 12:
				sPostfix = "the Gallant";
				break;
			case 13:
				sPostfix = "the Protector";
				break;
			case 14:
				sPostfix = "the Shield";
				break;
			case 15:
				sPostfix = "the Champion";
				break;
			case 16:
				sPostfix = "the Guardian";
				break;
			case 17:
				sPostfix = "the Sentinel";
				break;
			case 18:
				sPostfix = "the Warrior";
				break;
			case 19:
				sPostfix = "the Stalwart";
				break;
			case 20:
				sPostfix = "the Ironclad";
				break;
			case 21:
				sPostfix = "the Blade";
				break;
			case 22:
				sPostfix = "the Swordsman";
				break;
			case 23:
				sPostfix = "the Vanguard";
				break;
			case 24:
				sPostfix = "the Lancer";
				break;
			case 25:
				sPostfix = "the Spearhead";
				break;
			case 26:
				sPostfix = "the Battlemaster";
				break;
			case 27:
				sPostfix = "the Blademaster";
				break;
			case 28:
				sPostfix = "the Warlord";
				break;
			case 29:
				sPostfix = "the Vanquisher";
				break;
			case 30:
				sPostfix = "the Swordmaster";
				break;
		}
	}

	int nRndCleric = GetLocalInt(OBJECT_SELF,"RND_CLERIC");
	if (nRndCleric == 1)
	{
		int nResult = Random(30) + 1; // Generate a random number between 1 and 30
		if (nResult == 1)
		{
			sPostfix = "the Pious";
		}
		else if (nResult == 2)
		{
			sPostfix = "the Holy";
		}
		else if (nResult == 3)
		{
			sPostfix = "the Priest";
		}
		else if (nResult == 4)
		{
			sPostfix = "the Zealous";
		}
		else if (nResult == 5)
		{
			sPostfix = "of Phlan";
		}
		else if (nResult == 6)
		{
			sPostfix = "the Wise";
		}
		else if (nResult == 7)
		{
			sPostfix = "the Devout";
		}
		else if (nResult == 8)
		{
			sPostfix = "the Faithful";
		}
		else if (nResult == 9)
		{
			sPostfix = "the Righteous";
		}
		else if (nResult == 10)
		{
			sPostfix = "the Blessed";
		}
		else if (nResult == 11)
		{
			sPostfix = "the Pure";
		}
		else if (nResult == 12)
		{
			sPostfix = "the Sacred";
		}
		else if (nResult == 13)
		{
			sPostfix = "the Benevolent";
		}
		else if (nResult == 14)
		{
			sPostfix = "the Virtuous";
		}
		else if (nResult == 15)
		{
			sPostfix = "the Saintly";
		}
		else if (nResult == 16)
		{
			sPostfix = "the Healer";
		}
		else if (nResult == 17)
		{
			sPostfix = "the Anointed";
		}
		else if (nResult == 18)
		{
			sPostfix = "the Protector";
		}
		else if (nResult == 19)
		{
			sPostfix = "the Merciful";
		}
		else if (nResult == 20)
		{
			sPostfix = "the Revered";
		}
		else if (nResult == 21)
		{
			sPostfix = "the Graceful";
		}
		else if (nResult == 22)
		{
			sPostfix = "the Watchful";
		}
		else if (nResult == 23)
		{
			sPostfix = "the Forgiving";
		}
		else if (nResult == 24)
		{
			sPostfix = "the Humble";
		}
		else if (nResult == 25)
		{
			sPostfix = "the Divine";
		}
		else if (nResult == 26)
		{
			sPostfix = "the Preacher";
		}
		else if (nResult == 27)
		{
			sPostfix = "the Illuminated";
		}
		else if (nResult == 28)
		{
			sPostfix = "the Mystic";
		}
		else if (nResult == 29)
		{
			sPostfix = "the Herald";
		}
		else // nResult == 30
		{
			sPostfix = "the Exalted";
		}
	}

	int nRndMage = GetLocalInt(OBJECT_SELF,"RND_MAGE");
	if (nRndMage == 1)
	{
		int nResult = Random(30) + 1; // Generate a random number between 1 and 30
		switch (nResult)
		{
			case 1:
				sPostfix = "the Mad";
				break;
			case 2:
				sPostfix = "the Arcane";
				break;
			case 3:
				sPostfix = "the Black";
				break;
			case 4:
				sPostfix = "the Wizard";
				break;
			case 5:
				sPostfix = "of Waterdeep";
				break;
			case 6:
				sPostfix = "the Mage";
				break;
			case 7:
				sPostfix = "the Enigmatic";
				break;
			case 8:
				sPostfix = "the Mystical";
				break;
			case 9:
				sPostfix = "the Eldritch";
				break;
			case 10:
				sPostfix = "the Runeweaver";
				break;
			case 11:
				sPostfix = "the Sorcerous";
				break;
			case 12:
				sPostfix = "the Seer";
				break;
			case 13:
				sPostfix = "the Arcanist";
				break;
			case 14:
				sPostfix = "the Illustrious";
				break;
			case 15:
				sPostfix = "the Sage";
				break;
			case 16:
				sPostfix = "the Sorcerous";
				break;
			case 17:
				sPostfix = "the Occult";
				break;
			case 18:
				sPostfix = "the Arcane Adept";
				break;
			case 19:
				sPostfix = "the Spellbinder";
				break;
			case 20:
				sPostfix = "the Occultist";
				break;
			case 21:
				sPostfix = "the Conjurer";
				break;
			case 22:
				sPostfix = "the Seer";
				break;
			case 23:
				sPostfix = "the Invoker";
				break;
			case 24:
				sPostfix = "the Mysterious";
				break;
			case 25:
				sPostfix = "the Shrouded";
				break;
			case 26:
				sPostfix = "the Visionary";
				break;
			case 27:
				sPostfix = "the Spellweaver";
				break;
			case 28:
				sPostfix = "the Willbreaker";
				break;
			case 29:
				sPostfix = "the Charmer";
				break;
			case 30:
				sPostfix = "the Elementalist";
				break;
		}
	}

	int nRndBard = GetLocalInt(OBJECT_SELF,"RND_BARD");
	if (nRndBard == 1)
	{
		int nResult = Random(25) + 1; // Generate a random number between 1 and 25
		switch (nResult)
		{
			case 1:
				sPostfix = "the Subtle";
				break;
			case 2:
				sPostfix = "the Veiled";
				break;
			case 3:
				sPostfix = "the Shadowed";
				break;
			case 4:
				sPostfix = "the Intriguer";
				break;
			case 5:
				sPostfix = "of Altaruk";
				break;
			case 6:
				sPostfix = "the Elusive";
				break;
			case 7:
				sPostfix = "the Mysterious";
				break;
			case 8:
				sPostfix = "the Cryptic";
				break;
			case 9:
				sPostfix = "the Insidious";
				break;
			case 10:
				sPostfix = "the Quiet";
				break;
			case 11:
				sPostfix = "the Sly";
				break;
			case 12:
				sPostfix = "the Covert";
				break;
			case 13:
				sPostfix = "the Furtive";
				break;
			case 14:
				sPostfix = "the Discreet";
				break;
			case 15:
				sPostfix = "the Subversive";
				break;
			case 16:
				sPostfix = "the Shrouded";
				break;
			case 17:
				sPostfix = "the Obscured";
				break;
			case 18:
				sPostfix = "the Clever";
				break;
			case 19:
				sPostfix = "the Enigmatic";
				break;
			case 20:
				sPostfix = "of Elventree";
				break;
			case 21:
				sPostfix = "of Melvaunt";
				break;
			case 22:
				sPostfix = "of Deepingdale";
				break;
			case 23:
				sPostfix = "of Skullport";
				break;
			case 24:
				sPostfix = "the Crafty";
				break;
			case 25:
				sPostfix = "of Amn";
				break;
		}
	}

	int nRndDruid = GetLocalInt(OBJECT_SELF,"RND_DRUID");
	if (nRndDruid == 1)
	{
		int nResult = Random(25) + 1; // Generate a random number between 1 and 25
		switch (nResult)
		{
			case 1:
				sPostfix = "the Druid";
				break;
			case 2:
				sPostfix = "of the Forest";
				break;
			case 3:
				sPostfix = "of the Wild";
				break;
			case 4:
				sPostfix = "the Wolflord";
				break;
			case 5:
				sPostfix = "the Treelord";
				break;
			case 6:
				sPostfix = "the Verdant";
				break;
			case 7:
				sPostfix = "the Earthshaker";
				break;
			case 8:
				sPostfix = "the Feral";
				break;
			case 9:
				sPostfix = "of the Glade";
				break;
			case 10:
				sPostfix = "of the Crystal Forest";
				break;
			case 11:
				sPostfix = "the Thorned";
				break;
			case 12:
				sPostfix = "the Greenwarden";
				break;
			case 13:
				sPostfix = "the Naturebound";
				break;
			case 14:
				sPostfix = "the Forestborn";
				break;
			case 15:
				sPostfix = "the Spiritcaller";
				break;
			case 16:
				sPostfix = "the Leafblade";
				break;
			case 17:
				sPostfix = "the Mossy";
				break;
			case 18:
				sPostfix = "the Grovekeeper";
				break;
			case 19:
				sPostfix = "the Stormbringer";
				break;
			case 20:
				sPostfix = "the Earthshaper";
				break;
			case 21:
				sPostfix = "the Bramble";
				break;
			case 22:
				sPostfix = "of the Black Sands";
				break;
			case 23:
				sPostfix = "of the Silt Sea";
				break;
			case 24:
				sPostfix = "the Spiritbinder";
				break;
			case 25:
				sPostfix = "the Wildheart";
				break;
		}
	}

	int nRndRanger = GetLocalInt(OBJECT_SELF,"RND_RANGER");
	if (nRndRanger == 1)
	{
		int nResult = Random(25) + 1; // Generate a random number between 1 and 25
		switch (nResult)
		{
			case 1:
				sPostfix = "the Ranger";
				break;
			case 2:
				sPostfix = "of the Forest";
				break;
			case 3:
				sPostfix = "of the Wild";
				break;
			case 4:
				sPostfix = "the Strider";
				break;
			case 5:
				sPostfix = "the Venger";
				break;
			case 6:
				sPostfix = "the Pathfinder";
				break;
			case 7:
				sPostfix = "the Woodsman";
				break;
			case 8:
				sPostfix = "the Trailblazer";
				break;
			case 9:
				sPostfix = "the Hunter";
				break;
			case 10:
				sPostfix = "the Scout";
				break;
			case 11:
				sPostfix = "the Wayfarer";
				break;
			case 12:
				sPostfix = "the Outrider";
				break;
			case 13:
				sPostfix = "the Seeker";
				break;
			case 14:
				sPostfix = "the Sentinel";
				break;
			case 15:
				sPostfix = "the Forestborn";
				break;
			case 16:
				sPostfix = "the Survivalist";
				break;
			case 17:
				sPostfix = "the Tracker";
				break;
			case 18:
				sPostfix = "the Forager";
				break;
			case 19:
				sPostfix = "the Warder";
				break;
			case 20:
				sPostfix = "the Greenblade";
				break;
			case 21:
				sPostfix = "the Beastmaster";
				break;
			case 22:
				sPostfix = "the Thornhunter";
				break;
			case 23:
				sPostfix = "of the Deepwood";
				break;
			case 24:
				sPostfix = "of the Roughlands";
				break;
			case 25:
				sPostfix = "the Wilderness Guide";
				break;
		}
	}

	if (sRandomName != "")
    {
        if (sRandomName == "RANDOM")
        {
            switch (GetLocalInt(oNPC, "NAME_TYPE"))
            {
                case 1:   sRandomName = sTitle + " " + ms_RandomFirstName(oNPC) + " " + ms_RandomLastName(oNPC)+ " " + sPostfix; break;
                default:  sRandomName = sTitle + " " + ms_RandomFirstName(oNPC) + " " + sPostfix; break;
            }
        }
    
		if (bClassTitle)
		{
			sRandomName = sBaseRace +" "+ sClassTitle;		
		}		

		SetName(oNPC, (sRandomName));
			return;
    }
}

string ms_RandomFirstName(object oNPC = OBJECT_SELF)
{
    int Gender   = GetGender(oNPC);
    int Race     = MyPRCGetRacialType(oNPC);

    string Name;

    switch (Race)
    {
        case RACIAL_TYPE_ANIMAL:    Name = RandomName(0); break;
        case RACIAL_TYPE_DWARF:
            switch (Gender)
            {   default:            Name = RandomName(2); break;
                case GENDER_FEMALE: Name = RandomName(3); break; } break;
        case RACIAL_TYPE_ELF:
            switch (Gender)
            {   default:            Name = RandomName(5); break;
                case GENDER_FEMALE: Name = RandomName(6); break; } break;
        case RACIAL_TYPE_GNOME:
            switch (Gender)
            {   default:            Name = RandomName(8); break;
                case GENDER_FEMALE: Name = RandomName(9); break; } break;
        case RACIAL_TYPE_HALFELF:
            switch (Gender)
            {   default:            Name = RandomName(11); break;
                case GENDER_FEMALE: Name = RandomName(12); break; } break;
        case RACIAL_TYPE_HALFLING:
            switch (Gender)
            {   default:            Name = RandomName(14); break;
                case GENDER_FEMALE: Name = RandomName(15); break; } break;
        case RACIAL_TYPE_HALFORC:
            switch (Gender)
            {   default:            Name = RandomName(17); break;
                case GENDER_FEMALE: Name = RandomName(18); break; } break;
        case RACIAL_TYPE_HUMAN:
            switch (Gender)
            {   default:            Name = RandomName(20); break;
                case GENDER_FEMALE: Name = RandomName(21); break; } break;
        default:
            switch (Gender)
            {   default:            Name = RandomName(-1); break;
                case GENDER_FEMALE: Name = RandomName(0); break; } break;
    }

    return Name;
}

string ms_RandomLastName(object oNPC = OBJECT_SELF)
{
    int Race     = MyPRCGetRacialType(oNPC);

    string Name;

    switch (Race)
    {
        case RACIAL_TYPE_DWARF:     Name = RandomName(4); break;
        case RACIAL_TYPE_ELF:       Name = RandomName(7); break;
        case RACIAL_TYPE_GNOME:     Name = RandomName(10); break;
        case RACIAL_TYPE_HALFELF:   Name = RandomName(13); break;
        case RACIAL_TYPE_HALFLING:  Name = RandomName(16); break;
        case RACIAL_TYPE_HALFORC:   Name = RandomName(19); break;
        case RACIAL_TYPE_HUMAN:     Name = RandomName(22); break;
        default:                    Name = RandomName(1); break;
    }

    return Name;
}

//:: Function to get the class type with the highest level
int GetHighestClassType(object oCreature)
{
    int nHighestLevel = -1;
    int nHighestClass = -1;
    int nClassTypes = 254; // maximum

    int i = 0;
    while (i <= nClassTypes)
    {
        // Exclude racial/monster pseudo-classes
        if (i == CLASS_TYPE_ABERRATION || 
            i == CLASS_TYPE_ANIMAL || 
            i == CLASS_TYPE_BEAST || 
            i == CLASS_TYPE_CONSTRUCT || 
            i == CLASS_TYPE_DRAGON || 
            i == CLASS_TYPE_ELEMENTAL || 
            i == CLASS_TYPE_FEY || 
            i == CLASS_TYPE_GIANT || 
            i == CLASS_TYPE_HUMANOID || 
            i == CLASS_TYPE_MAGICAL_BEAST || 
            i == CLASS_TYPE_MONSTROUS || 
            i == CLASS_TYPE_OOZE || 
            i == CLASS_TYPE_OUTSIDER || 
            i == CLASS_TYPE_PLANT || 
            i == CLASS_TYPE_SHAPECHANGER || 
            i == CLASS_TYPE_UNDEAD || 
            i == CLASS_TYPE_VERMIN)
        {
            i++;
            continue;
        }

        int nLevel = GetLevelByClass(i, oCreature);
        if (nLevel > 0)
        {
            if (nLevel > nHighestLevel)
            {
                nHighestLevel = nLevel;
                nHighestClass = i;
            }
        }
        i++;
    }

    if (nHighestClass != -1)
    {
        FloatingTextStringOnCreature("Highest Level class is " + IntToString(nHighestClass) + 
                                     " at level " + IntToString(nHighestLevel) + ".", oCreature);
    }

    return nHighestClass;
}

//:: Returns class level based NPC titles
string GetClassLevelTitle(int nClassType, object oNPC = OBJECT_SELF)
{
    string sTitle;
    int nLevel  = GetLevelByClass(nClassType, oNPC);
    int nGender = GetGender(oNPC);
	
	switch (nClassType)
	{
		case CLASS_TYPE_BARBARIAN:		
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Brute" ;
				break;
				
				case 4: case 5:
				sTitle = "Vandal"; break;
				
				case 6:
				if (nGender == 1)
					{sTitle = "Plunderess"; break;}
				else
					{sTitle = "Plunderer"; break;}
				
				case 7:
				sTitle = "Pillager"; break;
				
				case 8:
				sTitle = "Marauder"; break;
				
				case 9:
				sTitle = "Reaver"; break;
				
				case 10:
				sTitle = "Barbarian"; break;
				
				case 11:
				sTitle = "Mauler"; break;
				
				case 12:
				sTitle = "Ravager"; break;
				
				case 13:
				sTitle = "Slaughterer"; break;
				
				case 14:
				sTitle = "Destroyer"; break;
				
				case 15:
				if (nGender == 1)
					{sTitle = "Chieftainess"; break;}
				else
					{sTitle = "Chieftain"; break;}
				
				case 16:
				sTitle = "Bloodletter"; break;
				
				case 17:
				sTitle = "Rampager"; break;
				
				case 18:
				sTitle = "Slayer"; break;
				
				case 19:
				sTitle = "Warmonger"; break;
				
				case 20:
				if (nGender == 1)
					{sTitle = "High Chieftainess"; break;}
				else
					{sTitle = "High Chieftain"; break;}
				
				default:
				if (nGender == 1)
					{sTitle = "Conqueress"; break;}
				else
					{sTitle = "Conqueror"; break;}
			}
			break;
				
		case CLASS_TYPE_ROGUE:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Lookout" ;
				break;
				
				case 4: case 5:
				sTitle = "Outlaw"; break;
				
				case 6:
				sTitle = "Scalawag"; break;
				
				case 7:
				sTitle = "Creeper"; break;
				
				case 8:
				sTitle = "Larker"; break;
				
				case 9:
				sTitle = "Footpad"; break;
				
				case 10:
				sTitle = "Rogue"; break;
				
				case 11:
				sTitle = "Cutpurse"; break;
				
				case 12:
				sTitle = "Thief"; break;
				
				case 13:
				sTitle = "Pilferer"; break;
				
				case 14:
				sTitle = "Robber"; break;
				
				case 15:
				sTitle = "Sharper"; break;
				
				case 16:
				sTitle = "Burglar"; break;
				
				case 17:
				sTitle = "Filcher"; break;
				
				case 18:
				sTitle = "Scoundrel"; break;
				
				case 19:
				sTitle = "Knave"; break;
				
				case 20:
				sTitle = "Prowler"; break;
				
				default:
				sTitle = "Master Rogue"; break;
				
			}
			break;
				
		case CLASS_TYPE_BARD:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Crier" ;
				break;
				
				case 4: case 5:
				if (nGender == 1)
					{sTitle = "Chantress"; break;}
				else
					{sTitle = "Chanter"; break;}
				
				case 6:
				sTitle = "Skop"; break;
				
				case 7:
				sTitle = "Accompanist"; break;
				
				case 8:
				sTitle = "Rhymer"; break;
				
				case 9:
				sTitle = "Singer"; break;
				
				case 10:
				sTitle = "Balladeer"; break;
				
				case 11:
				if (nGender == 1)
					{sTitle = "Cantoress"; break;}
				else
					{sTitle = "Cantor"; break;}
				
				case 12:
				sTitle = "Lutenist"; break;
				
				case 13:
				sTitle = "Melodist"; break;
				
				case 14:
				sTitle = "Lyrist"; break;
				
				case 15:
				sTitle = "Jongleur"; break;
				
				case 16:
				sTitle = "Loreweaver"; break;
				
				case 17:
				sTitle = "Chronicler"; break;
				
				case 18:
				sTitle = "Muse"; break;
				
				case 19:
				if (nGender == 1)
					{sTitle = "Rhapsode"; break;}
				else
					{sTitle = "Rhapsodist"; break;}
				
				case 20:
				sTitle = "Bard"; break;
				
				case 21:
				sTitle = "Raconteur"; break;
				
				case 22:
				sTitle = "Siren"; break;
				
				case 23:
				sTitle = "Songsmith"; break;

				case 24:
				sTitle = "Versifer"; break;
				
				case 25:
				sTitle = "Minstrel"; break;
				
				case 26:
				sTitle = "Sonneteer"; break;
				
				case 27:
				if (nGender == 1)
					{sTitle = "Trobairitz"; break;}
				else
					{sTitle = "Troubadour"; break;}	
				
				case 28:
				sTitle = "Citharist"; break;				
	
				case 29:
				sTitle = "High Minstrel"; break;	
				
				default:
				sTitle = "Master Bard"; break;
				
			}
			break;
				
		case CLASS_TYPE_SORCERER: 
		case CLASS_TYPE_WIZARD:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Apprentice" ;
				break;
				
				case 4: case 5:
				sTitle = "Adept"; break;
				
				case 6:
				sTitle = "Journeymage"; break;
				
				case 7:
				sTitle = "Hedge Mage"; break;
				
				case 8:
				sTitle = "Magician"; break;
				
				case 9:
				sTitle = "Prestidigitator"; break;
				
				case 10:
				sTitle = "Wizard"; break;
				
				case 11:
				sTitle = "Sage"; break;
				
				case 12:
				sTitle = "Visionary"; break;
				
				case 13:
				sTitle = "Loremaster"; break;
				
				case 14:
				sTitle = "Mage"; break;
				
				case 15:
				sTitle = "Fatespinner"; break;
				
				case 16:
				sTitle = "Cabalist"; break;
				
				case 17:
				sTitle = "Thaumaturge"; break;
				
				case 18:
				sTitle = "Theurgist"; break;
				
				case 19:
				sTitle = "Augur"; break;
				
				case 20:
				sTitle = "Spellbinder"; break;					
				
				default:
				sTitle = "Archmage"; break;
				
			}
			break;

		case CLASS_TYPE_CLERIC:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Candidate" ;
				break;
				
				case 4: case 5:
				sTitle = "Aspirant"; break;
				
				case 6:
				sTitle = "Novice"; break;
				
				case 7:
				sTitle = "Acolyte"; break;
				
				case 8:
				sTitle = "Initiate"; break;
				
				case 9:
				if (nGender == 1)
					{sTitle = "Priestess"; break;}
				else
					{sTitle = "Priest"; break;}
				
				case 10:
				sTitle = "Cleric"; break;
				
				case 11:
				sTitle = "Curate"; break;
				
				case 12:
				sTitle = "Apostle"; break;
				
				case 13:
				sTitle = "Ovate"; break;
				
				case 14:
				sTitle = "Missionary"; break;
				
				case 15:
				if (nGender == 1)
					{sTitle = "Canoness"; break;}
				else
					{sTitle = "Canon"; break;}
				
				case 16:
				if (nGender == 1)
					{sTitle = "Abbotess"; break;}
				else
					{sTitle = "Abbot"; break;}
				
				case 17:
				sTitle = "Bishop"; break;
				
				case 18:
				if (nGender == 1)
					{sTitle = "Matriarch"; break;}
				else
					{sTitle = "Patriarch"; break;}
				
				case 19:
				sTitle = "Preacher"; break;
				
				default:
				if (nGender == 1)
					{sTitle = "High Priestess"; break;}
				else
					{sTitle = "High Priest"; break;}
				
			}
			break;
		
		case CLASS_TYPE_DRUID:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Initiate" ;
				break;
				
				case 4: case 5:
				sTitle = "Devotee"; break;
				
				case 6:
				sTitle = "Beastling"; break;
				
				case 7:
				sTitle = "Grovelurker"; break;
				
				case 8:
				sTitle = "Shaper"; break;
				
				case 9:
				sTitle = "Springwalker"; break;
				
				case 10:
				sTitle = "Druid"; break;
				
				case 11:
				sTitle = "Naturekin"; break;
				
				case 12:
				sTitle = "Treewarden"; break;
				
				case 13:
				sTitle = "Auspex"; break;
				
				case 14:
				sTitle = "Haruspex"; break;
				
				case 15:
				sTitle = "Student of Stones"; break;
				
				case 16:
				sTitle = "Student of Waters"; break;
				
				case 17:
				sTitle = "Student of Forests"; break;
				
				case 18:
				sTitle = "Student of Winds"; break;
				
				case 19:
				sTitle = "Student of Changes"; break;
				
				case 20:
				sTitle = "Pathwarden"; break;
				
				default:
				sTitle = "Archdruid"; break;
				
			}
			break;
		
		case CLASS_TYPE_FIGHTER:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Guard";
				break;
				
				case 4: 
				sTitle = "Elite Guard"; break;
				
				case 5: case 6:
				sTitle = "Warrior"; break;
				
				case 7:
				sTitle = "Elite Warrior"; break;
				
				case 8:
				sTitle = "Soldier"; break;
				
				case 9:
				sTitle = "Enforcer"; break;
				
				case 10:
				sTitle = "Fighter"; break;
				
				case 11:
				sTitle = "Skirmisher"; break;
				
				case 12:
				sTitle = "Veteran"; break;
				
				case 13:
				sTitle = "Armiger"; break;
				
				case 14:
				sTitle = "Myrmidon"; break;
				
				case 15:
				sTitle = "Hero"; break;
				
				case 16:
				sTitle = "Vanguard"; break;
				
				case 17:
				sTitle = "Sentinel"; break;
				
				case 18:
				sTitle = "Dominator"; break;
				
				case 19:
				sTitle = "Warmonger"; break;
				
				case 20:
				sTitle = "Champion"; break;
				
				default:
				sTitle = "Grandmaster"; break;
				
			}
			break;
		
		case CLASS_TYPE_MONK:
			switch(nLevel)
			{
				case 1:
				sTitle = "Trainee"; break;
				
				case 2:
				sTitle = "Initiate"; break;
				
				case 3:
				sTitle = "Novice"; break;

				case 4:
				sTitle = "Neophyte"; break;

				case 5:
				sTitle = "Aspirant"; break;
				
				case 6:
				sTitle = "Acolyte"; break;
				
				case 7:
				sTitle = "Devotee"; break;
				
				case 8:
				sTitle = "Disciple"; break;
				
				case 9:
				sTitle = "Adept"; break;
				
				case 10:
				sTitle = "Ascetic"; break;
				
				case 11:
				sTitle = "Pilgrim"; break;
				
				case 12:
				sTitle = "Master"; break;
				
				case 13:
				sTitle = "Anchorite"; break;
				
				case 14:
				sTitle = "Mystic"; break;
				
				case 15:
				sTitle = "Meditator"; break;
				
				case 16:
				sTitle = "Seeker"; break;
				
				case 17:
				sTitle = "Guru"; break;
				
				case 18:
				sTitle = "Sensei"; break;
				
				case 19:
				sTitle = "Sannyasi"; break;
				
				case 20:
				sTitle = "Exemplar"; break;

				case 21:
				sTitle = "Transcendent"; break;
				
				default:
				sTitle = "High Master"; break;
				
			}
			break;

		case CLASS_TYPE_PALADIN:
			switch(nLevel)
			{
				case 1:
				sTitle = "Advocate"; break;
				
				case 2:
				sTitle = "Initiate"; break;
				
				case 3:
				sTitle = "Squire"; break;

				case 4:
				sTitle = "Gallant"; break;

				case 5:
				sTitle = "Emissary"; break;
				
				case 6:
				sTitle = "Guardian"; break;
				
				case 7:
				sTitle = "Devotee"; break;
				
				case 8:
				sTitle = "Disciple"; break;
				
				case 9:
				sTitle = "Adept"; break;
				
				case 10:
				sTitle = "Ascetic"; break;
				
				case 11:
				sTitle = "Pilgrim"; break;
				
				case 12:
				sTitle = "Master"; break;
				
				case 13:
				sTitle = "Anchorite"; break;
				
				case 14:
				sTitle = "Mystic"; break;
				
				case 15:
				sTitle = "Meditator"; break;
				
				case 16:
				sTitle = "Seeker"; break;
				
				case 17:
				sTitle = "Guru"; break;
				
				case 18:
				sTitle = "Sensei"; break;
				
				case 19:
				sTitle = "Sannyasi"; break;
				
				case 20:
				sTitle = "Exemplar"; break;

				case 21:
				sTitle = "Transcendent"; break;
				
				default:
				sTitle = "High Master"; break;
				
			}
			break;
			
		case CLASS_TYPE_RANGER:
			switch(nLevel)
			{
				case 1: case 2: case 3:
				sTitle = "Greenhorn" ;
				break;
				
				case 4: case 5:
				sTitle = "Tenderfoot"; break;
				
				case 6:
				sTitle = "Vagrant"; break;
				
				case 7:
				sTitle = "Tramp"; break;
				
				case 8:
				sTitle = "Nomad"; break;
				
				case 9:
				sTitle = "Wanderer"; break;
				
				case 10:
				sTitle = "Ranger"; break;
				
				case 11:
				sTitle = "Rambler"; break;
				
				case 12:
				sTitle = "Traveler"; break;
				
				case 13:
				sTitle = "Sojourner"; break;
				
				case 14:
				sTitle = "Outrider"; break;
				
				case 15:
				sTitle = "Wayfarer"; break;
				
				case 16:
				sTitle = "Excursionist"; break;
				
				case 17:
				sTitle = "Trekker"; break;
				
				case 18:
				sTitle = "Trailblazer"; break;
				
				case 19:
				sTitle = "Woodsman"; break;
				
				case 20:
				sTitle = "High Ranger"; break;
				
				case 21:
				sTitle = "Ranger"; break;
				
				case 22:
				sTitle = "Rambler"; break;
				
				case 23:
				sTitle = "Traveler"; break;
				
				case 24:
				sTitle = "Sojourner"; break;
				
				case 25:
				sTitle = "Outrider"; break;
				
				case 26:
				sTitle = "Wayfarer"; break;
				
				case 27:
				sTitle = "Excursionist"; break;
				
				case 28:
				sTitle = "Trekker"; break;
				
				case 29:
				sTitle = "Trailblazer"; break;			
				
				default:
				sTitle = "Ranger Lord"; break;
				
			}
			break;
		}

	return sTitle;
}

//::void main (){}
