// Object On Me v1.0
// objectonme.txt
// by Kelandon (tomwatts@berkeley.edu)
// 
// Call a town state when an object is on it. Note that terrain scripts call
// their START_STATEs at weird times. Adjust as needed.
//
// Memory Cells
//	0 - Which object to react to.
//	1 - Which town state to call.
//	2 - Whether to delete this object when the town script is called. If 0, no.
//		If 1, delete it before calling the script. If 2, delete it after.
//	3 - What script mode to set this script to. Generally 2 is good, but you can
//		choose any. From the docs:
//		0 - Call every 8 moves, but not if party is far away.
//		1 - Call every 8 moves, even if party is far away.
//		2 - Call every move, but not if party is far away.
//		3 - Call every move, even if party is far away.

beginterrainscript; 

variables;

body;

beginstate INIT_STATE; // state 0
	set_script_mode(get_memory_cell(3));
break;

beginstate START_STATE; // state 2
if (is_object_on_space(my_loc_x(),my_loc_y(),get_memory_cell(0)) == 0)
	end();
	
	if (get_memory_cell(2) == 1)
		put_object_on_space(my_loc_x(),my_loc_y(),-1);
	run_town_script(get_memory_cell(1));
	if (get_memory_cell(2) == 2)
		put_object_on_space(my_loc_x(),my_loc_y(),-1);
break;

beginstate SEARCH_STATE; // state 100
break;

beginstate UNLOCK_SPELL_STATE; // state 101
break;

beginstate SANCTIFICATION_STATE; // state 102
break;

beginstate BLOCK_MOVE_STATE; // state 112
break;

beginstate DISPEL_BARRIER_STATE; // state 113
break;

beginstate STEP_INTO_SPOT_STATE; // state 114
break;