;
;    GREAT BATTLES OF MIDDLE-EARTH PART 1:
;       
;
;      THE BATTLE OF FIVE ARMIES
;	        Events
;
;FLAGS:
;	Goblins:
;		00000000000000000000000000000001= Second Assualt
;		00000000000000000000000000000011= Third Assault
;		00000000000000000000000000000111= First Bodyguard Killed
;		00000000000000000000000000001111= Second BodyGuard Killed
;		00000000000000000000000000011111= Third BodyGuard Killed (Bolg Exposed!)
;
;	Dwarves:
;		00000000000000000000000000000001= Dain Killed
;		00000000000000000000000000000010= Thorin Killed
;
;	Humans:
;		00000000000000000000000000000001= Beorn's Arrival
;
;	Everybody:
;		10000000000000000000000000000000= Human Destroyed
;		01000000000000000000000000000000= Elves Destroyed

@BEGINEVENTS
@INITFLAG
@DEBUG

; No Negotiations

@IF
Negotiation
talker=Eagles
talkertype=HumanOrComputer
listener=Anybody
listenertype=HumanOrComputer
@THEN
@ENDIF

@IF
Negotiation
talker=Elves
talkertype=HumanOrComputer
listener=Anybody
listenertype=HumanOrComputer
@THEN
@ENDIF

@IF
Negotiation
talker=Dwarves
talkertype=HumanOrComputer
listener=Anybody
listenertype=HumanOrComputer
@THEN
@ENDIF

@IF
Negotiation
talker=Humans
talkertype=HumanOrComputer
listener=Anybody
listenertype=HumanOrComputer
@THEN
@ENDIF

@IF
Negotiation
talker=Goblins
talkertype=HumanOrComputer
listener=Anybody
listenertype=HumanOrComputer
@THEN
@ENDIF

; Prologue

@IF
Turn
turn=0
@Then
Text
^^GREAT BATTLES OF MIDDLE-EARTH PART ONE: THE BATTLE OF FIVE ARMIES 
^The three armies of Bard, Dain, and Thranduil have come to take by force the gold of 
^Erebor which was only recently made available by Bard's killing of the gold's former 
^'owner,' the great dragon Smaug.  The battle was about to begin and arrows were 
^already flying when . . . 
EndText
@ENDIF

@IF
Turn
turn=0
@THEN
Text
^^"'HALT!'"
EndText
@ENDIF

@IF
Turn
turn=0
@THEN
Text
Gandalf, the great wizard, suddenly appeared before the advancing armies. 
EndText
@ENDIF

@IF
Turn
turn=0
@THEN
Text
"'Halt!' he called in a voice like thunder, and his staff blazed forth with a flash 
^like the lightning.  'Dread has come upon you all!  Alas! it has come more swiftly 
^than I guessed.  The Goblins are upon you!  Bolg of the North is coming.  O Dain! 
^whose father you slew in Moria.  Behold! the bats are above his army like a sea of 
^locusts. They ride upon wolves and Wargs are in their train!'"
EndText
@ENDIF

@IF
Turn
turn=0
@THEN
Text
Even as Gandalf spoke the sky grew dark with the wings of bats.  The opposing armies 
^drew together to take council.  
^DAIN: "We cannot fight both Goblins and each other too! We must ally before we are 
^all destroyed!"
^The other leaders agreed.
^THRANDUIL: "I shall man the western spur of the mountain and you dwarves and men 
^shall man the eastern.  Together we shall crush their army!"
EndText
@ENDIF


; LOSER!!!

@IF
UnitKilled
unit=Bard
attacker=Goblins
defender=Humans
@THEN
Text
Alas!  Bard has been slain!  Confusion suddenly erupts in the ranks of the Lakemen as
^their leader falls. A mass slaughter ensues as the men retreat to their fallen lord. 
^^THE HUMAN PLAYER HAS LOST.
EndText
DestroyACivilization
whom=Humans
Flag
who=Everyone
state=on
Flag=10000000000000000000000000000000
continuous
@ENDIF

@IF
UnitKilled
unit=Bard
attacker=Goblins
defender=Humans
@THEN
Text
However, some of the men escape to join the ranks of the remaining armies to avenge 
^their leader!
Endtext
CreateUnit
owner=Dwarves
unit=Lakemen
count=7
veteran=no
homecity=none
locations
90,24
endlocations
@ENDIF

