// SCENARIO SCRIPT: Avernum 1 Template
// Remove non - A1 spells like Move Mountains?

beginscenarioscript;

variables;

short i,j,k,l,r1,choice;
short a,b,d,u;
string dlgstr,response, digit;

body;

beginstate LOAD_SCEN_STATE;
// This state called whenever this scenario is loaded, including when
// a save file is loaded.

	i = 0;
	while (i < 4) {
			change_custom_abil_uses(i,0,1);
		i = i + 1;
		}
	init_special_abil(0,"Custom Spellbook",32);
	
	init_special_item(0,"Gold Necklace","You found this gold necklace in a nephilim fortress. It is studded with precious stones and feels warm to the touch. However, when you try to put it on, it refuses to rest around your neck.");
	init_special_item(1,"Crown Token","You received this token from the mayor of Formello. She told you that it would get you into the Castle.");
	init_special_item(2,"Blessed Athame","This is a small, enchanted dagger, reputed for its ability to cut into practically anything, even magical things. It is often used to inscribe and scratch out runes.");
	init_special_item(3,"Royal Seal","This is a small brass seal, marked with the crown symbol of the royal family of the Empire. Such seals are extremely rare.");
	init_special_item(4,"Onyx Scepter","This is a scepter, two feet long, carved from a single piece of onyx. It is an intricate and enchanted piece of work, beautifully detailed and icy cold. You aren't sure what it's used for.");
	init_special_item(5,"Silver Circlet","This is a silver circlet, designed to be worn on the head. It's simple and unadorned. You can't see anything special about it.");
	init_special_item(6,"Slith Plans","These sheets of papyrus, stolen from a slith fort, are covered with a wide variety of maps and charts. ");
	init_special_item(7,"Dragon Scroll","This long scroll is made of thick leather, cracked and faded with incredible age. It is covered with illuminated drawings of dragons and writing in an alphabet you've never seen before.");
	init_special_item(8,"Slith Tome","This book, made of bound sheets of Avernum papyrus, was written by sliths for sliths. You can't understand a word of it.");
	init_special_item(9,"Torc of Sss-Thsss","You took this trophy off the head of Sss-Thsss, current (well, former) leader of the evil sliths in Avernum to prove that you managed to rid the world of his menace.");
	init_special_item(10,"Lost Message","This message was misplaced. Hopefully, you can find its proper owner.");
	init_special_item(11,"Mold","You found this small lump of unfamiliar purple mold in the tunnels of Avernum. ");
	init_special_item(12,"Crystal","This is a long, beautiful shard of quartz crystal.");
	init_special_item(13,"Metal Triangle","This is a silver, equilateral triangle, two inches on a side and a quarter-inch thick.");
	init_special_item(14,"Slith Amulet","This silver amulet is engraved with drawings of several slith warriors, marching in line through the underworld.");
	init_special_item(15,"Demonslayer Pommel","This is the pommel of the legendary blade Demonslayer, lost long ago in the underworld of Avernum. Alas, without the blade, it will do you no good.");
	init_special_item(16,"Demonslayer Blade","This is the blade of the legendary blade Demonslayer, lost long ago in the underworld of Avernum. Unfortunately, both the tip and the pommel of this magnificent weapon are missing.");
	init_special_item(17,"Demonslayer Tip","This is the tip of the legendary blade Demonslayer, lost long ago in the underworld of Avernum. Of course, the tip of a sword by itself is not a useful weapon.");
	init_special_item(18,"Password: First Part","You have learned the first part of a password. It's 'Kro'. The eventual purpose of this password, however, is shrouded in mystery.");
	init_special_item(19,"Password: Second Part","You have learned the second part of a password. It's 'Bas'. The eventual purpose of this password, however, is shrouded in mystery.");
	init_special_item(20,"Password: Third Part","You have learned the third part of a password. It's 'Eng'. The eventual purpose of this password, however, is shrouded in mystery.");
	init_special_item(21,"Password: Fourth Part","You have learned the fourth part of a password. It's 'Kai'. The eventual purpose of this password, however, is shrouded in mystery.");
	init_special_item(22,"Spider Queen Fangs","These fangs were pulled from the mouth of the powerful spider queen. Perhaps someone would buy such an unusual souvenier.");
	init_special_item(23,"Serpent Ring","You stole this ring in the city of Blosk. Dexter in Almaria offered you a reward for it. You've tried it on, but you don't think that it's magical.");
	init_special_item(24,"Small Package","This is a small box. Dexter is paying you to deliver it to someone named Meena in Spire, a village in the Abyss. You tried to open it, but it seems to be magically sealed.");
	init_special_item(25,"Black Fang","You found this fang in a drake's mouth. Strangely, it seems to be made entirely of onyx.");
	init_special_item(26,"Answering Stone","You recovered this stone from the depths of Lost Bahssikava. It's a rather plain piece of granite, covered with incomprehensible writing. It means a great deal to the sliths there.");
	init_special_item(27,"Ivory Brooch","You found this brooch in an old, moldy box in the lair of Motrax the dragon. It is carefully carved from a disk of ivory, which was probably brought down from the surface some time ago.");
	init_special_item(28,"Malachite Brooch","This brooch was hidden in the lair of the Giant, Intelligent, Friendly, Talking Spiders. It's a beautiful piece of jewelry made of finely carved green stone.");
	init_special_item(29,"Platinum Brooch","You bought this brooch from a man in Mertis. He didn't know what it was for. It's a beautiful piece of workmanship.");
	init_special_item(30,"Pearl Brooch","This lovely silver brooch set with pearls was found at the bottom of a terrifying, undead-infested tunnel. The amulet always feels icy cold.");
	init_special_item(31,"Chalcedony Brooch","This brooch, carved from a single, lovely piece of chalcedony, was recovered from Pyrog's lair. It was only obtained with a great deal of difficulty and personal risk.");
	init_special_item(32,"Bronze Key","This bronze key is very crude and slightly bent. You found it in a nephilim fortress. Based on its quality, the nephilim aren't very good craftsmen.");
	init_special_item(33,"Stone Key","This key, carved from tan and red striated stone, was found on an old battlefield in northeastern Avernum.");
	init_special_item(34,"Onyx Key","This small, lovely key is carved from a single piece of onyx. It's about three inches long, and lizards are carved along its shaft.");
	init_special_item(35,"Diamond Key","This key was taken from around the neck of the mighty dragon Pyrog.");
	init_special_item(36,"Iron Key","You uncovered this large, heavy, iron key in a box of robes in a large slith temple.");
	init_special_item(37,"Gold Key","The key was kept in storage in the Castle for many years, waiting for someone like you to recover it.");
	init_special_item(38,"Tin Key","You found this key in the basement of the giant castle. It's rather ugly and bent, and made of tin.");
	init_special_item(39,"Silver Key","This silver key was hidden in a tunnel in the Abyss. It's very small and delicate. It, and the lock it fits, were probably brought down from the surface.");
	init_special_item(40,"Bone Key","This key is carved from a single bone. It's about six inches long, and runes are carved along its length. You found it in Erika's tower.");
	init_special_item(41,"Crystal Key","This key is cut from a single piece of flawless quartz crystal. You can see tiny flecks of gold inside it.");
	init_special_item(42,"Black Iron Key","You obtained this ugly, black, iron key in the infernal reaches of Grah-Hoth's realm.");
	init_special_item(43,"Password: Disaster","You learned this strange password in a cave near the Tower of Magi.");

break;

beginstate START_SCEN_STATE;
	set_flag(100,0,1);
	reward_give(470);		
	reward_give(470);	
	reward_give(470);		
	set_town_visibility(0,0);
	
	create_boat(0,13,25,42,1);
	create_boat(1,13,26,40,1);
	create_boat(2,5,9,41,1);
	create_boat(3,5,11,41,1);
	create_boat(4,5,13,41,1);
	create_boat(5,7,43,8,0);
	create_boat(6,14,5,30,1);
	create_boat(7,14,6,30,1);
	create_boat(8,14,7,30,1);
	create_boat(9,18,20,21,0);
	create_boat(10,22,18,15,0);
	create_boat(11,22,31,27,0);
	create_boat(12,24,22,15,1);
	create_boat(13,39,26,33,0);
	create_boat(14,39,28,33,0);
	create_boat(15,41,23,37,0);
	create_boat(16,50,38,13,0);
	create_boat(17,54,25,34,0);
	create_boat(18,59,24,11,0);
	create_boat(19,62,12,3,0);
	create_boat(20,78,18,24,0);
	create_boat(21,80,4,8,0);
	create_boat(22,80,6,8,0);
	create_boat(23,81,17,22,0);	
	
	
// 0Solberg's Tower: Solberg
	add_item_to_shop(0,5011,2);

// 1Silvar: Efram
	add_item_to_shop(1,46,500);
	add_item_to_shop(1,50,500);
	add_item_to_shop(1,51,500);
	add_item_to_shop(1,55,500);
	add_item_to_shop(1,65,500);
	add_item_to_shop(1,66,500);
	add_item_to_shop(1,85,500);

// 2Silvar: Anastasia
	add_item_to_shop(2,25,500);
	add_item_to_shop(2,30,500);
	add_item_to_shop(2,111,500);
	add_item_to_shop(2,114,500);
	add_item_to_shop(2,16,500);
	add_item_to_shop(2,121,500);
	add_item_to_shop(2,122,500);
	add_item_to_shop(2,126,500);
	add_item_to_shop(2,136,500);
	add_item_to_shop(2,146,500);

// 3Silvar: Carol
	add_item_to_shop(3,5,500);
	add_item_to_shop(3,8,500);
	add_item_to_shop(3,10,500);

// 4Fort Duvno: Grimmet
	add_item_to_shop(4,50,500);
	add_item_to_shop(4,51,500);
	add_item_to_shop(4,55,500);
	add_item_to_shop(4,65,500);
	add_item_to_shop(4,66,500);
	add_item_to_shop(4,70,500);
	add_item_to_shop(4,121,500);
	add_item_to_shop(4,122,500);
	add_item_to_shop(4,126,500);
	add_item_to_shop(4,141,500);
	add_item_to_shop(4,157,500);

// 5Fort Duvno: Walner's Potions
	add_item_to_shop(5,4002,2);
	add_item_to_shop(5,4003,2);

// 6Fort Duvno: JR
	add_item_to_shop(6,85,500);
	add_item_to_shop(6,86,500);
	add_item_to_shop(6,90,500);
	add_item_to_shop(6,100,500);
	add_item_to_shop(6,101,500);
	add_item_to_shop(6,105,500);
	add_item_to_shop(6,102,1);

// 7Fort Duvno: Jason
	add_item_to_shop(7,170,500);
	add_item_to_shop(7,171,500);
	add_item_to_shop(7,174,500);
	add_item_to_shop(7,177,500);
	add_item_to_shop(7,164,500);
	add_item_to_shop(7,186,500);
	add_item_to_shop(7,172,1);

// 8x
	add_item_to_shop(8,8,500);

// 9x
	add_item_to_shop(9,9,500);

// 10Traveling Merchants, near Formello
	add_item_to_shop(10,10,500);
	add_item_to_shop(10,13,500);
	add_item_to_shop(10,17,500);
	add_item_to_shop(10,26,500);
	add_item_to_shop(10,91,500);
	add_item_to_shop(10,100,500);
	add_item_to_shop(10,114,500);
	add_item_to_shop(10,122,500);
	add_item_to_shop(10,150,500);
	add_item_to_shop(10,170,500);
	add_item_to_shop(10,177,500);
	add_item_to_shop(10,225,2);

