// t8Adlerauge.txt
//
// by Jeremy "Terror's Martyr" LeVeque
//

begincreaturescript;

variables;

short poink,px,py,mx,my,ok,gc;
short max,nowhp,pcent,potion;
short perish,hit;

body;

beginstate INIT_STATE;
	break;

beginstate DEAD_STATE;

	if(get_flag(66,2) == 1){
		message_dialog("General Adlerauge falls to the ground, defeated.  He points a finger to you with his last breath.","_You...  You don't understand.  You'll never understand._  He topples over lifelessly.");
	}
	if(get_flag(66,2) == 2){
		message_dialog("General Adlerauge falls to the ground, defeated.  He points a finger to you with his last breath.","_You can never aim for the center of the bulls-eye if you can't read zeros..._  He topples over lifelessly.");
	}
	if(get_flag(66,2) == 3){
		message_dialog("General Adlerauge falls to the ground, defeated.  He points a finger to you with his last breath.","_Absolute values of negative numbers, they're also positive.  Looks like you won't be able to escape after all..._  He topples over lifelessly.");
	}
	if(get_flag(66,2) == 4){
		message_dialog("General Adlerauge falls to the ground, defeated.  He points a finger to you with his last breath.","_Emery, he chose well.  Fight on, warriors..._  He topples over lifelessly.");
	}
	message_dialog("You have slain a rogue general collaborating with Zauberer of Sud Canopy.  What, though, were they trying to do?","Maybe now, you will be able to escape from this place and get some real answers on the other side.");
	set_terrain(5,14,0);
	set_terrain(6,14,0);
	set_terrain(7,14,0);

	set_flag(17,0,12);
	award_party_xp(500,40);
	award_party_xp(500,40);
	award_party_xp(500,40);

break;

beginstate START_STATE; 

max = get_max_health(ME);
potion = (max / 5);
nowhp = get_health(ME);

while(nowhp <= potion && get_flag(65,2) <= 3){
	if(get_flag(65,2) <= 3){
		play_sound(28);
		change_char_health(ME,potion);
		print_str("General Adlerauge swallows a healing potion!");
		inc_flag(65,2,1);
	}

max = get_max_health(ME);
potion = (max / 5);
nowhp = get_health(ME);

}

gc = 1;

ok = 0;

if(enemies_nearby(10) == 0)
	end();

while(ok < gc){

	poink = get_ran(1,0,119);
	if (char_ok(poink)) {
		px = char_loc_x(poink);
		py = char_loc_y(poink);

		if(can_see_loc(px,py) == 1 && get_attitude(poink) != get_attitude(ME)){
			perish = get_ran(1,1,20);
			if(perish == 1){
				text_bubble_on_char(ME,"Die!");
			}
			if(perish == 2){
				text_bubble_on_char(ME,"Thine mother a swine was!");
			}
			if(perish == 3){
				text_bubble_on_char(ME,"Perish!");
			}
			if(perish == 4){
				text_bubble_on_char(ME,"Rest in pieces!");
			}
			if(perish == 5){
				text_bubble_on_char(ME,"You get to burning!");
			}
			if(perish == 6){
				text_bubble_on_char(ME,"Take this!");
			}
			if(perish == 7){
				text_bubble_on_char(ME,"Shinde!");
			}
			if(perish == 8){
				text_bubble_on_char(ME,"Death comes for you!");
			}
			if(perish == 9){
				text_bubble_on_char(ME,"Stirb!");
			}
			if(perish == 10){
				text_bubble_on_char(ME,"Rot in hell!");
			}
			if(perish == 11){
				text_bubble_on_char(ME,"Dance with the reaper!");
			}
			if(perish == 12){
				text_bubble_on_char(ME,"Say hello to my little friend.");
			}
			if(perish == 13){
				text_bubble_on_char(ME,"Time to die!");
			}
			if(perish == 14){
				text_bubble_on_char(ME,"Damn you to hell!");
			}
			if(perish == 15){
				text_bubble_on_char(ME,"Feel the mayhem!");
			}
			if(perish == 16){
				text_bubble_on_char(ME,"I...  will kill you.");
			}
			if(perish == 17){
				text_bubble_on_char(ME,"Taste the pain!");
			}
			if(perish == 18){
				text_bubble_on_char(ME,"This is the end for you!");
			}
			if(perish == 19){
				text_bubble_on_char(ME,"Cease living!");
			}
			if(perish == 20){
				text_bubble_on_char(ME,"Today, you die!");
			}
			force_instant_terrain_redraw();
			pause(10);
			
			text_bubble_on_char(ME,"");
			mx = my_loc_x();
			my = my_loc_y();
			put_straight_zap(mx,my,px,py,5);
			set_character_pose(ME,1);
			force_instant_terrain_redraw();
			run_animation_sound(91);
			hit = get_ran(1,1,100);
			if(hit >= 20){
				damage_char(poink,get_ran(10,10,20),0);
			}
			else{
				play_sound(2);
				print_str("General Adlerauge misses!");
			}
			pause(5);

			set_character_pose(ME,2);
			force_instant_terrain_redraw();
			pause(3);
			ok = ok + 1;
		}
	}
}
break;

beginstate TALKING_STATE;
	if (get_memory_cell(3) == 0) {
		print_str("Talking: It doesn't respond.");
		end();
		}
	begin_talk_mode(get_memory_cell(3));
break;