begincreaturescript;

variables;

short i,target;
short beam;
short pc;
short randy;
short randx;
short locx;
short locy;

body;

beginstate INIT_STATE;
	if (get_memory_cell(0) == 2)
		set_mobility(ME,0);
	break;

beginstate DEAD_STATE;

	activate_hidden_group(3);
	relocate_character(56,my_loc_x(),my_loc_y());
	put_boom_on_char(ME,4,0);
	force_instant_terrain_redraw();
	run_animation_sound(102);
	pause(4);
	put_boom_on_space(my_loc_x(),my_loc_y(),0,4);
	put_boom_on_space(my_loc_x(),my_loc_y(),1,4);
	put_boom_on_space(my_loc_x(),my_loc_y(),0,4);
	put_boom_on_space(my_loc_x(),my_loc_y(),1,4);
	erase_char(56);
	erase_char(ME);
	put_stain_on_space(my_loc_x(),my_loc_y(),6);
	force_instant_terrain_redraw();
	run_animation_sound(5);
	force_instant_terrain_redraw();
	pause(2);

	if(get_flag(64,2) == 1){
		set_terrain(23,29,0);
		set_terrain(24,29,0);
		set_terrain(25,29,0);
		put_effect_on_space(23,29,8,4,0);
		put_effect_on_space(24,29,8,4,0);
		put_effect_on_space(25,29,8,4,0);
		force_instant_terrain_redraw();
		run_animation_sound(90);
		award_party_xp(500,40);
		award_party_xp(500,40);
		award_party_xp(500,40);
		award_party_xp(500,40);
	}
	else{
		message_dialog("One down, one to go...","");
		set_flag(64,2,1);
	}

break;

beginstate START_STATE; 
	if(get_ran(1,1,4) == 1){
		randx = get_ran(1,1,11);
		randy = get_ran(1,1,10);
		locx = (randx + 18);
		locy = (randy + 18);
		relocate_character(my_number(),locx,locy);
		print_str_color("The Holy Warrior teleports!",4);
		play_sound(10);
	}
if(can_see_loc(char_loc_x(0),char_loc_y(0)) == 1 || can_see_loc(char_loc_x(1),char_loc_y(1)) == 1 || can_see_loc(char_loc_x(2),char_loc_y(2)) == 1 || can_see_loc(char_loc_x(3),char_loc_y(3)) == 1){
	beam = 0;
	while(beam == 0){
		pc = random_party_member();
		if(can_see_loc(char_loc_x(pc),char_loc_y(pc)) == 1){
put_straight_zap(my_loc_x(),my_loc_y(),char_loc_x(pc),char_loc_y(pc),2);
set_character_pose(ME,1);
force_instant_terrain_redraw();
run_animation_sound(4);
damage_char(pc,100,4);
set_char_status(pc,2,-50,1,1);
print_str_color("Holy Beam!",4);
			beam = 1;
pause(1);
set_character_pose(ME,2);
		}
	}
}
break;

beginstate TALKING_STATE;
	print_str("Talking: It doesn't respond.");
break;