////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  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 creator 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"

//void main (){}


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

string GetClassLevelTitle(int nClassType);

int GetHighestClassLevel(object oCreature = 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");
	
	int nGender			= GetGender(oNPC);
	int bClassTitle		= GetLocalInt(oNPC,"CLASS_TITLE");
	int nHighClass 		= GetHighestClassLevel(oNPC);
	int nLevel 			= GetLevelByClass(nHighClass, oNPC);	
	
//:: Handles class level based NPC titles
	if (bClassTitle)
	{
		string sTitle;
		
		switch (nHighClass)
		{
			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;}
					
				}
					
			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;
					
				}
					
			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;
					
				}
					
			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;
					
				}

			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;}
					
				}
			
			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;
					
				}
			
			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;
					
				}
			
			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;
					
				}

			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;
					
				}

			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;
					
				}

		}

		//return sTitle;
	}

//:: Handles class based Henchman titles    
    int nRndRogue = GetLocalInt(OBJECT_SELF,"RND_ROGUE");
        if (nRndRogue == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Quick";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "the Quiet";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "the Sharp";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "the Sneak";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "the Rogue";
                    }
                else
                        sPostfix = "the Footpad";

            }

    int nRndBarb = GetLocalInt(OBJECT_SELF,"RND_BARBARIAN");
        if (nRndBarb == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Barbarian";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "the Destroyer";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "of the Plains";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "of Klar Clan";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "the Rampager";
                    }
                else
                        sPostfix = "the Reaver";

            }

    int nRndFight = GetLocalInt(OBJECT_SELF,"RND_FIGHTER");
        if (nRndFight == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Strong";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "the Stout";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "of the Blade";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "of Tyr";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "of Urik";
                    }
                else
                        sPostfix = "the Swordhand";

            }

    int nRndCleric = GetLocalInt(OBJECT_SELF,"RND_CLERIC");
        if (nRndCleric == 1)
            {
                int nResult = d6(1);
                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
                        sPostfix = "the Wise";

            }

    int nRndMage = GetLocalInt(OBJECT_SELF,"RND_MAGE");
        if (nRndMage == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Mad";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "the Arcane";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "the Black";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "the Wizard";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "of Ur-Draxa";
                    }
                else
                        sPostfix = "the Mage";

            }

    int nRndBard = GetLocalInt(OBJECT_SELF,"RND_BARD");
        if (nRndMage == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Dancer";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "the Troubador";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "of the Song";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "the Bard";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "the Raconteur";
                    }
                else
                        sPostfix = "the Minstrel";

            }

    int nRndDruid = GetLocalInt(OBJECT_SELF,"RND_DRUID");
        if (nRndDruid == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Druid";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "of the Forest";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "of the Wild";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "the Wolflord";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "the Treelord";
                    }
                else
                        sPostfix = "the Warden";

            }

    int nRndRanger = GetLocalInt(OBJECT_SELF,"RND_RANGER");
        if (nRndRanger == 1)
            {
                int nResult = d6(1);
                if (nResult == 1)
                    {
                        sPostfix = "the Ranger";
                    }
                else if(nResult == 2)
                    {
                        sPostfix = "of the Forest";
                    }
                else if(nResult == 3)
                    {
                        sPostfix = "of the Wild";
                    }
                else if(nResult ==4)
                    {
                        sPostfix = "the Strider";
                    }
                else if(nResult == 5)
                    {
                        sPostfix = "the Venger";
                    }
                else
                        sPostfix = "the Warden";

            }

	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 +" "+ sTitle;		
		}		

		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-based level title based on the class type
string GetClassLevelTitle(int nClassType)
{
    object oCreature 	= OBJECT_SELF; // Assuming this function is called on a creature object
	
    int nLevel 			= GetLevelByClass(nClassType, oCreature);
	int nGender			= GetGender(oCreature);
	
    string sTitle;

    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;}
				
			}
				
        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;
				
			}
				
        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;
				
			}
				
        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;
				
			}

        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;}
				
			}
		
        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;
				
			}
		
        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;
				
			}
		
        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;
				
			}

		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;
				
			}

		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;
				
			}

    }

    return sTitle;
}

//:: Function to get the highest class level of an object, excluding racial classes types
int GetHighestClassLevel(object oCreature)
{
    int nHighestLevel = -1;
    int nClassTypes = 254; // Maximum number of class types
    int i;

    for (i = 0; i <= nClassTypes; i++)
    {
        // Check if the class type is excluded
        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)
            continue;

        int nLevel = GetLevelByClass(i, oCreature);
        if (nLevel > 0)
        {
            if (nLevel > nHighestLevel)
            {
                nHighestLevel = nLevel;
            }
        }
        else
        {
            break; // Reached an invalid class level, exit the loop
        }
    }

    return nHighestLevel;
}


