spara wrote:Using custom populator is not really a solution as we will want to take over the system just once.
Assuming you can write the mission such that you know before you enter the system that you want to take it over, then a custom populator should work fine:
Code: Select all
System.infoForSystem(galnum,sysnum).populator = "myoxp_systemWillPopulate";
and then set it back to whatever its previous value was once the player leaves again. In 1.81 property changes are namespaced by OXP, so you don't even have to record what the previous value was - just set it back to
null
from the same script that set it in the first place, and whatever was there before will take effect.
Even if you only know it's definitely this one when
shipWillEnterWitchspace
is being called for the initial jump into the system, that's still early enough to make the change.
(Note: in 1.81 there's a possibility that another OXP will have also overridden the system populator and done so at a equal or higher layer than your OXP, so you may want to do a set followed by an immediate get - if that doesn't give the expected result, another OXP has already claimed the system for now, and you'll have to wait until it gives it back)