Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict entry to Rondel system #5095

Merged
merged 8 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/lang/module-advice/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
"description": "Headline starts with this pre-headline",
"message": "RUMOUR"
},
"RUMOUR_1_BODYTEXT": {
"description": "",
"message": "Someone in the Federal Navy told me that one day, one of their corvettes accidentally jumped to a Haber outpost system about 50ly out from Sol, called Rondel; almost causing open conflict. Not many people seem to know about the incident itself outside of the navy, but some say Rondel administration has been more aggressive towards visitors since, and freight pilots started avoiding the system."
},
"RUMOUR_1_HEADLINE": {
"description": "",
"message": "The Rondel Incident"
},
"TALE_1_BODYTEXT": {
"description": "",
"message": "Don't miss the beautiful eclipse on New Hope as Hades blocks out the light from Epsilon Eridani."
Expand Down
66 changes: 66 additions & 0 deletions data/lang/module-rondel/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"DEFENSE_CRAFT_ELIMINATED": {
"description": "",
"message": "System defense craft eliminated. Incident has been logged."
},
"INTERCEPTION_SUCCESSFUL": {
"description": "",
"message": "Interception successful. Hostile craft destroyed."
},
"WEAPONS_EVASIVE_ACTION": {
"description": "",
"message": "Weapons discharge detected. Take evasive action!"
},
"JETTISON_DEFENSIVE_PRECAUTION": {
"description": "",
"message": "Jettison detected. Apply defensive precautions!"
},
"RONDEL_RESTRICTED_ZONE": {
"description": "",
"message": "{playerShipLabel}, this star system is a restricted zone. You must leave within {seconds} seconds. Should you fail to comply, you will be assumed hostile and defensive precautions will be taken."
},
"HOSTILE_ACTION_REPORTED": {
"description": "",
"message": "Hostile action reported. Intercept and destroy!"
},
"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."
}
}
2 changes: 1 addition & 1 deletion data/modules/Advice/Advice.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local advice_probability = .2
-- There are three different versions of flavours "Rumours",
-- "Traveller's tale", and "Traveller's advice", which have fake /
-- arbitrary indices, for inflated feeling of rich universe and lore.
local rumours_num = 0
local rumours_num = 1
local travellers_tale_num = 1
local travellers_advice_indices = {481, -- tame black market
16, -- road faster taken
Expand Down
228 changes: 228 additions & 0 deletions data/modules/Rondel/Rondel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
-- Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

local Engine = require 'Engine'
local Lang = require 'Lang'
local Game = require 'Game'
local Space = require 'Space'
local cargo = require 'Commodities'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I will take care of that. Thanks.

Copy link
Contributor Author

@WKFO WKFO Dec 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I happen to be using that, actually.

local Comms = require 'Comms'
local Event = require 'Event'
local Legal = require 'Legal'
local Serializer = require 'Serializer'
local Equipment = require 'Equipment'
local ShipDef = require 'ShipDef'
local SystemPath = require 'SystemPath'
local Timer = require 'Timer'

--local Character = require 'Character'

local l_rondel = Lang.GetResource("module-rondel")
local l_ui_core = Lang.GetResource("ui-core")

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 rondel_syspath = SystemPath.New(-1,6,2,0)

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)
end
end

local onShipDestroyed = function (ship, attacker)
if ship:IsPlayer() or attacker == nil or not Game.system.path:IsSameSystem(rondel_syspath) then return end

for i = 1, #patrol do
if patrol[i] == ship then
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
Comms.ImportantMessage(l_rondel.INTERCEPTION_SUCCESSFUL, attacker.label)
break
end
end
end

local onShipFiring = function (ship)
if not Game.system.path:IsSameSystem(rondel_syspath) then return end

local police = ShipDef[Game.system.faction.policeShip]
if ship.shipId ~= police.id then
for i = 1, #patrol do
if ship:DistanceTo(patrol[i]) <= 4000000 and not shipFiring then
shipFiring = true
Comms.ImportantMessage(string.interp(l_rondel.WEAPONS_EVASIVE_ACTION, patrol[1].label))
attackShip(ship)
break
end
end
end
end

local onJettison = function (ship, cargo)
if not Game.system.path:IsSameSystem(rondel_syspath) then return end
if not jetissionedCargo and #patrol > 1 then
Comms.ImportantMessage(l_rondel.JETTISON_DEFENSIVE_PRECAUTION, patrol[1].label)
jetissionedCargo = true
end
attackShip(ship)
end

local onEnterSystem = function (player)
if not player:IsPlayer() then return end

local system = Game.system
if not system.path:IsSameSystem(rondel_syspath) then return end

local tolerance = 1
local hyperdrive = Game.player:GetEquip('engine',1)
if hyperdrive.fuel == cargo.military_fuel then
tolerance = 0.5
end

local ship
local shipdef = ShipDef[system.faction.policeShip]
for i = 1, 7 do
ship = Space.SpawnShipNear(shipdef.id, player, 50, 100)
ship:SetLabel(l_rondel.HABER_DEFENSE_CRAFT)
ship:AddEquip(Equipment.laser.pulsecannon_2mw)
Web-eWorks marked this conversation as resolved.
Show resolved Hide resolved
table.insert(patrol, ship)
end

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)

end

local onLeaveSystem = function (ship)
if ship:IsPlayer() then
shipFiring = false
jetissionedCargo = false
patrol = {}
end
end

local loaded_data

local onGameStart = function ()
shipFiring = false
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

local onGameEnd = function ()
shipFiring = false
jetissionedCargo = false
rondel_prize = false
rondel_victory = false
patrol = {}
end

local serialize = function ()
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)
Event.Register("onShipFiring", onShipFiring)
Event.Register("onJettison", onJettison)
Event.Register("onGameStart", onGameStart)
Event.Register("onGameEnd", onGameEnd)

Serializer:Register("Rondel", serialize, unserialize)