#textdomain wesnoth-tutorial

{./utils.cfg}

#define DEST X Y
{VARIABLE destx {X}}
{VARIABLE desty {Y}}
{VARIABLE dest set}
#enddef

#FIXME: You'd think that using CLEAR_VARIABLE here would make it fail the
#equals="set" test.  You'd be wrong...
#define NODEST
{VARIABLE dest unset}
#enddef

#define STUDENT_START_LOC
9,6
#enddef
#define MARKER_LOC
12,5
#enddef
#define DELFADOR_LOC
13,6
#enddef
#define QUINTAIN_LOC
13,5
#enddef
#define VILLAGE_LOC
11,7
#enddef
#define KEEP_LOC
9,6
#enddef

[tutorial]
	id=tutorial
	translator_comment=_ "Hello translators!  Tutorial is meant to be a little funny at the start, welcoming new players.  Please keep friendly fun feeling!  Any questions email rusty@rustcorp.com.au!"
	name=_ "Wesnoth Tutorial"
	map_data="ffffggcctggggggfffff
ffgggggccggggggggfff
fgggggggcggggggggggf
fgggggggccgggggggggf
ftfggggggg/ggggggggg
ffgggggg1Cccgggggggg
fgggggggCgt/gggggggg
fgtggggggggcgggggggf
ffggggggggggccgggggf
ffffgggggggggcggggff
ffffgggggggggcgggfff
"
	turns=12
	[music]
		name=elf-land.ogg
	[/music]
	next_scenario=2_Tutorial

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

	victory_when_enemies_defeated=no

	[side]
		type=Fighter
		description=student
		user_description=_"Konrad"
		canrecruit=1
		side=1
		controller=human
	[/side]

	[side]
		no_leader=yes
		type=Quintain
		description=Quintain
		user_description=_ "Quintain"
		side=2
		controller=ai
		[ai]
			passive_leader=no
			caution=0
			aggression=5
			[target]
				description=student
				value=10
			[/target]
			[target]
				description=Delfador
				value=.1
			[/target]
		[/ai]
	[/side]

	[side]
		no_leader=yes
		description=Delfador
		user_description=_ "Delfador"
		side=3
		team_name=1
		controller=null
	[/side]

	[event]
		name=prestart

		[unit]
			description=Delfador
			user_description=_ "Delfador"
			type=Elder Mage
			x,y={DELFADOR_LOC}
			side=3
			{IS_HERO}
		[/unit]
		{LABEL Delfador {DELFADOR_LOC}}

		[objectives]
			side=1
			summary=_ "You will learn the basics of:
 movement
 attacking
 healing
 recruiting"
			[objective]
				description=_ "Destroy a fierce enemy"
				condition=win
			[/objective]
			[objective]
				description=_ "Get yourself killed"
				condition=lose
			[/objective]
		[/objectives]

		[hide_unit]
			x,y={STUDENT_START_LOC}
		[/hide_unit]
		{VARIABLE student_hp 32}

	[/event]

	[event]
		name=start
		[message]
			speaker=narrator
			message=_"Who would you like to play?"
			[option]
				message="&" + "konrad-fighter.png" + "=" + _"Konrad"
				[command]
					{VARIABLE gender male}
					{VARIABLE student _"Konrad"}
				[/command]
			[/option]
			[option]
				message="&" + "human-princess.png" + "=" + _"Li'sar"
				[command]
					{VARIABLE gender female}
					{VARIABLE student _"Li'sar"}
					[store_unit]
						[filter]
							description=student
						[/filter]
						kill=yes
						variable=student_save
					[/store_unit]
					{VARIABLE student_x $student_save.x}
					{VARIABLE student_y $student_save.y}
					[unit]
						type=Fighteress
						side=1
						x,y=$student_x,$student_y
						description=student
						user_description= _"Li'sar"
						canrecruit=1
					[/unit]
					[redraw][/redraw]
				[/command]
			[/option]
		[/message]

		[unhide_unit][/unhide_unit]
		{LABEL $student {STUDENT_START_LOC}}
		[redraw][/redraw]

		{GENDER ([message]
			speaker=narrator
			message=_ "*Welcome to Wesnoth!" +
				_ "
For this tutorial, you are playing Konrad. " +
				_ "You are standing in the keep, and your mentor Delfador is on the East side of the river." +
				_ "
*Left click to continue..."
		[/message]) ([message]
			speaker=narrator
			message=_ "*Welcome to Wesnoth!" +
				_ "
For this tutorial, you are playing Li'sar. " +
				_ "You are standing in the keep, and your mentor Delfador is on the East side of the river." +
				_ "
*Left click to continue..."
		[/message])}

		{GENDER ({PRINT (_"Left click on Konrad")})
			({PRINT (_"Left click on Li'sar")})}
	[/event]

	[event]
		name=select
		[filter]
			side=1
		[/filter]

		{UNLABEL {STUDENT_START_LOC}}
		{CLEAR_PRINT}

		[redraw][/redraw]
		{GENDER ([message]
			speaker=narrator
			message=_ "*You have selected Konrad.
The places he could move to are highlighted." +
				_ "
*Left click or any key to continue..."
		[/message]) ([message]
			speaker=narrator
			message=_ "*You have selected Li'sar.
The places she could move to are highlighted." +
				_ "
*Left click or any key to continue..."
		[/message])}

		{LABEL (_ "HERE") {MARKER_LOC}}
		[redraw][/redraw]

		{GENDER ([message]
			speaker=narrator
			message=_ "Move Konrad next to Delfador, by clicking on the place marked 'HERE'." +
			_ "
*Left click or any key to continue..."
		[/message]) ([message]
			speaker=narrator
			message=_ "Move Li'sar next to Delfador, by clicking on the place marked 'HERE'." +
			_ "
*Left click or any key to continue..."
		[/message])}

		{DEST 12 5}
		{PRINT (_"Left click on tile labelled HERE")}
	[/event]

	# General catch for them moving to the wrong place.
	[event]
		name=moveto
		first_time_only=no
		[allow_undo][/allow_undo]

		[filter]
			side=1
		[/filter]

		[if]
			[or]
				[variable]
					name=x1
					numerical_not_equals=$destx
				[/variable]
			[/or]
			[or]
				[variable]
					name=y1
					numerical_not_equals=$desty
				[/variable]
			[/or]
		[then]
			[if]
				[variable]
					name=dest
					equals="set"
				[/variable]
			[then]
				[redraw][/redraw]
				[message]
					speaker=narrator
					message=_ "*Oops!
