//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 - Which dude is this? 0 1 2 3 4 5

begincreaturescript;

variables;

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

body;

beginstate INIT_STATE;
	last_walk = get_current_tick();
	set_courage(ME,0);

	if (get_memory_cell(4) == 0) 
		set_name(ME,"Doral");
	if (get_memory_cell(4) == 1) 
		set_name(ME,"Howell");
	if (get_memory_cell(4) == 3) 
		set_name(ME,"Penn");
	if (get_memory_cell(4) == 2) 
		set_name(ME,"Belyna");
	if (get_memory_cell(4) == 4) 
		set_name(ME,"Allison");
	if (get_memory_cell(4) == 5) 
		set_name(ME,"Ssserok");
		
	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 I have a target for some reason, go attack it
	if (target_ok()) {
		if (dist_to_char(get_target()) <= 16)
			set_state(3);
			else set_foe_target(ME,-1);
		}
	
	// Look for a target, attack it if visible
	if (get_foe_target(ME,12,0)) {
		if (dist_to_party() > 8)
			approach_char(ME,30000,7);
			else {
				do_attack();
				set_state(3);
				}
		}
		
	// Have I been hit? Strike back!
	if (who_shot_me() >= 0) {
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}

	if (get_memory_cell(4) == 0) {
		if (gf(165,7) == 4) {
			if (dist_to_nav_point(ME,5) <= 1) {
				sf(165,7,5);
				erase_char(ME);
				if (gf(165,12) == 1)
					begin_talk_mode(186);
					else begin_talk_mode(185);
				}
			approach_nav_point(ME,5,1);
			}
		}
	if (get_memory_cell(4) == 1) {
		if (gf(165,7) == 7) {
			if (dist_to_nav_point(ME,5) <= 1) {
				sf(165,7,8);
				erase_char(ME);
				begin_talk_mode(172);
				}
			approach_nav_point(ME,5,1);
			}
		}
	if ((get_memory_cell(4) == 2) || (get_memory_cell(4) == 3)) {
		if (gf(165,14) == 1) {
			if (dist_to_nav_point(ME,5) <= 1) {
				erase_char(17885);
				erase_char(17886);
				begin_talk_mode(173);
				}
			approach_nav_point(ME,5,1);
			}
		if (gf(165,14) == 2) {
			if (dist_to_nav_point(ME,4) <= 1) {
				erase_char(17885);
				erase_char(17886);
				begin_talk_mode(174);
				}
			approach_nav_point(ME,4,1);
			}
		}
		

	if (get_memory_cell(4) > 3) {
		if (gf(165,7) >= 11) {
			if (dist_to_nav_point(ME,4) <= 1) {
				print_named_str(ME,"reaches the closed gate. A guard opens it slightly.");
				print_str_color("  She slips through and the gate closes again.",2);
				erase_char(ME);
				end();
				}
			approach_nav_point(ME,4,1);
			}
		}



	// 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;
		if (gf(165,7) < 3)
			begin_talk_mode(170);
	if (get_memory_cell(4) == 0) {
		if (gf(165,7) == 3)
			begin_talk_mode(180);
		if (gf(165,7) > 3)
			print_str_color("He is heading toward the portal. He doesn't hear you.",2);
			
		}
	if (get_memory_cell(4) == 1) {
		if (gf(165,7) < 5)
			begin_talk_mode(171);
		if (gf(165,7) == 5)
			print_str_color("Sergeant Nichol shouts, 'Not so fast! Check in with me first!'",2);
		if (gf(165,7) == 6)
			begin_talk_mode(190);
		if (gf(165,7) > 6)
			print_str_color("He is heading toward the portal. He doesn't hear you.",2);
		}
	if ((get_memory_cell(4) == 2) || (get_memory_cell(4) == 3)) {
		if ((gf(165,7) == 8) || (gf(165,7) == 9)) {
			print_str_color("Sergeant Nichol shouts, 'Not yet! Something isn't right!'",2);
			end();
			}
		if (gf(165,7) < 10)
			begin_talk_mode(171);
		if ((gf(165,7) == 10) || (gf(165,7) == 11)) {
			print_named_str(ME,"is too transfixed with fear to speak.");
			end();
			}
		if (gf(165,7) < 13)
			begin_talk_mode(200);
		print_named_str(ME,"is too busy running to pay attention to you.");
		end();
		}
		
	if (get_memory_cell(4) >= 4) {
		if ((gf(165,7) == 8) || (gf(165,7) == 9)) {
			print_str_color("Sergeant Nichol shouts, 'Not yet! Something isn't right!'",2);
			end();
			}
		if (gf(165,7) < 10)
			begin_talk_mode(171);
		if (gf(165,7) == 10) {
			print_named_str(ME,"is too transfixed with fear to speak.");
			end();
			}
		if (gf(165,7) >= 11)
			print_str_color("She is running for her life. She ignores you.",2);
		}
		

break;