[terrain]
#textdomain wesnoth-tb
symbol_image=gate1
id=magic_barrier
name= _ "Magic Gate"
char=x
aliasof=W
[/terrain]

{terrain-graphics}
{TERRAIN_BASE x road}
{BUILDING x ({VIMG       36,40 gate1,gate2,gate3})}

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

	[music]
		name=wesnoth-1.ogg
		ms_before=500
	[/music]
	[music]
		name=wesnoth-2.ogg
		ms_before=500
		append=yes
	[/music]
        [music]
                name=gameplay03.ogg
                ms_before=500
                append=yes
        [/music]

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

	[event]
		[terrain]
			x=4
			y=4
			letter=x
		[/terrain]
		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}
	[/event]

	[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
		{IS_HERO}
		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
		#else
			recruit=Skeleton,Skeleton Archer,Vampire Bat,Dark Adept
		#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=25
		[/unit]
		[unit]
			side=2
			description=Guard
			user_description= _ "Guard"
			type=Bandit
			x=30
			y=24
		[/unit]
		#ifdef HARD
			[unit]
				side=2
				description=Guard
				user_description= _ "Guard"
				type=Bandit
				x=28
				y=23
			[/unit]
			[unit]
				side=2
				description=Guard
				user_description= _ "Guard"
				type=Bandit
				x=27
				y=27
			[/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=16
			ai_special=guardian
		[/unit]
		[unit]
			side=3
			description=Castle Guard
			user_description= _ "Castle Guard"
			type=Orcish Grunt
			x=18
			y=15
			ai_special=guardian
		[/unit]
		[unit]
			side=3
			description=Castle Guard
			user_description= _ "Castle Guard"
			type=Orcish Grunt
			x=20
			y=15
			ai_special=guardian
		[/unit]
		#ifdef HARD
			[unit]
				side=3
				description=Castle Guard
				user_description= _ "Castle Guard"
				type=Orcish Warrior
				x=15
				y=16
				ai_special=guardian
			[/unit]
			[unit]
				side=3
				description=Castle Guard
				user_description= _ "Castle Guard"
				type=Orcish Warrior
				x=23
				y=16
				ai_special=guardian
			[/unit]
		#endif
	[/side]

	#treasure chest
	[item]
		x=28
		y=2
		image=items/chest-plain-closed.png
	[/item]

	[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"
			image="arne.png"
			[option]
				message= _ "Alrek!"
                        [command]
					[message]
						description=Guard_leader
						message= _ "Wrong! Die!"
					[/message]
				[/command]
			[/option]
			[option]
				message= _ "Argol!"
				[command]
					[message]
						description=Guard_leader
						message= _ "Oh dear, that's wrong. Any last words?"
					[/message]
				[/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=19-31
					[/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."
			image="arne.png"
		[/message]
	[/event]

	[event]
		name=turn 3
		[unit]
			side=2
			description=Guard2_leader
			user_description= _ "Guard"
			type=Rogue
			x=16
			y=23
		[/unit]
		[unit]
			side=2
			description=Guard2
			user_description= _ "Guard"
			type=Bandit
			x=17
			y=23
		[/unit]
		[unit]
			side=2
			description=Guard2
			user_description= _ "Guard"
			type=Bandit
			x=16
			y=22
		[/unit]
		#ifdef HARD
			[unit]
				side=2
				description=Guard2
				user_description= _ "Guard"
				type=Bandit
				x=17
				y=22
			[/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."
			image="arne.png"
		[/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."
			image="arne.png"
			[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]
	[/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."
			image="arne.png"
		[/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=28
			y=2
			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
		        [item]
		                x=28
		                y=2
				image=items/chest-plain-open.png
			[/item]
		[removeitem]
			x=28
			y=2
		[/removeitem]
	[/event]

	[event]
		name=moveto
		[filter]
			x=3,4,5
			y=5,5,5
			side=1
		[/filter]
		[unit]
			type=Red Mage
			description=Bjarn
			user_description= _ "Bjarn"
			{IS_HERO}
			x=3
			y=2
			[modifications]
				{TRAIT_LOYAL}
				{TRAIT_INTELLIGENT}
			[/modifications]
		[/unit]
		[remove_shroud]
			x=1-5
			y=1-4
		[/remove_shroud]
		[message]
			speaker=unit
		[if]
			[variable]
				name=Unit.description
				equals="Arne"
			[/variable]
			[then]
				image="arne.png"
			[/then]
		[/if]
			message= _"I found Bjarn. He is in this cell."
		[/message]
		[store_unit]
			[filter]
			x=3,4,5
			y=5,5,5
			[/filter]
			variable=Unit
		[/store_unit]
		[if]
			[variable]
				name=Unit.description
				equals="Arne"
			[/variable]
			[then]
				[message]
					description=Bjarn
					message= _ "Good to see you, Arne. Please help me get out of this dungeon."
					image="bjarn.png"
				[/message]
			[/then]
			[else]
				[message]
					description=Bjarn
					message= _ "You must be one of Arne's men. Please help me get out of this dungeon."
					image="bjarn.png"
				[/message]
			[/else]
		[/if]
		[message]
			description=Bjarn
			message= _ "The damn Dark Sorcerer Rotharik has imprisoned me behind this magical barrier. You must get the key from him to free me. You can only open it with the key."
			image="bjarn.png"
		[/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=3,4,5
			y=5,5,5
			description=Arne
		[/filter]
		[if]
			[variable]
				name=Got_Key
				numerical_equals=1
			[/variable]
			[then]
				[terrain]
					x=4
					y=4
					letter=R
				[/terrain]
				[message]
					description=Bjarn
					message= _ "Thank you for saving me. I had almost given up hope you would free me."
					image="bjarn.png"
				[/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."
					image="arne.png"
				[/message]
				[message]
					description=Bjarn
					message= _ "Thank you for coming to my aid. Let us return to the village."
					image="bjarn.png"
				[/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..."
			image="arne.png"
		[/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!!!"
			image="arne.png"
		[/message]
	[/event]

[/scenario]