You moved to the wrong place!  After this message, you can press 'u' to Undo, then try again.
*Left click or any key to continue..."
				[/message]
			[/then]
			[/if]
		[/then]
		[/if]
	[/event]

	[event]
		name=moveto
		[filter]
			side=1
			x,y={MARKER_LOC}
		[/filter]

		{CLEAR_PRINT}
		{UNLABEL {MARKER_LOC}}
		{UNLABEL {DELFADOR_LOC}}
		{NODEST}
		[redraw][/redraw]

		[message]
			description=student
			message=_ "Good morning Delfador!  Is it time to attack things?"
		[/message]

		[message]
			description=Delfador
			message=_ "Um, well..."
		[/message]

		[message]
			description=student
			message=_ "Have you found an orc for me to fight, huh?  A troll?"
		[/message]

		[message]
			description=Delfador
			message=_ "Quiet!  I will summon an enemy for you..."
		[/message]

		[scroll_to_unit]
		description=Delfador
		[/scroll_to_unit]

		[sound]
		name=lightning.ogg
		[/sound]

		[colour_adjust]
		red=100
		green=100
		blue=100
		[/colour_adjust]

		[delay]
		time=10
		[/delay]

		[colour_adjust]
		red=0
		green=0
		blue=0
		[/colour_adjust]

		[unit]
			description=Quintain
			type=Quintain
			ai_special="guardian"
			x,y={QUINTAIN_LOC}
			side=2
		[/unit]

		{LABEL (_"Quintain") {QUINTAIN_LOC}}
		[redraw][/redraw]

		[message]
			description=Delfador
			message=_ "... this quintain!"
		[/message]

		[message]
		description=student
		message=_ "A quintain?  You want me to pretend to fight a dummy??"
		[/message]

		[message]
		description=Delfador
		message=_ "Child, you have 32 hitpoints and a sword.    I'm fairly sure you'll win."
		[/message]

		{GENDER ([message]
			speaker=narrator
			message=_ "To attack the quintain, you will first select the attacker (Konrad) and then the target (the quintain).  You will see a description of the details of the attack.  When you click OK, Konrad will attack." +
		_ "
*Left click or any key to continue..."
		[/message]) ([message]
			speaker=narrator
			message=_ "To attack the quintain, you will first select the attacker (Li'sar) and then the target (the quintain).  You will see a description of the details of the attack.  When you click OK, Li'sar will attack." +
		_ "
*Left click or any key to continue..."
		[/message])}

		[event]
			name=select
			[filter]
				side=1
			[/filter]

			{PRINT (_"Click on the quintain to attack it")}
		[/event]

		{GENDER ({PRINT (_"Left click on Konrad")})
			({PRINT (_"Left click on Li'sar")})}
	[/event]

	# We track student's hitpoints so Delfador can explain them.
	[event]
		name=attacker_hits
		first_time_only=no
		[filter_second]
			description=student
		[/filter_second]
		{VARIABLE_OP student_hp add -3}
	[/event]
	[event]
		name=defender_hits
		first_time_only=no
		[filter]
			description=student
		[/filter]
		{VARIABLE_OP student_hp add -3}
	[/event]

	[event]
		name=attack_end

		{CLEAR_PRINT}
		{UNLABEL {QUINTAIN_LOC}}

		[message]
			description=student
			message=_ "Hey! This quintain fights back!"
		[/message]

		[message]
			description=Delfador
			message=_ "Hmm, maybe we should have started with a doll."
		[/message]

		[message]
			description=student
			message=_ "Should I retreat?"
		[/message]

		[message]
			description=Delfador
			message=_ "Good idea!"
		[/message]

		{GENDER ([message]
			speaker=narrator
			message=_ "Note: the tiny blue shield near Delfador shows that you will lose the game if he is killed.  You will also lose the game if your leader (Konrad) is killed."
		[/message]) ([message]
			speaker=narrator
			message=_ "Note: the tiny blue shield near Delfador shows that you will lose the game if he is killed.  You will also lose the game if your leader (Li'sar) is killed."
		[/message])}

		{MOVE Delfador 13 6 13 8}

		{VARIABLE future_hp $student_hp}
		{VARIABLE_OP future_hp add -15}
		[message]
			description=Delfador
			message=_ "Unfortunately, you've used up your turn attacking the quintain.  The quintain will now get a turn."
		[/message]
		[message]
			description=student
			message=_ "The DUMMY gets a turn?"
		[/message]
		[message]
			description=Delfador
			message=_ "Yes: it's a magical quintain.