// 11x
	add_item_to_shop(11,11,500);
	add_item_to_shop(11,14,500);
	add_item_to_shop(11,18,500);
	add_item_to_shop(11,26,500);
	add_item_to_shop(11,86,500);
	add_item_to_shop(11,114,500);
	add_item_to_shop(11,127,500);
	add_item_to_shop(11,146,500);
	add_item_to_shop(11,151,500);
	add_item_to_shop(11,171,500);
	add_item_to_shop(11,177,500);
	add_item_to_shop(11,220,6);

// 12x
	add_item_to_shop(12,9,500);
	add_item_to_shop(12,15,500);
	add_item_to_shop(12,18,500);
	add_item_to_shop(12,31,500);
	add_item_to_shop(12,95,500);
	add_item_to_shop(12,105,500);
	add_item_to_shop(12,132,500);
	add_item_to_shop(12,146,500);
	add_item_to_shop(12,152,500);
	add_item_to_shop(12,172,500);
	add_item_to_shop(12,178,500);
	add_item_to_shop(12,282,1);

// 13Cotra: Elspeth
	add_item_to_shop(13,25,500);
	add_item_to_shop(13,26,500);
	add_item_to_shop(13,27,500);
	add_item_to_shop(13,30,500);
	add_item_to_shop(13,31,500);
	add_item_to_shop(13,35,1);
	add_item_to_shop(13,126,500);
	add_item_to_shop(13,127,5);
	add_item_to_shop(13,136,500);
	add_item_to_shop(13,137,5);
	add_item_to_shop(13,141,1);
	add_item_to_shop(13,146,500);

// 14Cotra: Elspeth
	add_item_to_shop(14,45,500);
	add_item_to_shop(14,46,500);
	add_item_to_shop(14,47,500);
	add_item_to_shop(14,50,500);
	add_item_to_shop(14,51,500);
	add_item_to_shop(14,55,1);
	add_item_to_shop(14,65,500);
	add_item_to_shop(14,66,500);
	add_item_to_shop(14,70,2);
	add_item_to_shop(14,86,500);
	add_item_to_shop(14,101,500);
	add_item_to_shop(14,105,500);

// 15Formello: Jen
	add_item_to_shop(15,4,500);
	add_item_to_shop(15,6,500);
	add_item_to_shop(15,11,500);
	add_item_to_shop(15,150,500);
	add_item_to_shop(15,173,500);

// 16Cotra: Jenny
	add_item_to_shop(16,220,500);
	add_item_to_shop(16,221,500);
	add_item_to_shop(16,222,500);
	add_item_to_shop(16,223,2);
	add_item_to_shop(16,225,2);
	add_item_to_shop(16,229,1);

// 17Formello: Jasmine's Armor
	add_item_to_shop(17,25,500);
	add_item_to_shop(17,26,500);
	add_item_to_shop(17,30,500);
	add_item_to_shop(17,31,500);
	add_item_to_shop(17,35,1);
	add_item_to_shop(17,121,500);
	add_item_to_shop(17,122,500);
	add_item_to_shop(17,126,6);
	add_item_to_shop(17,127,2);
	add_item_to_shop(17,137,2);
	add_item_to_shop(17,16,500);
	add_item_to_shop(17,22,500);

// 18Formello: Jasmine's Weapons
	add_item_to_shop(18,46,500);
	add_item_to_shop(18,50,500);
	add_item_to_shop(18,51,2);
	add_item_to_shop(18,55,2);
	add_item_to_shop(18,65,500);
	add_item_to_shop(18,66,500);
	add_item_to_shop(18,70,500);
	add_item_to_shop(18,85,500);
	add_item_to_shop(18,86,500);
	add_item_to_shop(18,100,500);

// 19Formello: Bernie's Brews
	add_item_to_shop(19,220,17);
	add_item_to_shop(19,221,14);
	add_item_to_shop(19,222,6);
	add_item_to_shop(19,223,5);
	add_item_to_shop(19,225,8);
	add_item_to_shop(19,226,1);
	add_item_to_shop(19,227,2);
	add_item_to_shop(19,228,2);

// 20Formello: Claudette's Spells
	add_item_to_shop(20,3000,2);
	add_item_to_shop(20,3001,2);
	add_item_to_shop(20,3002,2);
	add_item_to_shop(20,3003,2);
	add_item_to_shop(20,3004,2);
	add_item_to_shop(20,3005,2);

// 21Formello: Miles' Mage spells
	add_item_to_shop(21,2000,2);
	add_item_to_shop(21,2001,2);
	add_item_to_shop(21,2002,2);
	add_item_to_shop(21,2003,2);
	add_item_to_shop(21,2004,2);
	add_item_to_shop(21,2005,2);
	add_item_to_shop(21,2006,2);

// 22Formello: Miles' Strength potion
	add_item_to_shop(22,4004,1);

// 23Fort Draco:  Boutell
	add_item_to_shop(23,47,500);
	add_item_to_shop(23,50,500);
	add_item_to_shop(23,51,500);
	add_item_to_shop(23,55,500);
	add_item_to_shop(23,56,5);
	add_item_to_shop(23,60,500);
	add_item_to_shop(23,66,500);
	add_item_to_shop(23,67,2);
	add_item_to_shop(23,70,500);
	add_item_to_shop(23,71,2);
	add_item_to_shop(23,102,20);
	add_item_to_shop(23,106,500);

// 24Fort Draco:  Boutell
	add_item_to_shop(24,25,500);
	add_item_to_shop(24,26,500);
	add_item_to_shop(24,27,2);
	add_item_to_shop(24,30,500);
	add_item_to_shop(24,31,500);
	add_item_to_shop(24,35,13);
	add_item_to_shop(24,36,1);
	add_item_to_shop(24,127,500);
	add_item_to_shop(24,131,2);
	add_item_to_shop(24,137,500);
	add_item_to_shop(24,141,2);

