//#include "DIALOGS\Bootstrap Bill Turner_dialog.h"

void ProcessDialogEvent()
{
	ref NPChar;
	aref Link, NextDiag;

	DeleteAttribute(&Dialog,"Links");

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

	ref PChar;
	PChar = GetMainCharacter();

	
	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";
			Dialog.snd = "voice\PEDI\PEDI001";
			
			dialog.text = DLG_TEXT[0];
			link.l1 = DLG_TEXT[1];
			link.l1.go = "exit";

// -->SJG This is temporary dialog till Davy Jones character is done

			if (pchar.quest.main_line == "speak_with_peasant" && CheckCharacterItem(Pchar,"EITC_Passport"))
			{
				Dialog.snd = "voice\PEDI\PEDI002";
				Dialog.Text = DLG_TEXT[9];
				Link.l1 = DLG_TEXT[10];
				Link.l1.go = "ForDavyJones";
			}
			if (pchar.quest.main_line == "speak_with_peasant" && !CheckCharacterItem(Pchar,"EITC_Passport"))
			{
				Dialog.snd = "voice\PEDI\PEDI002";
				Dialog.Text = DLG_TEXT[2];
				Link.l1 = DLG_TEXT[3];
				Link.l1.go = "node_2";
			}
// SJG This is to get off marooned island
			if (pchar.quest.Beckett == "Barbossa_enacts_Mutiny")
			{
				Dialog.snd = "voice\PEDI\PEDI002";
				Dialog.Text = DLG_TEXT[28];
				Link.l1 = DLG_TEXT[29];
				Link.l1.go = "freeatlast";
			}
// <--SJG
			NextDiag.TempNode = "first time";
		break;

		case "node_2":
			Dialog.snd = "voice\PEDI\PEDI003";
			dialog.text = DLG_TEXT[4];
			link.l1 = DLG_TEXT[5];
			link.l1.go = "node_3";
		break;

		case "node_3":
			Dialog.snd = "voice\PEDI\PEDI004";
			dialog.text = DLG_TEXT[6];
			link.l1 = DLG_TEXT[7];
			link.l1.go = "exit";
			pchar.quest.main_line = "after_speak_with_peasant";
		break;

		case "Exit":
			DialogExit();
			NextDiag.CurrentNode = NextDiag.TempNode;
			EndQuestMovie();TrackQuestMovie("end","peasant_dialog.c -> Exit");
		break;

// -->SJG


		case "ForDavyJones":
			dialog.text = DLG_TEXT[11];
			link.l1 = DLG_TEXT[12];
			link.l1.go = "ForDavyJones2";
		break;

		case "ForDavyJones2":
			dialog.text = DLG_TEXT[13];
			link.l1 = DLG_TEXT[14];
			link.l1.go = "ForDavyJones3";
		break;

		case "ForDavyJones3":
			dialog.text = DLG_TEXT[15];
			link.l1 = DLG_TEXT[16];
			link.l1.go = "ForDavyJones4";
		break;

		case "ForDavyJones4":
			dialog.text = DLG_TEXT[17];
			link.l1 = DLG_TEXT[18];
			link.l1.go = "ForDavyJones5";
			ExchangeCharacterShip(Pchar, characterFromID("Barbossa"));
		break;

		case "ForDavyJones5":
			dialog.text = DLG_TEXT[19];
			link.l1 = DLG_TEXT[20];
			link.l1.go = "ForDavyJones6";
			link.l2 = DLG_TEXT[21];
			link.l2.go = "ForDavyJones8";
		break;

		case "ForDavyJones6":
			dialog.text = DLG_TEXT[22];
			link.l1 = DLG_TEXT[23];
			link.l1.go = "ForDavyJones7";
			SetCharacterShipLocation(Pchar, "Douwesen_shore_01");
		break;

		case "ForDavyJones7":
			dialog.text = DLG_TEXT[24];
			link.l1 = DLG_TEXT[25];
			link.l1.go = "ForDavyJones9";
			GiveShip2Character(pchar,"BlackPearl","Black Pearl",PIRATE,false,false); // PB
		break;

		case "ForDavyJones8":
			LAi_Fade("ForDavyJones8","");
			dialog.text = DLG_TEXT[26];
			link.l1 = DLG_TEXT[27];
			link.l1.go = "ForDavyJones9";
			pchar.ship.name = characters[GetCharacterIndex("BlackPearl")].ship.name;
			SetCharacterShipLocation(characterFromID("BlackPearl"), "Douwesen_shore_01");
			EnableEquip(pchar, BLADE_ITEM_TYPE, true);
			EnableEquip(pchar, GUN_ITEM_TYPE, true);
			EquipCharacterByItem(pchar, FindCharacterItemByGroup(pchar, BLADE_ITEM_TYPE));
			EquipCharacterByItem(pchar, FindCharacterItemByGroup(pchar, GUN_ITEM_TYPE));

		break;

		case "ForDavyJones9":
			SetQuestHeader("Davy Jones");
			AddQuestRecord("Davy Jones","1");
			DialogExit();
			NextDiag.CurrentNode = NextDiag.TempNode;
			EndQuestMovie();TrackQuestMovie("end","peasant_dialog.c -> Exit");
		break;

		case "freeatlast":
			dialog.text = DLG_TEXT[30];
			link.l1 = DLG_TEXT[31];
			link.l1.go = "freeatlast2";
			EnableEquip(pchar, BLADE_ITEM_TYPE, true);
			EnableEquip(pchar, GUN_ITEM_TYPE, true);
			EquipCharacterByItem(pchar, FindCharacterItemByGroup(pchar, BLADE_ITEM_TYPE));
			EquipCharacterByItem(pchar, FindCharacterItemByGroup(pchar, GUN_ITEM_TYPE));
		break;

		case "freeatlast2":
			dialog.text = DLG_TEXT[32];
			link.l1 = DLG_TEXT[33];
			link.l1.go = "freeatlast3";
		break;


		case "freeatlast3":
			dialog.text = DLG_TEXT[34];
			link.l1 = DLG_TEXT[35];
			link.l1.go = "freeatlast4";        
			Locations[FindLocation("Douwesen_shore_01")].reload.l2.disable = false;
			Locations[FindLocation("Douwesen_shore_01")].reload.l3.disable = false;

		break;

		case "freeatlast4":
			dialog.text = DLG_TEXT[36];
			link.l1 = DLG_TEXT[37];
			link.l1.go = "freeatlast5";
		break;

		case "freeatlast5":
			dialog.text = DLG_TEXT[38];
			link.l1 = DLG_TEXT[39];
			link.l1.go = "freeatlast6";
		break;

		case "freeatlast6":
			dialog.text = DLG_TEXT[40];
			link.l1 = DLG_TEXT[41];
			link.l1.go = "freeatlast7";
		break;

		case "freeatlast7":
			dialog.text = DLG_TEXT[42];
			link.l1 = DLG_TEXT[43];
			link.l1.go = "freeatlastExit";
		break;

		case "freeatlastexit":
			DialogExit();
			NextDiag.CurrentNode = NextDiag.TempNode;
			AddDialogExitQuest("peasantwandersoff");
		break;
// <--SJG
	}
}
