// specobj.txt - This very simple script waits until this object is searched. When it
// is, calls a given special node in the current town's script.

// Memory Cells - 
// 0 - What herb is this?
//	0 - none.
//	1 - Icicle moss
//	2 - Holly
//	3 - Frost Shrooms
//	4 - Karao Blossoms
//	5 - Strangle Weed
// 1 - how many herbs total? //default 1
// 2,3 - SDF coordinates.
// 4 - state to call.

beginterrainscript; 

variables;
short choice;

body;

beginstate INIT_STATE;
if ((get_memory_cell(0) < 0) || (get_memory_cell(0) > 5)){
	print_str_color("Error: Memory Cell not set properly.",2);
	end();
}
if(get_memory_cell(1) == 0)
	set_memory_cell(1,1);
	break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
print_str("OK");
if(get_flag(get_memory_cell(2),get_memory_cell(3)) >= get_memory_cell(1)){
	print_str_color("This herb supply has been exhausted.",4);
	end();
}
while(get_flag(get_memory_cell(2),get_memory_cell(3)) < get_memory_cell(1)){
	reward_give(469 + get_memory_cell(0));
	inc_flag(get_memory_cell(2),get_memory_cell(3),1);
}
if(get_memory_cell(0) == 1){
	if(get_memory_cell(1) > 1)
		print_str_color("You harvest a large patch of Icicle Moss.",4);
	else
		print_str_color("You successfully harvest Icicle Moss.",4);
	if(get_flag(250,1) == 0)
		message_dialog("The moss growing here hangs down from the crest of the boulder in a distinctive, triangular form, which gives the herb its name-- icicle moss. You recognize it immediately as one of the hearty alchemical regeants that can be found in these parts.","You carefully scrape off one of the greener tendrils-- this herb makes a useful catalyst in many potions.");
	set_flag(250,1,1);
}
if(get_memory_cell(0) == 2){
	if(get_memory_cell(1) > 1)
		print_str_color("You harvest a large patch of Mountain Holly.",4);
	else
		print_str_color("You successfully harvest Mountain Holly.",4);
	if(get_flag(250,2) == 0)
		message_dialog("You notice that some of the berries on this holly bush are approaching the deep purple color that the berries achieve when they are fully ripe. It is these berries that are useful in brewing potions.","It is unusual to find ripened berries at this time of year, but you aren't complaining. You pick a handful of the most mature berries.");
	set_flag(250,2,1);
}
if(get_memory_cell(0) == 3){
	if(get_memory_cell(1) > 1)
		print_str_color("You harvest a large patch of Frost Shrooms.",4);
	else
		print_str_color("You successfully harvest Frost Shrooms.",4);
	if(get_flag(250,3) == 0)
		message_dialog("This large blue mushroom is clearly a frost shroom. This strain of fungus thrives in this cold climate, but you've encountered it in the lowlands as well, and know that it is useful in purging the body of toxins.","You carefully carve out the base of the mushroom, discarding the large cap. Only the base is useful, which is unfortunate since it makes up such a small portion of the shroom.");
	set_flag(250,3,1);
}
if(get_memory_cell(0) == 4){
	if(get_memory_cell(1) > 1)
		print_str_color("You harvest a large patch of Karao Blossoms.",4);
	else
		print_str_color("You successfully harvest Karao Blossoms.",4);
	if(get_flag(250,4) == 0){
		reset_dialog();
		add_dialog_str(0,"You find a patch of delicate flowers growing here, an apparently impossible occurence. However when you inspect the flowers closer you notice a faint glow about them, and instantly understand how these fragile plants survive here.",0);
		add_dialog_str(1,"These are Karao Blossoms, a rare and potent regeant. A delicate plant needs all the advantages it can get in extreme climates like the Rim.",0);
		add_dialog_str(2,"Karao blossoms survive because of their powerful magical properties. They are saught by alchemists for the same reason. You gently pluck the brightest blossom in the patch.",0);
		add_dialog_choice(0,"OK");
		choice = run_dialog(1);
	}
	set_flag(250,4,1);
}
if(get_memory_cell(0) == 5){
	if(get_memory_cell(1) > 1)
		print_str_color("You harvest a large patch of Strangle Weed.",4);
	else
		print_str_color("You successfully harvest Strangle Weed.",4);
	if(get_flag(250,5) == 0){
		reset_dialog();
		add_dialog_str(0,"The trunk of this pine tree is whithered and sickly, all its needles have fallen off leaving it completely barren. Dead pine trees aren't an uncommon occurence, but sickly trees are a bit different. You approach to inspect it.",0);
		add_dialog_str(1,"As you suspected, this tree isn't dying of natural causes. Climbing up the tree is a creeping vine, with long needle-like tendrils burrowed into the bark of the tree-- strangle weed.",0);
		add_dialog_str(2,"You aren't rightly sure where this vine got it's name, from the choking effect it has on its host trees, or the same effect it has on humans who consume it.",0);
		add_dialog_str(3,"Regardless, you pluck a strand of the potent herb and wrap it in cloth, careful not to get any resin on your skin.",0);
		add_dialog_choice(0,"OK");
		choice = run_dialog(1);
	}
	set_flag(250,5,1);
}

break;
