// churchdoor.txt
// v 1.0.0, designed for scenario The Wolf at the Door
// By Thralni

// 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;
int i,choice;
string items;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
break;

beginstate SEARCH_STATE;
// reset flags
set_flag(225,1,0);
set_flag(225,2,0);
set_flag(225,3,0);
set_flag(225,4,0);
set_flag(225,5,0);
set_flag(225,6,0);
set_flag(225,7,0);
set_flag(225,8,0);
set_flag(225,9,0);

reset_dialog();
add_dialog_str(0,"This is the back door of this church, and we will have to get it open one way or another if we want to live longer than today. Problem is, it's locked quite well.",0);
add_dialog_str(1,"For starters, there is a huge lock that looks quite hard to pick, both mechanically and magically. One option remains then: bashing.",0);
add_dialog_str(2,"We could try bashing with our shoulders, as we usually do, but somehow it seems this will be as futile as unlocking. We can try, of course. Chances are we'll need something bigger and heavier.",0);
add_dialog_choice(0,"Bash with the shoulder.");
add_dialog_choice(1,"Bash with another thing.");
add_dialog_choice(2,"Never mind.");
choice = run_dialog(1);

if (choice == 1)
		message_dialog("We bash the door like madmen, but without much succes. The door stays firmly shut.","");