Now, this quintain gets five chances to hit you, and if it hits every time, you'll drop from $student_hp to $future_hp hit points.  Brace yourself!"
		[/message]
		{PRINT (_ "Click on the End Turn button on the bottom right")}
	[/event]

	[event]
		name="turn 2"

		# There is a 1 in 170,000 chance that the quintain will miss on all
		# 10 attacks.  Ignoring that.
		{CLEAR_PRINT}
		[refresh][/refresh]
		[message]
			description=student
			message=_ "Ouch!  I need to heal!  Only $student_hp hp left!"
		[/message]

		{LABEL (_"Village") {VILLAGE_LOC}}

		[message]
			description=Delfador
			message=_ "There is a village on the other side of the river.  Visiting villages is a good idea, and ending your turn in one will heal you: you should retreat to there."
		[/message]

		{GENDER ({PRINT (_"Left click on Konrad")})
			({PRINT (_"Left click on Li'sar")})}

		[event]
			name=select
			[filter]
				side=1
			[/filter]

			{GENDER ({PRINT (_"Click on the village to move Konrad")})
				({PRINT (_"Click on the village to move Li'sar")})}
		[/event]

		{DEST 11 7}
		[event]
			name=moveto
			[filter]
				side=1
				x,y=11,7
			[/filter]
			{CLEAR_PRINT}
			[redraw][/redraw]

			{NODEST}
			[message]
				speaker=narrator
				message=_ "You now 'own' this village: you can see it flies your flag, and soon a '1' will appear next to the house icon at the top of screen.  Villages give gold: every turn you gain two gold, plus one for every village you own.
