// SCENARIO SCRIPT

// This is the script for your entire scenario. It contains special encounters
// and code accessable from anywhere in the scenario. It also contains the code
// that initializes important special things in the scenario, like shops, and
// the names and descriptions of special items.

// You can create your own states, but they should be given numbers greater than
// or equal to 10.

// CPeters: I have reserved states 10 through 20. If you need more states than
// that, start eliminating states that are called by items, the item's entry in
// A2Templatedata.txt, and finally, the items in whatever towns you decide to
// keep from the Template.

beginscenarioscript;

variables;
	int choice;
body;

// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//   [1] Names and descriptions of special items.
//   [2] Names and effects of custom special abilities.
beginstate LOAD_SCEN_STATE;
break;

// START_SCEN_STATE is called only once at the very beginning of the scenario.
// Things that should go here include:
//   [1] A store's merchandise.
//   [2] Boats.
//   [3] Horses.
beginstate START_SCEN_STATE;
	// Initialize a few shops.

	// Shop 0 - armor
	add_item_to_shop(0,25,25);
	add_item_to_shop(0,26,20);
	add_item_to_shop(0,30,20);
	add_item_to_shop(0,31,10);
	add_item_to_shop(0,35,10);
	add_item_to_shop(0,121,15);
	add_item_to_shop(0,122,15);
	add_item_to_shop(0,126,3);
	add_item_to_shop(0,131,2);
	add_item_to_shop(0,111,15);
	add_item_to_shop(0,16,10);
	add_item_to_shop(0,136,10);
	add_item_to_shop(0,137,10);
	add_item_to_shop(0,141,5);

	// Shop 1 - weapons
	add_item_to_shop(1,45,25);
	add_item_to_shop(1,46,20);
	add_item_to_shop(1,50,15);
	add_item_to_shop(1,51,10);
	add_item_to_shop(1,55,5);
	add_item_to_shop(1,65,20);
	add_item_to_shop(1,66,10);
	add_item_to_shop(1,70,5);

	// Shop 2 - tools
	add_item_to_shop(2,170,500);
	add_item_to_shop(2,171,500);
	add_item_to_shop(2,172,30);
	add_item_to_shop(2,174,500);
	add_item_to_shop(2,177,500);

	// Shop 3 - missiles
	add_item_to_shop(3,85,500);
	add_item_to_shop(3,86,10);
	add_item_to_shop(3,90,10);
	add_item_to_shop(3,95,3);
	add_item_to_shop(3,100,20);
	add_item_to_shop(3,101,10);
	add_item_to_shop(3,105,10);

	// Shop 4 - potions
	add_item_to_shop(4,220,4);
	add_item_to_shop(4,221,3);
	add_item_to_shop(4,222,3);
	add_item_to_shop(4,223,2);

	// Shop 5 - food
	add_item_to_shop(5,4,500);
	add_item_to_shop(5,6,500);
	add_item_to_shop(5,7,500);

	// Boats
	create_boat(0,5,13,57,1);
	create_boat(1,5,15,57,1);
	create_boat(2,5,18,57,1);
	create_boat(3,5,21,57,1);
	create_boat(4,6,13,57,0);
	create_boat(5,9,11,56,1);
	create_boat(6,9,13,56,1);
	create_boat(7,9,16,56,1);	
break;

// START_STATE is called every tick the party is in the scenario.
beginstate START_STATE;
break;

beginstate 10; // Empire Records
	print_str_color("This is a small piece of the Empire's almost limitless bureaucratic paperwork. Maybe there is someone who would be interested in getting this information.",2);
break;

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

beginstate 12;
	reset_dialog();
	add_dialog_str(0,"As you stare 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);
	add_dialog_str(2,"Energy Pulse",3);
	add_dialog_str(3,"You sense that the crystal wants to connect with your mind and fill it with energy. You aren't sure what effect this would have, though.",3);
	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(0);

	if (choice == 1)
		end();
	if (choice == 2) {
// Uncomment the line below, and delete the line below that if Jeff ever gets off
// his fat, lazy arse, and fixes the char_take_item() function.
//		char_take_item(who_used_custom_item(),480);
		take_item(480);
		set_char_status(who_used_custom_item(),13,250,1,0);
		print_str_color("You stare into the crystal. It connects with you, and pours energy into your brain. It's too much for you to take. You pass out!",2);
	}
break;

beginstate 13; // Book
	reset_dialog();
	add_dialog_str(0,"MAGIC FOR DUMMIES - Many people these days are getting into all sorts of spell-casting. No longer is the powerful and lucrative field of magic restricted to only the talented and wise. Now you, yes, even you, can learn spells!",0);
	add_dialog_str(1,"This book will teach you how to cast a variety of cantrips, which will easily perform tasks such as cleaning a floor of dust, cooking a rump roast in moments, or even spaying a cat!",0);
	run_dialog(0);
break;

beginstate 14;
	turn_on_debug_mode();
break;