if (choice == 2) {
		clear_buffer();
		if (has_item(59) == 1 || has_item(60) == 1 || has_item(61) == 1 || has_item(62) == 1 || has_item(63) == 1) {
				append_string("1 Greatsword");
				set_flag(225,1,59);
				i = 1;
				}

		if (has_item(64) == 1 || has_item(65) == 1 || has_item(66) == 1 || has_item(67) == 1 || has_item(68) == 1) {
				if (i == 1) {
						append_string("- 2 Spear");
						set_flag(225,2,64);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Spear");
						set_flag(225,1,64);
						i = 1;
						}
				}

		if (has_item(69) == 1 || has_item(70) == 1 || has_item(71) == 1 || has_item(72) == 1 || has_item(73) == 1) {
				if (i == 2) {
						append_string("- 3 Pike");
						set_flag(225,3,69);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Pike");
						set_flag(225,2,69);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Pike");
						set_flag(225,1,69);
						i = 1;
						}
				}

		if (has_item(74) == 1 || has_item(75) == 1 || has_item(76) == 1 || has_item(77) == 1 || has_item(78) == 1) {
				if (i == 3) {
						append_string("- 4 Halberd");
						set_flag(225,4,74);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Halberd");
						set_flag(225,3,74);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Halberd");
						set_flag(225,2,74);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Halberd");
						set_flag(225,1,74);
						i = 1;
						}
				}

		if (has_item(82) == 1) {
				if (i == 4) {
						append_string("- 5 Staff");
						set_flag(225,5,82);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Staff");
						set_flag(225,4,82);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Staff");
						set_flag(225,3,82);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Staff");
						set_flag(225,2,82);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Staff");
						set_flag(225,1,82);
						i = 1;
						}
				}

		if (has_item(83) == 1) {
				if (i == 5) {
						append_string("- 6 Hammer");
						set_flag(225,6,83);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Hammer");
						set_flag(225,5,83);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Hammer");
						set_flag(225,4,83);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Hammer");
						set_flag(225,3,83);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Hammer");
						set_flag(225,2,83);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Hammer");
						set_flag(225,1,83);
						i = 1;
						}
				}

		if (has_item(84) == 1 || has_item(85) == 1 || has_item(86) == 1 || has_item(87) == 1 || has_item(88) == 1) {
				if (i == 6) {
						append_string("- 7 Javelin");
						set_flag(225,7,84);
						i = 7;
						}
				if (i == 5) {
						append_string("- 6 Javelin");
						set_flag(225,6,84);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Javelin");
						set_flag(225,5,84);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Javelin");
						set_flag(225,4,84);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Javelin");
						set_flag(225,3,84);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Javelin");
						set_flag(225,2,84);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Javelin");
						set_flag(225,1,84);
						i = 1;
						}
				}

		if (has_item(319) == 1) {
				if (i == 7) {
						append_string("- 8 Pick");
						set_flag(225,8,319);
						i = 8;
						}
				if (i == 6) {
						append_string("- 7 Pick");
						set_flag(225,7,319);
						i = 7;
						}
				if (i == 5) {
						append_string("- 6 Pick");
						set_flag(225,6,319);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Pick");
						set_flag(225,5,319);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Pick");
						set_flag(225,4,319);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Pick");
						set_flag(225,3,319);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Pick");
						set_flag(225,2,319);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Pick");
						set_flag(225,1,319);
						i = 1;
						}
				}

		if (has_item(370) == 1 || has_item(371) == 1) {
				if (i == 8) {
						append_string("- 9 Slith Spear");
						set_flag(225,9,370);
						i = 9;
						}
				if (i == 7) {
						append_string("- 8 Slith Spear");
						set_flag(225,8,370);
						i = 8;
						}
				if (i == 6) {
						append_string("- 7 Slith Spear");
						set_flag(225,7,370);
						i = 7;
						}
				if (i == 5) {
						append_string("- 6 Slith Spear");
						set_flag(225,6,370);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Slith Spear");
						set_flag(225,5,319);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Slith Spear");
						set_flag(225,4,370);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Slith Spear");
						set_flag(225,3,370);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Slith Spear");
						set_flag(225,2,370);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Slith Spear");
						set_flag(225,1,370);
						i = 1;
						}
				}
		if (i > 0) {
				message_dialog("We rummage through our backpacks, searching for useful stuff. Eventually, we do find something to bash with. What shall we bash with?","(At the next dialog box, choose your weapon and memorize the number, then fill it in the box after hitting _okay_)");
				get_buffer_text(items);

				message_dialog(items,"");

				get_text_response("What do we use?");

				check_text_response_match("1");
				if (got_text_match() == 1 && get_flag(225,1) > 0) {
						if (get_flag(225,1) == 59)
								message_dialog("We start to strike and hit the lock of this door with our greatsword. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 64)
								message_dialog("We start to ram the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 69)
								message_dialog("We start to ram the lock of this door with our pike. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("2");
				if (got_text_match() == 1 && get_flag(225,2) > 0) {
						if (get_flag(225,2) == 64)
								message_dialog("We start to ram the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 69)
								message_dialog("We start to ram the lock of this door with our pike. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("3");
				if (got_text_match() == 1 && get_flag(225,3) > 0) {
						if (get_flag(225,3) == 69)
								message_dialog("We start to ram the lock of this door with our pike. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("4");
				if (got_text_match() == 1 && get_flag(225,4) > 0) {
						if (get_flag(225,4) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("5");
				if (got_text_match() == 1 && get_flag(225,5) > 0) {
						if (get_flag(225,5) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("6");
				if (got_text_match() == 1 && get_flag(225,6) > 0) {
						if (get_flag(225,6) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,6) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,6) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,6) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("7");
				if (got_text_match() == 1 && get_flag(225,7) > 0) {
						if (get_flag(225,7) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,7) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,7) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("8");
				if (got_text_match() == 1 && get_flag(225,8) > 0) {
						if (get_flag(225,8) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,8) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("9");
				if (got_text_match() == 1 && get_flag(225,9) > 0) {
						if (get_flag(225,9) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}
				message_dialog("Sorry, you entered a wrong number.","");
				end();
				}
		// and if we can't ifn something to hit the door with...
		message_dialog("We take some time to rummage through our backpacks, but we can't find anything suitable to hit the door with. We should be having something long, like a two-handed weapon.","");
		set_ticks_forward(10);
		}
break;

beginstate BLOCK_MOVE_STATE;
// reset flags
set_flag(225,1,0);
set_flag(225,2,0);
set_flag(225,3,0);
set_flag(225,4,0);
set_flag(225,5,0);
set_flag(225,6,0);
set_flag(225,7,0);
set_flag(225,8,0);
set_flag(225,9,0);

reset_dialog();
add_dialog_str(0,"This is the back door of this church, and we will have to get it open one way or another if we want to live longer than today. Problem is, it's locked quite well.",0);
add_dialog_str(1,"For starters, there is a huge lock that looks quite hard to pick, both mechanically and magically. One option remains then: bashing.",0);
add_dialog_str(2,"We could try bashing with our shoulders, as we usually do, but somehow it seems this will be as futile as unlocking. We can try, of course. Chances are we'll need something bigger and heavier.",0);
add_dialog_choice(0,"Bash with the shoulder.");
add_dialog_choice(1,"Bash with another thing.");
add_dialog_choice(2,"Never mind.");
choice = run_dialog(1);

if (choice == 1)
		message_dialog("We bash the door like madmen, but without much succes. The door stays firmly shut.","");

if (choice == 2) {
		clear_buffer();
		if (has_item(59) == 1 || has_item(60) == 1 || has_item(61) == 1 || has_item(62) == 1 || has_item(63) == 1) {
				append_string("1 Greatsword");
				set_flag(225,1,59);
				i = 1;
				}

		if (has_item(64) == 1 || has_item(65) == 1 || has_item(66) == 1 || has_item(67) == 1 || has_item(68) == 1) {
				if (i == 1) {
						append_string("- 2 Spear");
						set_flag(225,2,64);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Spear");
						set_flag(225,1,64);
						i = 1;
						}
				}

		if (has_item(69) == 1 || has_item(70) == 1 || has_item(71) == 1 || has_item(72) == 1 || has_item(73) == 1) {
				if (i == 2) {
						append_string("- 3 Pike");
						set_flag(225,3,69);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Pike");
						set_flag(225,2,69);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Pike");
						set_flag(225,1,69);
						i = 1;
						}
				}

		if (has_item(74) == 1 || has_item(75) == 1 || has_item(76) == 1 || has_item(77) == 1 || has_item(78) == 1) {
				if (i == 3) {
						append_string("- 4 Halberd");
						set_flag(225,4,74);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Halberd");
						set_flag(225,3,74);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Halberd");
						set_flag(225,2,74);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Halberd");
						set_flag(225,1,74);
						i = 1;
						}
				}

		if (has_item(82) == 1) {
				if (i == 4) {
						append_string("- 5 Staff");
						set_flag(225,5,82);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Staff");
						set_flag(225,4,82);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Staff");
						set_flag(225,3,82);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Staff");
						set_flag(225,2,82);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Staff");
						set_flag(225,1,82);
						i = 1;
						}
				}

		if (has_item(83) == 1) {
				if (i == 5) {
						append_string("- 6 Hammer");
						set_flag(225,6,83);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Hammer");
						set_flag(225,5,83);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Hammer");
						set_flag(225,4,83);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Hammer");
						set_flag(225,3,83);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Hammer");
						set_flag(225,2,83);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Hammer");
						set_flag(225,1,83);
						i = 1;
						}
				}

		if (has_item(84) == 1 || has_item(85) == 1 || has_item(86) == 1 || has_item(87) == 1 || has_item(88) == 1) {
				if (i == 6) {
						append_string("- 7 Javelin");
						set_flag(225,7,84);
						i = 7;
						}
				if (i == 5) {
						append_string("- 6 Javelin");
						set_flag(225,6,84);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Javelin");
						set_flag(225,5,84);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Javelin");
						set_flag(225,4,84);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Javelin");
						set_flag(225,3,84);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Javelin");
						set_flag(225,2,84);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Javelin");
						set_flag(225,1,84);
						i = 1;
						}
				}

		if (has_item(319) == 1) {
				if (i == 7) {
						append_string("- 8 Pick");
						set_flag(225,8,319);
						i = 8;
						}
				if (i == 6) {
						append_string("- 7 Pick");
						set_flag(225,7,319);
						i = 7;
						}
				if (i == 5) {
						append_string("- 6 Pick");
						set_flag(225,6,319);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Pick");
						set_flag(225,5,319);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Pick");
						set_flag(225,4,319);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Pick");
						set_flag(225,3,319);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Pick");
						set_flag(225,2,319);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Pick");
						set_flag(225,1,319);
						i = 1;
						}
				}

		if (has_item(370) == 1 || has_item(371) == 1) {
				if (i == 8) {
						append_string("- 9 Slith Spear");
						set_flag(225,9,370);
						i = 9;
						}
				if (i == 7) {
						append_string("- 8 Slith Spear");
						set_flag(225,8,370);
						i = 8;
						}
				if (i == 6) {
						append_string("- 7 Slith Spear");
						set_flag(225,7,370);
						i = 7;
						}
				if (i == 5) {
						append_string("- 6 Slith Spear");
						set_flag(225,6,370);
						i = 6;
						}
				if (i == 4) {
						append_string("- 5 Slith Spear");
						set_flag(225,5,319);
						i = 5;
						}
				if (i == 3) {
						append_string("- 4 Slith Spear");
						set_flag(225,4,370);
						i = 4;
						}
				if (i == 2) {
						append_string("- 3 Slith Spear");
						set_flag(225,3,370);
						i = 3;
						}
				if (i == 1) {
						append_string("- 2 Slith Spear");
						set_flag(225,2,370);
						i = 2;
						}
				if (i == 0) {
						append_string("1 Slith Spear");
						set_flag(225,1,370);
						i = 1;
						}
				}
		if (i > 0) {
				message_dialog("We rummage through our backpacks, searching for useful stuff. Eventually, we do find something to bash with. What shall we bash with?","(At the next dialog box, choose your weapon and memorize the number, then fill it in the box after hitting _okay_)");
				get_buffer_text(items);

				message_dialog(items,"");

				get_text_response("What do we use?");

				check_text_response_match("1");
				if (got_text_match() == 1 && get_flag(225,1) > 0) {
						if (get_flag(225,1) == 59)
								message_dialog("We start to strike and hit the lock of this door with our greatsword. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 64)
								message_dialog("We start to ram the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 69)
								message_dialog("We start to ram the lock of this door with our pike. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,1) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("2");
				if (got_text_match() == 1 && get_flag(225,2) > 0) {
						if (get_flag(225,2) == 64)
								message_dialog("We start to ram the lock of this door with our spear. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 69)
								message_dialog("We start to ram the lock of this door with our pike. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the night sky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the night sky
 again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,2) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("3");
				if (got_text_match() == 1 && get_flag(225,3) > 0) {
						if (get_flag(225,3) == 69)
								message_dialog("We start to ram the lock of this door with our pike. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,3) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("4");
				if (got_text_match() == 1 && get_flag(225,4) > 0) {
						if (get_flag(225,4) == 74)
								message_dialog("We start to hit and ram the lock of this door with our halberd. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,4) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("5");
				if (got_text_match() == 1 && get_flag(225,5) > 0) {
						if (get_flag(225,5) == 82)
								message_dialog("We start to ram the lock of this door with our staff. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,5) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("6");
				if (got_text_match() == 1 && get_flag(225,6) > 0) {
						if (get_flag(225,6) == 83)
								message_dialog("We start to hammer on the lock of this door with our hammer. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,6) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,6) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,6) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("7");
				if (got_text_match() == 1 && get_flag(225,7) > 0) {
						if (get_flag(225,7) == 84)
								message_dialog("We start to hit and ram the lock of this door with our javelin. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,7) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,7) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("8");
				if (got_text_match() == 1 && get_flag(225,8) > 0) {
						if (get_flag(225,8) == 319)
								message_dialog("We start to hit the lock of this door with our pick. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						if (get_flag(225,8) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}

				check_text_response_match("9");
				if (got_text_match() == 1 && get_flag(225,9) > 0) {
						if (get_flag(225,9) == 370)
								message_dialog("We start to ram and hit the lock of this door with our spear. Soon, the wood begins to splinter and we see the nightsky again.","Alas, the door is pretty much pulverized. Any zombie that'd want to chase us will be free to do so...");

						set_ticks_forward(10);
						set_flag(6,10,1); // set flag to deactivate script, also causes changes in dialog message when zombies break through church doors
						set_terrain(15,26,137); // set door terrain to pulverized stone
						end();
						}
				message_dialog("Sorry, you entered a wrong number.","");
				end();
				}
		// and if we can't ifn something to hit the door with...
		message_dialog("We take some time to rummage through our backpacks, but we can't find anything suitable to hit the door with. We should be having something long, like a two-handed weapon.","");
		set_ticks_forward(10);
		}
break;

beginstate UNLOCK_SPELL_STATE;
break;

beginstate DISPEL_BARRIER_STATE;
break;
