void Gideon object# (0x48c) ()
{

	var party = UI_get_party_list();
	var player_name = getAvatarName();
	var polite_title = getPoliteTitle();
	var hour = UI_game_hour();
	var partynum = UI_get_array_size(party);
	var bark;
	var player_is_female;
	var greeting; //When addressing party as plural or singular
	
	var started_talking = UI_get_item_flag(item, READ);
		
	var single_plural;
	
	if (partynum > 1)
		single_plural = "you";
	else
		single_plural = "everyone";
	
	var time_of_day = timeFunction(hour);
	
	//Inn flags / variables
	var GIDEON_INN_PRICE = partynum * 4;
	var checkout = UI_get_item_flag(item, PETRA);
	var hasKey = UI_count_objects(PARTY, SHAPE_KEY, QUALITY_GIDEON_INN, FRAME_ANY);
	var door; 
	var open_doors;
	const int SHAPE_OPEN_DOOR  = 270;
	const int SHAPE_CLOSED_DOOR = 376;
	if (player_is_female) //
	{
	//	noun = "  ";
	//	title = "madame";
	}
	else 
	{
	//	noun = " ";
	//	title = " ";
	}

	if (event == DOUBLECLICK)
	{
		if (partynum > 1) greeting = "friends"; 
			else greeting = "friend"; //Avatar is solo
	
		var av_1st_greet = "@Greetings..@";
		var npc_1st_greet = "@Ah, new people!@";
		var av_2nd_greet  = "@Hello, again.@";
		var npc_2nd_greet = "@Come in, come in!@";	
		
		//call convo script
		startConvo(item, av_1st_greet, npc_1st_greet, av_2nd_greet, npc_2nd_greet); 

	}
	if (started_talking)
	{
		if (checkout)
		{
			item.say("@Good " + time_of_day + ", are you ready to check out?@");
			if (askYesNo())
			{
				if (hasKey)
				{
					say("Gideon serves " + single_plural + " a large breakfast and you hand him the key.");
					say("@Come back anytime, my friend.@");
					UI_add_party_items(partynum, SHAPE_FOOD, QUALITY_ANY, FRAME_EGG, false);
					UI_add_party_items(partynum, SHAPE_BOTTLE, QUALITY_ANY, FRAME_MILK, false);
					UI_remove_party_items(1, SHAPE_KEY, QUALITY_GIDEON_INN, FRAME_ANY, false);
					
					//clear stuff for usecode egg
					UI_clear_item_flag(item, PETRA);
					UI_clear_item_flag(AVATAR, BG_DONT_MOVE);
					
													
					//look for open doors / unlocked doors of quality 24
					var open_doors = UI_find_nearby([0x0ee, 0x641, 0], SHAPE_OPEN_DOOR, 10, MASK_NONE);
					
					//change open doors to closed, locked frame, correct quality
					for (door in open_doors)
					{
						UI_set_item_shape(door, SHAPE_CLOSED_DOOR);
						UI_set_item_frame(door, 2); //locked
						UI_set_item_quality(door, QUALITY_GIDEON_INN);
					}
					
					//find closed doors, make sure they are locked
					var closed_doors = UI_find_nearby([0x0ee, 0x641, 0], SHAPE_CLOSED_DOOR, 10, MASK_NONE);
					for (door in closed_doors)
					{
						UI_set_item_frame(door, 2); //locked
						UI_set_item_quality(door, QUALITY_GIDEON_INN);
					}
					
					
				}	
				else
					say("@Well, where is the key? Perhaps you left it in your room. Come back when you're ready to check out.@");
			//send Gideon back on regular schedule to avoid loop
				UI_clear_item_flag(AVATAR, BG_DONT_MOVE);
				UI_run_schedule(item);
				return;	
			}	
			else
				say("@Okay just let me know when you're ready to check out.@");
				UI_clear_item_flag(AVATAR, BG_DONT_MOVE);
				return;
		}
		
	
		
		if (!UI_get_item_flag(item, MET))
		{
			item.say("A man bent over with age. An old brown tunic hangs loosely on him. He looks at you, then looks over his shoulder and shouts to someone behind him.*");
			item.say("@There, I told you, Marta. New people, new food for our souls.@ He turns back to you. @Welcome to the Haunting Inn. Come and sit, for you must have many tales.@");
			UI_set_item_flag(item, MET);
		}
		else
		{
			item.say("@Is it you," + player_name + "? he says, leaning close and staring you in the eyes.@");
			item.say("@Of course it is! Welcome back, traveler.@");
		}

			var options = ["name", "job", "bye"];
		
	
		if (UI_get_item_flag(LORD_BRITISH, MET))
			add ("Lord British");
		
		if (UI_get_item_flag(TRENTON, MET))
			add ("Trenton Bell");

		if (UI_get_item_flag(DEZANA, MET))
			add ("Dezana");
			
		if (UI_get_item_flag(MARTA, MET))
			add ("Marta");			

		//set when you use Seance on Quenton
		if (gflags[LEARNED_MICHAEL_NAME])
			add("Michael");
			
		if (UI_get_item_flag(STIVIUS, MET))
			add ("Stivius");

	/////////////////////////////////////////////////////////////////////


	/////////////////////////////////////////////////////////////////////


			converse(options)
			{
				case "name"(remove): 
					say("@Gideon, my friend, Gideon's what I'm called by one and all.@*");
					add(["Gideon"]); 

				case "job"(remove):
					say("@My wife would say it is to annoy the customers with idle banter. She's dear. I have rooms for let.@");
					add(["banter", "rooms"]); 

				case "Gideon"(remove):
					say("@Tis an old family name meaning 'one who spreads the word.' My wife tells me I spread too many of them around.@");
					add(["word", "wife"]);
					
				case "wife"(remove): 
					say("@When I was a young man I visited the shrine to contemplate an emptiness I felt inside. Marta was there, so beautiful and shy.@");
					say("@We sat in silence together for hours. Finally, she could take no more and turned and kissed me.@*");
					say("A shout comes from the room behind him. He answers, @No, Marta, our guests are not asleep yet.@*");
					add(["Marta", "shrine"]);

				case "word"(remove):
					say("@The word I spread is one of kindness to all souls!@");

				case "shrine"(remove): 
					say("@The shrine of Spirituality. It is where we go when we are troubled. You should visit it sometime.@*");
					
				case "Marta"(remove): 
					say("@She hasn't come out of that room since she saw that darn ghost in the dining room a few nights ago.@*");
					say("@She told me the lanterns went out and a spectre drifted in front of her. She let out such a scream that I heard her from our bedroom.@*");
					say("He shakes his head and glances at the room behind him.*");
					add(["ghost"]); 


				case "ghost"(remove): 
					say("@My Marta doesn't spook that easy. After all, she's woke up next to me all these years. At first I thought maybe I should lock the cupboard where we keep the wine.@*");
					say("@But I don't think my Marta's been nippin'. I wish I knew what she saw.*");
					if (!gflags[LEARNED_ABOUT_QUENTON])
						gflags[LEARNED_ABOUT_QUENTON] = true; //set so you can ask others about ghost
					
					add(["cupboard"]); 


				case "cupboard"(remove): 
					say("@If you've never had Stivius' wine, you're in for a treat.@*");
					add(["Stivius"]); 


				case "Stivius"(remove): 
					say("@He lives next door. Strange fellow...I think he's sampled too much of his own wares.@*");
					
				case "rooms"(remove): 
					say("@" + GIDEON_INN_PRICE + " gold for a room and a meal. Interested?@");
					if (askYesNo())
					{
						if (hasGold(GIDEON_INN_PRICE))
						{
							if (UI_add_party_items(1, SHAPE_KEY, QUALITY_GIDEON_INN, 7, false))
							{
								chargeGold(GIDEON_INN_PRICE);
								say("@Enjoy your room, be sure to stop by for breakfast at checkout!@");
								UI_set_item_flag(item, PETRA);
								break;
							}
							else
								say("@You don't have room for the key.@");
						}
						else
						{
							say("@I'm sorry, but we require cash in advance for our rooms.@");
							break;
						}
					}
					else 
						say("@Perhaps some other time, then.@");
					
				case "banter"(remove): 
					say("@I'm sure by now you've heard such banter about old Quenton. He was a dear soul.@ Gideon looks past you into the distance.*");
					say("@I could not believe it was him by the well.@ His eyes become watery. @He lay so quiet, no sign of pain on his face, and just an amulet in his bloody hand.*@");
					say("He looks at the floor and mumbles. @Quen, I miss you, old mate.@*");
					add(["amulet", "Quenton"]); 


				case "word"(remove): 
					say("@The word I spread is one of kindness to all souls!@*");
	
				case "tales"(remove): 
					say("@Yes, let us swap stories for a while...@*");
		
				case "Haunting Inn"(remove): 
					say("@That name used to be just words. But now, with what Marta saw...@*");
					add(["Marta"]); 


				case "amulet"(remove): 
					say("@We went and told Yorl what had happened. When he returned with us to the well, he removed the amulet from Quenton's hand and took it to Marney.@*");
					say("@It took courage to tell her the news.@*");
					add("Yorl");
	
			//wording about Mondain altered for quest and fixing that glaring inconsistency!
				case "Quenton"(remove): 
					say("@We came to this island many years ago. As children we'd take the boats and race around the point. Marta and I took care of him when pirates sailing under Mondain's flag killed his wife Gwen.@*");
					say("@We care for his daughter, Marney, now. She's such a brave girl.@ He pauses a moment then continues.");
					say("@Neither I nor the travelers staying here heard anything the night he was killed.@*");
					add(["Mondain", "Gwen", "travelers", "Marney", "killed"]); 

				case "Mondain"(remove): 
					say("@Yes, Quenton and Yorl were out fishing when a few of those evil ones landed here. They were fleeing Lord British's men and apparently thought our hamlet was safe haven.@*");
					say("@Their ship's sail bore the crest of Mondain. They went around asking for some person named Relthor, or Renthar... something like that.@*");
					add(["Renthar"]); 

				case "Gwen"(remove): 
					say("@She was an angel to view. Blonde hair, green eyes, tall slender body. Marney could be her twin. I can still see Elisa's brave face as the men led her to their boat.@*");
					say("@They said that after she got them past their pursuers she would be freed.@ He hides his face in his hands. Our beliefs held us still.@*");
					say("@She turned and handed something to her crying little girl. Then she boarded the skiff, and they were gone.@*");
					add(["Marney", "boarded", "something"]); 

				case "travelers"(remove): 
					say("@I questioned them about the night of the murder. Still, of all of us, my Marta and I had the best vantage point from which to witness, or even hear, the murder.@*");
					say("@Still, of all of us, my Marta and I had the best vantage point from which to witness, or even hear, the murder.@");
					say("@Yet we saw and heard nothing.@");

				case "Marney"(remove): 
					if (gflags[FAILED_QUENTON_QUEST])
						say("@She is still missing. I pray she will be found safe.@ He wipes his eyes.");
					else
					{
						say("@She, like her mother, is strong in her beliefs. When we buried her father, she sang a song she wrote for him.@ He softly sings.*");
						say("@'You put your love in my heart, and now it's fallen apart, but all alone in the dark, I will remove the pain.'@");
						say("@'There is a sting in my eyes, and your name in my cries, but still I realize, that you are part of me.'@*");
						add(["beliefs"]); 
					}
				case "killed"(remove): 
					say("He looks at you a moment, then leans closer. @They say that Quenton was killed by a Gargoyle.@");
					say("@I've heard these beasts eat their prey. Why did they leave Quenton alone then?*");
				
				case "beliefs"(remove): 
					say("@We are a peaceful people. We believe that all men have hearts that can possess either good or evil.@*");
					say("@These evil ones believed that by tearing down others, they could become more powerful.@*");
					say("@The truth is, when you tear down another's ladder you become no higher, they just become lower. It is harder to build your ladder on your own, but you will see farther in the end.@*");
				
				case "boarded"(remove): 
					say("@Gwen bowed her head as they sailed off.@ He looks absently at the floor and attempts to clear his throat.");
					say("Speaking again, his voice is a whisper. @They found her body along the coast south of here.@*");
					add(["coast"]); 

				case "something"(remove): 
					say("@I couldn't see what it was.@*");
							
					
				case "coast"(remove): 
					say("He looks at you, his eyes red and his lip quivering. He simply nods.*");
					
				case "Trenton Bell"(remove): 
					say("@He means well, it's just his attitude is all wrong for the job. He should spend some time in New Magincia.@*");					
					add("New Magincia");
					
				case "New Magincia"(remove):
					say("@You should sail there someday.@");
					
				case "Renthar" (remove):
					if (!gflags[QUENTON_MURDER_SOLVED])
						say("@We had no such person in this town. Not by that name.@");
					else
						say("@We have welcomed into this town, so that he may continue his path to Spirituality. He is staying with us as long as he wants to, such a good soul.@");
						
					
				case "Yorl"(remove):
					say("His eyes light up. @He is one of the friendliest people in this hamlet. You must go see him, down by the pier. He's been like a father to Marney.@");	

				case "Michael"(remove):
					if (!gflags[QUENTON_MURDER_SOLVED])
					{	
						say("@Now there's a sad soul. He was so young when he got tangled up with the wrong group of kids. Had he been raised by someone with a good heart, he might have been one of Lord British's greatest knights.@");
						add (["Lord British"]);
					}
					else
						say("@It saddens me that his soul has gotten so dark he would have done such a terrible thing. I hope with his time in prison he will contemplate the Virtues.@");
					
				case "Dezana"(remove):
					say("@She's a dear soul. I sometimes feel sorry for her. I mean, her weight and all. Still, she is one of the most interesting people I've ever met.@");

				case "Horance"(remove):
					say("@He's the alchemist who lives on @Iver's Rounding. You'll need a boat to get there though.@");
					add(["Ivers Rounding"]);

				case "Ivers Rounding"(remove):
					say("@It was named after a famous pirate who beached his craft there during a storm.@");
					
				case "Trenton Bell"(remove):
					say("@He means well, it's just his attitude is all wrong for the job. He should spend some time in New Magincia.@");
					add(["New Magincia"]);
										
				case "Lord British"(remove):
					say("@I'm just an innkeep. Ask Yorl: his father used to sail for our ruler.@");		
			
				case "bye":
					var avatar_goodbye = "@Farewell, Gideon.@";
					var npc_goodbye = "@Come back, dear souls.@";
					sayGoodbye(item, npc_goodbye, avatar_goodbye);
					break;
	
			}                               
	}
	else scheduleBarks(item);
}