[terrain]
#textdomain wesnoth-tb
#impassable custom magic gate
symbol_image=../scenery/gate-rusty-se
id=magic_irongate
name= _ "Irongate"
string=Xzga
aliasof=Xu
[/terrain]

{terrain-graphics}
{TERRAIN_BASE Xzga flat/road}

[scenario]
#textdomain wesnoth-tb
id=3_Guarded_Castle
name= _ "Guarded Castle"
map_data="{campaigns/Two_Brothers/maps/3_Guarded_Castle.map}"
#ifdef EASY
	turns=30
#endif
#ifdef HARD
	turns=24
#endif
next_scenario=4_Return_To_The_Village
victory_when_enemies_defeated=no

	[music]
		name=revelation.ogg
		ms_before=500
	[/music]
	[music]
		name=loyalists.ogg
		ms_before=500
		append=yes
	[/music]
    [music]
        name=battle.ogg
        ms_before=500
        append=yes
    [/music]

	{DUSK}
	{FIRST_WATCH}
	{SECOND_WATCH}
	{DAWN}
	{MORNING}
	{AFTERNOON}



	[side]
		#ifdef EASY
			gold=170
		#endif
		#ifdef HARD
			gold=120
		#endif
		type=Knight
		description=Arne
		user_description= _ "Arne"
		unrenamable=yes
		fog=no
		side=1
		canrecruit=1
		controller=human
		recruit=Horseman,Bowman,Spearman,Footpad
		team_name=good
		shroud=yes
	[/side]

	[side]
		#ifdef EASY
			gold=40
		#endif
		#ifdef HARD
			gold=60
		#endif
		type=Dark Sorcerer
		description=Rotharik
		user_description= _ "Rotharik"
		unrenamable=yes
		experience=0
		side=2
		controller=ai
		canrecruit=1
		#ifdef HARD
			recruit=Skeleton,Skeleton Archer,Vampire Bat,Ghost,Dark Adept,Ghoul,Walking Corpse
		#else
			recruit=Skeleton,Skeleton Archer,Vampire Bat,Dark Adept,Ghoul,Walking Corpse
		#endif
		#ifdef EASY
			income=7
		#endif
		#ifdef HARD
			income=13
		#endif
		team_name=evil
		[unit]
			side=2
			description=Guard_leader
			user_description= _ "Guard"
			type=Assassin
			x=28
			y=26
		[/unit]
		[unit]
			side=2
			description=Guard
			user_description= _ "Guard"
			type=Bandit
			x=30
			y=25
		[/unit]
		#ifdef HARD
			[unit]
				side=2
				description=Guard
				user_description= _ "Guard"
				type=Bandit
				x=28
				y=24
			[/unit]
			[unit]
				side=2
				description=Guard
				user_description= _ "Guard"
				type=Bandit
				x=27
				y=28
			[/unit]
		#endif
	[/side]

	[side]
		no_leader=yes
		side=3
		team_name=evil

		#Orcish guards
		[unit]
			side=3
			description=Knago-Brek
			user_description= _ "Knago-Brek"
			type=Orcish Warrior
			unrenamable=yes
			x=19
			y=17
			ai_special=guardian
		[/unit]
		[unit]
			side=3
			description=Castle Guard
			user_description= _ "Castle Guard"
			type=Orcish Grunt
			x=18
			y=16
			ai_special=guardian
		[/unit]
		[unit]
			side=3
			description=Castle Guard
			user_description= _ "Castle Guard"
			type=Orcish Grunt
			x=20
			y=16
			ai_special=guardian
		[/unit]
		#ifdef HARD
			[unit]
				side=3
				description=Castle Guard
				user_description= _ "Castle Guard"
				type=Orcish Warrior
				x=15
				y=17
				ai_special=guardian
			[/unit]
			[unit]
				side=3
				description=Castle Guard
				user_description= _ "Castle Guard"
				type=Orcish Warrior
				x=23
				y=17
				ai_special=guardian
			[/unit]
		#endif
	[/side]

    [event]
        name=prestart
        [objectives]
            side=1
            [objective]
                description= _ "Rescue Bjarn"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Arne"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
        [/objectives]

        {VARIABLE Got_Key 0}
	{VARIABLE Trigger_Guards1 0}

        #placing prison gates
        [terrain]
            x=5
            y=5
            letter=Xzga
        [/terrain]
        {PLACE_IMAGE scenery/gate-rusty-se.png 5 5}
        [terrain]
            x=6
            y=10
            letter=Xzga
        [/terrain]
        {PLACE_IMAGE scenery/gate-rusty-sw.png 6 10}
