// Town 12: Bandit Camp
begintownscript;

variables;

short choice,i,j,k;
string dlgstr;

body;

beginstate INIT_STATE;
	set_crime_tolerance(2);
	
	reset_dialog();
	force_instant_terrain_redraw();
	add_dialog_str(0,"You approach the bandit camp south of Thassaka. You move stealthily through the trees, making no sound at all, hoping to reach the barbarians with the element of surprise.",0);
	add_dialog_str(1,"Suddenly you hear a hiss behind you, and you realize that you have been flanked! The barbarians knew that you were here, and they have attacked.",0);
	if (get_flag(11,2) == 1) {
		activate_hidden_group(1);
		add_dialog_str(2,"Fortunately, the army from Thassaka engages them as well. You are not alone in your fight, and the Thassakans can hold their own for a while at least.",0);
		}
	set_flag(12,0,run_dialog(1));
		
break;

beginstate EXIT_STATE;
	set_town_visibility(12,0);
	if (get_flag(11,2) == 0) {
		message_dialog("You flee the battle, as more and more bandits come charging in. They follow you and attack you from behind.","You never even see it coming.");
		kill_char(1000,2,0);
		}
	else
		set_flag(12,1,1);
break;

beginstate START_STATE;
	if (is_combat() == 1)
		end();
	if (get_flag(11,2) == 0)
		end();
	if (get_flag(12,2) != 0)
		end();
	
	k = 0;
	j = 0;
	i = 6;
	while ((i <= 31) && (j == 0)) {
		if (char_ok(i))
			j = 1;
		i = i + 1;
		}
	while ((i <= 43) && (j == 0)) {
		if (char_ok(i))
			k = k + 1;
		i = i + 1;
		}
	
	if (j == 0) {
		set_flag(12,2,1);
		if (k >= 2) {
			message_dialog("You have won the battle! The surviving Thassakans look at you with gratitude. _We would have been badly outmatched,_ one of them says, _if we did not have your aid. Consider this a token of our gratitude._","He hands you scroll upon which are written some advanced details on the casting of the spell, _Smite._");
			change_spell_level(0,1,5,2);
			change_spell_level(1,1,5,2);
			change_spell_level(2,1,5,2);
			change_spell_level(3,1,5,2);
			}
		else {
			message_dialog("You have won the battle! The sole surviving Thassakan looks at you with grim resolution. _We have defeated a strong contingent of barbarians, but the best of Thassaka's army is dead. I will reward you with what I have, but it is not much._","He hands you a pouch of gold.");
			change_coins(50);
			}
		}
	
break;

beginstate 10;
break;