*Left click or any key to continue..."
			[/message]
			{PRINT (_"Click on the End Turn button")}
		[/event]
	[/event]


	[event]
		name=recruit
		first_time_only=no
		# zookeeper suggested we eliminate traits by killing
		# the recruit and replacing it
		[kill]
			x,y=$x1,$y1
		[/kill]
		# Each one needs a unique description for next level.
		{VARIABLE_OP description_num add 1}
		[unit]
			description=$description_num
			generate_description=yes
			type=Elvish Fighter
			x,y=$x1,$y1
			side=1
			upkeep=full
			moves=0
		[/unit]
	[/event]

	[event]
		name="turn 3"

		{CLEAR_PRINT}
		{UNLABEL {VILLAGE_LOC}}
		[message]
			description=Delfador
			# FIXME: How many HP really?
			message=_ "You're about to be healed by 8 hitpoints.   But I think you're going to need some help against that quintain."
		[/message]

		[message]
			description=student
			message=_ "I'll recruit some elves!"
		[/message]

		{LABEL (_"Keep") {KEEP_LOC}}

		[message]
			description=Delfador
			message=_ "A splendid idea.  If you return to your keep, you can recruit two units.  You have plenty of gold for that."
		[/message]

		{DEST 9 6}
		{GENDER ({PRINT (_"Move Konrad to the keep")})
			({PRINT (_"Move Li'sar to the keep")})}

		[event]
			name=moveto
			[filter]
				x,y={KEEP_LOC}
			[/filter]

			{CLEAR_PRINT}
			{UNLABEL {KEEP_LOC}}
			[set_recruit]
				recruit=Elvish Fighter
				side=1
			[/set_recruit]
			[redraw][/redraw]

			[message]
				speaker=narrator
				message=_ "Whenever you're on a keep, you can recruit into castle tiles around it, by right-clicking and selecting 'Recruit'.  This time you will only be given one type of unit to choose: select it.
*Left click or any key to continue..."
			[/message]

			{PRINT (_"Right click on one castle tile and select Recruit")}
		[/event]

		[event]
			name=recruit
			[filter]
				x,y=10,6
			[/filter]
			{VARIABLE Fighter1 1}
			[if]
				[variable]
					name=Fighter2
					numerical_equals=1
				[/variable]
			[then]
				{CLEAR_PRINT}
				[redraw][/redraw]
				[message]
					speaker=narrator
					message=_ "These newly recruited units can do nothing this turn: you will control them next turn.
Note: after this dialog, you can move the mouse over a unit to see a description on the right of the screen.
*Left click or any key to continue..."
				[/message]
				# They can move to the village if they're smart
				{NODEST}
				{PRINT (_"Click on the End Turn button")}
			[/then]
			[else]
				{PRINT (_"Right click on the other castle tile and Recruit another unit")}
			[/else]
			[/if]
		[/event]

		[event]
			name=recruit
			[filter]
				x,y=9,7
			[/filter]
			{VARIABLE Fighter2 1}
			[if]
				[variable]
					name=Fighter1
					numerical_equals=1
				[/variable]
			[then]
				{CLEAR_PRINT}
				[redraw][/redraw]
				[message]
					speaker=narrator
					message=_ "These newly recruited units can do nothing this turn: you will control them next turn.
Note: after this dialog, you can move the mouse over a unit to see a description on the right of the screen.
*Left click or any key to continue..."
				[/message]
				# They can move to the village if they're smart
				{NODEST}
				{PRINT (_"Click on the End Turn button")}
			[/then]
			[else]
				{PRINT (_"Right click on the other castle tile and Recruit another unit")}
			[/else]
			[/if]
		[/event]
	[/event]

	# FIXME: Warn them if they try to attack with Konrad!
	[event]
		name="turn 4"

		{CLEAR_PRINT}
		[message]
			description=student
			message=_ "Hey, the quintain just healed by two hitpoints!  I'd better attack it at once!"
		[/message]
		[message]
			description=Delfador
			message=_ "Yes, if a unit doesn't do anything for a turn, it will slowly heal.
