Created
January 14, 2017 14:27
-
-
Save sisou/c59248170540f699db81d2320ee7043f to your computer and use it in GitHub Desktop.
Transport Fever EU Mission 7 - Added counter of remaining months for current phase. If counter < 0, the counter becomes the failed icon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local TaskManager = require "TaskManager" | |
local missionutil = require "missionutil" | |
local function makeIntroTask(labelParams, doneFn) | |
local info = { | |
name = _("Überblick"), | |
paragraphs = { | |
{ text = _("Wir schreiben das Jahr 1987 und Margaret Thatcher ist soeben das dritte Mal in Folge zur Premierministerin Grossbritanniens gewählt worden. Nun endlich kann ein Projekt in Angriff genommen werden, das schon seit über zweihundert Jahren geplant wird: Eine Landverbindung, die Reisende trockenen Fusses von Frankreich nach England bringt – ein Tunnel unter dem Ärmelkanal!\n\n\z | |
Wir wurden auserwählt, dieses Meisterwerk der Technik zu bauen. Zeigen wir unser Können!") | |
}, | |
}, | |
voiceOver = "europe_07_02.wav", | |
} | |
local function fn(taskManager, task) | |
task.setCompleted() | |
doneFn(taskManager) | |
end | |
info.options = { { labelParams.label or _("Ok!"), fn } } | |
info.optionsRightAlign = true | |
local task = missionutil.makeTask(info) | |
task.setProgressNone() | |
return task | |
end | |
local function makeTaskPrepare(taskParams, doneFn) | |
local info = { | |
title = _("Vorbereitungen"), | |
name = _("Vorbereitungen treffen"), | |
paragraphs = { | |
{ text = _("Endlich kann es losgehen. Eigentlich sollte der Tunnel ja schon längst gebaut sein, doch beim letzten Versuch fehlte dummerweise plötzlich das Geld. Nun aber sind alle guten Mutes – vor allem unsre Investoren!\n\n\z | |
Auf staatliche Zuschüsse warten wir allerdings vergebens. Die wird uns Frau Thatcher nicht gewähren. Die Arbeitslosigkeit ist hoch und die Arbeiter sind billig – sorgen wir dafür, dass wir auch die für den Bau nötigen Güter günstig erhalten.") | |
}, | |
{ type = "TASK", text = _("Sorge dafür, dass [link=${industry0}][/link] und [link=${industry1}][/link] die ersten Güter produzieren.") % | |
{ | |
industry0 = taskParams.steelMill, | |
industry1 = taskParams.sawMill, | |
} | |
}, | |
{ type = "HINT", text = _("Der Kanal ist zu breit, um Brücken darüber oder – zur Zeit noch – Tunnel darunter zu bauen. Nutze Schiffe, um die benötigten Güter zu transportieren.") | |
}, | |
{ type = "HINT", text = _("Das ist die erste von zwei Projektphasen. Für diese Phase werden ${years} Jahre veranschlagt.") % { years = taskParams.phase1 / 12 } | |
}, | |
}, | |
voiceOver = "europe_07_03.wav", | |
subTasks = { | |
{ name = _("Stahlwerk produziert Stahl") }, | |
{ name = _("Sägewerk produziert Bretter") }, | |
{ name = _("Monate verbleibend (optional)") } | |
}, | |
options = { | |
{ "Debug: Überspringen", function (taskManager) | |
taskManager:add("taskDig") | |
taskManager:add("taskInbalance") | |
taskManager:getById("taskPrepare").setCompleted() | |
taskManager:getById("taskPrepare").getUserState().endPhase1 = game.interface.getGameTime().date | |
end }, | |
}, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
-- debug only | |
-- taskManager:add("taskProbe") | |
task.getUserState().startPhase1 = game.interface.getGameTime().date | |
task.getUserState().phase1MonthLastCheck = 0 | |
end | |
task.update = function (taskManager) | |
if task.isCompleted() then return end | |
local steelMillProduction = game.interface.getEntity(taskParams.steelMill).itemsProduced.STEEL or 0 | |
local sawMillProduction = game.interface.getEntity(taskParams.sawMill).itemsProduced.PLANKS or 0 | |
if steelMillProduction > 0 then | |
task.setCompleted(1) | |
end | |
if sawMillProduction > 0 then | |
task.setCompleted(2) | |
end | |
if steelMillProduction > 0 or sawMillProduction > 0 then | |
if taskManager:getById("taskProbe") == nil then | |
taskManager:add("taskProbe") | |
end | |
end | |
if ( task.getUserState().phase1MonthLastCheck ~= game.interface.getGameTime().date.month) then | |
task.getUserState().phase1MonthLastCheck = game.interface.getGameTime().date.month | |
monthsPast = (game.interface.getGameTime().date.year * 12 + game.interface.getGameTime().date.month) - (task.getUserState().startPhase1.year * 12 + task.getUserState().startPhase1.month) | |
monthsLeft = taskParams.phase1 - monthsPast | |
if ( monthsLeft >= 0) then | |
task.setProgressCount(monthsLeft, -1 , 3) | |
else | |
task.setProgressBool(3) | |
end | |
end | |
if steelMillProduction > 0 and sawMillProduction > 0 then | |
task.setCompleted() | |
taskManager:add("taskDig") | |
task.getUserState().endPhase1 = game.interface.getGameTime().date | |
end | |
end | |
return task | |
end | |
local function makeTaskProbe(taskParams, doneFn) | |
local info = { | |
title = _("Meeresboden erforschen"), | |
name = _("Meeresboden erforschen"), | |
paragraphs = { | |
{ text = _("Die Geologie des Ärmelkanals ist weitestgehend bekannt. Zur Sicherheit sollten wir trotzdem die Beschaffenheit des Meeresbodens prüfen, damit auch ja kein Unglück geschieht...\n\n\z | |
Immerhin war es mitunter die Angst vor Katastrophen, die all unsere Vorgänger davon abhielt, das Projekt wirklich in die Hand zu nehmen – und damit haben sie nicht nur den Einfall der Kontinentaleuropäer gemeint.") | |
}, | |
{ type = "TASK", text = _("Kaufe das eigens für geologische Messungen entworfene Schiff und sorge dafür, dass es sich mindestens ${days} Tage lang im markierten Bereich aufhält.") % { days = taskParams.probeDays} | |
}, | |
{ type = "HINT", text = _("Eine Schiffslinie zwischen Dover und Calais sollte durch den markierten Bereich führen.") | |
}, | |
{ type = "HINT", text = _("Du kannst das Schiff stoppen, sobald es den markierten Bereiche erreicht hat.") | |
}, | |
{ type = "HINT", text = _("Schliesse die Aufgabe ab, bevor die Vorbereitungen abgeschlossen sind!") | |
}, | |
}, | |
camera = { taskParams.probeArea.pos[1], taskParams.probeArea.pos[2], 500.0 }, | |
voiceOver = "europe_07_04.wav", | |
options = { | |
{ "Debug: Überspringen", function (taskManager) | |
taskManager:getById("taskProbe").setCompleted() | |
taskManager:setZone("green") | |
end }, | |
}, | |
subTasks = { | |
{ name = _("Tage erforscht") } | |
}, | |
medalsHint = 1, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
local green = missionutil.makeCircleZone(taskParams.probeArea.pos, taskParams.probeArea.radius) | |
local greenZone = { polygon = green, draw = true, drawColor = missionutil.colors.GREEN } | |
taskManager:setZone("green", greenZone) | |
task.getUserState().shipDaysInArea = 0 | |
task.getUserState().shipDayLastCheck = 0 | |
taskManager:guiSetVisible("vehicleStore.item.model.vehicle/ship/scanship.mdl", true) | |
end | |
task.update = function (taskManager) | |
if task.isCompleted() then return end | |
if ( task.getUserState().shipDayLastCheck ~= game.interface.getGameTime().date.day) then | |
task.getUserState().shipDayLastCheck = game.interface.getGameTime().date.day | |
local shipInArea = false | |
local allVehicles = game.interface.getEntities({ pos = taskParams.probeArea.pos, radius = taskParams.probeArea.radius }, { type = "VEHICLE" }) | |
for i=1, #allVehicles do | |
local vehicleData = game.interface.getEntity(allVehicles[i]) | |
if vehicleData.carrier == "WATER" and vehicleData.vehicles[1].fileName == taskParams.scanShip then | |
if vehicleData.speed < 2 then shipInArea = true end | |
end | |
end | |
if shipInArea then | |
task.getUserState().shipDaysInArea = task.getUserState().shipDaysInArea + 1 | |
else | |
task.getUserState().shipDaysInArea = 0 | |
end | |
end | |
task.setProgressCount(task.getUserState().shipDaysInArea, -1 , 1) | |
if (task.getUserState().shipDaysInArea >= taskParams.probeDays) then | |
taskManager:guiSetVisible("vehicleStore.item.model.vehicle/ship/scanship.mdl", false) | |
task.addMedal("MEDAL_SCAN") | |
taskManager:setZone("green") | |
task.setCompleted() | |
end | |
end | |
return task | |
end | |
local function makeTaskDig(taskParams, doneFn) | |
local info = { | |
title = _("Bohrfabriken"), | |
name = _("Tunnel graben"), | |
paragraphs = { | |
{ text = _("Die Ressourcen sind bereit. Damit lassen sich die eigens für dieses Unterfangen entworfenen Tunnelbaumaschinen konstruieren. Das sind regelrechte Fabriken, die ganz selbstständig graben und Schutt abtransportieren und die Tunnelwände befestigen – es lebe die moderne Technik!\n\n\z | |
Wir sollten keine Zeit verlieren und dafür sorgen, dass die Trupps von beiden Seiten des Kanals gleich schnell zur Mitte vorstossen. Nur so vermeiden wir überflüssige Kosten. Und das ist absolut notwendig – die ersten Geldgeber drohen bereits mit dem Absprung...") | |
}, | |
{ type = "TASK", text = _("Liefere Maschinen von der [link=${factory}]Bohrmaschinenfabrik[/link] zu den Portalen [link=${industry0}][/link] und [link=${industry1}][/link]") % | |
{ | |
factory = taskParams.machinesFactory, | |
industry0 = taskParams.digSiteUK, | |
industry1 = taskParams.digSiteFR, | |
} | |
}, | |
{ type = "HINT", text = _("Dies ist die zweite von zwei Projektphasen. Für diese Phase werden ${years} Jahre veranschlagt.") % { years = taskParams.phase2 / 12 } | |
}, | |
}, | |
voiceOver = "europe_07_05.wav", | |
subTasks = { | |
{ name = _("Englische Baustelle beliefern") }, | |
{ name = _("Französische Baustelle beliefern") }, | |
{ name = _("Monate verbleibend (optional)") } | |
}, | |
options = { | |
{ "Debug: Überspringen", function (taskManager) | |
taskManager:add("taskBuildTunnel") | |
taskManager:getById("taskDig").setCompleted() | |
taskManager:getById("taskDig").getUserState().endPhase2 = game.interface.getGameTime().date | |
end }, | |
}, | |
medalsHint = 1, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
task.getUserState().target = { uk = taskParams.digTargetUK, fr = taskParams.digTargetFR } | |
task.getUserState().month = { uk = 0, fr = 0 } | |
if taskManager:getById("taskProbe") ~= nil then | |
if not taskManager:getById("taskProbe").isCompleted() then | |
taskManager:getById("taskProbe").setCompleted() | |
taskManager:setZone("green") | |
end | |
end | |
task.getUserState().startPhase2 = game.interface.getGameTime().date | |
task.getUserState().phase2MonthLastCheck = 0 | |
end | |
task.update = function (taskManager) | |
if task.isCompleted() then return end | |
local digProgressUK = game.interface.getEntity(taskParams.digSiteUK).itemsConsumed._sum or 0 | |
local digProgressFR = game.interface.getEntity(taskParams.digSiteFR).itemsConsumed._sum or 0 | |
task.setProgressCount(math.min(digProgressUK, task.getUserState().target.uk), task.getUserState().target.uk, 1) | |
task.setProgressCount(math.min(digProgressFR, task.getUserState().target.fr), task.getUserState().target.fr, 2) | |
if digProgressUK > taskParams.triggerInbalance or digProgressFR > taskParams.triggerInbalance then | |
if taskManager:getById("taskInbalance") == nil then | |
taskManager:add("taskInbalance") | |
end | |
end | |
if digProgressUK >= task.getUserState().target.uk and task.getUserState().month.uk == 0 then | |
task.getUserState().month.uk = game.interface.getGameTime().date.year * 12 + game.interface.getGameTime().date.month | |
end | |
if digProgressUK >= task.getUserState().target.fr and task.getUserState().month.fr == 0 then | |
task.getUserState().month.fr = game.interface.getGameTime().date.year * 12 + game.interface.getGameTime().date.month | |
end | |
if ( task.getUserState().phase2MonthLastCheck ~= game.interface.getGameTime().date.month) then | |
task.getUserState().phase2MonthLastCheck = game.interface.getGameTime().date.month | |
monthsPast = (game.interface.getGameTime().date.year * 12 + game.interface.getGameTime().date.month) - (task.getUserState().startPhase2.year * 12 + task.getUserState().startPhase2.month) | |
monthsLeft = taskParams.phase2 - monthsPast | |
if ( monthsLeft >= 0) then | |
task.setProgressCount(monthsLeft, -1 , 3) | |
else | |
task.setProgressBool(3) | |
end | |
end | |
if digProgressFR >= task.getUserState().target.fr and digProgressUK >= task.getUserState().target.uk then | |
if (math.abs(task.getUserState().month.fr - task.getUserState().month.uk) < 3) then | |
task.addMedal("MEDAL_MIDDLE") | |
end | |
task.setCompleted() | |
taskManager:add("taskBuildTunnel") | |
task.getUserState().endPhase2 = game.interface.getGameTime().date | |
end | |
end | |
return task | |
end | |
local function makeTaskInbalance(taskParams, doneFn) | |
local info = { | |
title = _("Zähe Sache"), | |
name = _("Bohrmaschinen verbessern"), | |
paragraphs = { | |
{ text = _("Der Untergrund auf der britischen Seite scheint sich gegen uns verschworen zu haben, genau wie die dortige Bevölkerung: Die zermürbt unsre Motivation mit ihrer ablehnenden Haltung fast genauso arg, wie der harte Stein unsre Tunnelbohrmaschinen. Für letzteres Problem gibt es immerhin Abhilfe: Mehr Maschinen – als mobile Ersatzteillager sozusagen.\n\n\z | |
Wir würden allerdings deutlich schneller vorankommen, wenn wir auf die Zusatzlieferungen verzichten könnten. Ein Ingenieur aus Hastings glaubt, unsere Maschinen für das harte Gestein optimieren zu können. Wir sollten ihn aufsuchen...") | |
}, | |
{ type = "HINT", text = _("Suche in Hastings nach dem geologischen Institut!") | |
}, | |
}, | |
camera = { game.interface.getEntity(taskParams.geologicalInstitute).position[1], game.interface.getEntity(taskParams.geologicalInstitute).position[2], 350.0 }, | |
voiceOver = "europe_07_06.wav", | |
options = { | |
{ _("Gut zu wissen!"), function (taskManager) taskManager:getById("taskInbalance").setCompleted() end }, | |
}, | |
medalsHint = 1, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
taskManager:getById("taskDig").getUserState().target.uk = taskManager:getById("taskDig").getUserState().target.uk + taskParams.increaseUK | |
taskManager:setMarker("markerGeology", {entity = taskParams.geologicalInstitute, type = "question"}) | |
end | |
task.setProgressNone() | |
return task | |
end | |
local function makeTaskGeology(taskParams, doneFn) | |
local info = { | |
title = _("Der Ingenieur"), | |
name = _("Maschinen liefern"), | |
paragraphs = { | |
{ text = _("Der Maschineningenieur hat versprochen, unsere Bohrmaschinen so zu optimieren, dass sie auch durchs härteste Gestein fräsen, als wäre es Butter. Wir müssen ihm nur einige unserer Maschinen liefern, damit er seine Anpassungen in der Praxis testen kann.") | |
}, | |
{ type = "TASK", text = _("Liefere ${amount} Maschinen zum [link=${labor}]Labor[/link] des Ingenieurs.") % { amount = taskParams.machines, labor = taskParams.geologicalInstitute } | |
}, | |
}, | |
camera = { game.interface.getEntity(taskParams.geologicalInstitute).position[1], game.interface.getEntity(taskParams.geologicalInstitute).position[2], 350.0 }, | |
voiceOver = "europe_07_07.wav", | |
options = { | |
{ "Debug: Überspringen Erfolg", function (taskManager) taskManager:getById("taskGeology").setCompleted() taskManager:add("taskGeologySuccess") end }, | |
{ "Debug: Überspringen Zu spät!", function (taskManager) taskManager:getById("taskGeology").setCompleted() taskManager:add("taskGeologyTooLate") end }, | |
}, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
if not taskManager:getById("taskInbalance").setCompleted() then taskManager:getById("taskInbalance").setCompleted() end | |
end | |
task.update = function (taskManager) | |
if task.isCompleted() then return end | |
local delivered = game.interface.getEntity(taskParams.geologicalInstitute).itemsConsumed._sum or 0 | |
task.setProgressCount(math.min(0, delivered), taskParams.machines) | |
if (delivered >= taskParams.machines) then | |
taskManager:getById("taskDig").getUserState().target.uk = taskManager:getById("taskDig").getUserState().target.uk - taskParams.decreaseUK | |
taskManager:getById("taskDig").getUserState().target.fr = taskManager:getById("taskDig").getUserState().target.fr - taskParams.decreaseFR | |
taskManager:add("taskGeologySuccess") | |
task.addMedal("MEDAL_DRILL") | |
task.setCompleted() | |
end | |
if taskManager:getById("taskDig") ~= nil then | |
if taskManager:getById("taskDig").isCompleted() then | |
taskManager:add("taskGeologyTooLate") | |
task.setCompleted() | |
end | |
end | |
end | |
return task | |
end | |
local function makeTaskGeologySuccess(taskParams, doneFn) | |
local info = { | |
title = _("Optimierte Maschinen"), | |
name = _("Maschinen optimiert"), | |
paragraphs = { | |
{ text = _("Der Ingenieur war erfolgreich. Sogar noch erfolgreicher, als erwartet: Der Bedarf an Maschinen hat sich für beide Tunnelbaustellen reduziert!") | |
}, | |
}, | |
camera = { game.interface.getEntity(taskParams.geologicalInstitute).position[1], game.interface.getEntity(taskParams.geologicalInstitute).position[2], 350.0 }, | |
voiceOver = "europe_07_08.wav", | |
options = { | |
{ _("Hervorragend!"), function (taskManager) taskManager:getById("taskGeologySuccess").setCompleted() end }, | |
}, | |
} | |
local task = missionutil.makeTask(info) | |
task.setProgressNone() | |
return task | |
end | |
local function makeTaskGeologyTooLate(taskParams, doneFn) | |
local info = { | |
title = _("Der Ingenieur – zu spät!"), | |
name = _("Zu spät!"), | |
paragraphs = { | |
{ text = _("Der Ingenieur hatte Erfolg. Leider zu spät! Die Bohrungen sind schon abgeschlossen.") | |
}, | |
}, | |
camera = { game.interface.getEntity(taskParams.geologicalInstitute).position[1], game.interface.getEntity(taskParams.geologicalInstitute).position[2], 350.0 }, | |
voiceOver = "europe_07_09.wav", | |
options = { | |
{ _("Das ist bedauerlich!"), function (taskManager) taskManager:getById("taskGeologyTooLate").setCompleted() end }, | |
}, | |
} | |
local task = missionutil.makeTask(info) | |
task.setProgressNone() | |
return task | |
end | |
local function makeTaskBuildTunnel(taskParams, doneFn) | |
local info = { | |
title = _("Der Tunnel ist vollendet!"), | |
name = _("Tunnel vollendet"), | |
paragraphs = { | |
{ text = _("Es ist vollbracht! Der Tunnel ist fertig. Nun müssen wir nur noch dafür sorgen, dass die Engländer aufhören, den Tunnel zu hassen. Die Zeitungen sind voll von Horrorgeschichten über Invasionen von Killer-Motten und tollwütigen Ratten und Legionen von nach Knoblauch stinkenden Franzmännern...\n\n\z | |
Sorgen wir dafür, dass dieses Geschwätz ins Reich der Legenden verwiesen wird!") | |
}, | |
}, | |
voiceOver = "europe_07_10.wav", | |
options = { | |
{ _("Hervorragend!"), function (taskManager) taskManager:add("taskUseTunnel") taskManager:getById("taskBuildTunnel").setCompleted() end }, | |
}, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
if taskManager:getById("taskInbalance") ~= nil then | |
if not taskManager:getById("taskInbalance").isCompleted() then taskManager:getById("taskInbalance").setCompleted() end | |
end | |
game.interface.upgradeConstruction (taskParams.digSiteFRConstr, taskParams.constrName, { productionLevel = 0, connected = 1 }) | |
game.interface.upgradeConstruction (taskParams.digSiteUKConstr, taskParams.constrName, { productionLevel = 0, connected = 1 }) | |
taskManager:setZone("cannelLockDown") | |
end | |
task.update = function (taskManager) | |
if task.isCompleted() then return end | |
end | |
return task | |
end | |
local function makeTaskUseTunnel(taskParams, doneFn) | |
local info = { | |
title = _("Tunnel nutzen"), | |
name = _("Tunnel nutzen"), | |
paragraphs = { | |
{ text = _("Es zeigt sich: Die Ängste der Bevölkerung sind unbegründet. Die Queen hat von der feierlichen Eröffnungsfahrt durch den Tunnel weder Killer-Motten noch tollwütige Ratten mitgebracht, sondern lediglich den französischen Ministerpräsidenten. Wir haben ein ganz anderes Problem.\n\n\z | |
Die Baukosten sind doppelt so hoch wie geplant. Hinzu kommen unerwartet happige Wartungskosten. Es wird ewig dauern, bis sich die Sache rentiert...") | |
}, | |
{ type = "TASK", text = _("Transportiere Passagiere und beliebige Güter durch den Tunnel.") | |
}, | |
{ type = "HINT", text = _("Die monatlichen Wartungskosten von ${upkeep} werden automatisch von unserem Konto abgezogen.") % {upkeep = taskParams.upkeep} | |
}, | |
}, | |
subTasks = { | |
{ name = _("Passagiere durch den Tunnel transportieren") }, | |
{ name = _("Güter durch den Tunnel transportieren") } | |
}, | |
voiceOver = "europe_07_11.wav", | |
options = { | |
{ "Debug: Überspringen", function (taskManager) taskManager:add("messageMissionComplete") taskManager:getById("taskUseTunnel").setCompleted() end }, | |
}, | |
} | |
local task = missionutil.makeTask(info) | |
task.init = function (taskManager, data) | |
task.getUserState().payUpkeep = { lastMonth = 0 } | |
task.getUserState().vehicle = {} | |
task.getUserState().deliveredPassengers = 0 | |
task.getUserState().deliveredCargo = 0 | |
end | |
task.update = function (taskManager) | |
if task.isCompleted() then return end | |
if task.getUserState().payUpkeep ~= game.interface.getGameTime().date.month then | |
task.getUserState().payUpkeep = game.interface.getGameTime().date.month | |
game.interface.book(taskParams.upkeep) | |
end | |
local westBound = game.interface.getEntities({ pos = {-1191, 90}, radius = 20 }, { type="VEHICLE" }) | |
local eastBound = game.interface.getEntities({ pos = {-1280, 200}, radius = 20 }, { type="VEHICLE" }) | |
if #westBound > 0 then | |
if task.getUserState().vehicle[westBound[1]] == "eastBound" then | |
task.getUserState().vehicle[westBound[1]] = "westBound" | |
vehicle = game.interface.getEntity(westBound[1]) | |
if vehicle.cargoLoad ~= nil then | |
if vehicle.cargoLoad.PASSENGERS ~= nil then task.getUserState().deliveredPassengers = task.getUserState().deliveredPassengers + vehicle.cargoLoad.PASSENGERS end | |
if vehicle.cargoLoad.COAL ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.COAL end | |
if vehicle.cargoLoad.IRON_ORE ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.IRON_ORE end | |
if vehicle.cargoLoad.STEEL ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.STEEL end | |
if vehicle.cargoLoad.LOGS ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.LOGS end | |
if vehicle.cargoLoad.PLANKS ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.PLANKS end | |
if vehicle.cargoLoad.MACHINES ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.MACHINES end | |
end | |
else | |
task.getUserState().vehicle[westBound[1]] = "westBound" | |
end | |
end | |
if #eastBound > 0 then | |
if task.getUserState().vehicle[eastBound[1]] == "westBound" then | |
task.getUserState().vehicle[eastBound[1]] = "eastBound" | |
vehicle = game.interface.getEntity(eastBound[1]) | |
if vehicle.cargoLoad ~= nil then | |
if vehicle.cargoLoad.PASSENGERS ~= nil then task.getUserState().deliveredPassengers = task.getUserState().deliveredPassengers + vehicle.cargoLoad.PASSENGERS end | |
if vehicle.cargoLoad.COAL ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.COAL end | |
if vehicle.cargoLoad.IRON_ORE ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.IRON_ORE end | |
if vehicle.cargoLoad.STEEL ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.STEEL end | |
if vehicle.cargoLoad.LOGS ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.LOGS end | |
if vehicle.cargoLoad.PLANKS ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.PLANKS end | |
if vehicle.cargoLoad.MACHINES ~= nil then task.getUserState().deliveredCargo = task.getUserState().deliveredCargo + vehicle.cargoLoad.MACHINES end | |
end | |
else | |
task.getUserState().vehicle[eastBound[1]] = "eastBound" | |
end | |
end | |
task.setProgressCount(math.min(taskParams.usagePassengers, task.getUserState().deliveredPassengers), taskParams.usagePassengers, 1) | |
task.setProgressCount(math.min(taskParams.usageCargo, task.getUserState().deliveredCargo), taskParams.usageCargo, 2) | |
if task.getUserState().deliveredPassengers >= taskParams.usagePassengers and task.getUserState().deliveredCargo >= taskParams.usageCargo then | |
if taskManager:getById("taskGeology") ~= nil then | |
if not taskManager:getById("taskGeology").isCompleted() then | |
taskManager:getById("taskGeology").isCompleted() | |
end | |
end | |
if taskManager:getById("taskInbalance") ~= nil then | |
if not taskManager:getById("taskInbalance").isCompleted() then | |
taskManager:getById("taskInbalance").isCompleted() | |
end | |
end | |
if taskManager:getById("taskProbe") ~= nil then | |
if not taskManager:getById("taskProbe").isCompleted() then | |
taskManager:getById("taskProbe").isCompleted() | |
end | |
end | |
task.setCompleted() | |
taskManager:add("messageMissionComplete") | |
end | |
end | |
return task | |
end | |
local function makeMissionCompleteTask(labelParams, doneFn) | |
local info = { | |
name = _("Geschafft"), | |
title = _("Betrieb im Tunnel"), | |
description = _("Wer hätte das gedacht! Unter dem Ärmelkanal herrscht reger Betrieb. Die eiserne Lady ist mächtig stolz auf uns!") % { }, | |
voiceOver = "europe_07_12.wav", | |
} | |
local function fn(taskManager, task) | |
if (taskManager:getById("taskMoney").getUserState().current == 1) then | |
task.addMedal("MEDAL_RICH") | |
end | |
if taskManager:getById("taskPrepare").getUserState().startPhase1 ~= nil and taskManager:getById("taskPrepare").getUserState().endPhase1 ~= nil and taskManager:getById("taskDig").getUserState().startPhase2 ~= nil and taskManager:getById("taskDig").getUserState().endPhase2 ~= nil then | |
phase1 = (taskManager:getById("taskPrepare").getUserState().endPhase1.year * 12 + taskManager:getById("taskPrepare").getUserState().endPhase1.month) - (taskManager:getById("taskPrepare").getUserState().startPhase1.year * 12 + taskManager:getById("taskPrepare").getUserState().startPhase1.month) | |
phase2 = (taskManager:getById("taskDig").getUserState().endPhase2.year * 12 + taskManager:getById("taskDig").getUserState().endPhase2.month) - (taskManager:getById("taskDig").getUserState().startPhase2.year * 12 + taskManager:getById("taskDig").getUserState().startPhase2.month) | |
if (phase1 <= labelParams.phase1) and (phase2 <= labelParams.phase2) then | |
task.addMedal("MEDAL_FAST") | |
end | |
end | |
missionutil.completeAllTasks(taskManager) | |
end | |
local task = missionutil.makeMissionCompleteTask(info, fn) | |
return task | |
end | |
function data() | |
local cannelLockDown = {{1700, -875}, {1330, -940}, {720, -980}, {-3200, -4100}, {-6200, -4100}, {-6200, -2300}, {-2390, -300}, {-2442, 440},{-2459, 454}, {-1942, 990}, {-680, 250}, {1700, 4200}, {1900, 4200}, {850, -550}, {1700, -840}, } | |
local messageIntro = | |
{ | |
label = _("Start mission..."), | |
} | |
local messageMissionComplete = | |
{ | |
label = _("End mission..."), | |
phase1 = 36, | |
phase2 = 72 | |
} | |
local buildings = | |
{ | |
steelMill = 13118, | |
steelMillConstr = 13117, | |
sawMill = 25617, | |
sawMillConstr = 25616, | |
digSiteUK = 25576, | |
digSiteFR = 22617, | |
coalMineConstr = 10117, | |
forestConstr = 25565, | |
ironOreMineConstr = 25560, | |
} | |
local taskPrepare = | |
{ | |
steelMill = buildings.steelMill, | |
sawMill = buildings.sawMill, | |
phase1 = messageMissionComplete.phase1 | |
} | |
local taskDig = | |
{ | |
digSiteUK = buildings.digSiteUK, | |
digSiteFR = buildings.digSiteFR, | |
digTargetUK = 1000, | |
digTargetFR = 1000, | |
triggerInbalance = 300, | |
machinesFactory = 19268, | |
machinesFactoryConstr = 7848, | |
phase2 = messageMissionComplete.phase2 | |
} | |
local taskInbalance = | |
{ | |
increaseUK = 200, | |
increaseFR = 0, | |
markerTown = 10412, | |
geologicalInstitute = 6204, | |
} | |
local taskProbe = | |
{ | |
probeArea = { pos = {550,550}, radius = 500 }, | |
probeDays = 60, | |
scanShip = "vehicle/ship/scanship.mdl", | |
} | |
local taskBuildTunnel = | |
{ | |
portalUK = { pos = {-1800, 700}, radius = 500}, | |
portalFR = { pos = {1000, -900}, radius = 500}, | |
digSiteFRConstr = 26277, | |
digSiteUKConstr = 18492, | |
constrName = "industry/tunnel_construction_site.con" | |
} | |
local taskUseTunnel = | |
{ | |
usagePassengers = 1000, | |
usageCargo = 1000, | |
upkeep = 100000, | |
} | |
local taskGeology = | |
{ | |
geologicalInstitute = 6204, | |
geologicalInstituteConstr = 10233, | |
machines = 10, | |
decreaseUK = 300, | |
decreaseFR = 100, | |
} | |
local tm = TaskManager.new() | |
tm:register("messageIntro", makeIntroTask, messageIntro, missionutil.addTask("taskPrepare")) | |
tm:register("taskPrepare", makeTaskPrepare, taskPrepare ) | |
tm:register("taskProbe", makeTaskProbe, taskProbe ) | |
tm:register("taskDig", makeTaskDig, taskDig ) | |
tm:register("taskInbalance", makeTaskInbalance, taskInbalance ) | |
tm:register("taskGeology", makeTaskGeology, taskGeology ) | |
tm:register("taskGeologySuccess", makeTaskGeologySuccess, taskGeology ) | |
tm:register("taskGeologyTooLate", makeTaskGeologyTooLate, taskGeology ) | |
tm:register("taskBuildTunnel", makeTaskBuildTunnel, taskBuildTunnel ) | |
tm:register("taskUseTunnel", makeTaskUseTunnel, taskUseTunnel ) | |
tm:register("messageMissionComplete", makeMissionCompleteTask,messageMissionComplete ) | |
local taskMoney = { startBudget = 30000000, loanFactor = 3.0, loanTrigger = 5000000 } | |
missionutil.registerMoneyTask(tm, taskMoney) | |
local mission = missionutil.makeMissionInterface(tm) | |
mission.onInit(function () | |
tm:add("messageIntro") | |
tm:add("taskMoney") | |
tm:guiSetVisible("vehicleStore.item.model.vehicle/ship/scanship.mdl", false) | |
tm:setZone("cannelLockDown", { polygon = cannelLockDown, draw = true, drawColor = missionutil.colors.RED, buildToolMode = "PROHIBIT" }) | |
game.interface.setPlayer(taskDig.machinesFactoryConstr, nil) | |
--[[ | |
game.interface.setPlayer(taskBuildTunnel.digSiteFRConstr, nil) | |
game.interface.setPlayer(taskBuildTunnel.digSiteUKConstr, nil) | |
game.interface.setPlayer(taskGeology.geologicalInstituteConstr, nil) | |
game.interface.setPlayer(buildings.steelMillConstr, nil) | |
game.interface.setPlayer(buildings.sawMillConstr, nil) | |
game.interface.setPlayer(buildings.coalMineConstr, nil) | |
game.interface.setPlayer(buildings.ironOreMineConstr, nil) | |
game.interface.setPlayer(buildings.forestConstr, nil) | |
game.interface.upgradeConstruction(buildings.steelMillConstr, "industry/steel_mill.con", { productionLevel = 0 }) | |
game.interface.upgradeConstruction(taskDig.machinesFactoryConstr, "industry/machines_factory.con", { productionLevel = 0 }) | |
]]-- | |
end) | |
mission.onMarkerEvent(function (params) | |
if tm:getById("messageMissionComplete") ~= nil then tm:setMarker(params.key) return end | |
if (params.key == "markerGeology") then | |
tm:add("taskGeology") | |
tm:setMarker("markerGeology") | |
end | |
end) | |
mission.onInitGui(function () | |
game.gui.playTrack("res/audio/music/25 - Roach.ogg", 0.0) | |
end) | |
return mission | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment