void ProcessDialogEvent()
{
	ref NPChar, PChar, d;
	PChar = GetMainCharacter();
	aref Link, Diag;
	string NPC_Meeting;

	DeleteAttribute(&Dialog,"Links");

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

	string iDay, iMonth;
	iDay = environment.date.day;
	iMonth = environment.date.month;
	string lastspeak_date = iday + " " + iMonth;
	
	switch(Dialog.CurrentNode)
	{
		// -----------------------------------|иалог первый - первая встреча
		case "First time":
			Dialog.defAni = "Gov_Dialog_1";
			Dialog.ani = "Gov_Dialog_1";
			Dialog.defCam = "1";
			Dialog.defSnd = "dialogs\0\017";
			Dialog.defLinkAni = "dialog_1";
			Dialog.defLinkCam = "1";
			Dialog.defLinkSnd = "dialogs\woman\024";
			Dialog.cam = "1";
			
			if(TradeCheck(PChar, NPChar, true)) { // NK
			if(NPChar.quest.meeting == "0")
			{
				Dialog.snd = "voice\ROMU\ROMU001";
				d.Text = TimeGreeting() + DLG_TEXT[0] + GetMyFullName(NPChar) + DLG_TEXT[1];
				Link.l1 = DLG_TEXT[2] + GetMyFullName(PChar) + DLG_TEXT[3] + PChar.Ship.name + DLG_TEXT[4];
				Link.l1.go = "meeting";
				NPChar.quest.meeting = "1"; 
			}
			else
			{
				Dialog.snd = "voice\ROMU\ROMU002";
				d.Text = TimeGreeting() + DLG_TEXT[5] + GetMyName(Pchar) + DLG_TEXT[6] + GetMyAddressForm(NPChar, PChar, ADDR_CIVIL, false, false) + DLG_TEXT[7];
				Link.l1 = DLG_TEXT[8];
				Link.l1.go = "Shipyard";
				Link.l2 = DLG_TEXT[9];
				Link.l2.go = "quest lines";
				Link.l3 = DLG_TEXT[10];
				Link.l3.go = "exit";
			}
			// NK -->
			}
			else
			{
				dialog.text = DLG_TEXT[27] + GetMyAddressForm(NPChar, PChar, ADDR_CIVIL, false, false) + DLG_TEXT[28];
				Link.l1 = DLG_TEXT[29];
				Link.l1.go = "exit";
				if(sti(PChar.Skill.Commerce)>=5)
				{
					Link.l2 = TranslateString("","high_trade_1");
					Link.l2.go = "high_price";
				}
				Diag.TempNode = "First time";
			}
			// NK <--
		break;

		case "high_price":
			dialog.text = TranslateString("","high_trade_2");
			link.l1 = TranslateString("","high_trade_3");
			link.l1.go = "shipyard_high";
			link.l2 = TranslateString("","high_trade_4");
			link.l2.go = "exit";
			Diag.TempNode = "First time";
		break;

		case "shipyard_high":
			dialog.Text = TranslateString("","high_trade_5");
			Link.l1 = TranslateString("","high_trade_6");
			Link.l1.go = "SHIPYARD_interface_high";
			Link.l2 = TranslateString("","high_trade_7");
			Link.l2.go = "Cannons_interface_high";
			Link.l3 = TranslateString("","high_trade_4");
			Link.l3.go = "Exit";
			Diag.TempNode = "First time";
		break;

		case "SHIPYARD_interface_high":
			Diag.TempNode = "First time";
			if(npchar.quest.Meeting != lastspeak_date)
			{
				FillShipsList(&NPChar); // NK

				npchar.quest.Meeting = lastspeak_date;
			}			
			DialogExit();
			tradeHigh = true;
			setCharacterShipLocation(pchar,"Cuba_port");	//ccc survival
			LaunchShipyard(npchar);
		break;

		case "Cannons_interface_high":
			Diag.TempNode = "First time";
			DialogExit();
			tradeHigh = true;
			setCharacterShipLocation(pchar,"Cuba_port");	//ccc survival
			LaunchCannons();
		break;

		case "Meeting":
				Dialog.snd = "voice\ROMU\ROMU003";
				d.Text = DLG_TEXT[11];
				Link.l1 = DLG_TEXT[12] + GetMyName(NPChar) +DLG_TEXT[13];
				Link.l1.go = "Shipyard";
				Link.l2 = DLG_TEXT[14];
				Link.l2.go = "quest lines";
				Link.l3 = DLG_TEXT[15];
				Link.l3.go = "exit";
		break;

		case "quest lines":
				Dialog.snd = "voice\ROMU\ROMU004";
				d.Text = DLG_TEXT[16] + GetMyName(Pchar) + DLG_TEXT[17];
				Link.l1 = DLG_TEXT[18];
				Link.l1.go = "no quest";
		break;

		case "No quest":
				Dialog.snd = "voice\ROMU\ROMU005";
				d.Text = DLG_TEXT[19] + GetMyName(Pchar) + DLG_TEXT[20];
				Link.l1 = DLG_TEXT[21];
				Link.l1.go = "shipyard";
				Link.l2 = DLG_TEXT[22];
				Link.l2.go = "exit";
		break;

		case "shipyard":
				Dialog.snd = "voice\ROMU\ROMU006";
				d.Text = DLG_TEXT[30] + DLG_TEXT[24];	// ccc 15oct04 shipyard waiting
				//Link.l9 = DLG_TEXT[31];	// ccc - PB: Is this still required?
				//Link.l9.go = "exit";		// ccc
				Link.l1 = DLG_TEXT[24];
				Link.l1.go = "SHIPYARD_interface";
				Link.l2 = DLG_TEXT[25];
				Link.l2.go = "Cannons_interface";

  // Viper - Emblemed Sails v2 Start

//			Link.l3 = "I would like to change my ships' sails";			//commented out by KAM
//			Link.l3.go = "Viper_Sails_Interface";					//commented out by KAM
			Link.l3 = DLG_TEXT[26];							//changed by KAM
			Link.l3.go = "exit";							//changed by KAM

		break;

		case "Viper_Sails_Interface":
			PChar.viper_changesails = true;
			//PostEvent("key_event",500,13,0);
			//NextDiag.CurrentNode = NextDiag.TempNode;
			//DialogExit();
			//Log_SetStringToLog("Select base sails");
			//BLI_EnableShow();
			dialog.Text = DLG_TEXT[32];
			Link.l1 = DLG_TEXT[33];
			Link.l1.go = "Exit";
		break;

  // Viper - Emblemed Sails v2 End

		case "SHIPYARD_interface":
			Diag.CurrentNode = Diag.TempNode;
			if (npchar.quest.Meeting != lastspeak_date)
			{
				FillShipsList(&NPChar); // NK

				npchar.quest.Meeting = lastspeak_date;
			}			
			DialogExit();
			setCharacterShipLocation(pchar,"Cuba_port");	//ccc survival
			LaunchShipyard(npchar);
		break;

		case "CANNONS_interface":
			Diag.CurrentNode = Diag.TempNode;
			DialogExit();
			setCharacterShipLocation(pchar,"Cuba_port");	//ccc survival
			LaunchCannons();
		break;

		case "exit":
			Diag.CurrentNode = Diag.TempNode;
			DialogExit();
		break;
		
	}
}
