So, I've been tinkering around with the Omnifactory trying to get it compatible with Uomoz's sector (UsS) and I've . . . well, failed. Sorta. Buuuut I've figured out
why it doesn't work, if anyone is interested.
Reader beware, for through 'yonder spoiler lies a wall o' text that may steal thy very heart from thee! Click at thy own risk.Spoiler
For some context:
I uploaded a quick fix for the 'free transfer' issue that's making the Omnifactory so horribly broken post-.6a. Download version 1.8b here.
This is literally a one-word change. All it does is assign the Omnifactory to the player faction instead of neutral. If you don't want to re-download the mod, you can just open OmniFacModPlugin.java and change STATION_FACTION to "player".
This requires a new game to take effect, but if you're comfortable editing save files you can change the station's ownership in your current save by doing the following:
- Open up your save's campaign.xml (make a backup first!)
- Search for <name>Omnifactory</name>
- Go up a few lines to the section that says something like <owner reference="../../CampaignOrbitalStation[4]/owner"></owner>
- Replace the entire owner section with the following:
<owner>
<id>player</id>
</owner>
That should change the station's ownership to the player faction in your current game.
STATION_FACTION = NeutralI found that the reason the Omnifactory gives stuff away for free when STATION_FACTION is set to "Neutral" is because UsS interprets the station's status in precisely the same way it does an
abandoned station. The code that creates the dialog options for stations has the conditional station.getFaction().
isNeutralFaction() which, if it returns "True" then provides the "Stash Items / Ships" and "Take Items / Ships" options. As the only stations in Uomoz that belong to the "neutral" faction are abandoned, this normally isn't a problem. (Well, unless you're a neutral omnifactory trying to make a buck.)
STATION_FACTION = PlayerCurrently, if STATION_FACTION is set to "Player" the omnifactory will tell you that "This station is for faction use only," and give you the option to join its faction if you don't belong to any others. If you do join, the only option the station then gives is to leave the faction. The reason for this behavior is because the UsS code which produces the dialog options recognizes the station's faction as non-independent and with neutral reputation (0.0) toward the player, allowing the player to approach, but the subsequent elseif statements don't have a contingency for a non "Neutral" faction station with neutral reputation toward the player that isn't independent or voidwalker (there is no else statement to fall back on). Thus, the code skips the trade, sell, stash, etc options and jumps down to the "Join Faction" option.
You are allowed to join the faction because UsS evaluates factions based upon their
display name. This works fine most of the time except that stations which belong to the "player" faction have the display name of "Your" (I.E., "
Your Omnifactory", just like "
Pirate Scout" or "
Independent Trader"). Next the joinFaction() method changes the player's faction to "Your". The dialog method still evaluates the first part the same, as no reputation changes have occurred, but now you belong to the station's faction, and are given the "Leave Faction" option. If chosen, it sets the player's faction back to "Player", again with no reputation changes.
STATION_FACTION = Player & Player has 1.0 reputation with Faction "Player""Well, if the problem is with the player having neutral reputation with their own faction, why don't I just set player reputation to 1.0?" I thought to myself. So I did, and it worked beautifully. The station dialog method evaluated just fine, assuming that I belonged to the faction in question (since you can't really get 1.0 rep with a faction in UsS without joining them) and gave me the normal trading options for a faction station. The problem was when I activated the Voidwalker Theta station. The activateTheta() method complies a list of all of the factions in the game and sets (not adjusts) them all to -2 except the neutral faction, which it sets to 0. This means I can't just create a cheeky little Omnifactory faction and dodge the voidwalker bullet, sadly.
Long story short, the only way I can see to get the Omnifactory to fully function both before and after voidwalker activation without editing save files (or having Uomoz change his code >.<) is to find a way to get the station.getFaction().isNeutralFaction() call to return false, while still keeping the Omnifactory's station id as "neutral", and Neutral's reputation with the player positive. Since I don't know how .isNeutralFaction() is evaluated, I can't guess at how to mess with it.
(And yes, I know LazyWizard and Uomoz probably already know all of this, but I didn't so, yeah. >.> )
However, my afternoon was not a complete failure, as I did manage to get the omnifactory to spawn in hyperspace, rather than choosing some potentially hostile sector to spawn in. (Yes, okay, fine. I know it's not that impressive a feat, but keep in mine that literally everything I know about Java I learned in the past four hours trying to get these two mods to cooperate.
)
So, here's the modified code for OmniFacModPlugin.java
(I apologize in advance for any atrocities of coding I may have committed. Seriously, the number of ClassNotFound exceptions I went through before I figured out what constructors are and what they do was truly unholy.) >.<
package data.scripts.world;
import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import data.scripts.world.OmniFac;
//I apologize to LazyWizard for anything terrible I may have done to his sexy, sexy mod :(
public class OmniFacModPlugin extends BaseModPlugin
{
private static final String OMNIFAC_ENABLED_FLAG = "lw_omnifac_enabled";
private static final String STATION_NAME = "Omnifactory";
private static final String STATION_FACTION = "player"; //This is case sensitive, just so you know. Yeah, I found that out the hard way. NullPointerException my ass. >:(
private static void initStation(SectorEntityToken station, SectorAPI sector)
{
OmniFac factory = new OmniFac(station);
FactionAPI player = Global.getSector().getFaction("player");
player.adjustRelationship("player",1);
factory.loadSettingsFromJSON("data/config/omnifac_settings.json");
sector.addScript(factory);
}
private static void createStation(SectorAPI sector)
{
LocationAPI asd = sector.getHyperspace();
SectorEntityToken a = asd.createToken(1900, 3700);
SectorEntityToken station = asd.addOrbitalStation(a, 90, 1, 999, STATION_NAME, STATION_FACTION);
initStation(station, sector);
}
private static void initOmniFac()
{
SectorAPI sector = Global.getSector();
createStation(sector);
}
@Override
public void onEnabled(boolean wasEnabledBefore)
{
Map data = Global.getSector().getPersistentData();
if (!data.containsKey(OMNIFAC_ENABLED_FLAG))
{
data.put(OMNIFAC_ENABLED_FLAG, true);
initOmniFac();
}
}
}
Here's the file if you don't feel like copy/pasting:
OmniFacModPlugin.java Just open the link, right click on the page, select "save as" and then save the document as OmniFacModPlugin.java and stick in your omnifactory folder under Omnifactory\data\scripts\world. I recommend you backup the original file before you replace it with this one because, you know,
I modified it, and that probably isn't a good thing.
Voidwalker activation will still make the Omnifactory hostile, but you can fix this by editing your save file. Look for the following lines:
<factionIdOne>player</factionIdOne>
<factionIdTwo>player</factionIdTwo>
<value>-2.0</value>
Change the -2.0 to 1.0 and you're golden again.
Anyway, there's the tale of my trials and tribulations while stumbling through the valley of code. Sorry for the spoilered wall of text, please don't hate me
EDIT: By default, Uomoz's compresses save files into a non-editable format. To get around this, you'll need to go into Uomoz's config files under "Starsector\mods\UomozSector\data\config" and find settings.json
Change
"compressSaveGameData":true, to
"compressSaveGameData":false, then go back into the game, load your save, save your save (preferably as a copy), and then try to edit it again