// specobj.txt 

// A very simple and important script. When the object is used,
// triggers a hardcoded special encounter

// Cell 0 - phase of thing
// 1 - flag attached
// 2,3,4,5 - adjacent flags

beginobjectscript; // talking object

variables;

short do_jump = 0;

body;

beginstate INIT_STATE;
	break;

beginstate DEAD_STATE;
	break;

beginstate START_STATE; 
	break;

beginstate USE_STATE;
	if (gf(90,0) != get_memory_cell(0)) {
		ok_dlog(51,1);
		end();
		}

	if (gf(90,get_memory_cell(1)) > 0) {
		ok_dlog(49,1);
		end();
		}
	
	do_jump = 0;
	if (get_memory_cell(2) > 0) {
		if (gf(90,get_memory_cell(2)) > 0)
			do_jump = 1;
		}
	if (get_memory_cell(3) > 0) {
		if (gf(90,get_memory_cell(3)) > 0)
			do_jump = 1;
		}
	if (get_memory_cell(4) > 0) {
		if (gf(90,get_memory_cell(4)) > 0)
			do_jump = 1;
		}
	if (get_memory_cell(5) > 0) {
		if (gf(90,get_memory_cell(5)) > 0)
			do_jump = 1;
		}

	if (do_jump == 0) {
		ok_dlog(51,1);
		end();
		}
	
	play_sound(153);
	sf(90,get_memory_cell(1),1) ;
	if (gf(90,2) == 0) {
		sf(90,2,1);
		ok_dlog(53,1);
		}
	print_str("The sparks leap from one orb to another.");
break;

beginstate RUN_ANIM_STATE;
	if (gf(90,0) != get_memory_cell(0))
		end();
	if (gf(90,get_memory_cell(1)) == 0)
		end();
		
	if (get_ran(1,0,100) < 80)
		run_sparkles_on_object(ME,9 + get_ran(1,0,2),1,1);
		
	break;