// 25Fort Draco:  Aife Alchemy
	add_item_to_shop(25,4007,1);

// 26x
	add_item_to_shop(26,465,10);

// 27Fort Draco: Sue
	add_item_to_shop(27,170,500);
	add_item_to_shop(27,171,500);
	add_item_to_shop(27,172,500);
	add_item_to_shop(27,174,500);
	add_item_to_shop(27,177,500);
	add_item_to_shop(27,220,1);
	add_item_to_shop(27,221,1);
	add_item_to_shop(27,222,1);
	add_item_to_shop(27,223,1);
	add_item_to_shop(27,244,1);
	add_item_to_shop(27,245,1);
	add_item_to_shop(27,175,1);
	add_item_to_shop(27,254,1);

// 28Fort Draco: Carlos
	add_item_to_shop(28,4,500);
	add_item_to_shop(28,6,500);
	add_item_to_shop(28,11,500);

// 29Camping Merchants: Oasis
	add_item_to_shop(29,5,500);
	add_item_to_shop(29,10,500);
	add_item_to_shop(29,22,500);
	add_item_to_shop(29,111,500);
	add_item_to_shop(29,114,500);
	add_item_to_shop(29,154,500);
	add_item_to_shop(29,174,500);
	add_item_to_shop(29,177,500);
	add_item_to_shop(29,201,500);
	add_item_to_shop(29,270,1);
	add_item_to_shop(29,207,2);

// 30Camping Merchants: Oasis
	add_item_to_shop(30,86,500);
	add_item_to_shop(30,91,1);
	add_item_to_shop(30,100,500);
	add_item_to_shop(30,105,500);
	add_item_to_shop(30,419,500);
	add_item_to_shop(30,171,500);
	add_item_to_shop(30,178,2);
	add_item_to_shop(30,465,2);
	add_item_to_shop(30,254,1);

// 31Mertis: Terri
	add_item_to_shop(31,8,500);
	add_item_to_shop(31,10,500);
	add_item_to_shop(31,15,500);
	add_item_to_shop(31,16,500);
	add_item_to_shop(31,18,500);
	add_item_to_shop(31,101,500);
	add_item_to_shop(31,86,500);
	add_item_to_shop(31,171,500);
	add_item_to_shop(31,177,500);
	add_item_to_shop(31,465,7);
	add_item_to_shop(31,392,2);
	add_item_to_shop(31,244,2);

// 32Mertis: Matt
	add_item_to_shop(32,25,500);
	add_item_to_shop(32,26,2);
	add_item_to_shop(32,30,500);
	add_item_to_shop(32,121,500);
	add_item_to_shop(32,122,500);
	add_item_to_shop(32,126,500);
	add_item_to_shop(32,111,500);
	add_item_to_shop(32,146,500);
	add_item_to_shop(32,136,500);
	add_item_to_shop(32,137,1);

// 33Mertis: Tina
	add_item_to_shop(33,45,500);
	add_item_to_shop(33,50,500);
	add_item_to_shop(33,55,500);
	add_item_to_shop(33,65,500);
	add_item_to_shop(33,90,500);

// 34Tower of Magi: Brantford
	add_item_to_shop(34,203,500);
	add_item_to_shop(34,204,500);
	add_item_to_shop(34,205,500);
	add_item_to_shop(34,184,500);
	add_item_to_shop(34,185,500);
	add_item_to_shop(34,187,500);
	add_item_to_shop(34,188,500);
	add_item_to_shop(34,189,500);

// 35Tower of Magi: Zathnia
	add_item_to_shop(35,4006,2);
	add_item_to_shop(35,4008,2);

// 36Tower of Magi: Ambrin
	add_item_to_shop(36,2000,2);
	add_item_to_shop(36,2001,2);
	add_item_to_shop(36,2002,2);
	add_item_to_shop(36,2003,2);
	add_item_to_shop(36,2004,2);
	add_item_to_shop(36,2005,2);
	add_item_to_shop(36,2006,2);
	add_item_to_shop(36,2007,2);
	add_item_to_shop(36,2008,2);
	add_item_to_shop(36,2009,2);
	add_item_to_shop(36,2010,2);

// 37Tower of Magi: X
	add_item_to_shop(37,2014,2);
	add_item_to_shop(37,2015,2);
	add_item_to_shop(37,2016,2);
	add_item_to_shop(37,2017,2);
	add_item_to_shop(37,2018,2);
	add_item_to_shop(37,2019,2);

// 38Tower of Magi: Throndell
	add_item_to_shop(38,3000,8);
	add_item_to_shop(38,3001,5);
	add_item_to_shop(38,3002,7);
	add_item_to_shop(38,3003,7);
	add_item_to_shop(38,3004,7);
	add_item_to_shop(38,3005,8);
	add_item_to_shop(38,3006,6);
	add_item_to_shop(38,3007,7);
	add_item_to_shop(38,3008,7);
	add_item_to_shop(38,3010,5);
	add_item_to_shop(38,3011,5);

// 39Tower of Magi: Throndell
	add_item_to_shop(39,3017,7);
	add_item_to_shop(39,3018,5);
	add_item_to_shop(39,3019,5);

// 40Tower of Magi: Glenda
	add_item_to_shop(40,220,8);
	add_item_to_shop(40,221,5);
	add_item_to_shop(40,222,5);
	add_item_to_shop(40,223,7);
	add_item_to_shop(40,230,1);
	add_item_to_shop(40,231,1);
	add_item_to_shop(40,245,6);
	add_item_to_shop(40,259,7);
	add_item_to_shop(40,247,2);
	add_item_to_shop(40,469,18);
	add_item_to_shop(40,282,1);
	add_item_to_shop(40,283,1);

