-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathMISS206.lua
More file actions
474 lines (419 loc) · 18 KB
/
MISS206.lua
File metadata and controls
474 lines (419 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
------------------------------------------------------------------------------
-- LUA-Script for MISS206.WLD (mission 7 of the original "Roman Campaign" --
-- --
-- Authors: CrazyL, Spikeone, ArthurMurray47, kubaau --
------------------------------------------------------------------------------
-------------------------------- TODO -----------------------------------------
-- EnableNextMissions()
-- Set Portraits
-------------------------------------------------------------------------------
-------------------------------- Lua Version used ----------------------------
function getRequiredLuaVersion()
return 1
end
function isMapPreviewEnabled()
return false
end
local requiredFeature = 5
function checkVersion()
local featureLevel = rttr:GetFeatureLevel()
if(featureLevel < requiredFeature) then
rttr:MsgBox("LUA-Version Error", "Your Return to the Roots version is outdated. The required LUA-Feature level is " ..requiredFeature.. ", your version is "..featureLevel..". The script can possibly crash or run unexpectedly!\n\nPlease update the game!", true)
end
end
-------------------------------- mission events and texts --------------------
-- Message-Window (mission statement and hints): 52 chars wide
eIdx = {1, 2, 3, 99}
rttr:RegisterTranslations(
{
cs =
{
Diary = 'Deník',
msg1 = 'Čtvrtý den 11. měsíce šestého roku.\n\nNaší skouti přinesli zprávy o tom že jsme na poloostrově, který je spojen se zbytkem pevniny dvěmy úzkýmy údolímy. Stopy naznačují, že se na jihu nalézá barbarská rasa Vikingů.',
msgh1 = 'Vyhledejte bránu.',
msg2 = 'Zajatý Viking nám řekl, že na poloostrově západně od nás žije další nesmírně bohatý kmen. Mají velké zásoby zlata. Přístup do jejich oblasti na západ od velké zátoky je silně opevněný. Přesnější podrobnosti se nám nepodařilo získat.',
msg3 = '19. den čtvrtého měsíce sedmého roku\n\nVikingové se zdají být extrémně silní. Nějak musíme získat přístup do jejich pevnosti. Je zajímavé, že tento kmen má na malém poloostrově severně od jejich zlatých dolů hřbitov velryb. Zajímalo by mě, jestli se bojí také duchů velryb?',
msg99 = 'Našli jsme bránu a obsadili ji.',
msgh99 = 'Dokončil jsi tuto misi. Další kapitola na tebe čeká ...'
},
de =
{
Diary = 'Tagebuch',
msg1 = '4. im 11. des 6. Jahres.\n\nUnsere Halbinsel scheint nur durch zwei schmale\nTäler mit dem Rest des Kontinents verbunden zu sein.\nSpuren weisen auf ein barbarisches Wikingervolk im\nSüden hin.',
msgh1 = 'Suchen Sie nach einem Tor.',
msg2 = 'Ein gefangener Wikinger erzählte uns, daß auf der\nHalbinsel westlich der unseren noch ein weiterer\nStamm lebt, der sehr reich sei, da er über große\nGoldvorräte verfüge. Genaueres war nicht zu\nerfahren, außer, daß der Zugang zu ihrem Gebiet im\nWesten der großen Bucht stark befestigt ist.',
msg3 = '19. im 4. des 7. Jahres\n\nDie Wikinger scheinen sehr stark zu sein. Wir müssen\ndiese Festung irgendwie knacken.\nInteressant ist, daß auch auch dieser Stamm einen\nWalfriedhof hat. Auf einer kleinen Halbinsel im\nNorden ihrer Goldminen. Ob auch sie Angst vor den\nWalgeistern haben?',
msg99 = 'Wir haben das Tor gefunden und besetzt.',
msgh99 = 'Sie haben diese Mission erfüllt. Das nächste Kapitel\nwartet auf Sie...'
},
en =
{
Diary = 'Diary',
msg1 = 'The Fourth Day of the 11th Month of the Sixth Year.\n\nIt appears that our peninsula is linked to the rest\nof the continent only by two narrow valleys. Tracks\nsuggest there is a barbarian race of Vikings in the\nsouth.',
msgh1 = 'Search for the gateway.',
msg2 = 'A captured Viking told us that another extremely\nwealthy tribe lives on the peninsula to the west of\nus. They have large stocks of Gold. Access to their\nregion to the west of the large bay is heavily\nfortified. More precise details could not be\nobtained.',
msg3 = '19th Day of the Fourth Month of the Seventh Year\n\nThe Vikings appear to be extremely strong. Somehow we\nmust gain access to their fortress.\nIt is interesting that this tribe also has a whale\ngraveyard on a small peninsula to the north of their\ngold mines. I wonder if they are afraid of the\nspirits of the whales as well?',
msg99 = 'We have found the gateway and occupied it.',
msgh99 = 'You have completed this mission. The next Chapter\nawaits you...'
}
})
-- format mission texts
function MissionText(e)
local msg = _('msg' .. tostring(e))
local msgh = _('msgh'.. tostring(e))
if(msg ~= ('msg' .. tostring(e)) and msgh ~= ('msgh'.. tostring(e))) then
rttr:MissionStatement(0, _('Diary'), msg .. '\n\n\n\n\n\n\n' ..msgh.. '\n\n\n\n\n\n\n', IM_SWORDSMAN, true)
rttr:SetMissionGoal(0, msgh)
elseif(msg ~= ('msg' .. tostring(e))) then
rttr:MissionStatement(0, _('Diary'), msg .. '\n\n\n\n\n\n\n', IM_SWORDSMAN, true)
else
rttr:Log("Error: no Translation found: " .. _('msg' .. tostring(e)))
end
end
-------------------------------- general settings -----------------------------
function onSettingsReady()
checkVersion()
rttr:Log("-----------------------\n MISS206.lua loaded... \n-----------------------\n")
rttr:ResetAddons() -- S2-settings
rttr:SetAddon(ADDON_CATAPULTS_ATTACK_ALLIES, true)
rttr:SetAddon(ADDON_FRONTIER_DISTANCE_REACHABLE, true)
rttr:SetGameSettings({
["fow"] = EXP_CLASSIC,
["teamView"] = false,
["lockedTeams"] = false
})
rttr:GetPlayer(0):SetNation(NAT_ROMANS) -- nation
rttr:GetPlayer(0):SetColor(0) -- 0:blue, 1:red, 2:yellow,
rttr:GetPlayer(1):SetAI(3) -- hard AI
rttr:GetPlayer(1):SetNation(NAT_VIKINGS) -- nation
rttr:GetPlayer(1):SetColor(1) -- yellow
rttr:GetPlayer(1):SetName('Erik') -- Enemy Name
rttr:GetPlayer(2):SetAI(3) -- hard AI
rttr:GetPlayer(2):SetNation(NAT_VIKINGS) -- nation
rttr:GetPlayer(2):SetColor(2) -- red
rttr:GetPlayer(2):SetName('Olof') -- Enemy Name
end
function getAllowedChanges()
return {
["addonsAll"] = false,
["ownNation"] = false,
["ownColor"] = false,
["ownTeam"] = false,
["aiNation"] = false,
["aiColor"] = false,
["aiTeam"] = false
}
end
-- start callback
function onStart(isFirstStart)
if isFirstStart then
rttr:GetPlayer(2):MakeOneSidedAllianceTo(1) -- !GLOBAL_SET_COMPUTER_ALLIANCE 2 1
rttr:GetPlayer(1):MakeOneSidedAllianceTo(2) -- !GLOBAL_SET_COMPUTER_ALLIANCE 1 2
rttr:GetPlayer(1):MakeOneSidedAllianceTo(0) -- !GLOBAL_SET_COMPUTER_ALLIANCE 1 0
rttr:GetPlayer(2):MakeOneSidedAllianceTo(0) -- !GLOBAL_SET_COMPUTER_ALLIANCE 2 0
end
for i = 0, (rttr:GetPlayerCount() - 1) do -- set resources
addPlayerRes(i, not isFirstStart)
addPlayerBld(i, not isFirstStart)
end
eState = {} -- enable all events (0: disable)
for _, i in ipairs(eIdx) do
eState[i] = 1
end
if not isFirstStart then -- initialize history of all called events, event counter at ["n"]
for i = 1, eHist["n"] do
MissionEvent(eHist[i], true) -- call events without mission text to activate all achievements
end
else
eHist = {["n"] = 0}
MissionEvent(1) -- initial event / start screen
end
rttr:GetWorld():SetComputerBarrier(10, 51, 22)
rttr:GetWorld():SetComputerBarrier(10, 36, 23)
rttr:GetWorld():SetComputerBarrier(8, 50, 60)
rttr:GetWorld():SetComputerBarrier(8, 49, 64)
rttr:GetWorld():SetComputerBarrier(8, 47, 68)
end
-- save callback
function onSave(saveGame)
saveGame:PushInt(eHist["n"])
for i = 1, eHist["n"] do
saveGame:PushInt(eHist[i])
end
return true
end
-- load callback
function onLoad(saveGame)
eHist = {["n"] = saveGame:PopInt()}
for i = 1, eHist["n"] do
eHist[i] = saveGame:PopInt()
end
return true
end
-------------------------------- set buildings --------------------------------
function addPlayerBld(p, onLoad)
-- set buildings for all players
rttr:GetPlayer(p):EnableAllBuildings()
rttr:GetPlayer(p):DisableBuilding(BLD_SHIPYARD, false)
rttr:GetPlayer(p):DisableBuilding(BLD_HARBORBUILDING, false)
if(p == 2) then
if onLoad then return end
rttr:GetPlayer(p):AIConstructionOrder(43, 59, BLD_FORTRESS)
end
end
-------------------------------- set resources --------------------------------
-- Don't add goods/people onLoad!
function addPlayerRes(p, onLoad)
if onLoad then return end
rttr:GetPlayer(p):ClearResources()
if(p == 0) then
-- goods
rttr:GetPlayer(p):AddWares({
[GD_BEER ] = 8,
[GD_TONGS ] = 1,
[GD_HAMMER ] = 2,
[GD_AXE ] = 1,
[GD_SAW ] = 1,
[GD_PICKAXE ] = 1,
[GD_SHOVEL ] = 1,
[GD_CRUCIBLE ] = 1,
[GD_RODANDLINE] = 3,
[GD_SCYTHE ] = 3,
[GD_WATER ] = 20,
[GD_CLEAVER ] = 1,
[GD_ROLLINGPIN] = 1,
[GD_BOW ] = 2,
[GD_BOAT ] = 13,
[GD_SWORD ] = 4,
[GD_IRON ] = 10,
[GD_FLOUR ] = 8,
[GD_FISH ] = 4,
[GD_BREAD ] = 6,
[GD_SHIELD ] = 4,
[GD_WOOD ] = 30,
[GD_BOARDS ] = 50,
[GD_STONES ] = 46,
[GD_GRAIN ] = 10,
[GD_COINS ] = 4,
[GD_GOLD ] = 15,
[GD_IRONORE ] = 15,
[GD_COAL ] = 30,
[GD_MEAT ] = 3,
[GD_HAM ] = 6
})
-- people
rttr:GetPlayer(p):AddPeople({
[JOB_HELPER ] = 100,
[JOB_WOODCUTTER ] = 6,
[JOB_FISHER ] = 4,
[JOB_FORESTER ] = 2,
[JOB_CARPENTER ] = 2,
[JOB_STONEMASON ] = 4,
[JOB_HUNTER ] = 2,
[JOB_FARMER ] = 4,
[JOB_MILLER ] = 2,
[JOB_BAKER ] = 2,
[JOB_BUTCHER ] = 2,
[JOB_MINER ] = 6,
[JOB_BREWER ] = 2,
[JOB_PIGBREEDER ] = 2,
[JOB_DONKEYBREEDER ] = 1,
[JOB_IRONFOUNDER ] = 1,
[JOB_MINTER ] = 2,
[JOB_METALWORKER ] = 1,
[JOB_ARMORER ] = 1,
[JOB_BUILDER ] = 8,
[JOB_PLANER ] = 4,
[JOB_GEOLOGIST ] = 4,
[JOB_PRIVATE ] = 24,
[JOB_PRIVATEFIRSTCLASS ] = 4,
[JOB_SERGEANT ] = 3,
[JOB_OFFICER ] = 2,
[JOB_GENERAL ] = 1,
[JOB_SCOUT ] = 7,
[JOB_SHIPWRIGHT ] = 1,
[JOB_PACKDONKEY ] = 0,
[JOB_CHARBURNER ] = 0
})
elseif(p == 1) then
-- goods
rttr:GetPlayer(p):AddWares({
[GD_BEER ] = 20,
[GD_TONGS ] = 0,
[GD_HAMMER ] = 0,
[GD_AXE ] = 0,
[GD_SAW ] = 0,
[GD_PICKAXE ] = 0,
[GD_SHOVEL ] = 0,
[GD_CRUCIBLE ] = 0,
[GD_RODANDLINE ] = 0,
[GD_SCYTHE ] = 0,
[GD_WATER ] = 0,
[GD_CLEAVER ] = 0,
[GD_ROLLINGPIN ] = 0,
[GD_BOW ] = 0,
[GD_BOAT ] = 0,
[GD_SWORD ] = 0,
[GD_IRON ] = 10,
[GD_FLOUR ] = 0,
[GD_FISH ] = 20,
[GD_BREAD ] = 20,
[GD_SHIELD ] = 0,
[GD_WOOD ] = 0,
[GD_BOARDS ] = 90,
[GD_STONES ] = 90,
[GD_GRAIN ] = 0,
[GD_COINS ] = 4,
[GD_GOLD ] = 35,
[GD_IRONORE ] = 15,
[GD_COAL ] = 40,
[GD_MEAT ] = 20,
[GD_HAM ] = 0
})
-- people
rttr:GetPlayer(p):AddPeople({
[JOB_HELPER ] = 50,
[JOB_WOODCUTTER ] = 10,
[JOB_FISHER ] = 10,
[JOB_FORESTER ] = 10,
[JOB_CARPENTER ] = 10,
[JOB_STONEMASON ] = 10,
[JOB_HUNTER ] = 10,
[JOB_FARMER ] = 20,
[JOB_MILLER ] = 10,
[JOB_BAKER ] = 10,
[JOB_BUTCHER ] = 10,
[JOB_MINER ] = 20,
[JOB_BREWER ] = 5,
[JOB_PIGBREEDER ] = 10,
[JOB_DONKEYBREEDER ] = 10,
[JOB_IRONFOUNDER ] = 8,
[JOB_MINTER ] = 5,
[JOB_METALWORKER ] = 5,
[JOB_ARMORER ] = 10,
[JOB_BUILDER ] = 20,
[JOB_PLANER ] = 20,
[JOB_GEOLOGIST ] = 10,
[JOB_PRIVATE ] = 35,
[JOB_PRIVATEFIRSTCLASS ] = 20,
[JOB_SERGEANT ] = 10,
[JOB_OFFICER ] = 8,
[JOB_GENERAL ] = 3,
[JOB_SCOUT ] = 10,
[JOB_SHIPWRIGHT ] = 0,
[JOB_PACKDONKEY ] = 40,
[JOB_CHARBURNER ] = 0
})
elseif(p == 2) then
-- goods
rttr:GetPlayer(p):AddWares({
[GD_BEER ] = 20,
[GD_TONGS ] = 0,
[GD_HAMMER ] = 0,
[GD_AXE ] = 0,
[GD_SAW ] = 0,
[GD_PICKAXE ] = 0,
[GD_SHOVEL ] = 0,
[GD_CRUCIBLE ] = 0,
[GD_RODANDLINE ] = 0,
[GD_SCYTHE ] = 0,
[GD_WATER ] = 0,
[GD_CLEAVER ] = 0,
[GD_ROLLINGPIN ] = 0,
[GD_BOW ] = 0,
[GD_BOAT ] = 0,
[GD_SWORD ] = 0,
[GD_IRON ] = 0,
[GD_FLOUR ] = 0,
[GD_FISH ] = 20,
[GD_BREAD ] = 20,
[GD_SHIELD ] = 0,
[GD_WOOD ] = 0,
[GD_BOARDS ] = 90,
[GD_STONES ] = 120,
[GD_GRAIN ] = 0,
[GD_COINS ] = 0,
[GD_GOLD ] = 0,
[GD_IRONORE ] = 0,
[GD_COAL ] = 30,
[GD_MEAT ] = 20,
[GD_HAM ] = 0
})
-- people
rttr:GetPlayer(p):AddPeople({
[JOB_HELPER ] = 50,
[JOB_WOODCUTTER ] = 10,
[JOB_FISHER ] = 10,
[JOB_FORESTER ] = 10,
[JOB_CARPENTER ] = 10,
[JOB_STONEMASON ] = 10,
[JOB_HUNTER ] = 10,
[JOB_FARMER ] = 20,
[JOB_MILLER ] = 10,
[JOB_BAKER ] = 10,
[JOB_BUTCHER ] = 10,
[JOB_MINER ] = 20,
[JOB_BREWER ] = 5,
[JOB_PIGBREEDER ] = 10,
[JOB_DONKEYBREEDER ] = 10,
[JOB_IRONFOUNDER ] = 8,
[JOB_MINTER ] = 8,
[JOB_METALWORKER ] = 10,
[JOB_ARMORER ] = 10,
[JOB_BUILDER ] = 20,
[JOB_PLANER ] = 20,
[JOB_GEOLOGIST ] = 10,
[JOB_PRIVATE ] = 40,
[JOB_PRIVATEFIRSTCLASS ] = 9,
[JOB_SERGEANT ] = 3,
[JOB_OFFICER ] = 2,
[JOB_GENERAL ] = 1,
[JOB_SCOUT ] = 10,
[JOB_SHIPWRIGHT ] = 0,
[JOB_PACKDONKEY ] = 40,
[JOB_CHARBURNER ] = 0
})
end
end
-------------------------------- mission events -------------------------------
function onOccupied(p, x, y)
-- only check human player
if(p ~= 0) then
return
end
if( (x == 13) and (y == 66) ) then MissionEvent(99)
end
end
function onExplored(p, x, y, o)
-- onContact events
if( ((p == 0) and (o == 1)) or ((p == 1) and (o == 0)) ) then MissionEvent(2)
end
if(p ~= 0) then
return
end
-- onExplored events
if( (x == 43) and (y == 59) ) then MissionEvent(3)
end
end
-- execute mission events, e == 1 is initial event, e == 99 is final event
function MissionEvent(e, onLoad)
-- event e is inactive
if(eState[e] <= 0) then
return
end
-- call side effects for active events, check "eState[e] == 1" for multiple call events!
if(e == 99) then
-- TODO: EnableNextMissions()
-- Show opened arc
rttr:GetWorld():AddStaticObject(13, 66, 561, 0xFFFF, 2)
end
-- update event state
eState[e] = eState[e] - 1
-- no history update or mission texts while loading
if not onLoad then
rttr:Log(">> Event: " .. e .. ",\teState[" .. e .. "] = " .. eState[e])
eHist["n"] = eHist["n"] + 1
eHist[eHist["n"]] = e
MissionText(e)
end
end