beginoutdoorscript;

variables;
short bmessage,missing,pcs,pcded;

body;

beginstate 0;
break;

beginstate 1;
break;

beginstate START_STATE;
break;

beginstate 10;

	if(get_flag(13,0) == 0){
		message_dialog("There is a large camp of Bugbears sitting at the gate.  Alas, you only realize this after they noticed you and began pouring out at you.","The combat is inevitable.  Fortunately, it shouldn't be too difficult.  After all, they're only savages.");
		create_out_spec_enc(0);
		set_flag(13,0,1);
		block_entry(1);
	}
	if(get_flag(13,0) == 1){
		block_entry(1);
	}

break;

beginstate 11;

	message_dialog("You flee the Bugbears.  The gate remains in their hands, guarded by their warriors.","You won't be able to get into the village without beating the guards, unfortunately.");
	set_flag(13,0,0);

break;

beginstate 12;

	message_dialog("The bugbears are defeated.  How fortuitous that the guard here was so piddling.","");
	large_draw_pic_dialog(403,"Slovenly heathens.");
	set_flag(13,0,2);

break;

beginstate 13;

	if(get_flag(42,0) == 0){
		message_dialog("There is the beginning of a crude road here.  It's almost as if the Bugbears think that they are a nation.  How cute.","");
		set_flag(42,0,1);
	}

break;

beginstate 14;

	if(get_flag(14,0) == 0){
		reset_dialog();
		if(party_size() > 1){
			add_dialog_str(0,"The guards at the gate of Machtschrein stop you.  They don't attack since you're the Specialists, but they don't look like they will let you pass.",0);
			add_dialog_str(1,"A guard addresses you, confirming your suspicions.  _Specialists, we were told to not let you pass if you were not in possession of the nine bugbear emblems._",0);
			add_dialog_str(2,"_Do you have them, Specialists?_",0);
		}
		else{
			add_dialog_str(0,"The guards at the gate of Machtschrein stop you.  They don't attack since you're the Specialist, but they don't look like they will let you pass.",0);
			add_dialog_str(1,"A guard addresses you, confirming your suspicions.  _Specialist, we were told to not let you pass if you were not in possession of the nine bugbear emblems._",0);
			add_dialog_str(2,"_Do you have them, Specialist?_",0);
		}
		add_dialog_choice(0,"No.");
		if(has_special_item(1) >= 9){
			add_dialog_choice(1,"Yes. [Show them the emblems]");
		}
		if(has_special_item(1) < 9){
			add_dialog_choice(1,"Yes.");
		}
		bmessage = run_dialog(0);
		if(bmessage == 1){
			message_dialog("The guards says, _You are not allowed into Machschrein without the emblems.  We hope you understand._","He returns to his post.");
			block_entry(1);
			end();
		}
		if(bmessage == 2){
			if(has_special_item(1) < 9){
				reset_dialog();
				add_dialog_str(0,"The response you get sends shivers down your spine.  _Produce the emblems.  We were told to check for them before letting you in._",0);
				add_dialog_str(1,"The guards are definitely not pleased when you are not able to produce nine emblems.  Others come down from the ramparts and demand an explanation.",0);
				add_dialog_choice(0,"Whoops- we must have forgotten a few.");
				add_dialog_choice(1,"Right, we were lying.  Sorry.");
				bmessage = run_dialog(0);

				if(bmessage == 1){
	missing = (9 - has_special_item(1));
	inc_flag(43,0,missing);
	print_str("Whoops...");
				}
				if(bmessage == 2){
	inc_flag(43,0,4);
	print_str("Sorry...");
				}
				if(get_flag(43,0) < 5){
	message_dialog("The guards are clearly disappointed, but restrain themselves from action.","You doubt, though, that they will be as generous in the future.");
	block_entry(1);
	end();
				}
				if(get_flag(43,0) >= 5){
	reset_dialog();
	add_dialog_str(0,"_Do you take us for fools?  This is the final insult!  Come with us and face judgement, or we will have you slain here on the spot._",0);
	add_dialog_str(1,"The guard clearly means it.  He unsheathes his sword, and has the other guards still on the ramparts aim their arrows at you.",0);
	add_dialog_str(2,"If you were to fight them, you might be able to beat them.  Likely not, but it might be worth a try.  Surrendering also runs the risk of getting you slain.",0);
	add_dialog_choice(0,"Fight.");
	add_dialog_choice(1,"Surrender.");
	bmessage = run_dialog(0);

	if(bmessage == 1){
		message_dialog("The moment you show signs of resistance, horns are blown at the top of Machtschrein.  Soon enough, the entirety of Schwertschrein is barreling at you.","You didn't even stand a chance...");
		kill_char(1000,3,0);
		end_scenario(0);
	}
	if(bmessage == 2){
		message_dialog("You are brought before an extremely disappointed Leader and a court of twelve judges.  He unleashes a tirade at you about your massive incompetence.","The court deems you totally incompetent and relegates you to grunt jobs for the rest of your days.  Whoops.");
		end_scenario(0);
	}
				}
			}
			else{
				message_dialog("You produce the nine emblems.  Satisfied, the guards wave you by.","");
				set_flag(14,0,1);
				award_party_xp(500,40);
				award_party_xp(500,40);
				award_party_xp(500,40);
				award_party_xp(500,40);
			}
		}
	}

