From c4238e5d5fada81cf4de2948f86902c4b20d415c Mon Sep 17 00:00:00 2001 From: WKFO Date: Sun, 3 Jan 2021 01:52:06 +0300 Subject: [PATCH] Add prize for defeating the entire Haber force at Rondel --- data/lang/module-rondel/en.json | 36 ++++++++ .../{PolicePatrol => Rondel}/Rondel.lua | 92 +++++++++++++++++-- 2 files changed, 121 insertions(+), 7 deletions(-) rename data/modules/{PolicePatrol => Rondel}/Rondel.lua (63%) diff --git a/data/lang/module-rondel/en.json b/data/lang/module-rondel/en.json index 73a369dff..61f934eea 100644 --- a/data/lang/module-rondel/en.json +++ b/data/lang/module-rondel/en.json @@ -26,5 +26,41 @@ "HABER_DEFENSE_CRAFT": { "description": "", "message": "Haber Defense Craft" + }, + "SOLFED_INTEL": { + "description": "", + "message": "Solar Federation Intelligence" + }, + "SOLFED_INTEL_INTRO": { + "description": "", + "message": "Keep your voice down, pilot. I'm an undercover agent working for Solar Federation Intelligence. Your ship's computer memory has some data we are interested in." + }, + "PERFECT": { + "description": "", + "message": "Perfect. If anyone asks... Surely no one will ask, but if anyone asks, please remember that we were just haggling over a second hand shield generator." + }, + "YOU_SHALL_HAVE_THE_DATA": { + "description": "", + "message": "You shall have the data." + }, + "WHAT_IS_THIS_ABOUT": { + "description": "", + "message": "What data? What is this all about?" + }, + "YOU_VISITED_STAR_SYSTEM": { + "description": "", + "message": "You may or may not have visited some star system we would like to know more about." + }, + "NOT_INTERESTED": { + "description": "", + "message": "What if I'm not interested?" + }, + "CREDITS_PROMISE": { + "description": "", + "message": "250,000 in cash. Right now. I would find that interesting." + }, + "HEY_OVER_HERE": { + "description": "", + "message": "Hey, over here." } } diff --git a/data/modules/PolicePatrol/Rondel.lua b/data/modules/Rondel/Rondel.lua similarity index 63% rename from data/modules/PolicePatrol/Rondel.lua rename to data/modules/Rondel/Rondel.lua index 941776bbf..d70cced82 100644 --- a/data/modules/PolicePatrol/Rondel.lua +++ b/data/modules/Rondel/Rondel.lua @@ -14,6 +14,8 @@ local Equipment = require 'Equipment' local ShipDef = require 'ShipDef' local Timer = require 'Timer' +--local Character = require 'Character' + local l_rondel = Lang.GetResource("module-rondel") local l_ui_core = Lang.GetResource("ui-core") @@ -21,6 +23,65 @@ local patrol = {} local shipFiring = false local jetissionedCargo = false +local rondel_victory = false -- has the player defeated all Rondel guards once in their career? +local rondel_prize = false -- whether the player has been rewarded or not + +local ads = {} + +local onChat = function (form, ref, option) + local ad = ads[ref] + form:Clear() + + form:SetTitle(l_rondel.SOLFED_INTEL) + + if option == -1 then + form:Close() + return + end + + form:SetMessage(l_rondel.SOLFED_INTEL_INTRO) + + if option == 1 then + ads[ref] = nil + form:RemoveAdvertOnClose() + form:SetMessage(l_rondel.PERFECT) + Game.player:AddMoney(250000) + rondel_prize = true + return + elseif option == 2 then + form:SetMessage(l_rondel.YOU_VISITED_STAR_SYSTEM) + elseif option == 3 then + form:SetMessage(l_rondel.CREDITS_PROMISE) + end + + form:AddOption(l_rondel.YOU_SHALL_HAVE_THE_DATA, 1) + form:AddOption(l_rondel.WHAT_IS_THIS_ABOUT, 2) + form:AddOption(l_rondel.NOT_INTERESTED, 3) + +end + +local onDelete = function (ref) + ads[ref] = nil +end + +local onCreateBB = function (station) + if rondel_prize or not rondel_victory then return end + + local ad = { + title = l_rondel.HEY_OVER_HERE, + --message = "", + station = station, + --character = Character.New({armour=false}), + } + + local ref = station:AddAdvert({ + description = ad.title, + --icon = "", + onChat = onChat, + onDelete = onDelete}) + ads[ref] = ad +end + local attackShip = function (ship) for i = 1, #patrol do patrol[i]:AIKill(ship) @@ -35,6 +96,8 @@ local onShipDestroyed = function (ship, attacker) table.remove(patrol, i) if #patrol > 1 then Comms.ImportantMessage(l_rondel.DEFENSE_CRAFT_ELIMINATED, patrol[1].label) + elseif #patrol == 0 then + rondel_victory = true end break elseif patrol[i] == attacker then @@ -93,14 +156,14 @@ local onEnterSystem = function (player) Game.SetTimeAcceleration("1x") Timer:CallAt(Game.time + 2, function () Comms.ImportantMessage(string.interp(l_rondel.RONDEL_RESTRICTED_ZONE, {seconds = tostring(600*tolerance), playerShipLabel = Game.player:GetLabel()}), ship.label) + Timer:CallAt(Game.time + 600*tolerance, function() + if #patrol > 1 then + attackShip(player) + Comms.ImportantMessage(l_rondel.HOSTILE_ACTION_REPORTED, ship.label) + end + end) end) - Timer:CallAt(Game.time + 600*tolerance, function() - if #patrol > 1 then - attackShip(player) - Comms.ImportantMessage(l_rondel.HOSTILE_ACTION_REPORTED, ship.label) - end - end) end local onLeaveSystem = function (ship) @@ -118,6 +181,18 @@ local onGameStart = function () jetissionedCargo = false if loaded_data then patrol = loaded_data.patrol + rondel_prize = loaded_data.rondel_prize + rondel_victory = loaded_data.rondel_victory + if loaded_data.ads then + for k,ad in pairs(loaded_data.ads) do + local ref = ad.station:AddAdvert({ + description = ad.title, + --icon = "", + onChat = onChat, + onDelete = onDelete}) + ads[ref] = ad + end + end loaded_data = nil end end @@ -125,17 +200,20 @@ end local onGameEnd = function () shipFiring = false jetissionedCargo = false + rondel_prize = false + rondel_victory = false patrol = {} end local serialize = function () - return { patrol = patrol } + return { patrol = patrol, ads = ads, rondel_prize = rondel_prize, rondel_victory = rondel_victory } end local unserialize = function (data) loaded_data = data end +Event.Register("onCreateBB", onCreateBB) Event.Register("onEnterSystem", onEnterSystem) Event.Register("onLeaveSystem", onLeaveSystem) Event.Register("onShipDestroyed", onShipDestroyed)