// basicnpc.txt
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// Memory Cells:
//   Cell 0 - How creature moves.
//     0 - If 0, wander randomly. 
//     1 - Stands still until a target appears.
//     2 - Completely immobile, even if target appears.
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this 
//     is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when
//     creature is killed, sets SDF(3,5) to 1.)
//   Cell 3 - Dialogue node to start with if talked to. if left at 0, this
//     character doesn't talk.

begincreaturescript;

variables;

short i,target,charschk,charscnt,counting,last_abil_time;

body;

beginstate INIT_STATE;
	if (get_memory_cell(0) == 2)
		set_mobility(ME,0);
	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))
		set_flag(get_memory_cell(1),get_memory_cell(2),1);
break;

beginstate START_STATE; 

			charschk = 80;
			charscnt = 0;
			while(charschk <= 119 && charscnt < 1){
				if(char_ok(charschk) == TRUE){
					charscnt = (charscnt + 1);
				}
				charschk = (charschk + 1);
			}

			if(charscnt >= 2){
				charschk = 80;
				while(charschk <= 119){
					if(char_ok(charschk) == TRUE){
put_effect_on_space(char_loc_x(charschk),char_loc_y(charschk),12,1,2);
erase_char(charschk);
					}
					charschk = (charschk + 1);
				}
				set_character_pose(ME,1);
				force_instant_terrain_redraw();
				run_animation_sound(69);
				pause(4);

			}

			else{
put_effect_on_space(char_loc_x(0),char_loc_y(0),12,1,2);
set_character_pose(ME,1);
force_instant_terrain_redraw();
run_animation_sound(69);
damage_char(0,get_ran(6,1,7),0);
			}

			if(is_combat() == TRUE)
				set_character_pose(ME,2);
			if(is_combat() ==FALSE)
				set_character_pose(ME,0);
			force_instant_terrain_redraw();
			pause(4);

			if(get_flag(68,0) == 0){
				message_dialog("A throwing axe?  How unique!  And to think, he threw it in the distance, and also caught it seemlessly.","Perhaps this one is not to be underestimated, then.");
				set_flag(68,0,1);
			}



break;

beginstate 3; // attacking

break;

beginstate TALKING_STATE;

break;