break;

beginstate 15;

	if(get_flag(55,0) == 0){
		set_town_visibility(6,1);
		message_dialog("You see a cave in front of you.  That's not to say that you saw it first- in fact, you smelled something faintly disgusting well before you saw it.","Whatever could be inside, it's stinking up everything in the immediate area.");
		set_flag(55,0,1);
	}

break;

beginstate 16;

	if(get_flag(14,0) == 1){
		message_dialog("You pass by the barracks of Machtschrein.  Honestly, they are somewhat understaffed.","In North Canopy, equal emphasis is placed on both the political and military centers of power.  It's odd, but in its own way, it makes a modicum of sense.");
		set_flag(14,0,2);
	}

break;

beginstate 17;

	if(character_in_party(275) >= 4){
		reset_dialog();
		add_dialog_str(0,"Suddenly, Baldev leaps out of your party and turns to you looking majestic once again.  _I thank you profoundly._",0);
		add_dialog_str(1,"_I would feel dishonored were you not to seek me out for your proper reward.  Look to the south and you will see a hill.  Look by the odd tree on the hill's summit and you will find our lair._",0);
		add_dialog_str(2,"Without further delay, Baldev strides forth into the thickets to the south and is out of sight.",0);
		add_dialog_choice(0,"See you later!");
		bmessage = run_dialog(1);
		bmessage = remove_char_from_party(275);
		set_flag(62,2,3);
		set_town_visibility(7,1);
		award_party_xp(500,40);
		award_party_xp(500,40);
		award_party_xp(500,40);
		award_party_xp(500,40);
	}

break;

beginstate 18;

	if(character_in_party(14) >= 4){
		message_dialog("Suddenly, General Alderauge stops you.  _Are you insane?_","_You have your orders, and that is to follow me into the catacombs.  You will not be leaving Machtschrein until your mission is complete!_");
		block_entry(1);
	}

break;

beginstate 19;

	if(get_flag(33,0) >= 30){
		message_dialog("A troop is camped out here.  They have directives not to let anybody in so that a group of wizards, loyal ones, will be able to work on repairing the Mezanine in privacy.","They don't let you through- which, honestly, you aren't complaining about.");
		block_entry(1);
	}

break;

beginstate 20;

	message_dialog("There is a small hamlet here, taking care of various tasks such as timber, reproduction and consumption.","It's a cute little town, but you have no interest in it.");
	block_entry(1);

break;

beginstate 21;

	if(get_flag(54,0) == 0){
		message_dialog("You are prevented from going this way by a large group of guards.","They tell you that they have strict orders not to let anything through without Leader's direct command.");
		block_entry(1);
	}
	if(get_flag(54,0) == 1){
		reset_dialog();
		add_dialog_str(0,"The soldiers here have been expecting you.  They tell you that the attacking army has already been through this place.",0);
		add_dialog_str(1,"You are not too late to join in the attack, however.  Although when you pass through the gate, it will be sealed behind you, not to be reopened.",0);
		add_dialog_str(2,"Are you ready to confront Sud Canopy?",0);
		add_dialog_choice(0,"Let's Go!");
		add_dialog_choice(1,"Now wait just one minute...");
		bmessage = run_dialog(0);
		if(bmessage == 2){
			block_entry(1);
		}
		if(bmessage == 1){
			message_dialog("You pass the stone portal.  The guards begin closing the gate as you do.","By the time you have passed through its threshold, the gate closes with a resounding slam.  You are now in Sud Canopy.");
			out_move_party(12,44);
			set_flag(54,0,2);
		}
	}

break;

beginstate 22;

	message_dialog("You can't turn back now.  Literally, you can't turn back- the guards have the gates closed.","You have to finish your duty here first.");
	block_entry(1);