@IF
UnitKilled
unit=Bard
attacker=Goblins
defender=Humans
@THEN
CreateUnit
owner=Elves
unit=Lakemen
count=7
veteran=no
homecity=none
locations
48,52
endlocations
@ENDIF

@IF
UnitKilled
unit=Thranduil
attacker=Goblins
defender=Elves
@THEN
Text
Thranduil, who once stood in the halls of Menegroth, is no more!  Even as his spirit
^flies to Mandos his followers flee the wrath of the Goblins!
^^THE ELF PLAYER HAS LOST.
EndText
DestroyACivilization
whom=Elves
CreateUnit
owner=Humans
unit=Elf Spearmen
count=7
veteran=no
homecity=none
locations
115,39
endlocations
Flag
whom=Everyone
state=on
flag=0100000000000000000000000000000
continuous
@ENDIF

@IF
UnitKilled
unit=Thranduil
attacker=Goblins
defender=Elves
@THEN
Text
But all is not lost!  A few of the elves stand their ground to fight alongside 
^dwarf and human!
EndText 
CreateUnit
owner=Dwarves
unit=Elf Spearmen
count=7
veteran=no
homecity=none
locations
90,24
endlocations
@ENDIF

@IF
UnitKilled
Unit=Thorin
attacker=Goblins
defender=Dwarves
@AND
CheckFlag
who=Dwarves
flag=00000000000000000000000000000001
state=off
@THEN
Text
Thorin falls to the ground mortally wounded.  But the steeled dwarves pay no heed,
^for Dain picks up the armor of his ancestors to fight on!
EndText
Flag
who=Dwarves
state=on
flag=00000000000000000000000000000010
continuous
CreateUnit
owner=Goblins
unit=Fallen Thorin
veteran=no
homecity=none
locations
83,49
endlocations
@ENDIF

@IF
UnitKilled
Unit=Thorin
attacker=Goblins
defender=Dwarves
@AND
CheckFlag
who=Dwarves
flag=00000000000000000000000000000001
state=on
@THEN
Text
Thorin falls to the ground mortally wounded to join his brother Dain.  But even
^though all seems lost for the Dwarves, they continue to fight on, for their 
^hatred for the Goblins now only glows brighter!  
EndText
Flag
who=Dwarves
state=on
flag=00000000000000000000000000000010
continuous
@ENDIF

@IF
UnitKilled
Unit=Dain
attacker=Goblins
defender=Dwarves
@AND
CheckFlag
who=Dwarves
flag=00000000000000000000000000000010
state=on
@THEN
Text
Dain falls to the ground mortally wounded to join his brother Thorin.  But even
^though all seems lost for the Dwarves, they continue to fight on, for their 
^hatred for the Goblins now only glows brighter!  
EndText
Flag
who=Dwarves
state=on
flag=00000000000000000000000000000001
continuous
@ENDIF

@IF
UnitKilled
Unit=Thorin
attacker=Goblins
defender=Dwarves
@AND
CheckFlag
who=Dwarves
flag=00000000000000000000000000000010
state=off
@THEN
Text
Alas! Bolg has had his revenge!  Dain has been slain!
EndText
Flag
who=Dwarves
state=on
flag=00000000000000000000000000000001
continuous
@ENDIF

@IF
UnitKilled
unit=Eagle King
attacker=Goblins
defender=Eagles
@THEN
Text
The Eagle king has been slain!  The other eagles, disillusioned by the loss
^of their leader, return to their cozy nests.
^^THE EAGLE PLAYER HAS LOST
EndText
DestroyACivilization
whom=Eagles
CreateUnit
owner=Humans
unit=Eagles
count=4
veteran=yes
homecity=none
locations
63,13
endlocations
@ENDIF

@IF
UnitKilled
unit=Eagle King
attacker=Goblins
defender=Eagles
@THEN
Text
But a few of the Eagles return to fight with the remaining
^warriors!
EndText
CreateUnit
owner=Elves
unit=Eagles
count=4
veteran=yes
homecity=none
locations
116,14
endlocations
@ENDIF

@IF
UnitKilled
unit=Eagle King
attacker=Goblins
defender=Eagles
@THEN
CreateUnit
owner=Dwarves
unit=Eagles
count=4
veteran=yes
homecity=none
locations
118,13
endlocations
@ENDIF

