#define MONK_OXBAY		   "in the town of #slocname#"
#define MONK_REDMOND		 "at the shore of #slocname#"
#define MONK_CONCEICAO	   "near the citygates of #slocname#"
#define MONK_MUELLE		  "on the causeway of #slocname#"
#define MONK_FLEUR		   "somewhere in #slocname#"
#define MONK_QUEBRADAS	   "on #slocname#"
#define MONK_DOUWESEN		"somewhere in the jungles of #slocname#"
#define MONK_COUNT		   7


void InitNoSaveMod()
{
	ref PChar = GetMainCharacter();
	if(!CheckAttribute(PChar, "NoSave.Init"))
	{
		//Trace("Create monks");
		CreateMonk( "Kanhoji",	   "Angria",	   TranslateString("",MONK_OXBAY),     "Oxbay_town");
		CreateMonk( "Robert",	   "Surcouf",	   TranslateString("",MONK_REDMOND),   "Redmond_shore_01");
		CreateMonk( "Yusuf",	   "Rais",		   TranslateString("",MONK_CONCEICAO), "Conceicao_town_exit");
		CreateMonk( "Uela",	       "de Marisco",   TranslateString("",MONK_MUELLE),    "Muelle_passage");
		CreateMonk( "Victor",	   "Hugues",	   TranslateString("",MONK_FLEUR),     "Falaise_de_fleur_shore_01");
		CreateMonk( "Bartolomeo",  "el Portugues", TranslateString("",MONK_QUEBRADAS), "QC_town_exit");
		CreateMonk( "Roche",	   "Brasiliano",   TranslateString("",MONK_DOUWESEN),  "Douwesen_Jungle_02");

		PChar.NoSave.Init = true;
	}
}
		 

void CreateMonk(	string Firstname, 
					string Lastname, 
					string Town,
					string Location)
{
	int i;
	ref monk;
	string Fullname = Firstname + " " + Lastname;
	i = GetCharacterIndex(Fullname);
	//Trace("start create monk " + Fullname);
	if( i == -1 )
	{
		//Trace("Create new monk");
		// NK 05-04-05 use CHARACTERS_QUANTITY
		/*for(i=0; i<MAX_CHARACTERS; i++)
		{
			makeref(tailor,Characters[i]); 
			if(tailor.id == "0") break;
		}*/
		makeref(monk, Characters[CHARACTERS_QUANTITY]);
		CHARACTERS_QUANTITY++;
		if(monk.id != "0")
		{
			//Trace("cquant not blank!");
			i = FindBlankCharSlot();
			CHARACTERS_QUANTITY = i+1;
			makeref(monk, Characters[i]);
			//Trace("new slot is " + i + ", new charq " + (i+1));
		}
		// NK <--

		monk.old.name 		   = Firstname;
		monk.old.lastname	   = Lastname;
		monk.name 			   = TranslateString("",Firstname);
		monk.lastname 		   = TranslateString("",Lastname);
		monk.id				   = Fullname;
		monk.model			   = "Animists3";
		monk.town 			   = Town;
		monk.nation			   = CLERIC;
		monk.skill.Fencing	   = 10;
		monk.skill.Sneak	   = 10;
		monk.location 		   = Location;
		monk.location.group	   = "monk"; // KK
		monk.location.locator  = "goto1"; //Ah! That's why. This only works for _current_ loc, not desired loc. NK 05-04-24 LAi_FindRandomLocator(monk.location.group);
		monk.sex			   = "man";
		monk.dialog.filename   = "monk_dialog.c";
		LAi_SetCitizenType(monk);
		LAi_group_MoveCharacter(monk, "ENGLAND_CITIZENS");
		LAi_SetLoginTime(monk, 0.0, 24.0);
		LAi_SetHP(monk, 800.0, 800.0);
		facemaker(monk);
		DeleteAttribute(monk, "location.etime");
		DeleteAttribute(monk, "location.stime");
	}
}

bool IsCharacterEquipByGroup(ref chref, string groupID)
{
	return CheckAttribute(chref,"equip."+groupID);
}

string GetRandomLocation(string ThisLocation)
{
	int i;
	int breakcounter = 0;
	string Location  = ThisLocation;
// KK -->
	string locname;
	while(Location == ThisLocation)
	{
		i = rand(MONK_COUNT -1);
		switch (i)
		{
			case 0: 
				Location = MONK_OXBAY;
				locname = GetTownName("Oxbay"); 
				break;
			case 1: 
				Location = MONK_REDMOND;
				locname = FindIslandName("Redmond");
				break;
			case 2: 
				Location = MONK_CONCEICAO;
				locname = FindIslandName("Conceicao");
				break;
			case 3: 
				Location = MONK_MUELLE;
				locname = FindIslandName("Isla Muelle");
				break;
			case 4: 
				Location = MONK_FLEUR;
				locname = GetTownName("Falaise de Fleur");
				break;
			case 5: 
				Location = MONK_QUEBRADAS;
				locname = FindIslandName("Quebradas Costillas");
				break;
			case 6: 
				Location = MONK_DOUWESEN;
				locname = FindIslandName("Douwesen");
				break;
		}
		breakcounter++;
		if(breakcounter > 1000) break;
	}
	Preprocessor_Add("locname", locname);
	Location = PreprocessText(Location);
	Preprocessor_Remove("locname");
// <-- KK
	return Location;
}