#       [terrain]
#           x=7
#           y=7
#           letter=Xzga
#       [/terrain]
#       {PLACE_IMAGE scenery/gate-rusty-se.png 5 5}

	#makeing it more like a real prison
    {PLACE_IMAGE items/bones.png 5 12}
    {PLACE_IMAGE items/bones.png 9 6}
    {PLACE_IMAGE items/bones.png 2 6}
    {PLACE_IMAGE items/bones.png 9 3}
    
	[item]
		x=2
		y=10
		image=items/brazier-lit1.png
		halo=halo/holy/white-cleric-aura.png
	[/item]

	#treasure chest
    {PLACE_IMAGE items/chest-plain-closed.png 34 4}

	#evil altar
    {PLACE_IMAGE items/altar-evil.png 29 3}
    {PLACE_IMAGE items/brazier.png 28 2}
    {PLACE_IMAGE items/brazier.png 30 2}

	#some other items
    {PLACE_IMAGE items/brazier.png 10 10}
    {PLACE_IMAGE items/brazier.png 12 11}
    {PLACE_IMAGE items/brazier.png 26 11}
    {PLACE_IMAGE items/brazier.png 28 10}

    [/event]

	[event]
		name=start
		#ifdef EASY
		[recall]
			description=Brena
		[/recall]
		#endif

		[message]
			speaker=narrator
			message= _ "Arne arrived at the castle and was immediately challenged by some guards."
		[/message]
		[message]
			description=Guard_leader
			message= _ "Halt! Friend or foe? Give the password."
		[/message]

		[message]
			description=Arne
			message= _ "The password is"
			[option]
				message= _ "Alrek!"
                        [command]
					[message]
						description=Guard_leader
						message= _ "Wrong! Die!"
					[/message]
					{VARIABLE Trigger_Guards1 1}
				[/command]
			[/option]
			[option]
				message= _ "Argol!"
				[command]
					[message]
						description=Guard_leader
						message= _ "Oh dear, that's wrong. Any last words?"
					[/message]
					{VARIABLE Trigger_Guards1 1}
				[/command]
			[/option]
			[option]
				message= _ "Sithrak!"
				[command]
					[message]
						description=Guard_leader
						message= _ "Pass, friend."
					[/message]
					[kill]
						description=Guard
					[/kill]
					[kill]
						description=Guard_leader
					[/kill]
					[remove_shroud]
						side=1
						x=0-38
						y=20-32
					[/remove_shroud]
				[/command]
			[/option]
		[/message]
	[/event]

	[event]
		name=sighted
		[filter]
			side=3
		[/filter]
		[message]
			description=Knago-Brek
			message= _ "Haha! We not kill people for long time. Weapon wants blood. We now kill humans!!"
		[/message]
		[message]
			description=Arne
			message= _ "I knew that we had to fight to free my brother! Come on men, lets kill some orcs."
		[/message]
	[/event]

