// Town script for town 10: Castle entrance gate

begintownscript;

variables;

body;

beginstate INIT_STATE;
break;

beginstate EXIT_STATE;
set_flag(10,1,0);
break;

beginstate START_STATE;
break;

beginstate 10;
if (get_flag(10,1) == 0) { // If gates are not yet opened, run code. Otherwise not

if (get_flag(5,7) > 0) {
		if (get_flag(5,7) == 1) {
				message_dialog("You say the words Benthol taught you. The gate open in front of your noses.","");
				set_terrain(15,14,32);
				set_terrain(16,14,32);
				set_terrain(17,14,32);
				set_terrain(15,24,30);
				set_terrain(16,24,30);
				set_terrain(17,24,30);
				set_flag(10,1,1);
				end();
				}
			if (get_flag(10,0) == 0) {
					message_dialog("You say the spell. At first, nothing happens. Soon, however, you hear a voice: _Did you really think you could give me a fake sceptre! Your death lies here!_ Then, several monsters appear.","The voice returns after the monsters are summoned. It says: _If you survive this, bring me the real sceptre, and the real spell will be yours. For now, have fun with my pets._ Immediately after that, you feel drained.");
					activate_hidden_group(2);
					award_party_xp(20,-500);
					set_flag(10,0,1);
					end();
					}
			
			if (get_flag(10,0) == 1) {
					message_dialog("Again you walk to the gates, hoping your spell will work now. Instead you hear the voice of Benthol: _These monsters were to punish you. If you want the real spell, come and get it! Give me the real sceptre, and the real spell will be yours._","The silence of the mountains returns.");
					end();
					}
		}
	message_dialog("The gates here are closed. There is no lever or wheel, which suggests a spell. What a shame you don't know it.","");
}
break;