//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;
	last_walk = get_current_tick();

	set_name(ME,"Ozimus");
	set_resistance(ME,7,100);
	set_courage(ME,100);
	
	if (gf(62,1) > 0)
		erase_char(ME);
	if (gf(62,22) > 0)
		erase_char(ME);
	break;

beginstate DEAD_STATE;
	begin_talk_mode(11);
break;

beginstate START_STATE; 
	if (gf(62,3) == 0)
		end();

	if (path_a_or_b == 0) {
		if ((get_nearest_party_char(8) >= 0) || (who_shot_me() >= 0)) {
			sf(62,19,1);
			path_a_or_b = 1;
			talk_no_exit(30);
			}
		}
	else if (path_a_or_b == 1) {
		if (dist_to_nav_point(ME,0) <= 2) {
			if (gf(62,21) > 0)
				path_a_or_b = 2;
				else if ((dist_to_party() <= 6) || (who_shot_me() >= 0)) {
					path_a_or_b = 2;
					relocate_char(ME,406,271,0);
					talk_no_exit(12);
					}
			}
			else approach_nav_point(ME,0,1);
		}
	else if (path_a_or_b == 2) {
		if ((gf(62,21) > 0) || (get_health(ME) < get_max_health(ME) / 2)) {
			if ((dist_to_party() <= 6) || (who_shot_me() >= 0)) {
				path_a_or_b = 3;
				talk_no_exit(13);
				}
			}
		}
	else if (path_a_or_b == 3) {
		if (dist_to_nav_point(ME,1) <= 1) {
			if ((get_nearest_party_char(6) >= 0) || (who_shot_me() >= 0)) {
					talk_no_exit(14);
					}
			}
			else approach_nav_point(ME,1,2);
		}
		


	// if we're in combat and the above didn't give me anything to do, just
	// stop now. Otherwise, game will keep running script, and that eats up CPU time.
	if (am_i_doing_action() == FALSE)
		end_combat_turn();
break;

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

beginstate TALKING_STATE;
		print_str("Talking: Ozimus is too busy fleeing to talk to you.");

break;