void ProcessDialogEvent()
{
	ref NPChar, crew;
	aref Link, Diag;
	int con;
	string loc;

	DeleteAttribute(&Dialog,"Links");

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

	ref PChar;
	PChar = GetMainCharacter();
	int loc_id = FindLocation(PChar.location);

	switch(Dialog.CurrentNode)
	{
		case "exit":
			Diag.CurrentNode = Diag.TempNode;
			DialogExit();
		break;

		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\PADI\PADI001";

				switch(makeint(Npchar.nation))
				{
					case 0 : if(Npchar.sex=="man"){PlaySound("VOICE\" + LanguageGetLanguage() + "\Eng_m_b_005.wav");}else{PlaySound("VOICE\" + LanguageGetLanguage() + "\Eng_f_c_003.wav");}break;
					case 1 : if(Npchar.sex=="man"){PlaySound("VOICE\" + LanguageGetLanguage() + "\Fre_m_c_001.wav");}else{PlaySound("VOICE\" + LanguageGetLanguage() + "\Fra_f_a_003.wav");}break;
					case 2 : if(Npchar.sex=="man"){PlaySound("VOICE\" + LanguageGetLanguage() + "\Spa_m_b_003.wav");}break;
					case 3 : if(Npchar.sex=="man"){PlaySound("VOICE\" + LanguageGetLanguage() + "\Por_m_a_001.wav");}break;
					case 4 : if(Npchar.sex=="man"){PlaySound("VOICE\" + LanguageGetLanguage() + "\Dut_m_a_003.wav");}else{PlaySound("VOICE\" + LanguageGetLanguage() + "\Dut_f_a_003.wav");}break;
					case 5 : if(Npchar.sex=="man"){PlaySound("VOICE\" + LanguageGetLanguage() + "\Por_m_b_004.wav");}break;
				}

				Dialog.Text = DLG_TEXT[0];
				Link.l1 = DLG_TEXT[1];
				Link.l1.go = "exit";
				Link.l2 = DLG_TEXT[2];
				Link.l2.go = "weapons";
				Link.l3 = DLG_TEXT[3];
				Link.l3.go = "clothesyou";
				if(MAX_CREWMEMBERS>0)
				{
					Link.l4 = DLG_TEXT[7];
					Link.l4.go = "returntoshipalone";
				}
				Link.l5 = DLG_TEXT[4];
				Link.l5.go = "returntoship";
				if(loc_id != -1 && locations[loc_id].type == "Jungle" || locations[loc_id].type == "KR_Jungle" || locations[loc_id].type == "KR_Jungle1" || locations[loc_id].type == "Seashore")
				{
					if (makeint(environment.time) >= 21.0 || makeint(environment.time) < 8.0)
					{
						link.l6 = DLG_TEXT[8];
						link.l6.go = "camp_day";
					}
					else
					{
						link.l6 = DLG_TEXT[9];
						link.l6.go = "camp_night";
					}
				}
				Diag.TempNode = "first time";
		break;

		case "install_camp":
			Dialog.text = DLG_TEXT[10];
			link.l1 = DLG_TEXT[11];
			link.l1.go = "exit";
			AddGeometryToLocation(PChar.location, "smg");
		break;

		case "camp_day":
			Dialog.text = DLG_TEXT[10];
			link.l1 = DLG_TEXT[11];
			link.l1.go = "camp_day_wait";
			link.l2 = DLG_TEXT[12];
			link.l2.go = "exit";
		break;

		case "camp_night":
			Dialog.text = DLG_TEXT[10];
			link.l1 = DLG_TEXT[13];
			link.l1.go = "camp_night_wait";
			link.l2 = DLG_TEXT[12];
			link.l2.go = "exit";
		break;

		case "camp_night_wait":
			DialogExit();
			TavernWaitDate("wait_night");
			PlaySound("objects\abordage\abordage_loosing.wav");
			Whr_UpdateWeather(false);

		break;

		case "camp_day_wait":
			DialogExit();
			TavernWaitDate("wait_day");
			PlaySound("NATURE\cricket.wav");
			PlaySound("NATURE\fireplace1.wav");
			PlaySound("AMBIENT\town\cough.wav");
			PlaySound("AMBIENT\tavern\man1.wav");
			PlaySound("AMBIENT\tavern\open_bottle.wav");
			Whr_UpdateWeather(false);
		break;

		case "weapons":
			DialogExit();
			LaunchCharacterItemChange(NPChar);
		break;

		case "clothesyou":
			DialogExit();
			LaunchKAMSelectOfficerModel(sti(NPChar.index)); // KK
		break;

		case "returntoshipalone":
			Dialog.Text = DLG_TEXT[5];
			Link.l1 = DLG_TEXT[14];
			Link.l1.go = "exit_alone";
		break;

		case "returntoship":
			Dialog.Text = DLG_TEXT[5];
			Link.l1 = DLG_TEXT[6];
			Link.l1.go = "exit_return";
		break;

		case "exit_return":
			for(con =  1; con <= 10 ; con++)
			{
				crew = characterFromID("Treas_Crewmember_" + con);
				if(Lai_IsDead(crew)){RemoveCharacterCrew(PChar,1); LAi_SetHP(crew, PChar.chr_ai.hp_max, PChar.chr_ai.hp);}
				loc = LAi_FindRandomLocator("reload");
				LAi_SetActorType(crew);
				LAi_ActorRunToLocation(crew, "reload", loc, "None", "reload", "", "", 20.0);
			}
			LANDCREWMEMBERS = false;
			DialogExit();
		break;

		case "exit_alone":
			if(MAX_CREWMEMBERS>1){MAX_CREWMEMBERS=MAX_CREWMEMBERS-1;}
			loc = LAi_FindRandomLocator("reload");
			LAi_SetActorType(Npchar);
			LAi_ActorRunToLocation(Npchar, "reload", loc, "None", "reload", "", "", 20.0);
			DialogExit();
		break;
	}
}
