Master of Orion

Master of Orion

Unofficial Code Patch Steam Workshop
Ben 16 Jan, 2021 @ 6:47am
MOO2 Project
Hi WhatIsSol,

It's been a few years since I played Master of Orion - I bought the alpha and was pretty unimpressed! Popped back on to see whether anything had changed, and thankfully the devs made some effort to add in what should have been in the initial game.

I've come across the work you have been doing and it's really good; thanks for taking the time to add all these updates!

I've been surprised no one has tried to make a mod to try replicate MOO2 yet, although Spud has been doing a lot of nifty work as well with some mods having similarities to it. I've made a mod that is close enough to MOO2, with the help of your UCP, but wanted to add some extra details, like the tolerance perk and some other things .. all of which would require updates to the code.

After decompiling the .dll it seems I am stumped when trying to recompile it - I get a few thousand errors ranging from expression to unexpected characters ... without modifying anything. Any help would be appreciated.

If you are feeling generous, maybe you could add what I'm looking for into the UCP, given it wouldn't change anything existing but add more functionality; what I'm trying to do at the moment is add a new racial perk that allows the race to treat any biome as terran, utilizing some of the existing Aquatic code.

Current code is below if you're interested, thanks!

RacialPerk.cs -------------- public class RacialPerk : SerializedData<RacialPerk> { ... public const string BIOME_TOLERANT = "perk_biome_tolerant"; ... Civilisation.cs -------------------- public float GetPerkFarmingFactorOverride(Planet planet) { if ((bool) this.GetRacialPerkValue("perk_aquatic")) { PlanetBiomeType biome = planet.biome; if (biome.key == "biome_ocean" || biome.key == "biome_terran") return SerializedData<PlanetBiomeType>.Get("biome_gaia").viableFarmingFactor; if (biome.key == "biome_swamp") return SerializedData<PlanetBiomeType>.Get("biome_terran").viableFarmingFactor; } if ((bool)this.GetRacialPerkValue("perk_biome_tolerant")) { PlanetBiomeType biome = planet.biome; if ( biome.key == "biome_volcanic" || biome.key == "biome_toxic" || biome.key == "biome_radiated" || biome.key == "biome_barren" || biome.key == "biome_desert" || biome.key == "biome_tundra" || biome.key == "biome_arid" || biome.key == "biome_swamp" || biome.key == "biome_ocean" ) return SerializedData<PlanetBiomeType>.Get("biome_terran").viableFarmingFactor; } return planet.biome.viableFarmingFactor; } public float GetPerkIndustryFactorOverride(Planet planet) { if ((bool) this.GetRacialPerkValue("perk_aquatic")) { PlanetBiomeType biome = planet.biome; if (biome.key == "biome_ocean" || biome.key == "biome_terran") return SerializedData<PlanetBiomeType>.Get("biome_gaia").viableIndustryFactor; if (biome.key == "biome_swamp") return SerializedData<PlanetBiomeType>.Get("biome_terran").viableIndustryFactor; } if ((bool) this.GetRacialPerkValue("perk_biome_tolerant")) { PlanetBiomeType biome = planet.biome; if ( biome.key == "biome_volcanic" || biome.key == "biome_toxic" || biome.key == "biome_radiated" || biome.key == "biome_barren" || biome.key == "biome_desert" || biome.key == "biome_tundra" || biome.key == "biome_arid" || biome.key == "biome_swamp" || biome.key == "biome_ocean" ) return SerializedData<PlanetBiomeType>.Get("biome_terran").viableIndustryFactor; } return planet.biome.viableIndustryFactor; }
Last edited by Ben; 16 Jan, 2021 @ 8:13am
< >
Showing 1-14 of 14 comments
Spud Dastardly 16 Jan, 2021 @ 7:17am 
I think that should be in (code) (/code) formatting, not spoiler text. What are you using to decompile and recompile? Ildasm and Ilasm?
WhatIsSol  [developer] 16 Jan, 2021 @ 7:27am 
:::: 1.7: How this patch was created
I do all my edits of the DLL in CIL using the tools ildasm (decompile) and ilasm (compile). All available from MS Visual Studio (free version) or the Windows SDK. For editing the CIL I just use notepad++

For SWF I use the JPEXS Free Flash Decompiler and I edit the p-code directly
WhatIsSol  [developer] 16 Jan, 2021 @ 7:45am 
Keying it off of :

IF (( isColonizable == true) & ( isUberBiome == false)) select "terrian"

Would I think be more mod friendly.

But that is assuming of course you want Uber to better, obviously drop the second check if you just want it to treat all as terrian.
Last edited by WhatIsSol; 16 Jan, 2021 @ 7:47am
WhatIsSol  [developer] 16 Jan, 2021 @ 8:07am 
Also the question of the AI - with this trait terraforming planets might be a waste of time, so a check would need to be added to prevent that.
Ben 16 Jan, 2021 @ 8:27am 
Originally posted by Spud Dastardly:
I think that should be in (code) (/code) formatting, not spoiler text. What are you using to decompile and recompile? Ildasm and Ilasm?

Ah, didn't know the forums had that - was hoping the spoiler would hide the bulky text, so you could click on a spoiler button to open it up.

Used JetBrains dotPeek and also .NET Reflector to decompile. It seems to work as the code looks fine, so I think it might be the compiler (using the native c# compiler in Visual Studio 2019)
Ben 16 Jan, 2021 @ 8:34am 
Originally posted by WhatIsSol:
:::: 1.7: How this patch was created
I do all my edits of the DLL in CIL using the tools ildasm (decompile) and ilasm (compile). All available from MS Visual Studio (free version) or the Windows SDK. For editing the CIL I just use notepad++

For SWF I use the JPEXS Free Flash Decompiler and I edit the p-code directly

Thanks, I'll look into adding those to VS. For the AI, it will definitely need to avoid wasting time on terraforming ... something I'll need to look into once I can get everything working!
WhatIsSol  [developer] 16 Jan, 2021 @ 8:46am 
Those tools work off the CIL not the C# routines. You can repair the C# projects and get it to recompile but I never bothered myself.

Sounds simple enough to add, Spud indicates he would support in 5X, so why not?
WhatIsSol  [developer] 16 Jan, 2021 @ 9:09am 
Spud says that in MOO2 this trait while saying it made everything Terrian it actually added +25% instead. So a closer MOO2 implementation would be to adjust the viableXFactors.

This would also still allow terraforming to be useful.
Ben 16 Jan, 2021 @ 11:15am 
Yeah I noticed it's CIL and not C#, not familiar with CIL tbh. Decompiled and compiled, still no luck ... I'll have to play around with it.

Ah yes, forgot MOO2 had that description but the mechanic was +25% to habitable area, effectively making even the terrible planets like Radiated, Toxic etc. Swamps.

Sounds good if you're up for it. For flexibility might be best to add the variable in the Globals YAML and cap it at 1.

WhatIsSol  [developer] 16 Jan, 2021 @ 6:17pm 
Yeah I'm going to post a thread to the main discussion talking about Tolerant, Aquatic, and Subterranean trait.
WhatIsSol  [developer] 18 Jan, 2021 @ 5:55pm 
Add.0.0.6.2a: Added new Empire Trait - Adaptive, this works like the old Master Of Orion 2 Tolerant perk. The viable Farming and Industry factor will be increased by 25% up to a max of 100% (Gaia). This has the effect of allowing more of those cells to be productive at a worse biome level than normal.
Ben 21 Jan, 2021 @ 7:38am 
Cool, good stuff!
Ben 23 Jan, 2021 @ 4:08am 
For the Adaptive perk, how will the +25% work when interacting with the way the game seems to handle viable farm/prod and max tiles for a biome?

I've been playing around with it and I don't know how the Devs decided to code this - should be simple math really. Max tiles on planet size seems to not like uneven numbers i.e. 5, so when giving max tiles to a biome it can't reach that number.

When you have max tiles as 10 for a planet size, and set viable to 0.8 for both farm/prod on a biome, you'd expect max pop to be 8 but it seems to go haywire, and the rounding doesn't seem to make sense.
WhatIsSol  [developer] 23 Jan, 2021 @ 6:18pm 
MaxTiles must be divisible by 2. The game logic is food cells = MaxTiles / 2 and it expects and integer. Same with production cells.

As to usable it is just that number times the viableXFactor. I think it uses ceiling to get an integer value from that calculation.
< >
Showing 1-14 of 14 comments
Per page: 1530 50