-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8578817
Restrict entry to Rondel system
WKFO 9d9479c
Move Rondel.lua to PolicePatrol
WKFO 5c5e1e0
Add rumour about Rondel
WKFO 1a47242
Use custom ship label for Rondel guards
WKFO 60d19bb
Don't attempt to send message from a nonexistant ship
WKFO b62e8cd
Copyright date update
WKFO 307b179
Add prize for defeating the entire Haber force at Rondel
WKFO 24011e7
Use IsSameSystem() instead of checking system name
WKFO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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." | ||
} | ||
} |
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
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
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' | ||
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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks to be unused.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.