// basicnpc.txt
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// NPC that doesn't move or do anything
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this is killed, set to 1.

begincreaturescript;

variables;

short i,target;
short which_targ = 0;
short which_step = 0;
short num_ae = 0;
short last_abil;
short ae_range = 5;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();
	which_targ = 2 * get_memory_cell(0);
	break;

beginstate DEAD_STATE;
	inc_flag(0,20,1);
break;

beginstate START_STATE; 
	if (dist_to_nav_point(ME,which_targ) > 1) {
		last_abil = get_current_tick();
		approach_nav_point(ME,which_targ,1);
		}
		else {
			if ((is_combat()) && (get_nearest_hate_char(ae_range) >= 0) && (tick_difference(last_abil,get_current_tick()) > 1)) {
				run_char_animation(2,1,35);	
				last_abil = get_current_tick();
		
					print_named_str(ME,"summons a rain of fire.");
					place_particle_num(ME,2,4,8);
					damage_nearby(get_ran(1,200,250),ae_range,2,0);
		
					drain_energy_nearby(50,ae_range,0);
		
					pc_heard_sound_delay(178,100);						
					create_missile_spiral(154,40,ae_range,2);
				num_ae = num_ae + 1;
				if (num_ae == 2)
					which_targ = which_targ + 1;
				
				}			
			}
		
break;

beginstate TALKING_STATE;
	print_str("Talking: It doesn't respond.");
break;