endless-sky
endless-sky copied to clipboard
Feat(mechanics) : Government system restrictions
Feature Details
You can specify a set of systems and planets a government cannot access, using a locationFilter. This is done under a new category for governments, restricted
. (see the change I did to government.txt if you want a concrete example)
This only changes the behaviour of any random fleet, constrained AI following you will go with you into danger.
Edit: unconstrained
ships will not be affected by this whatsoever.
Behaviour when you manually force a fleet to spawn in a restricted system.
This does not prevent specified fleet from spawning. To be clear: if you say `"Large Unfettered" 1000` for a system, and then restrict access to that system for them, it will still make them appear there, they will just not come from any other system into that forbidden system and will be unable to land there. Any nearby system will not have an attack fleet coming from there too, even though this specific fleet spawned there may move as it pleases (excluding to other restricted systems).If you want to remove the fleet from the system that is easy to do with an event, I made it this way to allow more flexibility. Also if you say you want a fleet to spawn there, there is no reason for it not to spawn because of this.
UI Screenshots
n/a
Usage Examples
MasterOfGrey agreed with me that the Hai should never attack the system of Wah Yoot (the Unfettered capital) with their fleets, so I changed that to be the case.
With this, merchants could be made to avoid pirate worlds, or just stay in republic owned space even. Or even make patrol ships that only go to given systems, or only go 5 jumps away etc.
The way to use this is to put restricted
in the government that should not have access to some systems, and then follow the same syntax as usual for destinations/source etc.
Testing Done
With a very high fleet spawn rate, I prevented the Hai from going into Unfettered space, which they did not try to, or come from that system either.
Performance Impact
There is probably some, because we need to check if a ship can go to a system before giving that command, but thats required for this to work. Thanks to @warp-core this now stores a bool to know if the locationFilter is empty
Is
LocationFilter
the right container for this information? Or should it start as aset<const System *>
and only change if the needs require it? Or should you go a slight bit further and handle planet landing/takeoff restrictions, too?
LocationFilter is indeed appropriate because that way you can limit by government etc, so I handled planet restrictions too. You are right it was an oversight on my part! I think I did everything that was asked, but do point out if I misunderstood something.
I feel like government
is the wrong place for this. It makes more sense, at least to me, to have these restrictions be a part of a system
or planet
.
Instead of
government Hai
restricted
system "Wah Yoot"
we have this
system "Wah Yoot"
restricted
"Hai"
I feel like
government
is the wrong place for this. It makes more sense, at least to me, to have these restrictions be a part of asystem
orplanet
.
That is impractical, what if you want to restrict merchant access to all pirate systems, or just say they cannot leave their government? It would be harder to read, and require way more text written for the same result.
Also the way I did it, it could be used to put the "Hai" and "Hai (Whormhole access)" into one government, given it does not affect behaviour of fleets following you (at least it shoudn't) and the only fleets who go trough the whormhole do so with you as escort I think.
Maybe we should add the ability to allow these restrictions to be ignored on a fleet-by-fleet basis or allow fleets to determine their own specific restrictions?
So you mean adding a new field in npc, restrictions, that would be limiting where a fleet can go? The problem code wise is that as far as I can see ships dont belong to fleets, fleets just exist to make them spawn. That means it would have to be added to every single ship in the fleet (not optimized) or make fleet actually permanent and restructure quite a lot of stuff (lot of work). You can just spawn a new government, though I guess it may not be practical and we don't want too many of those, so you could create a temporary one with an event?
I actualized the restrictions to make it so any Hai hostile to the Unfettered will not enter their systems
Maybe we should add the ability to allow these restrictions to be ignored on a fleet-by-fleet basis or allow fleets to determine their own specific restrictions?
I see two options for stuff like this: a) we remove the restriction when we need a fleet to go somewhere it normally wouldn't. And then re-instate the restriction afterwards. b) We allow some things to override the restriction. For example, if an NPC or fleet is specifically instructed to fly to a restricted system, then it will ignore the restriction and fly to the system.
B is the better option, I think. A has a lot of side-consequences and potentially plenty of other NPCs doing things they shouldn't for the duration of the mission in which the NPC we care about doing said things.
As a side note, worth noting that, in all likelyhood, some merchants are actually of the Han Solo or Captain Reynolds variety: Namely, people who are not averse to including smuggling and other illegal activities for which visiting a planet world/system is very much part of the job.
For example, if an NPC or fleet is specifically instructed to fly to a restricted system, then it will ignore the restriction and fly to the system.
That's not even a feature yet, but I could maybe make it a personality? Say "independant"; meaning that any restrictions normally imposed on the government don't apply to that fleet?
There is actually an unconstrained
personality, I'll make sure it is not affected by this.
I really like when coding is so dynamic! Thx for the reviews
Now that the event changes (that were part of this PR) were brought into master it should make it more merge-rd.
What's the time complexity of LocationFilter::IsEmpty()?
O8, it checks if 8 things are empty.
The bigger performance impact would be when we can't access a planet I recon, but sure I can store a bool.
I got a little issue with this code; restricting a planet restricts the system above it as well, and looking at the code I can't really make sense of it. It looks like checking for planets should check for system as well, but not the other way around.
Great idea - this mechanic would definitely be useful for some Patir missions in the near future
Since I haven't previously subscribed to this thread, I'm hopping in just to say that this feature would be a medium-high priority for other things I'd like to do in the not-so-distant future.
I got a little issue with this code; restricting a planet restricts the system above it as well, and looking at the code I can't really make sense of it. It looks like checking for planets should check for system as well, but not the other way around.
Changing this would require changing things that are out of scope for this PR, I think it's a bug that also affects the enforcement zones but that nobody noticed, and I couldnt find the source of it.
Since I'm going to leave soon I'll close this PR so we can focus on others that I deem more important. I'll open this back up in 3 months once I get back, but the only use cases I see is preventing entering into unfettered space and containing the Korath ships to the Ember Waste, surely that can wait.
There also is the issue of limiting a planet affecting the system above it which is deep in code (and a separate issue to this PR, I'm pretty sure)
~~I was just reviewing this again.~~
If you want post a review I'll gladly take care of it, that said I think other PRs matter more And I dont think we can get all of them merged before I leave, even though I'd love that
I'd just like to point out that if we merge this PR we can remove all the governments that exist just to enter the wormhole or not by giving the new unrestricted
personality to the fleets we want to have allowed to pass the wormhole, and restrict the government as a whole.
That means we can at the very least remove the new governments added by Hai reveal of:
"Free Worlds that won't enter wormhole"
"Republic that won't enter wormhole"
"Syndicate that won't enter wormhole"
"Deep Security that won't enter wormhole"
"Bounty Hunter that Won't Enter Hai Space"
And then we will be able to depreciate some other governments, too.
LOL we reached the limit on personalities using the current method.
LOL we reached the limit on personalities using the current method.
I knew this day would come. :pensive:
I'm going to be going on a trip for 3 months, meaning I will be much less active on my PRs. That said, they all are as ready as I could make them, which is why I'm not closing them or marking them as waiting for op.
I won't be able to test and make changes fast, but feel free to post comments and especially to do the needed changes, I truly don't mind. In fact I'd like that.
This PR would allow removing HR's extra governments, and depreciating other govs that are just hacks of access to a wormhole, and more with the EW raids finally staying in the EW and no longer having Hai attack the Unfettered in their own systems.
This may be for a separate PR, but I would like to have a restriction only for landing. This would block the ships from the "stolen ship" missions landing, and could also block the fleeing Republic fleet in that one Free Worlds mission from landing, without blocking them from leaving the system.
Definitely another PR, as rn this does not affect landing at all
Fair enough.
With #7076 in, and apparently working just fine, there are some things brought up by https://github.com/endless-sky/endless-sky/pull/8791#issuecomment-1566472306 that would be much better to do if this were merged (assuming it's working and issues have been addressed.)
This is working, it just doesnt affect landing but only systems for a reason I never managed to catch (but I suspect is with the underlying code and not this PR) That part can always be corrected later tho
Is this because of the conflicts? I dont see what I need to do further since planet access is to be an expansion in another PR and this works well without it.
If there is a conflict all that is needed is to ask me to fix it and I will, I dont get notifications or smth for those so that'd be useful. In the same way, I dont get notifications for labels.
Mhhhh not sure why that segfaults but its a recent change for sure