1--       _________ __                 __
2--      /   _____//  |_____________ _/  |______     ____  __ __  ______
3--      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
4--      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
5--     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
6--             \/                  \/          \//_____/            \/
7--  ______________________                           ______________________
8--                        T H E   W A R   B E G I N S
9--         Stratagus - A free fantasy real time strategy game engine
10--
11--      (c) Copyright 2014-2019 by Andrettin
12--
13--      This program is free software; you can redistribute it and/or modify
14--      it under the terms of the GNU General Public License as published by
15--      the Free Software Foundation; either version 2 of the License, or
16--      (at your option) any later version.
17--
18--      This program is distributed in the hope that it will be useful,
19--      but WITHOUT ANY WARRANTY; without even the implied warranty of
20--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21--      GNU General Public License for more details.
22--
23--      You should have received a copy of the GNU General Public License
24--      along with this program; if not, write to the Free Software
25--      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26--
27
28if (LoadedGame == false) then
29	SetPlayerData(0, "Faction", "suebi-tribe")
30	SetPlayerData(0, "Resources", "copper", 5000)
31	SetPlayerData(0, "Resources", "lumber", 5000)
32	SetPlayerData(0, "Resources", "stone", 2500)
33	SetAiType(0, "land-attack")
34	SetPlayerData(1, "Faction", "aedui-tribe")
35	SetPlayerData(1, "Resources", "copper", 2000)
36	SetPlayerData(1, "Resources", "lumber", 2000)
37	SetPlayerData(1, "Resources", "stone", 1000)
38	SetAiType(1, "land-attack")
39	SetPlayerData(2, "Faction", "sequani-tribe")
40	SetPlayerData(2, "Resources", "copper", 0)
41	SetPlayerData(2, "Resources", "lumber", 0)
42	SetPlayerData(2, "Resources", "stone", 0)
43	SetAiType(2, "passive")
44
45	SetPlayerData(GetFactionPlayer("Sequani Tribe"), "Allow", "unit-teuton-barracks", "F")
46
47	if (GrandStrategy == false) then
48		unit = CreateUnit("unit-suebi-swordsman", 0, {Players[0].StartPos.x, Players[0].StartPos.y})
49		SetUnitVariable(unit, "Active", false)
50		unit = CreateUnit("unit-suebi-swordsman", 0, {Players[0].StartPos.x, Players[0].StartPos.y})
51		SetUnitVariable(unit, "Active", false)
52		unit = CreateUnit("unit-teuton-archer", 0, {Players[0].StartPos.x, Players[0].StartPos.y})
53		SetUnitVariable(unit, "Active", false)
54
55		unit = CreateUnit("unit-teuton-swordsman", 1, {Players[1].StartPos.x, Players[1].StartPos.y})
56		SetUnitVariable(unit, "Active", false)
57		unit = CreateUnit("unit-teuton-archer", 1, {Players[1].StartPos.x, Players[1].StartPos.y})
58		SetUnitVariable(unit, "Active", false)
59		unit = CreateUnit("unit-teuton-archer", 1, {Players[1].StartPos.x, Players[1].StartPos.y})
60		SetUnitVariable(unit, "Active", false)
61	end
62
63	SetDiplomacy(0, "allied", 2)
64	SetSharedVision(0, true, 2)
65	SetDiplomacy(2, "allied", 0)
66	SetSharedVision(2, true, 0)
67end
68
69-- The Battle of Magetobria introduction
70AddTrigger("the-battle-of-magetobria-introduction",
71	function()
72		if (GameCycle == 0) then
73			return false
74		end
75		if (GetFactionExists("Suebi Tribe") and PlayerHasObjective(GetFactionPlayer("Suebi Tribe"), "- Defeat the Aedui") == false) then
76			player = GetFactionPlayer("Suebi Tribe")
77			return true
78		end
79		return false
80	end,
81	function()
82		Event(
83			"",
84			"We, the Suebi, have been hired by the Sequani and Arverni tribes to come into Gaul and help them defeat their enemies, the Aedui. We are now positioned in a Sequani settlement, Magetobria, and an Aedui army approaches...",
85			player,
86			{"~!Continue"},
87			{function(s)
88				RemovePlayerObjective(player, "- Defeat your rivals")
89				AddPlayerObjective(player, "- Defeat the Aedui")
90			end}
91		)
92		return false
93	end
94)
95
96AddTrigger("the-battle-of-magetobria-victory",
97	function()
98		if (GameCycle == 0) then
99			return false
100		end
101		if (GetFactionExists("Suebi Tribe") and PlayerHasObjective(GetFactionPlayer("Suebi Tribe"), "- Defeat the Aedui") and GetNumRivals(GetFactionPlayer("Suebi Tribe")) == 0) then
102			player = GetFactionPlayer("Suebi Tribe")
103			return true
104		end
105		return false
106	end,
107	function()
108		Event(
109			"",
110			"The Aedui have been crushed, victory is ours!",
111			player,
112			{"~!Continue"},
113			{function(s)
114			Event(
115				"",
116				"We were granted land in Gaul by the Sequani and the Arverni. However, our chieftain Ariovistus wanted more. Not only did he begin to lord over the Aedui, but much of the Sequani's lands was taken for settlement, with our kinsmen being brought from beyond the Rhine. The Gaulish tribes lied prostate before us.",
117				player,
118				{"~!Continue"},
119				{function(s)
120				Event(
121					"",
122					"It would not be long, however, until an intervening force would sweep our warriors back across the Rhine into Germania: Caesar's Legions. The brilliant general bested Ariovistus in the field, forcing the chieftain to abandon his plans to conquer Gaul for the Suebi.",
123					player,
124					{"~!Continue"},
125					{function(s)
126						if (player == GetThisPlayer()) then
127							ActionVictory()
128							if (GrandStrategy == false) then
129								SetQuestCompleted("the-battle-of-magetobria", GameSettings.Difficulty)
130							end
131						end
132					end},
133					nil,
134					nil,
135					GrandStrategy
136				)
137				end}
138			)
139			end}
140		)
141		return false
142	end
143)
144