"use strict";

DATA_SDS_DIALOGUE["Fred_c1_advice_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Fred",
		script: [
			{command:"buffer", text:"Sorry, miss.  I'd love to let you out, but the gate's broken.  I've told Ned about it, so it should be fixed soon.\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Fred_c1_trapped_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Fred",
		script: [
			{command:"buffer", text:"Wow, I remember the night I stuck that rock up there!  Who knew it would cause this much trouble nine months later?\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"Anyway, it's out, so my job's done!  Gotta go!\n"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Fred_c1_quake_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Fred",
		script: [
			{command:"buffer", text:"I'd just finished fixing the gate for Ned, but that last earthquake jammed it closed again.  You'll have to wait a bit longer, I'm afraid.\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Fred_c1_hurry_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Fred",
		script: [
			{command:"buffer", text:"We'd almost figured out how to move the boulders and get Guy out, when suddenly he just burst out on his own!\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Fred_c1_boss_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Fred",
		script: [
			{command:"buffer", text:"Now you've done it.  All that fighting broke the gate completely off its track.  I don't think we can fix it...\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Fred_c2_leaving_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Fred",
		script: [
			{command:"buffer", text:"Ned's going to start work on the new gate soon; until then we've both got to keep watch.\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Fred_c5_advice_0"]=
	{ 
		x: DEFINE_DIALOGUE_BOX_UPPER.x,
		y: DEFINE_DIALOGUE_BOX_UPPER.y,
		width: DEFINE_DIALOGUE_BOX_UPPER.width,
		height: DEFINE_DIALOGUE_BOX_UPPER.height,
		pauses: false,
		blocks: true,
		title: "Meli",
		script: [
			{command:"buffer", text:"(All I do is break stuff and make his job harder.  I should just leave.)\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

Dialogue_getCurrentEvent["Fred"] = function(){
		var retval = null;
		var line = 0;
		if (GLOBAL_SCRATCHPAD.check("Dlg_Fred_Line")){
			line = GLOBAL_SCRATCHPAD.check("Dlg_Fred_Line");
		}

		if (GLOBAL_DIARY.check(5,"BOSS",true)){
			retval = "GD_Fred_c2_leaving_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(5,"AWAKE")){
			retval = "GD_Fred_c5_advice_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(2,"LEAVING_HOME")){
			retval = "GD_Fred_c2_leaving_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(1,"BOSS")){
			retval = "GD_Fred_c1_boss_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(1,"HURRY")){
			retval = "GD_Fred_c1_hurry_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(1,"SHRINEQUAKE")){
			retval = "GD_Fred_c1_quake_"+line;
			line = Math.min(line+1,0);
		}
		else{ // nothing to say
			retval = "GD_Fred_c1_advice_"+line;
			line = Math.min(line+1,0);
		}
		GLOBAL_SCRATCHPAD.note("Dlg_Fred_Line",line);
		return retval;
	};
	
	