// Status Nearby v1.0.0
// statusnearby.txt
// by Kelandon (tomwatts@berkeley.edu)
// Once per turn, causes a status for nearby creatures if the party is in sight.

// Memory Cells - 
//	0 - Which status.
//	1 - Radius of status effect.
//	2 - How much of the status.
//	3 - Good_evil_or_all. If 0, only party-friendly creatures get the status. If
//		1, only party-hostile ones do. If 2, all creatures do.
//	4 - Sound to play when causing the status. If left at 0, none.
//	5 - What will deactivate the status-causing. If 0, an SDF (defined in cells
//		6 and 7). Currently this is the only choice, but obviously there is the
//		power to add more.
//	6,7 - If cell 5 is 0, coordinates of SDF that will deactivate the
//		status-causer.

beginterrainscript; 

variables;
short last_abil_time;
short i_am_active;

body;

beginstate INIT_STATE;
	last_abil_time = get_current_tick();
	i_am_active = 1;
break;

beginstate START_STATE;
if (get_memory_cell(5))
	if (get_flag(get_memory_cell(6),get_memory_cell(7)))
		i_am_active = 0;

if (i_am_active)
	if (tick_difference(get_current_tick(),last_abil_time) > 0)
		if (can_see_char(1000))
			{force_status_nearby(get_memory_cell(0),get_memory_cell(1),get_memory_cell(2),get_memory_cell(3));
			if (get_memory_cell(4) > 0)
				play_sound(get_memory_cell(4));
			last_abil_time = get_current_tick();
			}
break;

beginstate SEARCH_STATE;
break;
	
beginstate BLOCK_MOVE_STATE;
break;