// 41Guard Loot: west of Cotra
	add_item_to_shop(41,370,5);
	add_item_to_shop(41,371,1);
	add_item_to_shop(41,326,1);
	add_item_to_shop(41,218,2);

// 42Fort Dranlon: DB spell
	add_item_to_shop(42,2013,13);

// 43Fort Dranlon: Sylow
	add_item_to_shop(43,5,500);
	add_item_to_shop(43,171,500);
	add_item_to_shop(43,172,500);
	add_item_to_shop(43,174,500);
	add_item_to_shop(43,177,500);
	add_item_to_shop(43,101,500);
	add_item_to_shop(43,106,500);
	add_item_to_shop(43,86,500);
	add_item_to_shop(43,214,5);
	add_item_to_shop(43,220,7);
	add_item_to_shop(43,244,5);
	add_item_to_shop(43,259,1);

// 44Gemstone Mine, north of Dranlon
	add_item_to_shop(44,204,500);
	add_item_to_shop(44,205,500);
	add_item_to_shop(44,469,500);
	add_item_to_shop(44,326,2);

// 45Healing Monks
	add_item_to_shop(45,3016,5);

// 46Almaria: Jasmine
	add_item_to_shop(46,7,500);
	add_item_to_shop(46,10,500);

// 47Almaria: Julio
	add_item_to_shop(47,220,500);
	add_item_to_shop(47,221,500);
	add_item_to_shop(47,222,500);
	add_item_to_shop(47,223,2);
	add_item_to_shop(47,225,1);
	add_item_to_shop(47,226,1);
	add_item_to_shop(47,229,6);

// 48Almaria: Dexter
	add_item_to_shop(48,85,500);
	add_item_to_shop(48,86,500);
	add_item_to_shop(48,90,500);
	add_item_to_shop(48,91,500);
	add_item_to_shop(48,95,500);
	add_item_to_shop(48,96,500);
	add_item_to_shop(48,100,500);
	add_item_to_shop(48,101,500);
	add_item_to_shop(48,105,500);
	add_item_to_shop(48,106,500);

// 49Almaria: Dexter's Tools
	add_item_to_shop(49,174,500);
	add_item_to_shop(49,170,500);
	add_item_to_shop(49,171,500);
	add_item_to_shop(49,172,500);
	add_item_to_shop(49,178,500);
	add_item_to_shop(49,224,500);
	add_item_to_shop(49,469,7);

// 50Almaria: Rhiannon
	add_item_to_shop(50,393,500);
	add_item_to_shop(50,460,500);
	add_item_to_shop(50,461,500);
	add_item_to_shop(50,462,500);

// 51Almaria: Rosemary
	add_item_to_shop(51,27,500);
	add_item_to_shop(51,31,500);
	add_item_to_shop(51,32,500);
	add_item_to_shop(51,35,500);
	add_item_to_shop(51,40,1);
	add_item_to_shop(51,123,500);
	add_item_to_shop(51,127,500);
	add_item_to_shop(51,131,500);
	add_item_to_shop(51,142,500);
	add_item_to_shop(51,139,1);

// 52Almaria: Ramirez
	add_item_to_shop(52,47,500);
	add_item_to_shop(52,51,500);
	add_item_to_shop(52,56,500);
	add_item_to_shop(52,60,1);
	add_item_to_shop(52,67,500);
	add_item_to_shop(52,71,500);
	add_item_to_shop(52,75,1);
	add_item_to_shop(52,48,1);

// 53Slith Village, east of waterfalls
	add_item_to_shop(53,370,2);
	add_item_to_shop(53,371,2);
	add_item_to_shop(53,112,1);
	add_item_to_shop(53,214,6);
	add_item_to_shop(53,215,8);
	add_item_to_shop(53,216,5);
	add_item_to_shop(53,217,1);
	add_item_to_shop(53,218,7);
	add_item_to_shop(53,219,1);

// 54Mushroom Farm, w of Almaria
	add_item_to_shop(54,5,500);
	add_item_to_shop(54,214,6);
	add_item_to_shop(54,215,2);
	add_item_to_shop(54,216,2);
	add_item_to_shop(54,219,1);

// 55Silverlocke's Hut
	add_item_to_shop(55,235,18);
	add_item_to_shop(55,236,18);
	add_item_to_shop(55,237,15);
	add_item_to_shop(55,238,20);
	add_item_to_shop(55,239,14);

// 56Gnass: Garthass
	add_item_to_shop(56,220,12);
	add_item_to_shop(56,221,11);
	add_item_to_shop(56,222,20);
	add_item_to_shop(56,223,19);
	add_item_to_shop(56,233,2);
	add_item_to_shop(56,234,1);
	add_item_to_shop(56,244,15);
	add_item_to_shop(56,245,19);
	add_item_to_shop(56,259,5);
	add_item_to_shop(56,248,2);
	add_item_to_shop(56,258,2);
	add_item_to_shop(56,270,1);

// 57Gnass: Skatha
	add_item_to_shop(57,370,500);
	add_item_to_shop(57,371,2);

// 58Blosk: Jonnhalyn
	add_item_to_shop(58,46,500);
	add_item_to_shop(58,47,500);
	add_item_to_shop(58,51,500);
	add_item_to_shop(58,52,500);
	add_item_to_shop(58,55,500);
	add_item_to_shop(58,56,500);
	add_item_to_shop(58,60,500);
	add_item_to_shop(58,66,500);
	add_item_to_shop(58,67,500);
	add_item_to_shop(58,71,500);
	add_item_to_shop(58,75,500);

// 59Blosk: Jonnhalyn
	add_item_to_shop(59,28,500);
	add_item_to_shop(59,21,500);
	add_item_to_shop(59,36,500);
	add_item_to_shop(59,40,500);
	add_item_to_shop(59,123,500);
	add_item_to_shop(59,127,500);
	add_item_to_shop(59,128,500);
	add_item_to_shop(59,132,500);
	add_item_to_shop(59,114,500);
	add_item_to_shop(59,138,500);
	add_item_to_shop(59,142,500);
	add_item_to_shop(59,129,1);