break;

beginstate 23;

	block_entry(1);
	reset_dialog();
	add_dialog_str(0,"There is a large plantation here.  Because of your status and the fact that you will never be in any one barracks at a specific time, you are to purchase your food here.",0);
	add_dialog_choice(0,"Leave.");
	add_dialog_choice(1,"Buy food.");
	bmessage = run_dialog(0);
	if(bmessage == 1){
		block_entry(1);
		end();
	}
	begin_shop_mode("Plantation","Most of the residents of Canopy who don't join the military support an industry.  This industry is the thriving one of growing things.  This is good for you, because you are allowed to buy things which grow to stay alive.",5,0,-1);
	block_entry(1);

break;

beginstate 24;

	message_dialog("Mining is a large industry in North Canopy.  This is one of the places where it takes place.  Fortunately for you, you have no business in a place like this.","You leave without regrets- no matter how dangerous this job is, it beats mining.");
	block_entry(1);

break;

beginstate 25;

	if(get_flag(69,0) == 1)
		print_str("Some soldiers on the road greet you.");
	if(get_flag(69,0) == 0){
		message_dialog("A group of soldiers sits here by the road, protecting North Canopy from whatever would come to harm it.","They don't give you trouble because of your elite standing, but they don't seem anxious to engage in conversation either.");
		set_flag(69,0,1);
	}

	outdoor_enc_result(1);

break;

beginstate 26;

	set_out_fight_town_loaded(5);

break;

beginstate 27;

	block_entry(1);
	if(get_flag(71,0) == 0){
		add_dialog_str(0,"You approach the ring of stones laid out before you.  Inside, you see a woman standing behind an lechtern and on a dais.",0);
		add_dialog_str(1,"As you approach closer, you see that the place is identified as _Hellen's Respite._  The woman on the podium, then, must be Hellen.",0);
		add_dialog_str(2,"She is an admitted atheist, yet also a woman devoted to herbal medicines with enough power to heal all ails and revive the dead.",0);
		bmessage = run_dialog(0);
		set_flag(71,0,1);
	}
	reset_dialog();
	add_dialog_str(0,"Hellen is still here and willing to heal you.  As she sees your interest, she says, _Greetings.  What may I do for you?_",0);
	pcs = 0;
	pcded = 0;
	while(pcs <= 3 && pcded == 0){
		if(char_ok(pcs) == FALSE){
			pcded = 1;
		}
		pcs = (pcs + 1);
	}
	add_dialog_choice(0,"Nothing, Thanks!");
	add_dialog_choice(1,"Healing [10 Gold]");
	if(pcded > 0){
		add_dialog_choice(2,"Revive Dead [1000 Gold]");
	}
	bmessage = run_dialog(0);
	if(bmessage == 1){
		end();
	}
	if(bmessage == 2){
		if(coins_amount() >= 10){
			pcs = 0;
			while(pcs < 4){
				if(char_ok(pcs) == TRUE){
set_party_status(0,(get_char_status(pcs,0) * -1),0);
set_party_status(6,(get_char_status(pcs,6) * -1),0);
set_party_status(7,(get_char_status(pcs,7) * -1),0);
set_party_status(8,(get_char_status(pcs,8) * -1),0);
set_party_status(9,(get_char_status(pcs,9) * -1),0);
set_party_status(10,(get_char_status(pcs,10) * -1),0);
set_party_status(11,(get_char_status(pcs,11) * -1),0);
set_party_status(12,(get_char_status(pcs,12) * -1),0);
set_party_status(13,(get_char_status(pcs,13) * -1),0);
set_party_status(18,(get_char_status(pcs,18) * -1),0);
set_party_status(20,(get_char_status(pcs,20) * -1),0);
set_party_status(21,(get_char_status(pcs,21) * -1),0);
set_party_status(28,(get_char_status(pcs,28) * -1),0);
change_char_energy(pcs,9999);
change_char_health(pcs,9999);
				}

				pcs = (pcs + 1);
			}
			change_coins(-10);
		}
		else{
			print_str_color("Not enough gold!",1);
			end();
		}
	}
	if(bmessage == 3){
		if(coins_amount() >= 1000){
			pcs = 0;
			while(pcs < 4){
				if(char_ok(pcs) == FALSE){
					restore_pc(pcs);
				}
				pcs = (pcs + 1);
			}
			change_coins(-1000);
		}
		else{
			print_str_color("Not enough gold!",1);
			end();
		}
	}

break;