1---------------------------------------------------------------------
2-- This file is part of Freedroid
3--
4-- Freedroid is free software; you can redistribute it and/or modify
5-- it under the terms of the GNU General Public License as published by
6-- the Free Software Foundation; either version 2 of the License, or
7-- (at your option) any later version.
8--
9-- Freedroid is distributed in the hope that it will be useful,
10-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-- GNU General Public License for more details.
13--
14-- You should have received a copy of the GNU General Public License
15-- along with Freedroid; see the file COPYING. If not, write to the
16-- Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17-- MA 02111-1307 USA
18----------------------------------------------------------------------
19--[[WIKI
20PERSONALITY = { "Devious", "Focused", "Polite", "Vengeful" },
21MARKERS = { NPCID1 = "Koan" },
22PURPOSE = "$$NAME$$ sells grenades to Tux. $$NAME$$ also hints at the future of the Red Guard.",
23BACKSTORY = "$$NAME$$ is the bomb maker for the Red Guard. $$NAME$$ hints that he threw a grenade that caused great
24	 destruction and resulted in the loss of many of \'his people\'.",
25RELATIONSHIP = {
26	{
27		actor = "$$NPCID1$$",
28		text = "$$NAME$$ is the opposite of $$NPCID1$$. $$NAME$$ destroys life while $$NPCID1$$ creates life."
29	},
30}
31WIKI]]--
32
33local Npc = FDrpg.get_npc()
34local Tux = FDrpg.get_tux()
35
36return {
37	EveryTime = function()
38		if (Tux:has_met("Koan")) then
39			hide("node56")
40		end
41
42		if (not Tux:has_met("Duncan")) then
43			show("node0", "node90", "node99")
44		elseif (not guard_follow_tux) and
45		       (not Duncan_Koan_quest) then
46			next("node50")
47		end
48
49		if (not Duncan_Koan_quest_really_done) then
50			if (Tux:has_item_backpack("Pandora's Cube")) or
51			   (Koan:is_dead()) or
52			   (Koan_spared_via_dialog) then
53				--Koan died, and you brought the cube back or
54				--Koan died, but you didn't bring the cube back or
55				--Koan is alive!
56				if (not Duncan_Koan_quest_done) then --if you just came back from Koan
57					next("node60")
58				elseif (not Duncan_not_given_cube) and
59				       (Koan:is_dead()) then
60					--if, after talking to Duncan, Koan became dead
61					next("node60")
62				end
63			end
64		end
65
66		if (tux_has_joined_guard) then
67			hide("node3", "node4")
68		end
69
70		if (Duncen_node_62_hide) then
71			hide("node62")
72		end
73	end,
74
75	{
76		id = "node0",
77		text = _"Hi... Erm... Who are you?",
78		code = function()
79			Npc:says(_"Duncan McNamara, The Red Guard's resident bomb maker, at your service.")
80			Npc:set_name("Duncan - Bombmaker")
81			hide("node0", "node90") show("node1")
82		end,
83	},
84	{
85		id = "node1",
86		text = _"I would like to buy a bomb.",
87		code = function()
88			Npc:says_random(_"Yes. I am sure we can arrange something. Take a look.",
89							_"Sure. These are my offers today.")
90			trade_with("Duncan")
91			if (not guard_follow_tux) then
92				hide("node1") show("node2", "node7")
93			end
94		end,
95	},
96	{
97		id = "node2",
98		text = _"I see only grenades. Do you have something bigger?",
99		code = function()
100			Npc:says(_"My deepest apologies, I do not.")
101			Npc:says(_"The Red Guard prohibits the sales of extremely destructive munitions.")
102			Npc:says(_"It is not yet the time for the fall of their rule, so I remain loyal.")
103			hide("node2") show("node3", "node4", "node5", "node6")
104		end,
105	},
106	{
107		id = "node3",
108		text = _"The fall of the Red Guard? I am going to report that you are inciting a revolution!",
109		code = function()
110			Npc:says(_"My word against yours. If you wish to try it, please, be my guest.")
111			Npc:says(_"I am not inciting anything. I am just stating what I see as inevitable in the future.")
112			Npc:says(_"I have taken part in many conflicts and I have seen how governments collapse.")
113			Npc:says(_"As soon as the war is over, the Red Guard will disband.")
114			Npc:says(_"Of course, I am making the assumption of victory, which is highly unlikely with the current state of affairs.")
115			hide("node3", "node4")
116		end,
117	},
118	{
119		id = "node4",
120		text = _"The fall of the Red Guard? Tell me more about it.",
121		code = function()
122			Npc:says(_"It is not the time to speak of such things yet. Come another day, and we shall talk about it in more detail.")
123			Npc:says(_"The Red Guard can have their great laser beams and plasma cannons... But nothing can save them.")
124			hide("node3", "node4")
125		end,
126	},
127	{
128		id = "node5",
129		text = _"I want to buy some grenades.",
130		code = function()
131			Npc:says_random(_"Certainly.",
132							_"Sure.",
133							_"With pleasure.")
134			trade_with("Duncan")
135		end,
136	},
137	{
138		id = "node6",
139		text = _"What kind of grenade is the best?",
140		code = function()
141			Npc:says(_"You get what you pay for.")
142			hide("node6")
143		end,
144	},
145	{
146		id = "node7",
147		text = _"How did you get into making explosives?",
148		code = function()
149			Npc:says(_"Twenty years ago there was a conflict.")
150			Npc:says(_"A grenade I threw destroyed a being which killed many of... my people.")
151			Npc:says(_"Now I make more to smash the destroyers.")
152			hide("node7")
153		end,
154	},
155	{
156		id = "node50",
157		code = function()
158			Npc:says(_"Ah. Welcome again Linarian.")
159			Npc:says(_"I have a little request for you.")
160			Npc:says(_"I know someone who needs to be taught a lesson.")
161			Npc:says(_"Interested?")
162			Duncan_Koan_quest = true
163			show("node51", "node59")
164		end,
165	},
166	{
167		id = "node51",
168		text = _"Tell me more.",
169		code = function()
170			Npc:says(_"Ah, excellent.")
171			Npc:says(_"A... friend of mine, Koan, stole something of great value to me.")
172			Npc:says(_"He is hiding somewhere in the desert, I don't know exactly where.")
173			hide("node51") show("node52")
174		end,
175	},
176	{
177		id = "node52",
178		text = _"I will get your property back.",
179		code = function()
180			Npc:says(_"Excellent. I am pleased to hear this.")
181			Npc:says(_"There is something you must know.")
182			Npc:says(_"There are not too many bots in the desert, but they are invincible. It is best to avoid them.")
183			Npc:says(_"I will be waiting here for your return.")
184			Tux:says(_"That is all I need to know. I will find Koan.")
185			Npc:says(_"Only time will tell.")
186			if (cmp_obstacle_state("DesertGate", "closed")) and
187			   (not Tux:has_met("Tania")) then
188				Npc:says(_"Here are a couple of circuits to grease open the western gate, if you know what I mean.")
189				Tux:add_gold(25)
190			end
191			Npc:says(_"Good luck!")
192			Tux:add_quest("Doing Duncan a favor", _"I have to find Koan in the desert west of town and get Duncan something very precious.")
193			hide("node52", "node59") show("node55", "node56")
194		end,
195	},
196	{
197		id = "node55",
198		text = _"What are those bots?",
199		code = function()
200			Npc:says(_"We call them 'Harvesters'.")
201			Npc:says(_"They were designed to chop down trees in the mountains.")
202			Npc:says(_"Now they chop down people.")
203			Npc:says(_"Their only weak point is their security system. But no one has managed to stay alive long enough to hack them.")
204			hide("node55")
205		end,
206	},
207	{
208		id = "node56",
209		text = _"What is it that he took from you?",
210		code = function()
211			Npc:says(_"A cube. Trust me, you can't miss it.")
212			hide("node56")
213		end,
214	},
215	{
216		id = "node59",
217		text = _"No, I don't find bloodshed a pleasurable activity.",
218		code = function()
219			Npc:says(_"That is fine. I will find someone else.")
220			end_dialog()
221		end,
222	},
223	{
224		id = "node60",
225		code = function()
226			if (Tux:has_item_backpack("Pandora's Cube")) then
227				if (Duncan_Koan_quest_done) then
228					if (Koan:is_dead()) then -- we killed koan manually or using the dialog and got
229						--the cube when we return first time to Duncan after seeing Koan
230						Tux:says(_"Hey, I think I finally found your cube.")
231						Npc:says(_"Oh, great!")
232					else -- does this ever show up though?
233						Tux:says(_"Hey!")
234						Npc:says(_"Hmm...?")
235						Tux:says(_"I think I found Koan after all ... finally.")
236						Npc:says(_"Oh, nice!")
237						Npc:says(_"Did you also get the cube?")
238						Duncan_Koan_quest_really_done = true
239					end
240				else -- koan is dead
241					Npc:says(_"So... Any news on the Koan matter?")
242				end
243				Duncan_Koan_quest_done = true
244				show("node62", "node63")
245				if (Duncen_node_62_hide) then
246					hide("node62")
247				end
248				Duncen_node_62_hide = true
249			elseif (Koan:is_dead()) then -- we don't have the cube but Koan is dead
250				if (Duncan_talked_Koan_dead) then -- let Duncan ask for the cube differently if
251					-- tux already returned without the cube while Koan was dead
252					Npc:says(_"Did you finally find the cube?")
253					Tux:says(_"Uhmmm...")
254					Npc:says(_"You better go getting it!")
255				else -- we killed koan somehow but don't have the cube
256					Npc:says(_"You don't look too well, what did happen?")
257					Tux:says(_"He ... he is dead...")
258					Npc:says(_"Koan?")
259					if (Koan_spared_via_dialog) then -- we told Koan we won't kill him, and lied to Duncan
260						--about not finding him. Afterwards we went back to Koan and killed him manually
261						Npc:says(_"I thought you hadn't found him?")
262						Tux:says(_"Yes, I didn't find him at first, now I did.")
263					else -- we lost the cube and killed Koan via dialog
264						Tux:says(_"Yes.")
265					end
266					Npc:says(_"And the cube that he was carrying? Where is it?")
267					Tux:says(_"I must have left it somewhere...")
268					Npc:says(_"Fetch it and bring it to me.")
269					Duncan_talked_Koan_dead = true
270					Tux:update_quest("Doing Duncan a favor", _"Unfortunately, I forgot to bring the cube. Duncan was not amused.")
271				end
272				end_dialog()
273			elseif (Koan_spared_via_dialog) then -- we didn't kill via the dialog
274				Tux:says(_"I could not find him anywhere in the desert. I don't think he is there anymore.")
275				Npc:says(_"I see.")
276				Tux:end_quest("Doing Duncan a favor", _"I lied to Duncan about not finding Koan.")
277				Duncan_Koan_quest_done = true
278				end_dialog()
279			end
280			show("node64")
281		end,
282	},
283	{
284		id = "node62",
285		text = _"I think this is your cube.",
286		code = function()
287			Npc:says(_"Yes. I appreciate your help.")
288			hide("node62", "node63") next("node69")
289		end,
290	},
291	{
292		id = "node63",
293		text = _"Now, what is this big cube that you had me carry all the way here?",
294		code = function()
295			Npc:says(_"Just a memento from a friend.")
296			Npc:says(_"A little more than a portable end of the world, which I am looking forward to disassembling and learning its secrets.")
297			Npc:says(_"Nothing that important.")
298			Duncen_node_62_hide = true
299			hide("node62", "node63") show("node67", "node68")
300		end,
301	},
302	{
303		id = "node64",
304		text = _"A 'few' bots? The place was crawling with Harvesters! I nearly got killed!",
305		code = function()
306			Npc:says(_"There were only one hundred and twenty bots in the entire desert region. This hardly qualifies as many, considering the size of the area.")
307			Tux:says(_"What? You know exactly how many bots were in the desert? Without being there? I don't like this.")
308			Npc:says(_"I just know a lot of things. You do not need to worry about it.")
309			Tux:says(_"I don't like this at all. I'm getting out of here.")
310			Npc:says(_"As you wish.")
311			end_dialog()
312			hide("node64")
313		end,
314	},
315	{
316		id = "node67",
317		text = _"Hey, that is really neat. Here is your cube. Enjoy disassembling it and have fun with it.",
318		code = function()
319			Npc:says(_"I will.")
320			hide("node67", "node68") next("node69")
321		end,
322	},
323	{
324		id = "node68",
325		text = _"WHAT? No way I am giving you a doomsday device! Forget about it.",
326		code = function()
327			Npc:says(_"I understand. So be it.")
328			Tux:end_quest("Doing Duncan a favor", _"No way am I giving Duncan that cube thingie, who knows what he would do with it.")
329			Duncan_not_given_cube = true
330			end_dialog()
331			hide("node67", "node68")
332		end,
333	},
334	{
335		id = "node69",
336		code = function()
337			Tux:add_xp(3000)
338			Tux:del_item_backpack("Pandora's Cube", 1)
339			sell_item("Plasma Shockwave Emitter")
340			Tux:end_quest("Doing Duncan a favor", _"I gave Duncan the cube thingie. It feels nice to help people.")
341			Duncan_Koan_quest_really_done = true
342			end_dialog()
343		end,
344	},
345	{
346		id = "node90",
347		text = _"I feel you are... Different.",
348		code = function()
349			Npc:says(_"What a great way to start a conversation.")
350			Npc:says(_"Yes, that is true. I am not who I seem to be.")
351			Npc:says(_"But then again, neither are you, so my thoughts are, we are even.")
352			--; TRANSLATORS: %s = Tux:get_player_name()
353			Tux:says(_"What do you mean? I am %s and not anyone else.", Tux:get_player_name())
354			Npc:says(_"And I am Duncan McNamara, the maker of grenades and nothing else.")
355			Npc:set_name("Duncan - Bombmaker")
356			Npc:says(_"I believe the topic is thoroughly exhausted now.")
357			hide("node0", "node1", "node2", "node90") show("node5", "node92")
358		end,
359	},
360	{
361		id = "node92",
362		text = _"Tell me who you are. I need to know.",
363		code = function()
364			Npc:says(_"Twenty years ago, people were kinder to each other.")
365			Npc:says(_"I suggest you be kind to me as well, and I will be kind to you.")
366			Npc:says(_"That way I get to keep my secret, and you get to keep yours.")
367			hide("node92") show("node93")
368		end,
369	},
370	{
371		id = "node93",
372		text = _"I don't have any secrets.",
373		code = function()
374			Npc:says(_"And neither do I.")
375			hide("node93")
376		end,
377	},
378	{
379		id = "node97",
380		code = function()
381			Npc:says(_"I wish you cold winds.")
382			Tux:says(_"Huh? How do you know the Linarian farewell? No one around here knows it.")
383			Npc:says(_"I read many books on Linarians. That is all.")
384			Npc:says(_"Nothing more and nothing less.")
385			show("node98") next("node98")
386		end,
387	},
388	{
389		id = "node98",
390		text = _"I wish you cold winds.",
391		code = function()
392			Npc:says(_"May the ice bring you wisdom.")
393			end_dialog()
394		end,
395	},
396	{
397		id = "node99",
398		text = _"See you later.",
399		code = function()
400			if (not Duncan_coldwinds) then
401				Duncan_coldwinds = true
402				next("node97")
403			else
404				Npc:says(_"See you later.")
405				end_dialog()
406			end
407		end,
408	},
409}
410