// townscript for town 18: Attack Empire HQ.

begintownscript;

variables;

int choice;

body;

beginstate INIT_STATE;
break;

beginstate EXIT_STATE;
break;

beginstate START_STATE;
break;

beginstate 10;

if (get_flag(16,0) == 9) {
		message_dialog("The battle is over. There is nothing to see. To proceed to the Empire HQ, leave this place as you came here and walk to the Empire HQ as normal.","(through the outdoors, that is)");
		block_entry(1);
		end();
		}
		
		reset_dialog();
		add_dialog_str(0,"This road leads to the Empire HQ. You're on your way to the Empire HQ (or at least you're passing by), when something disturbing is happening.",0);
		add_dialog_str(1,"The forest is quiet, nothing moves. Dust floats through the air, towards you. As you walk on, the dust slowly fades and you see the Thralni - Empire conflict has reached a breaking point.",0);
		add_dialog_str(2,"A massive army has gathered in front of the Empire HQ! You decide to wait and see what happens. It would be foolish to just charge in. Then you hear calls and cries.",0);
		add_dialog_choice(0,"Oh oh...");
		choice = run_dialog(1);

// 1) Start of the cutscene

		text_bubble_on_char(0,"That looks serious");
		force_instant_terrain_redraw();
		pause(15);

		text_bubble_on_char(0,"");
		text_bubble_on_char(1,"Lets stay here");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(1,"");
		text_bubble_on_char(1,"and wait");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(1,"");
		text_bubble_on_char(1,"until its over");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(1,"");
		text_bubble_on_char(2,"I agree.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(2,"");
		text_bubble_on_char(3,"Me too.");
		force_instant_terrain_redraw();
		pause(15);

// 2) talking to men: Thralni
		
		text_bubble_on_char(3,"");
		set_total_visibility(1);
		force_view_center(45,35);
		force_instant_terrain_redraw();
		pause(10);

		text_bubble_on_char(7,"Today...");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"is the day...");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"the Empire shall pay");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"for ruining Riverrod");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"and banning me");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"Me, and my followers");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"The Empire shall regret");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"the day they came");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"to attack the Thraldom");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"Follow me");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"my soldiers");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"into the fight");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(7,"");
		text_bubble_on_char(7,"of your life!!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(6,"yeeeeeee!");
		text_bubble_on_char(8,"yeeeeeee!");
		text_bubble_on_char(9,"yeeeeeee!");
		text_bubble_on_char(10,"yeeeeeee!");
		text_bubble_on_char(11,"yeeeeeee!");
		text_bubble_on_char(12,"yeeeeeee!");
		text_bubble_on_char(13,"yeeeeeee!");
		text_bubble_on_char(14,"yeeeeeee!");
		force_instant_terrain_redraw();
		pause(25);
		
		force_view_center(45,20);
		text_bubble_on_char(6,"");
		text_bubble_on_char(7,"");
		text_bubble_on_char(8,"");
		text_bubble_on_char(9,"");
		text_bubble_on_char(10,"");
		text_bubble_on_char(11,"");
		text_bubble_on_char(12,"");
		text_bubble_on_char(13,"");
		text_bubble_on_char(14,"");
		force_instant_terrain_redraw();
		pause(15);

// 3) Talking to men: Empire

		text_bubble_on_char(18,"The moment");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"is finally there");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"Thralni");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"stands in front");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"of our castle gates");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"If he thinks");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"he can crush");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"the Empire powers");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"then he is mistaken!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(15,"yeeeeeee!!");
		text_bubble_on_char(16,"yeeeeeee!!");
		text_bubble_on_char(17,"yeeeeeee!!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"Silence!");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(15,"");
		text_bubble_on_char(16,"");
		text_bubble_on_char(17,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(18,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(18,"We shall crush him");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"AND his army!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"We'll find his hideout!!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"We'll destroy Riverrod!!!");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(15,"yeeeeeee!!");
		text_bubble_on_char(16,"yeeeeeee!!");
		text_bubble_on_char(17,"yeeeeeee!!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(15,"");
		text_bubble_on_char(16,"");
		text_bubble_on_char(17,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(18,"Follow me");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"And may god");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		text_bubble_on_char(18,"be with us!");
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(18,"");
		force_instant_terrain_redraw();
		pause(15);
		
// 4) army's run to meat eachother

		run_animation_sound(16);
		pause(5);
		
		run_animation_sound(18);
		pause(5);

		text_bubble_on_char(6,"yeeeeeee!");
		text_bubble_on_char(8,"yeeeeeee!");
		text_bubble_on_char(9,"yeeeeeee!");
		text_bubble_on_char(10,"yeeeeeee!");
		text_bubble_on_char(11,"yeeeeeee!");
		text_bubble_on_char(12,"yeeeeeee!");
		text_bubble_on_char(13,"yeeeeeee!");
		text_bubble_on_char(14,"yeeeeeee!");
		text_bubble_on_char(15,"yeeeeeee!");
		text_bubble_on_char(16,"yeeeeeee!");
		text_bubble_on_char(17,"yeeeeeee!");
		force_instant_terrain_redraw();
		pause(10);

// 5) Blasting the gates

		force_view_center(45,29);
		force_instant_terrain_redraw();
		pause(10);

		put_straight_zap(43,35,45,28,0);
		put_boom_on_space(45,28,1,0);
		run_animation_sound(54);
		run_animation();
		set_terrain(45,28,137);
		pause(5);
		
		put_straight_zap(45,33,46,27,0);
		put_boom_on_space(46,27,1,0);
		run_animation_sound(54);
		run_animation();
		set_terrain(46,27,137);
		pause(5);
		
		put_straight_zap(43,35,43,27,0);
		put_boom_on_space(43,27,1,0);
		run_animation_sound(54);
		run_animation();
		set_terrain(43,27,137);
		pause(5);
		
		put_straight_zap(47,37,47,27,0);
		put_boom_on_space(47,27,1,0);
		run_animation_sound(54);
		run_animation();
		set_terrain(47,27,137);
		pause(5);

		text_bubble_on_char(6,"");
		text_bubble_on_char(8,"");
		text_bubble_on_char(9,"");
		text_bubble_on_char(10,"");
		text_bubble_on_char(11,"");
		text_bubble_on_char(12,"");
		text_bubble_on_char(13,"");
		text_bubble_on_char(14,"");
		force_instant_terrain_redraw();
		pause(3);

// 6) Empire army running
	
		text_bubble_on_char(18,"lets get them!");
		relocate_character(18,45,22);
		relocate_character(15,44,21);
		relocate_character(16,46,19);
		relocate_character(17,46,21);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(18,45,23);
		relocate_character(15,45,21);
		relocate_character(16,46,20);
		put_straight_zap(45,37,44,27,0);
		put_boom_on_space(44,27,1,0);
		run_animation_sound(54);
		run_animation();
		set_terrain(44,27,137);
		force_instant_terrain_redraw();
		pause(8);
		
		relocate_character(18,45,24);
		relocate_character(15,45,22);
		relocate_character(16,46,21);
		relocate_character(17,45,21);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(18,45,25);
		relocate_character(15,45,23);
		relocate_character(16,45,21);
		relocate_character(17,45,22);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(18,45,26);
		relocate_character(15,45,24);
		relocate_character(16,45,22);
		relocate_character(17,45,23);
		text_bubble_on_char(15,"");
		text_bubble_on_char(16,"");
		text_bubble_on_char(17,"");
		text_bubble_on_char(18,"");
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(18,45,27);
		relocate_character(15,45,25);
		relocate_character(16,45,23);
		relocate_character(17,45,24);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(18,44,27);
		relocate_character(15,45,26);
		relocate_character(16,45,24);
		relocate_character(17,45,25);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(18,43,27);
		relocate_character(15,45,27);
		relocate_character(16,45,26);
		relocate_character(17,45,25);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(15,44,27);
		relocate_character(16,45,27);
		relocate_character(17,45,26);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(16,46,27);
		relocate_character(17,45,27);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(16,47,27);
		relocate_character(17,46,27);
		force_instant_terrain_redraw();
		pause(3);

// 7) Empire in place, commanding

		text_bubble_on_char(18,"Stay behind the walls!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(18,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(15,"Yes sir!");
		text_bubble_on_char(16,"Yes sir!");
		text_bubble_on_char(17,"Yes sir!");
		text_bubble_on_char(18,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(15,"");
		text_bubble_on_char(16,"");
		text_bubble_on_char(17,"");
		force_view_center(45,32);
		force_instant_terrain_redraw();
		pause(30);
		
		message_dialog("You look at the parties. Both standing, with a wall in between them. The silence is oppressive as a big stone on your shoulders.","A trumpet begins to play, and the two armies run to fight each other.");
		
		run_animation_sound(16);
		pause(5);
		
		run_animation_sound(18);
		pause(10);
		
// 8) Starting fight
		
		put_straight_zap(43,37,45,35,0);
		put_boom_on_space(45,35,1,0);
		run_animation_sound(54);
		run_animation();
		set_terrain(45,35,137);
		pause(5);
		
		text_bubble_on_char(6,"yeeeeeee!");
		text_bubble_on_char(7,"yeeeeeee!");
		text_bubble_on_char(8,"yeeeeeee!");
		text_bubble_on_char(9,"yeeeeeee!");
		text_bubble_on_char(10,"yeeeeeee!");
		text_bubble_on_char(11,"yeeeeeee!");
		text_bubble_on_char(12,"yeeeeeee!");
		text_bubble_on_char(13,"yeeeeeee!");
		text_bubble_on_char(14,"yeeeeeee!");
		relocate_character(6,43,32);
		relocate_character(7,45,32);
		relocate_character(8,47,32);
		relocate_character(9,43,34);
		relocate_character(10,47,34);
		relocate_character(11,47,36);
		relocate_character(12,45,36);
		relocate_character(13,43,36);
		relocate_character(14,45,38);
		force_instant_terrain_redraw();
		pause(3);
		
		relocate_character(6,43,31);
		relocate_character(7,45,31);
		relocate_character(8,47,31);
		relocate_character(9,43,33);
		relocate_character(10,47,33);
		relocate_character(11,47,35);
		relocate_character(12,45,35);
		relocate_character(13,43,35);
		relocate_character(14,45,37);
		force_instant_terrain_redraw();
		pause(3);
		
		text_bubble_on_char(6,"");
		text_bubble_on_char(7,"");
		text_bubble_on_char(8,"");
		text_bubble_on_char(9,"");
		text_bubble_on_char(10,"");
		text_bubble_on_char(11,"");
		text_bubble_on_char(12,"");
		text_bubble_on_char(13,"");
		text_bubble_on_char(14,"");
		relocate_character(6,43,30);
		relocate_character(7,45,30);
		relocate_character(8,47,30);
		relocate_character(9,43,32);
		relocate_character(10,47,32);
		relocate_character(11,47,34);
		relocate_character(12,45,34);
		relocate_character(13,43,34);
		relocate_character(14,45,36);
		force_instant_terrain_redraw();
		pause(3);
		
		put_straight_zap(44,27,47,30,0);
		put_boom_on_space(47,30,1,0);
		run_animation_sound(54);
		run_animation_sound(29);
		run_animation();
		kill_char(8,2,0);
		relocate_character(10,47,31);
		relocate_character(13,43,33);
		relocate_character(14,45,35);
		force_instant_terrain_redraw();
		pause(3);
		
		if (get_flag(18,0) == 0) {
				force_view_center(48,56);
				force_instant_terrain_redraw();
				pause(5);
				}
			if (get_flag(18,0) == 1) {
					force_view_center(7,13);
					force_instant_terrain_redraw();
					pause(5);
					}
		
		run_animation_sound(13);
		text_bubble_on_char(1,"Why do they do it?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(1,"");
		text_bubble_on_char(0,"I really don't know.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(0,"");
		force_view_center(45,30);
		force_instant_terrain_redraw();
		
		put_straight_zap(43,33,44,22,0);
		put_boom_on_space(44,22,1,0);
		run_animation_sound(54);
		set_terrain(44,22,126);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,22,137);
		set_terrain(44,23,126);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,24,126);
		set_terrain(44,23,137);
		force_instant_terrain_redraw();
		pause(3);
		

		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,25,126);
		set_terrain(44,24,80);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,26,126);
		set_terrain(44,25,80);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,27,126);
		set_terrain(44,26,80);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,27,126);
		run_animation_sound(29);
		run_animation();
		kill_char(15,2,0);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,28,126);
		set_terrain(44,27,137);
		force_instant_terrain_redraw();
		pause(3);
		
		set_terrain(44,28,137);
		force_instant_terrain_redraw();
		pause(3);
		
		message_dialog("At this moment, the Empire army is much smaller, and Thralni's army is quite big. The two armies stand at the walls, ready to kill each other.","");
		
		// View now at the wall in southern corner of field
		
		force_view_center(13,51);
		force_instant_terrain_redraw();
		pause(20);
		
		force_view_center(14,35);
		force_instant_terrain_redraw();
		pause(20);
		
		text_bubble_on_char(46,"Thralni!");
		force_instant_terrain_redraw();
		pause(15);
		
		force_view_center(13,51);
		text_bubble_on_char(46,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(45,"Ye!");
		force_instant_terrain_redraw();
		pause(15);
		
		force_view_center(14,35);
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(46,"You're gonna die now!");
		text_bubble_on_char(45,"");
		force_instant_terrain_redraw();
		pause(15);
		
		force_view_center(13,51);
		text_bubble_on_char(46,"");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(45,"I don't think so!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(45,"");
		text_bubble_on_char(45,"Soldiers");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(45,"");
		text_bubble_on_char(45,"ATTACK!");
		force_instant_terrain_redraw();
		pause(15);
		
		force_view_center(14,35);
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(0,"");
		text_bubble_on_char(45,"");
		text_bubble_on_char(46,"ATTACK!");
		force_instant_terrain_redraw();
		pause(15);
		
		message_dialog("The leftovers of the two armies run to each other, screaming. Of terror, maybe, but probably to fight for justice, to fight for that what they think is good.","The battle takes some time. You keep watching until it is over. When it has finally finished, You turn away and walk back. The Empire didn't win. It was Thralni who won.");
		
		if (get_flag(18,0) == 0) {
				force_view_center(48,56);
				force_instant_terrain_redraw();
				pause(5);
				}
			if (get_flag(18,0) == 1) {
					force_view_center(7,13);
					force_instant_terrain_redraw();
					pause(5);
					}
		
		set_town_visibility(18,0);
		set_flag(16,0,9);
		set_flag(18,1,1);
		set_flag(200,1,1);
		set_total_visibility(0);
		
		block_entry(1);
		
	end();
	
break;