"use strict";
DATA_SDS_DIALOGUE["Ernest_c2_grace_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: "Ernest",
		script: [
			{command:"buffer", text:"Oh?\n"},			//0
			{command:"wait"},
			{command:"clear"},
			{command:"buffer", text:"Ah; it's you.  What's up?  Looking for the bay shrine?\n"},			//2
			{command:"wait"},
			{command:"buffer", text:"This place looks like a shrine, doesn't it?  But no, it isn't.  Not since a lifetime and a half ago.\n"},			//4
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c2_grace_1"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"This building used to be the landchildren's shrine for the Goddess' Bracelets.  ...  Looks like I can skip the lesson on the Bracelets and what they do, eh?\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"The story goes that back when the Gargoyle broke out, the resultant seismic disruptions sunk the whole shrine into the bay, and collapsed half of it.\n"},			//2
			{command:"wait"},
			{command:"buffer", text:"Our local hero kicked off her career by rescuing the shrinekeeper, and took the Bracelets as thanks.\n"},			//4
			{command:"wait"},
			{command:"buffer", text:"Later on, she used the Bracelets and a mighty trident to pulverize the Gargoyle into all that stone kibble you see outside.\n"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c2_grace_2"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"After the war, all sides agreed that warship Nautilus, sunk in combat but nearly intact, would be a suitable replacement shrine.\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"And so we seachildren took control of both the landchildren's Bracelets and our village's original Treasure.\n"},
			{command:"wait"},
			{command:"buffer", text:"Come to think of it, I don't know why the two Treasures ended up eventually switching places...\n"},
			{command:"wait"},
			{command:"buffer", text:"I suspect Rinda just had both, took a liking to the Bracelets, and pulled a fast one on Melody when she came of age!\n"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c2_grace_3"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"Melody?  She came by not long ago; she can't be too far away.  Why don't you ask Grace?\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

// wherein Ernest used a smaller casting from an earlier dig to lure the thief back
DATA_SDS_DIALOGUE["Ernest_c2_grace_4"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"That reminds me- thank my Lela if you see her!  Using the girl as bait... what a plan!\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c2_grace_5"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"Melody?  She came by not long ago; she can't be too far away.  Why don't you ask Grace?\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c2_treasure_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: "Ernest",
		script: [
			{command:"buffer", text:"Tracked down the Necklace, did you?\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"You know, I've heard there's one more shrine still standing above water, somewhere in the eastern forest.\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"... Say, you think I could borrow the Necklace for a bit?  I'd love to go see how that shrine compares with this one!\n"},
			{command:"chooseH", choices:{"Sorry...":6, "Be my guest!":10}},
			{command:"clear"},
			{command:"buffer", text:"Ah, well.  Had to ask.  Maybe I'll get to see it later.\n"},
			{command:"wait"},
			{command:"return", retval:0},
			{command:"clear"},
			{command:"buffer", text:"Really?!  Thank- wait, did you say smoke?  Monsters?  Ghosts??  Finding the Goddess???\n"},
			{command:"wait"},
			{command:"buffer", text:"That's... a bit over my level of commitment.  You hang onto the Necklace.  I think I'll be content here until this all blows over.\n"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c2_treasure_1"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"Ah, well.  It's not as if I've run out of work to do here.\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c3_treasure_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: "Ernest",
		script: [
			{command:"buffer", text:"Wait, there's a whole water complex in the forest?\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"And it's connected to a dry tunnel that comes out just behind the village??\n"},
			{command:"wait"},
			{command:"buffer", text:"Of a similar construction to the village shrine???\n"},
			{command:"wait"},
			{command:"clear"},
			{command:"buffer", text:"You know, I may just be wanting that necklace after all!\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_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:"(He looks busy.  I'd only be bothering him.)\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_c5_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: "Ernest",
		script: [
			{command:"buffer", text:"Hey there!  Haven't seen you around lately.  Notice anything different?\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};
DATA_SDS_DIALOGUE["Ernest_c5_boss_1"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"I finally got the shrine's statues put back in!\n"},			//0
			{command:"wait"},
			{command:"buffer", text:"Both of them are replicas, though.  The originals were very nearly stolen shortly before you came to the village.\n"},
			{command:"wait"},
			{command:"buffer", text:"I was so alarmed when the Goddess went missing that I dug the Hero out of storage and set it up hoping to lure the thieves back and catch them in the act.\n"},
			{command:"wait"},
			{command:"buffer", text:"The plan worked, and we recovered both originals, but until we can get this place cleaned up and properly staffed, history can't risk us having anything but copies on public display!"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};
DATA_SDS_DIALOGUE["Ernest_c5_boss_2"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"Anyway, if you want to know more about either statue, just take a peek.\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Ernest_statue_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: "Ernest",
		script: [
			{command:"buffer", text:"That's our Goddess' form, when she manifests in our world... if history is to be believed.\n"},			//0
			{command:"wait"},
			{command:"clear"},
			{command:"buffer", text:"I wish she'd chosen something smaller- I already had to cast these replica statues in sections, but even the Goddess' tail alone must weigh as much as Lela and I combined!\n"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};
DATA_SDS_DIALOGUE["Ernest_statue_1"]=
	{ 
		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: "Ernest",
		script: [
			{command:"buffer", text:"Behold, the legendary hero of the Gargoyle Crisis!  A... somewhat newer statue than the Goddess.\n"},			//0
			{command:"wait"},
			{command:"clear"},
			{command:"buffer", text:"At least, the original is newer.  I actually made the Hero replica first as practice for the Goddess.\n"},
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

DATA_SDS_DIALOGUE["Meli_statue_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:"(... the Goddess?  Is this statue new, or have I just been unforgivably oblivious?)\n"},			//0
			{command:"wait"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};
DATA_SDS_DIALOGUE["Meli_statue_1"]=
	{ 
		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:"(A girl about my age...  She looks familiar, somehow, but I could swear I haven't even seen this statue before...)\n"},			//0
			{command:"wait"},
			{command:"clear"},
			{command:"return", retval:0},
		] // an array of options/commands which will be evaluated in sequence
	};

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

		if (GLOBAL_DIARY.check(5,"BOSS",true)){
			retval = "GD_Ernest_c5_boss_"+line;
			line = Math.min(line+1,2);
		}
		else if (GLOBAL_DIARY.check(5,"AWAKE")){
			retval = "GD_Ernest_c5_advice_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(3,"TREASURE")){
			retval = "GD_Ernest_c3_treasure_"+line;
			line = Math.min(line+1,0);
		}
		else if (GLOBAL_DIARY.check(2,"TREASURE")){
			retval = "GD_Ernest_c2_treasure_"+line;
			line = Math.min(line+1,1);
		}
		else{
			retval = "GD_Ernest_c2_grace_"+line;
			line = Math.min(line+1,5);
		}
		GLOBAL_SCRATCHPAD.note("Dlg_Ernest_Line",line);
		return retval;
	};