@IF
CityDestroyed
city=Thorin's Gate
owner=Dwarves
@THEN
Text
Thorin's Gate has been stormed!  Orcs pour into Erebor to claim the mounds of 
^treasure filling its halls.  The few remaining Dwarves, Elves and Men retire
^from fighting, for it is nearly impossible to retake the gate from so many
^defenders.
^^ALL PLAYERS HAVE LOST.
EndText
ENDGAME
endscreens=no
@ENDIF  

@IF
CityTaken
city=Thorin's Gate
attacker=Goblins
defender=Dwarves
@THEN
Text
Thorin's Gate has been stormed!  Orcs pour into Erebor to claim the mounds of 
^treasure filling its halls.  The few remaining Dwarves, Elves and Men retire
^from fighting, for it is nearly impossible to retake the gate from so many
^defenders.
^^ALL PLAYERS HAVE LOST.
EndText
ENDGAME
endscreens=no
@ENDIF  

; First Assualt


@IF
UnitKilled
unit=Sword Orcs
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Wolves
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Wolves
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Bats
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Bats
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Trolls
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Trolls
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Wargs
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Orc Archers
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Pike Orcs
attacker=Humans
defender=Goblins
@THEN
CreateUnit
owner=Goblins
unit=Pike Orcs
count=2
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

;  Second Assault

@IF
Turn
turn=10
@THEN
Text
Suddenly, from the mountains, a terrible cry is heard!  The Elves, Men and Dwarves look
^towards the cry in dismay, for the Goblins have found hidden passages in the mountains 
^and are assaulting them from behind!
EndText
ChangeTerrain
terraintype=0
maprect
56,38,56,38,57,37,57,37
Flag
who=Goblins
flag=00000000000000000000000000000001
state=on
continuous
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
63,27,63,27,65,29,65,29
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
69,21,69,21,71,23,71,23
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
73,19,73,19,74,20,74,20
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
77,19,77,19,76,20,76,20
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
115,27,115,27,114,28,114,28
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
118,32,118,32,117,33,117,33
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
123,41,123,41,122,42,122,42
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
112,22,112,22,112,22,112,22
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
101,15,101,15,102,16,102,16
@ENDIF

@IF
Turn
turn=10
@THEN
ChangeTerrain
terraintype=0
maprect
93,15,93,15,93,15,93,15
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
55,31
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
55,31
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
60,24
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
60,24
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
67,19
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
67,19
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
73,13
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
73,13
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
92,12
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
92,12
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
99,13
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
99,13
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
114,20
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
114,20
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
117,25
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
117,25
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
120,29
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
120,29
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=10
homecity=none
veteran=no
locations
128,36
endlocations
@ENDIF

@IF
Turn
turn=10
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=5
homecity=none
veteran=no
locations
128,36
endlocations
@ENDIF


@IF
UnitKilled
unit=Sword Orcs
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

@IF
UnitKilled
unit=Wolves
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Wolves
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

@IF
UnitKilled
unit=Bats
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Bats
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

@IF
UnitKilled
unit=Trolls
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Trolls
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

@IF
UnitKilled
unit=Wargs
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

@IF
UnitKilled
unit=Orc Archers
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

@IF
UnitKilled
unit=Pike Orcs
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
flag=00000000000000000000000000000001
state=on
@THEN
CreateUnit
owner=Goblins
unit=Pike Orcs
count=1
veteran=no
homecity=none
randomize
locations
126,36
121,29
117,25
113,21
111,17
99,13
91,13
74,14
67,19
61,25
56,30
endlocations
@ENDIF

;  Third Assault

@IF
Turn
turn=15
@THEN
Text
From the south, a terrible commotion is heard.  But soon it is evident that the 
^Goblins have brought in reinforcements, especially Bolg's Body Guards!
EndText
CreateUnit
owner=Goblins
unit=BodyGuards
veteran=no
homecity=none
locations
82,52
endlocations
Flag
who=Goblins
state=on
flag=00000000000000000000000000000010
continuous
@ENDIF

@IF
Turn
turn=15
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=20
veteran=no
homecity=none
locations
82,52
endlocations
@ENDIF

@IF
Turn
turn=15
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=20
veteran=no
homecity=none
locations
76,52
endlocations
@ENDIF

