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 2013-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
28DefineQuest("the-first-dwarves", {
29	Name = "The First Dwarves",
30	Icon = "icon-modsognir",
31	PlayerColor = "red",
32	FailEffects = function(s)
33		if (trigger_player == GetThisPlayer() and GetCurrentCampaign() == "the-first-dwarves") then
34			CallDialogue("campaign-defeat", trigger_player)
35		end
36	end,
37	ObjectiveStrings = {"- Overcome Svarinshaug's perils", "- Modsognir must survive", "- Durin must survive"},
38	Uncompleteable = true,
39	Unobtainable = true,
40	HeroesMustSurvive = {"modsognir", "durin"}
41})
42
43DefineQuest("a-rocky-home", {
44	Name = "A Rocky Home",
45	Icon = "icon-modsognir",
46	Description = "A clan of dwarves led by Modsognir has arrived in Svarinshaug, seeking a new home. Beset by hostile natural forces on all sides, can they survive their first winter?",
47	PlayerColor = "red",
48	CompletionEffects = function(s)
49		CallDialogue("a-rocky-home-materials-collected", trigger_player)
50	end,
51	Unobtainable = true,
52	Objectives = {
53		{
54			"objective-type", "build-units",
55			"objective-string", "Build a Mead Hall",
56			"quantity", 1,
57			"unit-type", "unit-dwarven-town-hall"
58		},
59		{
60			"objective-type", "gather-resource",
61			"objective-string", "Gather 800 Lumber",
62			"quantity", 800,
63			"resource", "lumber"
64		},
65		{
66			"objective-type", "gather-resource",
67			"objective-string", "Gather 2400 Stone",
68			"quantity", 2400,
69			"resource", "stone"
70		},
71		{
72			"objective-type", "build-units",
73			"objective-string", "Build a Yale Hunting Lodge",
74			"quantity", 1,
75			"unit-type", "unit-yale-hunting-lodge"
76		}
77	},
78	HeroesMustSurvive = {"modsognir", "durin"}
79})
80
81DefineQuest("the-mead-of-wisdom", {
82	Name = "The Mead of Wisdom",
83	Icon = "icon-durin",
84	Description = "The sage of Modsognir's clan has disappeared, taken by two dwarves called Fjalar and Galar. Modsognir has sent Durin to enter their hall, rescue the sage - or what remains of him - and bring the evil pair to justice.\n\nMap: Fjalar's and Galar's Hall",
85	World = "nidavellir",
86	Civilization = "dwarf",
87	Map = "maps/nidavellir/fjalars-and-galars-hall.smp",
88	Scenario = "scripts/civilizations/dwarf/scenarios/the_mead_of_wisdom.lua",
89	PlayerColor = "white",
90	LoadingMusic = "DwarfLoading",
91	MapMusic = "DwarfTheme2",
92	Unobtainable = true
93})
94
95DefineQuest("the-mastersmith-brothers", {
96	Name = "The Mastersmith Brothers",
97	Icon = "icon-dwarven-runemaster",
98	Description = "The brothers Brokk and Eitri have come to renown for their remarkable smithing abilities. It would surely be a boon for us to have them under our employ.",
99	PlayerColor = "red",
100	Conditions = function(s)
101		if (GetPlayerData(trigger_player, "UnitTypesCount", "unit-dwarven-smithy") > 0 or GetPlayerData(trigger_player, "UnitTypesCount", "unit-brising-smithy") > 0) then
102			return true
103		end
104		return false
105	end,
106	CompletionEffects = function(s)
107		SetPlayerData(trigger_player, "Resources", "jewelry", GetPlayerData(trigger_player, "Resources", "jewelry") + 1000)
108	end,
109	Rewards = "+1000 Jewelry",
110	Hint = "A selection of heroes is available for recruitment at the Mead Hall.",
111	Objectives = {
112		{
113			"objective-type", "recruit-hero",
114			"objective-string", "Recruit Brokk",
115			"character", "brokk"
116		},
117		{
118			"objective-type", "recruit-hero",
119			"objective-string", "Recruit Eitri",
120			"character", "eitri"
121		}
122	},
123	Competitive = true
124})
125
126DefineQuest("the-ring-of-riches", {
127	Name = "The Ring of Riches",
128	Icon = "icon-ring",
129	Description = "The mastersmith brothers Brokk and Eitri seek to create a gold ring the like of which none of us have seen before. They request to be provided with the necessary gold for the task.",
130	PlayerColor = "white",
131	Conditions = function(s)
132		if (GetPlayerData(trigger_player, "UnitTypesCount", "unit-dwarven-smithy") > 0 or GetPlayerData(trigger_player, "UnitTypesCount", "unit-brising-smithy") > 0) then
133			return true
134		end
135		return false
136	end,
137	CompletionEffects = function(s)
138		SetPlayerData(trigger_player, "Resources", "copper", GetPlayerData(trigger_player, "Resources", "copper") - 4000)
139		local brokk_unit = FindHero("brokk", trigger_player)
140		if (brokk_unit) then
141			unit = CreateUnit("unit-ring", PlayerNumNeutral, {GetUnitVariable(brokk_unit, "PosX"), GetUnitVariable(brokk_unit, "PosY")}, GetUnitVariable(brokk_unit, "MapLayer"))
142			if (GetUniqueItemData("draupnir", "CanDrop")) then
143				SetUnitVariable(unit, "Unique", "draupnir")
144			else
145				SetUnitVariable(unit, "GenerateSpecialProperties", trigger_player, true) -- if Draupnir cannot drop, then generate a magic ring
146			end
147			SetUnitVariable(unit, "Identified", false)
148		end
149	end,
150	ObjectiveStrings = {"- Brokk and Eitri must survive"},
151	Rewards = "Magic Ring, Lose 4000 Copper",
152	Objectives = {
153		{
154			"objective-type", "gather-resource",
155			"objective-string", "Gather 1000 Gold",
156			"quantity", 1000,
157			"resource", "gold"
158		},
159		{
160			"objective-type", "have-resource",
161			"objective-string", "Have 4000 Copper",
162			"quantity", 4000,
163			"resource", "copper"
164		}
165	},
166	HeroesMustSurvive = {"brokk", "eitri"},
167	Competitive = true
168})
169
170DefineQuest("the-thunder-hammer", {
171	Name = "The Thunder Hammer",
172	Icon = "icon-brising-smithy",
173	Description = "The mastersmiths Brokk and Eitri have spoken of their desire to craft a magnificent hammer, stronger than any other. To do so they will require plenty of metal, however.",
174	PlayerColor = "white",
175	Conditions = function(s)
176		if (GetPlayerData(trigger_player, "UnitTypesCount", "unit-dwarven-smithy") > 0 or GetPlayerData(trigger_player, "UnitTypesCount", "unit-brising-smithy") > 0) then
177			return true
178		end
179		return false
180	end,
181	CompletionEffects = function(s)
182		CallDialogue("brokk-and-eitri-craft-mjollnir", trigger_player)
183		SetPlayerData(trigger_player, "Resources", "copper", GetPlayerData(trigger_player, "Resources", "copper") - 4000)
184		local brokk_unit = FindHero("brokk", trigger_player)
185		if (brokk_unit) then
186			unit = CreateUnit("unit-runesmiths-hammer", PlayerNumNeutral, {GetUnitVariable(brokk_unit, "PosX"), GetUnitVariable(brokk_unit, "PosY")}, GetUnitVariable(brokk_unit, "MapLayer"))
187			if (GetUniqueItemData("mjollnir", "CanDrop")) then
188				SetUnitVariable(unit, "Unique", "mjollnir")
189			else
190				SetUnitVariable(unit, "GenerateSpecialProperties", trigger_player, true) -- if Mjollnir cannot drop, then generate a magic hammer
191			end
192			SetUnitVariable(unit, "Identified", false)
193		end
194	end,
195	ObjectiveStrings = {"- Brokk and Eitri must survive"},
196	Rewards = "Magic Hammer, Lose 4000 Copper",
197	Objectives = {
198		{
199			"objective-type", "gather-resource",
200			"objective-string", "Gather 4000 Copper",
201			"quantity", 4000,
202			"resource", "copper"
203		},
204		{
205			"objective-type", "have-resource",
206			"objective-string", "Have 4000 Copper",
207			"quantity", 4000,
208			"resource", "copper"
209		}
210	},
211	HeroesMustSurvive = {"brokk", "eitri"},
212	Competitive = true
213})
214
215DefineQuest("the-magnificent-spear", {
216	Name = "The Magnificent Spear",
217	Icon = "icon-long-spear",
218	Description = "Ivaldi and his sons are of a mind to craft a wondrous spear, for which they will need a significant amount of materials.",
219	PlayerColor = "white",
220	Conditions = function(s)
221		if (GetPlayerData(trigger_player, "UnitTypesCount", "unit-dwarven-smithy") > 0 or GetPlayerData(trigger_player, "UnitTypesCount", "unit-brising-smithy") > 0) then
222			return true
223		end
224		return false
225	end,
226	CompletionEffects = function(s)
227		SetPlayerData(trigger_player, "Resources", "copper", GetPlayerData(trigger_player, "Resources", "copper") - 2000)
228		SetPlayerData(trigger_player, "Resources", "lumber", GetPlayerData(trigger_player, "Resources", "lumber") - 2000)
229		local ivaldi_unit = FindHero("ivaldi", trigger_player)
230		if (ivaldi_unit) then
231			unit = CreateUnit("unit-long-spear", PlayerNumNeutral, {GetUnitVariable(ivaldi_unit, "PosX"), GetUnitVariable(ivaldi_unit, "PosY")}, GetUnitVariable(ivaldi_unit, "MapLayer"))
232			if (GetUniqueItemData("gungnir", "CanDrop")) then
233				SetUnitVariable(unit, "Unique", "gungnir")
234			else
235				SetUnitVariable(unit, "GenerateSpecialProperties", trigger_player, true) -- if Gungnir cannot drop, then generate a magic ring
236			end
237			SetUnitVariable(unit, "Identified", false)
238		end
239	end,
240	ObjectiveStrings = {"- Ivaldi must survive"},
241	Rewards = "Magic Spear, Lose 2000 Copper and 2000 Lumber",
242	Objectives = {
243		{
244			"objective-type", "gather-resource",
245			"objective-string", "Gather 2000 Copper",
246			"quantity", 2000,
247			"resource", "copper"
248		},
249		{
250			"objective-type", "gather-resource",
251			"objective-string", "Gather 2000 Lumber",
252			"quantity", 2000,
253			"resource", "lumber"
254		},
255		{
256			"objective-type", "have-resource",
257			"objective-string", "Have 2000 Copper",
258			"quantity", 2000,
259			"resource", "copper"
260		},
261		{
262			"objective-type", "have-resource",
263			"objective-string", "Have 2000 Lumber",
264			"quantity", 2000,
265			"resource", "lumber"
266		}
267	},
268	HeroesMustSurvive = {"ivaldi"},
269	Competitive = true
270})
271
272DefineQuest("the-sleek-ship", {
273	Name = "The Sleek Ship",
274	Icon = "icon-dwarven-transport-ship",
275	Description = "The master craftsman Ivaldi and his sons have laid out a project to build a magnificent ship of unrivalled speed.",
276	PlayerColor = "white",
277	Conditions = function(s)
278		if (GetUniqueItemData("skidbladnir", "CanDrop")) then
279			return true
280		end
281		return false
282	end,
283	CompletionEffects = function(s)
284		SetUnitVariable(FindUnit("unit-dwarven-transport-ship", trigger_player, false, true), "Unique", "skidbladnir")
285	end,
286	ObjectiveStrings = {"- Ivaldi must survive"},
287	Rewards = "The Transport will become the Skidbladnir unique ship",
288	Hint = "Select a Dock and then click on the Build Transport button to build the ship required for this quest.",
289	Objectives = {
290		{
291			"objective-type", "build-units",
292			"objective-string", "Build a Transport",
293			"quantity", 1,
294			"unit-type", "unit-dwarven-transport-ship"
295		}
296	},
297	HeroesMustSurvive = {"ivaldi"},
298	Competitive = true
299})
300
301DefineQuest("the-necklace-of-the-brisings", {
302	Name = "The Necklace of the Brisings",
303	Icon = "icon-dwarven-steelclad",
304	Description = "The necklace made for Modsognir's wife by a group of four dwarven smiths has been stolen! The culprits, a band of local dwarven thieves, sneaked away with the necklace last night, going back to their hideout. We must recover the necklace from these bandits!\n\nMap: Aurvang",
305	RequiredQuest = "the-mead-of-wisdom",
306	World = "nidavellir",
307	Civilization = "dwarf",
308	Map = "maps/nidavellir/aurvang.smp",
309	Scenario = "scripts/civilizations/dwarf/scenarios/the_necklace_of_the_brisings.lua",
310	PlayerColor = "black",
311	LoadingMusic = "DwarfLoading",
312--	MapMusic = "DwarfTheme4",
313	Unobtainable = true
314})
315
316DefineQuest("the-slaying-of-grafvitnir", {
317	Name = "The Slaying of Grafvitnir",
318	Icon = "icon-wyrm",
319	Description = "Svarinshaug has been discovered to house a kobold tribe, who will attack the dwarves on sight for trespassing on their sacred ground. Modsognir's clan must now slay the kobolds and the wyrm they worship, Grafvitnir.",
320	World = "nidavellir",
321	Civilization = "dwarf",
322	PlayerColor = "black",
323	ObjectiveStrings = {"- Destroy the Grafvitning Tribe"},
324	Unobtainable = true,
325	Uncompleteable = true,
326	Unfailable = true,
327	HeroesMustSurvive = {"modsognir", "durin"}
328})
329
330DefineQuest("dvalins-runes", {
331	Name = "Dvalin's Runes",
332	Icon = "icon-norse-runewriting",
333	Description = "The wise Dvalin seeks to devise a system of runes, and asks for our support in this endeavor. Dvalin claims that those runes are not only symbols of magic significance, but that they will also allow us to lay our thought down in fixed form for the future generations.",
334	PlayerColor = "red",
335	CompletionEffects = function(s)
336		SetPlayerData(trigger_player, "Resources", "copper", GetPlayerData(trigger_player, "Resources", "copper") + 2500)
337	end,
338	ObjectiveStrings = {"- Dvalin must survive"},
339	Rewards = "+2500 Copper",
340	Hint = "Select a Bastion and then click on the Research Runewriting button to research the technology required for this quest.",
341	Objectives = {
342		{
343			"objective-type", "research-upgrade",
344			"objective-string", "Research Runewriting",
345			"upgrade", "upgrade-dwarven-runewriting"
346		}
347	},
348	HeroesMustSurvive = {"dvalin"}
349})
350