// barrier.txt - A magic barrier, dispelled by the Dispel Barrier spell
// Cell 0 - The strength of the spell needed to dispel it.
//  0 - level 1, 1 - level 2, 2 - level 3
// Call 1,2 - The stuff done flag to set to 1 when the barrier gone

beginobjectscript;

variables;

body;

beginstate INIT_STATE;
	if ((get_memory_cell(1) > 0) || (get_memory_cell(2) > 0)) {
		if (get_sdf(get_memory_cell(1),get_memory_cell(2)) > 0)
			kill_object(ME,1);
		}

	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; 
	if ((get_memory_cell(1) > 0) || (get_memory_cell(2) > 0)) {
		if (get_sdf(get_memory_cell(1),get_memory_cell(2)) > 0)
			kill_object(ME,0);
		}
break;

beginstate DISPEL_STATE;
	if (current_unlock_strength() >= get_memory_cell(0) + 1) {
		if ((get_memory_cell(1) > 0) || (get_memory_cell(2) > 0))
			set_flag(get_memory_cell(1),get_memory_cell(2),1);
		print_str_color("Dispel Barrier: The barrier fades away.",2);
		kill_object(ME,0);
		}
		else if (get_memory_cell(0) >= 90)
			print_str_color("Dispel Barrier: This barrier is too powerful to ever be affected by this spell.",2);
			else {
				print_str_color("Dispel Barrier: The spell is too weak to affect this barrier.",2);
				print_str_color("  (You need to cast Dispel Barrier at a higher level to remove it.)",2);
				}
break;

beginstate RUN_ANIM_STATE; 
	if ((get_memory_cell(0) == 1) && (get_ran(1,0,4) == 1))
		run_sparkles_on_object(ME,19,6,0);
	if ((get_memory_cell(0) == 2) && (get_ran(1,0,4) == 1))
		run_sparkles_on_object(ME,20,6,0);
	if ((get_memory_cell(0) >= 90) && (get_ran(1,0,4) == 1))
		run_sparkles_on_object(ME,21,6,0);
		
	break;
	
beginstate USE_STATE;
	print_str_color("Use: You can't use this object.",2);
break;