// 60Blosk: Leith
	add_item_to_shop(60,171,500);
	add_item_to_shop(60,172,500);
	add_item_to_shop(60,174,500);
	add_item_to_shop(60,175,500);
	add_item_to_shop(60,176,7);
	add_item_to_shop(60,178,500);
	add_item_to_shop(60,218,2);
	add_item_to_shop(60,228,2);
	add_item_to_shop(60,229,2);
	add_item_to_shop(60,230,2);
	add_item_to_shop(60,259,1);
	add_item_to_shop(60,202,6);

// 61Blosk: Bruce
	add_item_to_shop(61,91,500);
	add_item_to_shop(61,96,500);
	add_item_to_shop(61,101,500);
	add_item_to_shop(61,102,2);
	add_item_to_shop(61,106,500);
	add_item_to_shop(61,107,2);
	add_item_to_shop(61,86,500);
	add_item_to_shop(61,87,2);

// 62Blosk: Demel
	add_item_to_shop(62,419,500);

// 63Tower of Patrick: Kai
	add_item_to_shop(63,4009,2);
	add_item_to_shop(63,4011,2);

// 64Spire: Cliff
	add_item_to_shop(64,25,500);
	add_item_to_shop(64,30,500);
	add_item_to_shop(64,35,500);
	add_item_to_shop(64,50,500);
	add_item_to_shop(64,55,500);
	add_item_to_shop(64,60,500);
	add_item_to_shop(64,70,500);
	add_item_to_shop(64,75,500);
	add_item_to_shop(64,100,500);
	add_item_to_shop(64,105,500);
	add_item_to_shop(64,126,500);
	add_item_to_shop(64,131,500);

// 65Spire: Entwhistle
	add_item_to_shop(65,174,500);
	add_item_to_shop(65,175,500);
	add_item_to_shop(65,171,500);
	add_item_to_shop(65,172,500);
	add_item_to_shop(65,177,500);
	add_item_to_shop(65,178,500);
	add_item_to_shop(65,327,500);
	add_item_to_shop(65,469,500);
	add_item_to_shop(65,326,500);
	add_item_to_shop(65,272,1);
	add_item_to_shop(65,217,1);
	add_item_to_shop(65,469,500);

// 66Spire: Eustace
	add_item_to_shop(66,8,500);
	add_item_to_shop(66,9,500);

// 67Spire: Eunice
	add_item_to_shop(67,220,500);
	add_item_to_shop(67,221,500);
	add_item_to_shop(67,222,500);
	add_item_to_shop(67,224,2);
	add_item_to_shop(67,225,2);
	add_item_to_shop(67,214,1);
	add_item_to_shop(67,215,1);

// 68Bargha: Marlowe
	add_item_to_shop(68,4,500);
	add_item_to_shop(68,5,500);
	add_item_to_shop(68,8,500);

// 69Bargha: Johnson
	add_item_to_shop(69,90,500);
	add_item_to_shop(69,91,500);
	add_item_to_shop(69,92,2);
	add_item_to_shop(69,95,500);
	add_item_to_shop(69,96,500);
	add_item_to_shop(69,97,2);
	add_item_to_shop(69,101,500);
	add_item_to_shop(69,102,1);
	add_item_to_shop(69,106,500);
	add_item_to_shop(69,107,1);
	add_item_to_shop(69,86,500);
	add_item_to_shop(69,87,6);

// 70Dharmon Armor:  north of city
	add_item_to_shop(70,27,500);
	add_item_to_shop(70,32,500);
	add_item_to_shop(70,37,500);
	add_item_to_shop(70,41,500);
	add_item_to_shop(70,42,2);
	add_item_to_shop(70,123,500);
	add_item_to_shop(70,128,500);
	add_item_to_shop(70,133,2);
	add_item_to_shop(70,138,500);
	add_item_to_shop(70,143,2);
	add_item_to_shop(70,421,1);

// 71Dharmon: Malville spells
	add_item_to_shop(71,3012,7);
	add_item_to_shop(71,3013,5);
	add_item_to_shop(71,3014,6);

// 72Dharmon: Clive
	add_item_to_shop(72,52,500);
	add_item_to_shop(72,56,500);
	add_item_to_shop(72,57,500);
	add_item_to_shop(72,61,500);
	add_item_to_shop(72,62,500);
	add_item_to_shop(72,72,500);
	add_item_to_shop(72,76,500);
	add_item_to_shop(72,77,500);
	add_item_to_shop(72,102,500);
	add_item_to_shop(72,107,500);
	add_item_to_shop(72,87,500);
	add_item_to_shop(72,92,1);

// 73Dharmon: Hestia
	add_item_to_shop(73,392,500);

// 74Dharmon: Alchemical Secrets
	add_item_to_shop(74,4009,2);
	add_item_to_shop(74,4011,2);
	add_item_to_shop(74,4014,2);
	add_item_to_shop(74,4015,2);

// 75Dharmon: Powerful Spells
	add_item_to_shop(75,2014,17);
	add_item_to_shop(75,2015,19);
	add_item_to_shop(75,2016,11);

// 76Erika's Tower: Erika the Alchemist
	add_item_to_shop(76,4003,2);
	add_item_to_shop(76,4013,2);
	add_item_to_shop(76,4014,2);
	add_item_to_shop(76,4015,2);

// 77x
	add_item_to_shop(77,8,500);

// 78x
	add_item_to_shop(78,8,500);

// 79x
	add_item_to_shop(79,8,500);

// 80x
	add_item_to_shop(80,8,500);

// 81x
	add_item_to_shop(81,8,500);

// 82x
	add_item_to_shop(82,8,500);

// 83x
	add_item_to_shop(83,8,500);