# Trigger 2nd guards at turn3 only if you did not attack the first ones in turn 1, if they are attacked in turn 1, triger this event in turn 6
	[event]
		name=turn 3
		[if]
			[variable]
				name=Trigger_Guards1
				numerical_equals=0
			[/variable]
		[then]
		[unit]
			side=2
			description=Guard2_leader
			user_description= _ "Guard"
			type=Rogue
			x=16
			y=24
		[/unit]
		[unit]
			side=2
			description=Guard2
			user_description= _ "Guard"
			type=Bandit
			x=17
			y=24
		[/unit]
		[unit]
			side=2
			description=Guard2
			user_description= _ "Guard"
			type=Bandit
			x=16
			y=24
		[/unit]
		#ifdef HARD
			[unit]
				side=2
				description=Guard2
				user_description= _ "Guard"
				type=Bandit
				x=17
				y=23
			[/unit]
		#endif
		[message]
			description=Guard2_leader
			message= _ "Are you our relief arriving? Does this mean we get to leave here now?"
		[/message]
		[message]
			description=Arne
			message= _ "Um, yes. Fine. You can go."
		[/message]
		[message]
			description=Guard2_leader
			message= _ "Um, you're supposed to give the password."
		[/message]
		[message]
			description=Arne
			message= _ "Oh, of course. I had nearly forgotten."
			[option]
				message= _ "Eleben."
				[command]
					[message]
						description=Guard2_leader
						message= _ "Thanks! Irritating little formality, isn't it?"
					[/message]
					[kill]
						description=Guard2
					[/kill]
					[kill]
						description=Guard2_leader
					[/kill]
				[/command]
			[/option]
			[option]
				message= _ "Elbrethil."
				[command]
					[message]
						description=Guard2_leader
						message= _ "That's the wrong password! These aren't our relief! Get them!"
					[/message]
				[/command]
			[/option]
			[option]
				message= _ "Toras."
				[command]
					[message]
						description=Guard2_leader
						message= _ "Wrong! So you thought to trick us into deserting our posts? Die!"
					[/message]
				[/command]
			[/option]
       [/message]
        [message]
            description=Arne
            message= _ "I think I should better support my men at the front to make sure we can free my brother."
        [/message]
	[/then]
    [/if]
	[/event]

    [event]
        name=turn 6
        [if]
            [variable]
                name=Trigger_Guards1
                numerical_equals=1
            [/variable]
        [then]
        [unit]
            side=2
            description=Guard2_leader
            user_description= _ "Guard"
            type=Rogue
            x=16
            y=24
        [/unit]
        [unit]
            side=2
            description=Guard2
            user_description= _ "Guard"
            type=Bandit
            x=17
            y=24
        [/unit]
        [unit]
            side=2
            description=Guard2
            user_description= _ "Guard"
            type=Bandit
            x=16
            y=24
        [/unit]
        #ifdef HARD
            [unit]
                side=2
                description=Guard2
                user_description= _ "Guard"
                type=Bandit
                x=17
                y=23
            [/unit]
        #endif
        [message]
            description=Guard2_leader
            message= _ "Are you our relief arriving? Does this mean we get to leave here now?"
        [/message]
        [message]
            description=Arne
            message= _ "Um, yes. Fine. You can go."
        [/message]
        [message]
            description=Guard2_leader
            message= _ "Um, you're supposed to give the password."
        [/message]
        [message]
            description=Arne
            message= _ "Oh, of course. I had nearly forgotten."
            [option]
                message= _ "Eleben."
                [command]
                    [message]
                        description=Guard2_leader
                        message= _ "Thanks! Irritating little formality, isn't it?"
                    [/message]
                    [kill]
                        description=Guard2
                    [/kill]
                    [kill]
                        description=Guard2_leader
                    [/kill]
                [/command]
            [/option]
            [option]
                message= _ "Elbrethil."
                [command]
                    [message]
                        description=Guard2_leader
                        message= _ "That's the wrong password! These aren't our relief! Get them!"
                    [/message]
                [/command]
            [/option]
            [option]
                message= _ "Toras."
                [command]
                    [message]
                        description=Guard2_leader
                        message= _ "Wrong! So you thought to trick us into deserting our posts? Die!"
                    [/message]
                [/command]
            [/option]
       [/message]
        [message]
            description=Arne
            message= _ "I think I should better support my men at the front to make sure we can free my brother."
        [/message]
    [/then]
    [/if]
    [/event]

	[event]
		name=die
		[filter]
			description=Rotharik
		[/filter]
		[message]
			speaker=unit
			message= _ "Nooo! This is the end..."
		[/message]
		[message]
			speaker=second_unit
			message= _ "There's a key in his robes."
		[/message]
		[message]
			description=Arne
			message= _ "It must be the key to the cell they're holding Bjarn in! I will take the key. I can't wait to see my brother. Come on, let's free him."
		[/message]
		{VARIABLE Got_Key 1}
		[objectives]
			side=1
			[objective]
				description= _ "Move Arne to the cell with his brother to free him"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Arne"
				condition=lose
			[/objective]
			[objective]
				description= _ "Turns run out"
				condition=lose
			[/objective]
		[/objectives]
		[modify_turns]
			add=6
		[/modify_turns]
	[/event]

	[event]
		name=moveto
		[filter]
			x=34
			y=4
			side=1
		[/filter]
		#ifdef EASY
			[sound]
				name=gold.ogg
			[/sound]
			[message]
				speaker=unit
				message= _ "Look what I have found in here! I can count a hundred pieces of gold."
			[/message]
			[gold]
				side=1
				amount=100
			[/gold]
		#endif
		#ifdef HARD
			[sound]
				name=gold.ogg
			[/sound]
			[message]
				speaker=unit
				message= _ "Look what I have found in here! I can count fifty pieces of gold."
			[/message]
			[gold]
				side=1
				amount=50
			[/gold]
		#endif
		[removeitem]
			x=34
			y=4
		[/removeitem]
		{PLACE_IMAGE items/chest-plain-open.png 34 4}
	[/event]

    [event]
        name=moveto
        [filter]
            x=1-8
            y=1-11
            side=1
        [/filter]
        [unit]
            description=Bjarn
            user_description= _ "Bjarn"
            unrenamable=yes
            type=Red Mage
            profile=bjarn.png
            {IS_HERO}
            x=3
            y=3
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
        [/unit]
        [remove_shroud]
            x=1-8,9-10,5
            y=1-12,1-7,13
        [/remove_shroud]
    [/event]

	[event]
		name=moveto
		[filter]
			x=4-8,7,8
			y=5-8,4,4
			side=1
		[/filter]
		[message]
			speaker=unit
        [store_unit]
            [filter]
            x=4-8,7,8
            y=5-8,4,4
            [/filter]
            variable=MyUnit
        [/store_unit]
		[if]
			[variable]
				name=MyUnit.description
				equals="Arne"
			[/variable]
			[then]
				image="arne.png"
			[/then]
		[/if]
			message= _"I found Bjarn. He is in this cell."
		[/message]
		[if]
			[variable]
				name=MyUnit.description
				equals="Arne"
			[/variable]
			[then]
				[message]
					description=Bjarn
					message= _ "Good to see you, Arne. Please help me get out of this dungeon."
				[/message]
			[/then]
			[else]
				[message]
					description=Bjarn
					message= _ "You must be one of Arne's men. Please help me get out of this dungeon."
				[/message]
			[/else]
		[/if]
		[message]
			description=Bjarn
			message= _ "The damn Dark Sorcerer Rotharik has imprisoned me behind this magical enhanced iron gate. It can only be opend with the correct key. You must get it from him to free me."
		[/message]
        [if]
            [variable]
                name=Got_Key
                numerical_equals=0
            [/variable]
            [then]
        		[objectives]
		        	side=1
        			[objective]
		        		description= _ "Kill the dark sorcerer to get the cellkey"
        				condition=win
        			[/objective]
	        		[objective]
	        			description= _ "Death of Arne"
	        			condition=lose
	        		[/objective]
        			[objective]
        				description= _ "Turns run out"
        				condition=lose
        			[/objective]
        		[/objectives]
            [/then]
        [/if]
	[/event]

	[event]
		name=moveto
		first_time_only=no
		[filter]
			x=5,6
			y=6,5
			description=Arne
		[/filter]
		[if]
			[variable]
				name=Got_Key
				numerical_equals=1
			[/variable]
			[then]
				[terrain]
					x=5
					y=5
					letter=Rr
				[/terrain]
				[message]
					description=Bjarn
					message= _ "Thank you for saving me. I had almost given up hope you would free me."
				[/message]
				[message]
					description=Arne
					message= _ "Oh it was nothing, a few elves, one or two dark sorcerers, a bunch of orcs and some undead. Really just a day's work for us mercenaries."
				[/message]
				[message]
					description=Bjarn
					message= _ "Thank you for coming to my aid. Let us return to the village."
				[/message]
				[endlevel]
					result=victory
					bonus=yes
				[/endlevel]
			[/then]
		[/if]
	[/event]

	[event]
		name=victory
		{CLEAR_VARIABLE Got_Key}
	[/event]

	[event]
		name=die
		[filter]
			description=Arne
		[/filter]
		[message]
			description=Arne
			message= _ "Everything is lost now that I am dead..."
		[/message]
		[endlevel]
			result=defeat
		[/endlevel]
	[/event]

	[event]
		name=time over
		[message]
			description=Rotharik
			message= _ "You are too late! Your brother is already dead! Muhahahaha..."
		[/message]
		[message]
			description=Arne
			message= _ "Argh!!!"
		[/message]
	[/event]

[/scenario]
