// TOWN SCRIPT
//    Town 3: Marralis

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

int i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	turn_off_training(1);
	if (get_flag(4,5) == 2) {
		erase_char(40);
		erase_char(38);
		erase_char(39);
		}
break;

beginstate EXIT_STATE;
// Always called when the town is left.
	if (get_flag(4,4) == 0) {
		block_entry(0);
		end();
		}
	if (get_flag(4,4) > 0 && get_flag(4,5) == 0) {
		message_dialog("You haven't finished what you need to do at the Great Circle! You cannot leave at this critical point.","");
		block_entry(1);
		// block_entry(1) allows the party to exit
		}
break;

beginstate START_STATE;
// Starting state of the town, called every turn until you change the state.
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(30,"Fight me!");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(30,"I challenge you");
	if (get_ran(1,0,100) < 6)
		text_bubble_on_char(30,"It's time to d-d-d-duel!");
	if (get_flag(4,3) == 0) {
		end();
		}
	i = 6;
	while (i < 38) {
		set_target(i,38);
		i = i + 1;
		}
break;

beginstate 10;
	if (get_flag(4,1) == 250) {
		end();
		}
	message_dialog("From this close, you can see a large group of Hunan gathered at the top of the hill. It would have been impossible for them to not spot you, but they do nothing.","Perhaps you can move closer.");
	set_flag(4,1,250);
break;

beginstate 11;
	if (get_flag(4,2) == 250) {
		end();
		}
	message_dialog("You can see the Great Circle quite well now. A huge beast of a Hunan, presumably Lu Liath, stands in the center. He roars something at you; you aren't sure what it is, but it sounds like something about a challenge or a champion.","If you go inside the circle, he'll probably personally fight you. This could be a good thing, or a bad thing.");
	set_flag(4,2,250);
break;

beginstate 12;
	if (get_flag(4,4) > 0 && get_flag(4,5) == 0) {
		message_dialog("You haven't finished what you need to do at the Great Circle! You cannot leave at this critical point.","");
		block_entry(1);
		// block_entry(1) allows the party to exit
		}
break;