@IF
Turn
turn=15
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=20
veteran=no
homecity=none
locations
80,52
endlocations
@ENDIF

@IF
Turn
turn=15
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=20
veteran=no
homecity=none
locations
86,52
endlocations
@ENDIF

@IF
Turn
turn=15
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=20
veteran=no
homecity=none
locations
72,52
endlocations
@ENDIF

@IF
UnitKilled
unit=Sword Orcs
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Sword Orcs
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Wolves
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Wolves
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Bats
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Bats
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Trolls
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Trolls
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Wargs
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Orc Archers
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Orc Archers
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

@IF
UnitKilled
unit=Pike Orcs
attacker=Humans
defender=Goblins
@AND
CheckFlag
who=Goblins
state=on
flag=00000000000000000000000000000010
@THEN
CreateUnit
owner=Goblins
unit=Pike Orcs
count=1
veteran=no
homecity=none
randomize
locations
80,40
83,35
89,43
85,41
84,42
81,43
83,49
79,43
78,36
endlocations
@ENDIF

;  Reinforcements

@IF
RandomTurn
denominator=10
@THEN
JustOnce
Text
Gandalf, after watching the battle for a while, suddenly enters the fray
^alongside the elves!
EndText
CreateUnit
owner=Elves
unit=Gandalf
veteran=yes
homecity=none
locations
49,51
endlocations
@ENDIF

@If
UnitKilled
unit=Gandalf
attacker=Goblins
defender=Elves
@THEN
Text
Gandalf retires back to the guardhouse for the rest of the battle.
EndText 
@ENDIF

@IF 
RandomTurn
denominator=15
@AND
CheckFlag
who=Elves
flag=00000000000000000000000000000001
state=off
@THEN
JustOnce
Text
Bilbo quietly slips on the Ring and begins spying for the Dwarves!
Endtext
CreatUnit
owner=Dwarves
unit=Bilbo
veteran=yes
homecity=none
locations
47,51
endlocations
Flag
who=Elves
state=on
flag=00000000000000000000000000000001
@ENDIF

@IF
UnitKilled
unit=Bilbo
attacker=Goblins
defender=Dwarves
@THEN
Text
BILBO: Whew! This spying business has plum wore me out!  I'll go back 
^to my hiding place to rest.
EndText
Flag
who=Elves
state=off
flag=00000000000000000000000000000001
@ENDIF

@IF
RandomTurn
denominator=25
@THEN
Text
Bard finds and rescues some Dwarves from drowning in the river!
^DWARVES: We are forever grateful!  We shall fight on your side until we
^come to our own company.
EndText
CreateUnit
owner=Humans
unit=Dwarves
count=2
veteran=yes
homecity=none
locations
107,43
endlocations
@ENDIF

@IF
Turn
turn=20
@THEN
Text
"Suddenly there was a great shout, and from the Gate came a trumpet call.
^Out leapt the King under the Mountain, and his companions followed him,
^all clothed in shining armor!
EndText
ChangeTerrain
terraintype=6
maprect
83,21,84,20,85,21,84,22
CreateUnit
owner=Dwarves
unit=Thorin
veteran=yes
homecity=none
locations
84,18
endlocations
@ENDIF

@IF
Turn
turn=20
@THEN
Text
THORIN: "'To me! To me! Elves and Men! To me! O my kinsfolk!'"
^Suddenly, the hearts and souls of the downtrodden were uplifted and they 
^joined this new offensive with renewed vigor.
EndText
CreateUnit
owner=Dwarves
unit=Dwarves
count=11
veteran=yes
homecity=none
locations
84,18
endlocations
@ENDIF

@IF
Turn
turn=20
@THEN
CreateUnit
owner=Elves
unit=Elf Archers
count=5
veteran=yes
homecity=none
locations
83,19
endlocations
@ENDIF

@IF
Turn
turn=20
@THEN
CreateUnit
owner=Humans
unit=H. Archers
count=5
veteran=yes
homecity=none
locations
85,19
endlocations
@ENDIF

@IF
Turn
turn=20
@THEN
CreateUnit
owner=Dwarves
unit=Dwarves
count=5
veteran=yes
homecity=none
locations
84,20
endlocations
@ENDIF

@IF
Turn
turn=22
@THEN
CreateUnit
owner=Goblins
unit=Wargs
count=8
veteran=no
homecity=none
locations
83,29
84,30
85,29
endlocations
@ENDIF