// 84x
	add_item_to_shop(84,8,500);

// 85x
	add_item_to_shop(85,8,500);

// 86x
	add_item_to_shop(86,8,500);

// 87x
	add_item_to_shop(87,8,500);

// 88x
	add_item_to_shop(88,8,500);

// 89x
	add_item_to_shop(89,8,500);

// 90Hermit Merchant, near TM
	add_item_to_shop(90,205,500);

// 91x
	add_item_to_shop(91,214,500);

// 92x
	add_item_to_shop(92,225,500);
	add_item_to_shop(92,202,1);
	add_item_to_shop(92,332,2);

// 93x
	add_item_to_shop(93,244,100);
	add_item_to_shop(93,27,2);

// 94x
	add_item_to_shop(94,172,100);
	add_item_to_shop(94,176,101);
	add_item_to_shop(94,253,101);

// 95x
	add_item_to_shop(95,147,100);
	add_item_to_shop(95,304,1);
	add_item_to_shop(95,63,2);

// 96x
	add_item_to_shop(96,166,100);

// 97x
	add_item_to_shop(97,175,100);

// 98x
	add_item_to_shop(98,178,100);

// 99x
	add_item_to_shop(99,200,100);

// 100

break;

beginstate START_STATE;
// This state will be called every turn the player is in the scenario,
// whether in town, combat, or outdoors.
break;

beginstate 10;
	print_str_color("You read the scroll.",2);
	print_str_color("It describes a bit of obscure history of the early years of Avernum.",2);
	print_str_color("Alas, it is neither interesting nor useful.",2);
break;

beginstate 11;
	u = 445;
	set_state_continue(27);
break;

beginstate 12;
	u = 446;
	set_state_continue(27);
break;

beginstate 13;
	u = 447;
	set_state_continue(27);
break;

beginstate 14;
	u = 448;
	set_state_continue(27);
break;

beginstate 15;
	u = 449;
	set_state_continue(27);
break;

beginstate 16;
	u = 450;
	set_state_continue(27);
break;

beginstate 17;
	u = 451;
	set_state_continue(27);
break;

beginstate 18;
	u = 452;
	set_state_continue(27);
break;

beginstate 19;
	u = 453;
	set_state_continue(27);
break;

beginstate 20;
	u = 454;
	set_state_continue(27);
break;

beginstate 21;
	u = 455;
	set_state_continue(27);
break;

beginstate 22;
	u = 456;
	set_state_continue(27);
break;

beginstate 23;
	u = 457;
	set_state_continue(27);
break;

// Recall Crystal
beginstate 24;
	if	(is_outdoor() == 0) {
		print_str_color("The Crystal will only work when you are outdoors.",1);	
		end();
		}
	if	(is_outdoor() == 1) {
		set_town_visibility(0,1);
		set_flag(100,0,1);
		set_state_continue(25);
	}
break;

// These need to be altered.
beginstate 25;
	if (current_out_section() == 0)
		out_move_party(11,44);
	if (current_out_section() == 1)
		out_move_party(24,24);
	if (current_out_section() == 2)
		out_move_party(29,31);
	if (current_out_section() == 3)
		out_move_party(17,44);
	if (current_out_section() == 4)
		out_move_party(12,27);
	if (current_out_section() == 5)
		out_move_party(30,22);
	if (current_out_section() == 6)
		out_move_party(42,31);
	if (current_out_section() == 7)
		out_move_party(25,27);
	if (current_out_section() == 8)
		out_move_party(26,27);
	if (current_out_section() == 9)
		out_move_party(37,33);		
	if (current_out_section() == 10)
		out_move_party(37,33);
	if (current_out_section() == 11)
		out_move_party(32,28);
	if (current_out_section() == 12)
		out_move_party(24,24);
	if (current_out_section() == 13)
		out_move_party(39,7);
	if (current_out_section() == 14)
		out_move_party(39,41);
	if (current_out_section() == 15)
		out_move_party(18,39);
	if (current_out_section() == 16)
		out_move_party(11,13);
	if (current_out_section() == 17)
		out_move_party(30,34);
	if (current_out_section() == 18)
		out_move_party(28,27);
	if (current_out_section() == 19)
		out_move_party(26,27);
	if (current_out_section() == 20)
		out_move_party(26,27);
	if (current_out_section() == 21)
		out_move_party(36,14);
	if (current_out_section() == 22)
		out_move_party(18,25);
	if (current_out_section() == 23)
		out_move_party(13,18);
	if (current_out_section() == 24)
		out_move_party(37,45);
	if (current_out_section() == 25)
		out_move_party(29,24);
	if (current_out_section() == 26)
		out_move_party(30,16);
	if (current_out_section() == 27)
		out_move_party(18,15);
	if (current_out_section() == 28)
		out_move_party(11,37);
	if (current_out_section() == 29)
		out_move_party(22,39);
	if (current_out_section() == 30)
		out_move_party(21,26);
	if (current_out_section() == 31)
		out_move_party(27,27);
	if (current_out_section() == 32)
		out_move_party(21,38);
	if (current_out_section() == 33)
		out_move_party(23,26);
	if (current_out_section() == 34)
		out_move_party(24,23);
	if (current_out_section() == 35)
		out_move_party(44,34);
	if (current_out_section() == 36)
		out_move_party(13,18);
	if (current_out_section() == 37)
		out_move_party(24,42);
	if (current_out_section() == 38)
		out_move_party(13,18);
	if (current_out_section() == 39)
		out_move_party(13,18);
	if (current_out_section() == 40)
		out_move_party(13,18);
	if (current_out_section() == 41)
		out_move_party(28,25);
break;

// Spellbook for Safe Travel and other custom spells.
beginstate 26;
	get_text_response("Choose a letter: ");

		check_text_response_match("H");
			 if (got_text_match())
			set_state_continue(131);
break;

