//#include "DIALOGS\eng_officiant_dialog.h"
	
void ProcessDialogEvent()
{
	int tmpLangFileID = LanguageOpenFile("interface_strings.txt");
	ref NPChar;
	aref Link, NextDiag;

	string shiploc = ""; // KK
	string ShipLocationName = ""; // KK

	DeleteAttribute(&Dialog,"Links");

	makeref(NPChar,CharacterRef);
	makearef(Link, Dialog.Links);
	makearef(NextDiag, NPChar.Dialog);

	ref PChar;
	PChar = GetMainCharacter();
	string iDay, iMonth;
	iDay = environment.date.day;
	iMonth = environment.date.month;
	string lastsex_date = iday + " " + iMonth;

	ref lcn = &Locations[FindLocation(PChar.location)];	//ccc Survival
	// MAXIMUS -->
	string curGreeting = "";
	if(CheckAttribute(NPChar,"greeting")) { curGreeting = NPChar.greeting; }
	if(lcn.image == "Tavern_Upstairs_01.tga") NPChar.greeting = "VOICE\" + LanguageGetLanguage() + "\Fre_f_a_006.wav";
	else NPChar.greeting = curGreeting;
	// MAXIMUS <--
	
	switch(Dialog.CurrentNode)
	{
		// -----------------------------------Диалог первый - первая встреча
		case "First time":
			Dialog.defAni = "dialog_stay1";
			Dialog.defCam = "1";
			Dialog.defSnd = "dialogs\0\017";
			Dialog.defLinkAni = "dialog_1";
			Dialog.defLinkCam = "1";
			Dialog.defLinkSnd = "dialogs\woman\024";
			Dialog.ani = "dialog_stay2";
			Dialog.cam = "1";
			NextDiag.TempNode = "first time";

			//ccc Survival ->
			if(lcn.image == "Tavern_Upstairs_01.tga")
			{
//				PlaySound("VOICE\" + LanguageGetLanguage() + "\Fre_f_a_006.wav")
				dialog.text = DLG_TEXT[38] + GetTownName(GetTownIDFromLocID(PChar.location)) + DLG_TEXT[39]; // KK
				link.l1 = DLG_TEXT[51];
				link.l1.go = "survival";
			}
			else
			//ccc Survival <-
			{
				if (characters[GetCharacterIndex("Father Bernard")].quest.church_help == "letters_1" || characters[GetCharacterIndex("Father Bernard")].quest.church_help == "letters_2" && npchar.id == "Greenford_officiant")
				{
					dialog.snd = "Voice\ENOF\ENOF002";
					dialog.text = DLG_TEXT[0] + GetMyAddressForm(NPChar, PChar, ADDR_CIVIL, false, false) + DLG_TEXT[1];
					link.l1 = DLG_TEXT[2] + GetMyFullName(NPChar) + DLG_TEXT[3];
					link.l1.go = "church_help";
				}
				else
				{
					switch(Rand(4))
					{
						case 0:
							dialog.snd = "Voice\ENOF\ENOF001";
							dialog.text = DLG_TEXT[4];
							link.l1 = DLG_TEXT[5];
							link.l1.go = "exit";
						break;

						case 1:
							dialog.snd = "Voice\ENOF\ENOF001";
							dialog.text = DLG_TEXT[6];
							link.l1 = DLG_TEXT[7];
							link.l1.go = "exit";
						break;

						case 2:
							dialog.snd = "Voice\ENOF\ENOF001";
							dialog.text = DLG_TEXT[8];
							link.l1 = DLG_TEXT[9];
							link.l1.go = "exit";
							string roomWait = "";
							link.l2 = DLG_TEXT[62];
							if (makeint(environment.time) >= 22.0 || makeint(environment.time) < 10.0)
							{
								roomWait = "eveningwait";
								link.l2.go = "room_day_wait_with_girl";
							}
							else
							{
								roomWait = "daywait";
								link.l2.go = "room_night_wait_with_girl";
							}
						break;

						case 3:
							dialog.snd = "Voice\ENOF\ENOF001";
							dialog.text = DLG_TEXT[10];
							link.l1 = DLG_TEXT[11];
							link.l1.go = "exit";
						break;

						case 4:
							dialog.snd = "Voice\ENOF\ENOF001";
							dialog.text = DLG_TEXT[12];
							link.l1 = DLG_TEXT[13];
							link.l1.go = "exit";
						break;
					}
				}
			}
		break;

		case "room_day_wait_with_girl":
			PlayStereoSound("INTERFACE\took_item.wav");
			DialogExit();
			NextDiag.CurrentNode = "after_love";
			AddDialogExitQuest("sleep_in_tavern");
			TavernWaitDate2("wait_day");
			NPChar.additionalSound = "VOICE\"+LanguageGetLanguage()+"\whore_1.wav";
		break;

		case "room_night_wait_with_girl":
			PlayStereoSound("INTERFACE\took_item.wav");
			DialogExit();
			NextDiag.CurrentNode = "after_love";
			AddDialogExitQuest("sleep_in_tavern");
			TavernWaitDate2("wait_night");
			NPChar.additionalSound = "VOICE\"+LanguageGetLanguage()+"\whore_1.wav";
		break;

		case "after_love":
			DeleteAttribute(NPChar,"additionalSound");
			dialog.text = DLG_TEXT[4];
			link.l1 = DLG_TEXT[5];
			link.l1.go = "exit";
			NextDiag.TempNode = "first time";
		break;

		case "church_help":
			dialog.snd = "Voice\ENOF\ENOF003";	
			dialog.text = DLG_TEXT[14];
			link.l1 = DLG_TEXT[15] + GetMyFullName(&Characters[GetCharacterIndex(DLG_TEXT[16])]) + DLG_TEXT[18];
			link.l1.go = "church_help_2";
		break;

		case "church_help_2":
			dialog.snd = "Voice\ENOF\ENOF004";
			dialog.text = DLG_TEXT[19];
			link.l1 = DLG_TEXT[20];
			link.l1.go = "church_help_4";
		break;

		case "church_help_4":
			dialog.snd = "Voice\ENOF\ENOF005";
			dialog.text = DLG_TEXT[21] + characters[GetCharacterIndex(DLG_TEXT[22])].name + " " +  + characters[GetCharacterIndex(DLG_TEXT[23])].lastname + DLG_TEXT[24];
			link.l1 = DLG_TEXT[25];
			link.l1.go = "church_help_5";
		break;

		case "church_help_5":
			dialog.snd = "Voice\ENOF\ENOF006";
			dialog.text = DLG_TEXT[26];
			link.l1 = DLG_TEXT[27];
			link.l1.go = "exit";
			characters[GetCharacterIndex("Father Bernard")].quest.church_help = "after_off";
			AddQuestRecord("Church_help", 7);
		break;

		case "Exit":
			DialogExit();
			NextDiag.CurrentNode = NextDiag.TempNode;
			NPChar.greeting = curGreeting;// MAXIMUS
		break;

		case "without_money":
			NextDiag.TempNode = "first time";
			Dialog.defAni = "dialog_stay1";
			Dialog.defCam = "1";
			Dialog.defSnd = "dialogs\0\017";
			Dialog.defLinkAni = "dialog_1";
			Dialog.defLinkCam = "1";
			Dialog.defLinkSnd = "dialogs\woman\024";
			Dialog.ani = "dialog_stay2";
			Dialog.cam = "1";
			
			dialog.snd = "Voice\ENOF\ENOF007";
			dialog.text = DLG_TEXT[28];
			link.l1 = DLG_TEXT[29];
			link.l1.go = "without_money_2";
		break;

		case "without_money_2":
			dialog.snd = "Voice\ENOF\ENOF008";
			dialog.text = DLG_TEXT[30];
			link.l1 = DLG_TEXT[31];
			link.l1.go = "without_money_3";
		break;

		case "without_money_3":
			dialog.snd = "Voice\ENOF\ENOF009";
			dialog.text = DLG_TEXT[32];
			link.l1 = DLG_TEXT[33];
			link.l1.go = "without_money_4";
		break;

		case "without_money_4":
			dialog.snd = "Voice\ENOF\ENOF010";
			dialog.text = DLG_TEXT[34];
			link.l2 = DLG_TEXT[35];
			link.l2.go = "exit";
			ChangeCharacterReputation(pchar, -1);
		break;

		case "sister":
			dialog.snd = "Voice\ENOF\ENOF011";
			dialog.text = DLG_TEXT[36];
			link.l1 = DLG_TEXT[37];
			link.l1.go = "exit";
			characters[GetCharacterIndex("Virginie d'Espivant")].dialog.currentnode = "speak_2";
			AddDialogExitQuest("virginie_speak");
			Dialog.TempNode = "first time";
		break;

		//ccc Survival ->
		case "survival":
			dialog.text = DLG_TEXT[52];
			link.l1 = DLG_TEXT[40];
			link.l1.go = "survival1";
		break;

		case "survival1":
			dialog.text = DLG_TEXT[41];
			link.l1 = DLG_TEXT[42];
			link.l1.go = "survival2";
		break;


		case "survival2":
			dialog.text = DLG_TEXT[43];
// KK -->
			if (GetCharacterShipType(PChar) != SHIP_NOTUSED) {
				link.l1 = DLG_TEXT[44];
				link.l1.go = "survival3";
			} else {
				link.l1 = DLG_TEXT[48];// MAXIMUS [was 47]
				link.l1.go = "survival4";
			}
// <-- KK
		break;

		case "survival3":
// KK -->//changed by MAXIMUS string GetCharacterShipLocation(ref rChar) declared in locations.c
			ShipLocationName = LanguageConvertString(tmpLangFileID, GetCharacterShipLocationName(PChar));
			Preprocessor_Add("island_name", XI_ConvertString(GetIslandNameByLocationID(PChar.location)));
			if (CheckAttribute(&Locations[FindLoadedLocation()], "townsack")) Preprocessor_Add("town_name", GetTownName(Locations[FindLoadedLocation()].townsack));
			ShipLocationName = PreprocessText(ShipLocationName);
			Preprocessor_Remove("island_name");
			Preprocessor_Remove("town_name");
			if (HasSubStr(ShipLocationName, "port"))
				dialog.text = DLG_TEXT[45] + ShipLocationName + DLG_TEXT[47];
			else
				dialog.text = DLG_TEXT[45] + DLG_TEXT[46] + ShipLocationName + DLG_TEXT[47];
// <-- KK
			link.l1 = DLG_TEXT[48];
			link.l1.go = "survival4";
		break;

		case "survival4":
			dialog.text = DLG_TEXT[49];
			link.l1 = DLG_TEXT[50];
			link.l1.go = "exitS";
		break;

// KK -->
		case "Blaze_must_escape":
			dialog.text = DLG_TEXT[53];
			link.l1 = DLG_TEXT[54];
			link.l1.go = "Blaze_must_escape_1";
		break;

		case "Blaze_must_escape_1":
			dialog.text = DLG_TEXT[55] + XI_ConvertString("cap"+GetNationDescByType(GetCurrentLocationNation())) + DLG_TEXT[56] + GetTownName(GetTownIDFromLocID(PChar.location)) + DLG_TEXT[57];
			link.l1 = DLG_TEXT[58];
			link.l1.go = "Blaze_must_escape_2";
		break;

		case "Blaze_must_escape_2":
//			shiploc = GetCharacterShipLocation(PChar);//changed by MAXIMUS string GetCharacterShipLocation(ref rChar) declared in locations.c
			ShipLocationName = GetCharacterShipLocationName(PChar);//shiploc;
//			if (HasSubStr(ShipLocationName, " on")) ShipLocationName = strcut(ShipLocationName, 0, findSubStr(ShipLocationName, " on", 0));
			if (HasSubStr(ShipLocationName, "port")) dialog.text = DLG_TEXT[59] + LanguageConvertString(tmpLangFileID,ShipLocationName) + DLG_TEXT[60];
			else dialog.text = DLG_TEXT[59] + DLG_TEXT[46] + LanguageConvertString(tmpLangFileID,ShipLocationName) + DLG_TEXT[60];
			link.l1 = DLG_TEXT[61];
			link.l1.go = "ExitS";
		break;

		case "ExitS":
			DialogExit();
			NextDiag.CurrentNode = NextDiag.TempNode;

			NPChar.greeting = curGreeting;// MAXIMUS

			AddDialogExitQuest("ResurrectionEvent_OfficiantLeaves"); // KK
		break;
// <-- KK

		//ccc Survival <-

	}
	LanguageCloseFile(tmpLangFileID);
}