@IF
Turn
turn=23
@THEN
CreateUnit
owner=Goblins
unit=Elf Archers
count=8
veteran=no
homecity=none
locations
85,39
endlocations
@ENDIF

@IF
Turn
turn=25
@THEN
Text
Suddenly, from the western sky, Bilbo spys hundreds of dots speeding towards them!
^BILBO: "'The Eagles! The Eagles! The Eagles are coming!'"
Endtext
CreateUnit
owner=Eagles
unit=Eagles
count=8
veteran=no
homecity=none
locations
63,13
endlocations
@ENDIF

@IF
Turn
turn=25
@THEN
CreateUnit
owner=Eagles
unit=Bombers
count=8
veteran=no
homecity=none
locations
63,13
endlocations
@ENDIF

@IF
Turn
turn=25
@THEN
CreateUnit
owner=Eagles
unit=Bombers
count=8
veteran=no
homecity=none
locations
116,14
endlocations
@ENDIF

@IF
Turn
turn=25
@THEN
CreateUnit
owner=Eagles
unit=Eagles
count=8
veteran=no
homecity=none
locations
116,14
endlocations
@ENDIF

@IF
Turn
turn=25
@THEN
CreateUnit
owner=Eagles
unit=Eagle King
veteran=yes
homecity=none
locations
63,13
endlocations
@ENDIF

@IF
UnitKilled
unit=Thorin
attacker=Goblins
defender=Dwarves
@AND
CheckFlag
who=Humans
flag=00000000000000000000000000000001
state=off
@THEN
Delay
delay=10
Text
From the south, from who knows where, comes Beorn the Changeling!  
^Swinging his ax he makes his way to the fallen Thorin!
Endtext
CreateUnit
owner=Humans
unit=Beorn
veteran=yes
homecity=none
locations
46,52
endlocations
Flag
who=Humans
state=on
flag=00000000000000000000000000000001
@ENDIF

@IF
Turn
turn=40
@AND
CheckFlag
who=Humans
flag=00000000000000000000000000000001
state=off
@THEN
Text
From the south, from who knows where, comes Beorn the Changeling!  
^Swinging his ax he makes his way to the fallen Thorin!
Endtext
CreateUnit
owner=Humans
unit=Beorn
veteran=yes
homecity=none
locations
46,52
endlocations
Flag
who=Humans
state=on
flag=00000000000000000000000000000001
@ENDIF

;  EndGame

@IF
UnitKilled
unit=BodyGuards
attacker=AnyBody
defender=Goblins
@AND
CheckFlag
who=Humans
flag=00000000000000000000000000000001
state=off
@THEN
Text
With a awful cry, the first BodyGuard comes down before the feet of 
^the defenders.  But now is not the time for rejoicing, for he is 
^quickly replaced by another one!
EndText
CreateUnit
owner=Goblins
unit=BodyGuards
veteran=yes
homecity=none
locations
76,52
endlocations
@ENDIF

@IF
UnitKilled
unit=BodyGuards
attacker=AnyBody
defender=Goblins
@AND
CheckFlag
who=Humans
flag=00000000000000000000000000000001
state=on
@THEN
Text
The final Bodyguard has been killed! Quick Beorn! Bolg is now exposed!
EndText
CreateUnit
owner=Goblins
unit=Bolg
veteran=yes
homecity=none
locations
76,52
endlocations
@ENDIF

@IF
UnitKilled
unit=Bolg
attacker=AnyBody
defender=Goblins
@AND
CheckFlag
who=Dwarves
state=off
flag=00000000000000000000000000000010
@THEN
Text
The victor lifts the head of Bolg high over the crowd of ever increasing
^hordes.  At the sight of their dead leader though the orcs flee, 
^zealously pursued by the defenders.  After the last one is chased into 
^the Running River, the battlefield is spied by Elf, Dwarf and Man.
^Though many a Goblin lies dead, many friends lie therein too.  But the
^victory has been won, and all of the beleagured troops rush to claim 
^the prize, a huge pot of gold!  
^^CONGRAGULATIONS!  YOU HAVE WON THE BATTLE OF FIVE ARMIES!  
EndText
EndGame
endscreens=no
@ENDIF
@ENDEVENTS