beginstate 27;
	reset_dialog();
	add_dialog_str(0,"As you stare deep into the Mind Crystal, you start to hear strange, whispering voices in your mind. The words are barely audible, but they seem to be trying to teach you something.",0);
	add_dialog_str(1,"You concentrate, and you start to get an impression of what ability the item is trying to teach you:",0);	
	clear_buffer();
	if(u == 445)
	append_string("Summon Beast");
	if(u == 446)
	append_string("Call Spirit");
	if(u == 447)
	append_string("Lay On Hands");
	if(u == 448)
	append_string("Natural Curing");
	if(u == 449)
	append_string("Go Berzerk");
	if(u == 450)
	append_string("Inner Might");
	if(u == 451)
	append_string("Defensive Glow");
	if(u == 452)
	append_string("Blademaster");
	if(u == 453)
	append_string("Anatomy");
	if(u == 454)
	append_string("Gymnastics");
	if(u == 455)
	append_string("Pathfinder");
	if(u == 456)
	append_string("Magery");
	if(u == 457)
	append_string("Resistance");
	
	get_buffer_text(dlgstr);
	add_dialog_str(2,dlgstr,0);

	clear_buffer();	
	if(u == 445)
	append_string("This is the ability to summon aid to your side once per day. The higher your level, the better the aid you will obtain.");
	if(u == 446)
	append_string("This is the ability to communicate with the spirit world. In addition to always having someone to talk to, once per day you can summon a shade to aid you. The higher your level, the better the aid you will obtain.");
	if(u == 447)
	append_string("This blessing is a healing touch. Once per day, you can heal yourself. The amount of healing increases with your level.");
	if(u == 448)
	append_string("Merely by concentrating, you can purge yourself of disease and poison. This ability works once per day. The higher your level, the better the effect.");
	if(u == 449)
	append_string("You can cause yourself to go berserk, increasing your effectiveness in combat while enabling your foes to hit you more easily. This ability works once per day. The higher your level, the better the effect.");
	if(u == 450)
	append_string("This is the ability to bless yourself, increasing the effectiveness of your blows in combat. This ability works once per day. The higher your level, the better the effect.");
	if(u == 451)
	append_string("This is the ability to magically shield yourself, protecting you from enemy attacks. This ability works once per day. The higher your level, the better the effect.");
	if(u == 452)
	append_string("A Blademaster will get bonuses when using any sort of hand-to-hand weapon. The more of this powerful skill you have, the more likely you are to hit and the more damage you will do.");
	if(u == 453)
	append_string("Intimate knowledge of anatomy will help you with First Aid and aid you when fighting humanoids. Your blows will do more damage against humans and similar species.");
	if(u == 454)
	append_string("Nimbleness in combat is a great advantage. This skill makes you a leaping, spinning, fighting machine. Gymnastics skill makes you harder to hit and helps you act faster in combat.");
	if(u == 455)
	append_string("Pathfinder skill helps you find your way through hostile terrain. Your chance of being poisoned or diseased by swamps and the like is reduced. The more of this skill you have, the better the effect.");
	if(u == 456)
	append_string("Knowledge of Magery gives you intimate familiarity with the secret ways of magic. Any spell you cast will be more effective. The more you have, the better the bonus. You can't train in this skill.");
	if(u == 457)
	append_string("You have learned how to evade magical attacks. The more of this skill you have, the higher the chance of hostile magic (like fire and cold) doing less damage to you. You can't train in this skill.");
	
	get_buffer_text(dlgstr);
	add_dialog_str(3,dlgstr,0);
	
	add_dialog_str(4,"This crystal can only teach one character, so choose carefully whether or not to use it now.",0);			
	
	add_dialog_choice(0,"Don't use it yet.");
	add_dialog_choice(1,"Use the crystal.");	
	choice = run_dialog(1);
	
	if (choice == 2) {
	if(u < 452)
	set_state_continue(132);
	else
	set_state_continue(133);
	}
break;


beginstate 131;
	d = who_used_custom_item();
	if	(get_energy (d) < 6) 
		print_str_color("You lack the required magical energy.",1);	
	if	(get_stat(d,12) < 5) 
		print_str_color("You lack the required knowledge of Priest spells.",1);	
		
	if	((get_energy (d) >= 6) && (get_stat(d,12) >= 5)) {
		change_char_energy(d,-6);
		set_party_status(27,100,1);
	}
	
	else end();
break;

beginstate 132;
	reset_dialog();
	add_dialog_str(0,"You stare into the crystal. It teaches you a new ability.",0);
	add_dialog_str(1,"To use this ability, press the Use Ability button.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	
	if(u == 445)
	set_char_trait(who_used_custom_item(),15,1);
	if(u == 446)
	set_char_trait(who_used_custom_item(),16,1);
	if(u == 447)
	set_char_trait(who_used_custom_item(),17,1);
	if(u == 448)
	set_char_trait(who_used_custom_item(),18,1);
	if(u == 449)
	set_char_trait(who_used_custom_item(),19,1);
	if(u == 450)
	set_char_trait(who_used_custom_item(),20,1);
	if(u == 451)
	set_char_trait(who_used_custom_item(),21,1);

	take_item(u);
break;

beginstate 133;
	reset_dialog();
	add_dialog_str(0,"You stare into the crystal. It teaches you a new skill.",0);
	add_dialog_str(1,"To see your new skills, look on the Character Info screen.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	if(u == 452)
	alter_stat(who_used_custom_item(),21,1);
	if(u == 453)
	alter_stat(who_used_custom_item(),22,1);
	if(u == 454)
	alter_stat(who_used_custom_item(),23,1);
	if(u == 455)
	alter_stat(who_used_custom_item(),24,1);
	if(u == 456)
	alter_stat(who_used_custom_item(),25,1);
	if(u == 457)
	alter_stat(who_used_custom_item(),26,1);

	take_item(u);
	
break;

