// 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 dx = 0,dy = 12;
short last_abil;
short i_rang = 0;

body;

beginstate INIT_STATE;
	set_name(ME,"Golem Doomringer");
	set_char_unkillable(ME,1);
	set_level(ME,34);
	set_boss_level(ME,2);
	
	if (get_memory_cell(0) == 0)
		dx = 861;
		else dx = 871;
		
	if (gf(13,11) > 0)
		erase_char(ME);
		
	break;

beginstate DEAD_STATE;
	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 (gf(13,11) > 0) {
		set_char_unkillable(ME,0);
		
		damage_char(ME,5000,0);
		end();
		}
	if (gf(12,26) == 0) {
		heal_char(ME,1000);
		end();
		}
	if (i_rang)
		end();
		
	if (tick_difference(last_abil,get_current_tick()) > 0) {
		last_abil = get_current_tick();
		if (get_health(ME) < (get_max_health(ME) * 4) / 5) {
			heal_char(ME,get_max_health(ME) / 30);
			print_str_color("The golem is too damaged to move. It regenerates slowly.",2);
			
			if (gf(12,27) == 0) {
				sf(12,27,1);
				begin_talk_mode(20);
				}
			end();
			}
			else {
				if (dy < 6) {
					i_rang = 1;
					sf(12,28 + get_memory_cell(0),1);
					begin_talk_mode(21);
					}
				move_to_loc(ME,dx,dy);
				dy = dy - 1;
				print_str_color("A golem trudges slowly forward toward the gong.",3);
				}
		}
	
break;

beginstate TALKING_STATE;
	print_named_str(ME,"does not respond.");
break;