// door.txt - This is the basic script that powers all doors. If you are 
// working on a scenario that contains doors, DO NOT REMOVE THIS SCRIPT.

// If you place a door, this script is automatically attached to it. The
// default settings for the script are for a basic, unlocked door. To make it
// locked, you will need to change the memory cells.

// Memory Cells - 
//   0 - Lock level. If left at 0, door is unlocked. Otherwise, the strength/tool
//     use needed to get it open. If this is set to a really high number (say, 200),
//     it can't be unlocked by normal means
//   1 - Key needed. If left at 0, no special item helps unlock the door. Otherwise,
//     if that party has this special item, the door automatically unlocks.
//   2,3 - Coordinates for a stuff done flag. If these are 0 and 0, ignored. Otherwise,
//     the stuff done flag is set to 1 when the door is unlocked. If the flag is non-zero,
//     than when the party enters this zone, the door will ebcome unlocked.

beginterrainscript; 

variables;
	short i;
	short i_am_open = 0;
	short cur_terrain;
	short i_am_locked = 0;
	
	short door_opened;
	short choice;
	short last_abil_time;
body;

beginstate INIT_STATE;
	last_abil_time = get_current_tick();
	set_ter_script_mode(0,2);
break;

beginstate START_STATE;
	if (tick_difference(last_abil_time,get_current_tick()) >= 1) {
		i = 0;
		while (i < 120) {
			//if (char_ok(i)) {
			if ( (char_ok(i)) && (can_see_char(i)) && (dist_to_char(i) <= 12) && (get_attitude(i) > 9)) {
				put_jagged_zap(my_loc_x(),my_loc_y(),char_loc_x(i),char_loc_y(i),0);
				damage_char(i,get_ran(2,1,12),1);
				run_animation();
				last_abil_time = get_current_tick();
				print_str_color("The rune blasts a monster with energy!",2);
				if (char_ok(i) == 0) {
					print_str_color("The rune kills a monster.",2);
					award_party_xp(20,get_level(i));
					}
				i = 120;
				}
				//}
			i = i + 1;
			}
		}

break;

beginstate SEARCH_STATE;
break;

beginstate BLOCK_MOVE_STATE;

break;
