// Searchable Terrain v1.1.0
// searchter.txt (variant of specobj.txt)
// by Kelandon (tomwatts@berkeley.edu)
// 
// Much the same as Search-Block, but will only do anything if the terrain on
// this spot is a particular kind.
//
// Memory Cells - 
//	0 - Number of a state in the town script. This is the state that is called
//		when the item is used.
//	1,2,3 - When the state is called. Cells 1, 2, and 3 correspond to being
//		searched, blocking the party's move, and being stepped into; 0 means
//		that the state will be called, and anything else means it won't.
//	4 - What terrain this spot has to be.

beginterrainscript; 

variables;

body;

beginstate INIT_STATE; // state 0
break;

beginstate START_STATE; // state 2
break;

beginstate SEARCH_STATE; // state 100
if (get_terrain(my_loc_x(),my_loc_y()) == get_memory_cell(4))
	if (get_memory_cell(1) == 0)
		run_town_script(get_memory_cell(0));
break;
	
beginstate BLOCK_MOVE_STATE; // state 112
if (get_terrain(my_loc_x(),my_loc_y()) == get_memory_cell(4))
	if (get_memory_cell(2) == 0)
		run_town_script(get_memory_cell(0));
break;
	
beginstate STEP_INTO_SPOT_STATE; // state 114
if (get_terrain(my_loc_x(),my_loc_y()) == get_memory_cell(4))
	if (get_memory_cell(3) == 0)
		run_town_script(get_memory_cell(0));
break;

beginstate UNLOCK_SPELL_STATE; // state 101 
break; 

beginstate SANCTIFICATION_STATE; // state 102 
break;

beginstate DISPEL_BARRIER_STATE; // state 113 
break; 