// runebarrier.txt - This script produces a barrier that regenerates when
//	the space is stepped on, until a specified SDF hits one. The
//	barrier won't clear itself, so it should be done through another
//	script (most likely the town script).
//	The script lets you choose the type of barrier produced, as well
//	as the type of sparkles that show when it appears.
//		-Written by Ephesos

// Memory Cells - 
//   0 - Type of barrier summoned. 1 = fire, 2 = force.
//   1,2 - Coordinates for a stuff done flag. When the SDF is equal to 1,
//	the script won't regenerate the barrier anymore, and passage
//	won't be blocked anymore.
//   3 - Type of sparkles used when the barrier regenerates. (see Appendix
//	for the list of sparkles)


beginterrainscript; 

variables;

body;

beginstate INIT_STATE;
	if(get_flag(get_memory_cell(1),get_memory_cell(2)) != 1) {
		put_object_on_space(my_loc_x(),my_loc_y(), 2 + get_memory_cell(0));
		force_instant_terrain_redraw();
		}
break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
break;

beginstate STEP_INTO_SPOT_STATE;
	if(get_flag(get_memory_cell(1),get_memory_cell(2)) != 1) {
		block_entry(1);
		if(is_object_on_space(my_loc_x(),my_loc_y(), 2 + get_memory_cell(0)) == 0) {
			put_sparkles_on_space(my_loc_x(),my_loc_y(), get_memory_cell(3), 6);
			run_animation_sound(51); //shooting flames,
						 //or, your sound of choice
			put_object_on_space(my_loc_x(),my_loc_y(), 2 + get_memory_cell(0));
			force_instant_terrain_redraw();
			print_str_color("The barrier reappears!",2);
			}
		}
break;