//twopts.txt - Like basic monst, but this character spends all its time 
// oscillating between its start point and a given nav point.
// Memory Cells:
//   Cell 0 - Dialogue node when spoken to
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this is killed, set to 1.
//	 Cell 3 - The nav point the character marches out to.
//   Cell 4 - If nonzero, the character runs to its nav point immediately.
//     If 0, only goes occasionally.

begincreaturescript;

variables;

short i,target;
short path_a_or_b = 0;
short last_walk;

body;

beginstate INIT_STATE;
	set_name(ME,"Gremess");
	set_char_unkillable(ME,1);
	
	if (gf(163,1) > 0)
		erase_char(ME);
		
	last_walk = get_current_tick();

	break;

beginstate DEAD_STATE;
	// Set the appropriate stuff done flag for this character being dead
	if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
		inc_flag(get_memory_cell(1),get_memory_cell(2),1);
break;

beginstate START_STATE; 
	if (path_a_or_b == 0) {
		if (get_nearest_party_char(5) >= 0) {
			path_a_or_b = 1;
			talk_no_exit(10);
			}
		}
		else {
			if (dist_to_nav_point(ME,2) <= 4)
				erase_char(ME);
			approach_nav_point(ME,2,2);
			}
			

break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);
	do_attack();
break;

beginstate TALKING_STATE;
	if (path_a_or_b == 0) {
			path_a_or_b = 1;
			talk_no_exit(10);
			}
break;