But before you send your fighters against the quintain, you should know they have two kinds of attack..."
		[/message]
		[message]
			description=student
			message=_ "I'll tell them to use the one which does most damage!"
		[/message]
		[message]
			description=Delfador
			message=_ "And which would that be?  The sword (5-4) or the bow (3-3)?  I guess you'll find out..."
		[/message]
		{PRINT (_"Left click on an Elvish Fighter")}
		{VARIABLE encourage (_"End your turn, then attack again.")}

		[event]
			name=select
			[filter]
				type=Elvish Fighter
			[/filter]
			{PRINT (_"Left click on the Quintain to attack it.")}
		[/event]

		[event]
			name=attack
			{CLEAR_PRINT}
		[/event]
		[event]
			name=attack_end

			[special_filter]
				weapon=sword
			[/special_filter]

			{VARIABLE used_sword 1}
			[if]
				[variable]
					name=used_bow
					numerical_equals=1
				[/variable]
			[then]
				[if]
					[variable]
						name=quintain_dead
						numerical_equals=1
					[/variable]
				[then]
					[message]
						description=Delfador
						message=_ "Your elf used a sword (5-4, or 5 damage, 4 attacks), which is a melee attack, so the quintain defended with its melee attack (3-5).  The ranged attack was safer."
					[/message]
				[/then]
				[else]
					[message]
						description=Delfador
						message=_ "Your elf used a sword (5-4, or 5 damage, 4 attacks), which is a melee attack, so the quintain defended with its melee attack (3-5).  The ranged attack was safer.
End your turn, then attack again."
					[/message]
					{PRINT (_"Click on the End Turn button")}
				[/else]
				[/if]
			[/then]
			[else]
				[message]
					description=Delfador
					message=_ "Your elf used a sword (5-4, or 5 damage, 4 attacks), which is a melee attack, so the quintain defended with its melee attack (3-5).
You should tell the other Elf to use the bow."
				[/message]
				{PRINT (_"Attack with the other Elf")}
				[event]
					name=attack
					{CLEAR_PRINT}
				[/event]
			[/else]
			[/if]
		[/event]
		[event]
			name=attack_end

			{VARIABLE used_bow 1}
			[special_filter]
				weapon=bow
			[/special_filter]

			[if]
				[variable]
					name=used_sword
					numerical_equals=1
				[/variable]
			[then]
				[if]
					[variable]
						name=quintain_dead
						numerical_equals=1
					[/variable]
				[then]
					[message]
						description=Delfador
						message=_ "Your elf used a bow, which is a ranged attack (3-3, or 3 damage, 3 attacks).  The quintain has no ranged attack, only a melee attack, so it could not defend itself."
					[/message]
				[/then]
				[else]
					[message]
						description=Delfador
						message=_ "Your elf used a bow, which is a ranged attack (3-3, or 3 damage, 3 attacks).  The quintain has no ranged attack, only a melee attack, so it could not defend itself.
End your turn, then attack again."
					[/message]
					{PRINT (_"Click on the End Turn button")}
				[/else]
				[/if]
			[/then]
			[else]
				[message]
					description=Delfador
					message=_ "Your elf used a bow, which is a ranged attack (3-3, or 3 damage, 3 attacks).  The quintain has no ranged attack, only a melee attack, so it could not defend itself."
				[/message]
				{PRINT (_"Attack with the other Elf")}
				[event]
					name=attack
					{CLEAR_PRINT}
				[/event]
			[/else]
			[/if]
		[/event]
	[/event]

	[event]
		name="turn 5"
		{CLEAR_PRINT}
		[message]
			description=Delfador
			message=_ "Keep attacking, with both elves, until the quintain is finished!"
		[/message]
	[/event]

	[event]
		name="turn 6"
		[message]
			description=Delfador
			message=_ "Maybe you should recruit another elf?"
		[/message]
		[message]
			speaker=narrator
			message=_ "Note:
You can right click on a unit to see a detailed Unit Description."
		[/message]
	[/event]

	[event]
		name="turn 7"
		[if]
			[variable]
				name=quintain_dead
				numerical_equals=1
			[/variable]
		[then]
			[message]
				speaker=narrator
				message=_ "Note:
Remember to pull back wounded units into villages, and recruit more if you need.  Take special care of units with the highest experience points (XP)."
			[/message]
		[/then]
		[/if]
	[/event]

	[event]
		name="turn 8"
		[if]
			[variable]
				name=quintain_dead
				numerical_equals=1
			[/variable]
		[then]
			[message]
				speaker=narrator
				message=_ "Note:
These dummies only attack if you are a single tile away.  With care, you should be able to kill them one at a time."
			[/message]
		[/then]
		[/if]
	[/event]

	[event]
		name="turn 9"
		[message]
			speaker=narrator
			message=_ "Note:
Each village you own can support a single unit for free.  After that, each unit costs you one gold per turn."
		[/message]
	[/event]

	[event]
		name="turn 10"
		[message]
			speaker=narrator
			message=_ "Note:
When a unit gets enough experience (the experience bar is the smaller bar on the right), it will go up a level.  Elvish Fighters have two options, and you will get to choose which one you want."
		[/message]
	[/event]

	[event]
		name="turn 11"
		[message]
			speaker=narrator
			message=_ "Note:
Once you select a unit, you see percentages for different places: higher means more defensible.  For example, defence is good in castles and villages, bad inside rivers.  The dummies' attacks are magical, however, so they have a 70% chance of hitting you wherever you stand."
		[/message]
	[/event]

	[event]
		name=die
		[filter]
			description=student
		[/filter]
		[endlevel]
			result=defeat
		[/endlevel]
	[/event]

	[event]
		name=die
		[filter]
			type=Quintain
		[/filter]
		{CLEAR_PRINT}
		[message]
			speaker=second_unit
			message=_ "The quintain is dead, sirs, and I have gained more experience!"
		[/message]
		{GENDER ([message]
			description=Delfador
			message=_ "Yes, you gain more experience through battle, especially killing an opponent: gain enough experience and you become more powerful." +
			_ "Now Konrad, I will leave you with more dummies to practice on!  After that, we have real work to do..."
		[/message]) ([message]
			description=Delfador
			message=_ "Yes, you gain more experience through battle, especially killing an opponent: gain enough experience and you become more powerful." +
			_ "Now Li'sar, I will leave you with more dummies to practice on!  After that, we have real work to do..."
		[/message])}
		{VARIABLE quintain_dead 1}

		[unit]
			description=Quintain
			type=Quintain
			ai_special="guardian"
			x,y=16,10
			side=2
		[/unit]
		[unit]
			description=Quintain
			type=Quintain
			ai_special="guardian"
			x,y=13,11
			side=2
		[/unit]
		[unit]
			description=Quintain
			type=Quintain
			ai_special="guardian"
			x,y=9,11
			side=2
		[/unit]
		[unit]
			description=Quintain
			type=Quintain
			ai_special="guardian"
			x,y=4,10
			side=2
		[/unit]

		{MOVE Delfador 13 8 2 1}
		[kill]
			description=Delfador
		[/kill]

		[scroll_to_unit]
			type=Quintain
		[/scroll_to_unit]

		[event]
			name=new turn
			first_time_only=no
			[message]
				speaker=narrator
				message=_ "Do you want to keep practicing?"
				[option]
					message=_ "Yes, I'm still figuring it out."
				[/option]
				[option]
					message=_ "No, I think I've got it."
					[command]
						[endlevel]
							result=victory
						[/endlevel]
					[/command]
				[/option]
			[/message]
		[/event]
	[/event]

	[event]
		name=time over
		[if]
			[variable]
				name=quintain_dead
				numerical_equals=1
			[/variable]
		[then]
			[endlevel]
				result=victory
			[/endlevel]
		[/then]
		[else]
			[endlevel]
				result=defeat
			[/endlevel]
		[/else]
		[/if]
	[/event]
[/tutorial]
