Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - seronis

Pages: [1] 2
Looking for ways to optimize my gov scripts so that im not polling the research web more often than needed.


While doing a quick test game before pushing my changes to the repo I noticed that the console log had a new line.

"Unable to bind all functions for module planet."

Normally if you get a message like that you also have several script compiling error lines but there are no compiling errors listed, and in game I didnt notice any ill behavior.  This line doesnt show up when running a standard game and it doesnt show up when using a 100% unmodified file in my mod.  Which probably means its not referring to the onQueueEvent or onRepair functions that are commented out by default in that file (and thus not bound).

Anyone able to help me figure out what I did wrong or if this can be safely ignored?


Reaper pointed out to me that error is related to import statements at the top of the file not finding a match for a function you try to import. This was the answer as I forgot to add an older file i edited to my current copy of the mod.

Modding / [resource] A more diverse empire color set
« on: May 09, 2016, 07:07:04 PM »
Attached is a replacement EmpireColors.txt  (should be placed in ".../Star Ruler/Mods/[modname]/Game Data") that expands the empire color choices from their default 9 to 30 semi-bright colors evenly spread along the color spectrum from red to violet. There are no pastels or desaturated tones. There are also 6 shades of gray including black and white for a total of 36 options.

Modding / what is purpose of isEssential tag in resources.xml [answered]
« on: September 25, 2014, 06:37:11 PM »
what is purpose of isEssential tag in resources.xml?

Doing a file search I find no mention of it in any of the angelscript files. Literally the only script reference for it is in resources.xml itself. Is this tag used in the untouchable compiled code anywhere or is it an irrelevant tag and completely ignorable ?

Modding / Working on a new mod. Anyone else doing so too?
« on: September 23, 2014, 02:04:10 AM »
Along with Banished, Dont Starve and Skyrim i've been playing a bit more star ruler lately and I am again a little bit motivated to work on an old mod idea about revamping the galactic bank and how planets manage transporting resources. Just dropping the 'infinite free storge' aspect and making the size of a system have an effect on how fast you can transfer stuff into and out of the bank 'stockpile'.

I've seen several unfamiliar (and a few familiar) names on the list of people browsing the forums. Anyone else working on projects of their own right now?

Modding / [fixed] Modding API site hanging on connection
« on: September 20, 2014, 09:25:59 PM »
Tried going to the API website (the one you guys have auto generate) and the connection is hanging without all the page contents sent.  Could this be fixed sometime?


Working like normal now. Thank you

Been using Linux for 6 months now and missing my StarRuler gaming so felt like seeing how difficult it would be to get the game running without having to dual boot windows.  Ended up using a non modded copy of wine straight from the repo and what I consider a fairly standard winetricks additions. 

sudo apt-get install wine
sudo apt-get install winetricks
winetricks d3dx9_36 vcrun2008 gecko corefonts

at this point i went to and downloaded the windows *.msi installer for steam and ran it.  Steam itself loaded without a problem and so did installing StarRuler.  First attempt at running SR after install CTDd instantly so i went into the steam folder for SR and ran first the OpenAL installer and then the  C Redistributable installer.  Both finished nearly instantly and SR loaded fine after that.  Quite less frustration than I was prepared for

Modding / Discussion on governors and how optimized they are/need to be
« on: January 22, 2013, 02:24:01 PM »
After a few games it should become very obvious that the vanilla games governors are intended as the least qualified person doing the job. They are not optimized in their building choices by any means. I think this is a good thing as it introduces a learning curve to the game. Play more, learn more, do better.

The AI is given a difficulty rating that increases the payout of the 'cheating ai' feature at higher difficulty levels. The cheating feature just makes it so that all AI controlled empires receive a stipend of free resources every second. The size of this stipend increases the longer the game has been running. This helps simulate an AI that has taken the time to slowly optimize the building choices of the planets it is in control of, without having to complicate the game with AI scripts to do the task.

So the discussion, is what exactly do all of YOU think a governor should be doing? And how would you break those desired tasks down into tiers so that you can decide exactly how skilled you want your gov to be?

Things that *I* think a governor should do are stuff like:
  • enough cities to cover the minimal worker requirements
  • enough ports to cover all EXPORT requirements
  • Alert the player to adverse situations (food shortage definitely, goods/lux shortage maybe)
  • quickly renovate outdated structures

Things i've seen other governors do
  • Build predefined number of orbital defense stations dependant on gov type
  • maintain a minimal number of haulers in each system
  • automate building colonizers and sending them to known systems

So what ELSE would you like to see a governor do besides these features?  Assume that its a brand new player who has never played before. What features will remove frustration? What features would hurt the 'fun' of learning and shouldnt be available from the start? When it comes to the AI, what features should be active at each difficulty level so that the AI doesnt _HAVE_ to cheat to be competitive?

My personal goals are to remove micromanagement from players who ALREADY KNOW what they are doing, without removing any required learning from the player. Secondary is to reduce frustration to new players. Only last do I consider 'player automation features' to be priorities but I would still love to code a bunch of those.

Help & Support / HOWTO: set up port forwarding without router login/pass
« on: January 17, 2013, 06:53:27 PM »

The program at the above link is an open source java program so it will run on any OS with a valid java runtime environment set up. It uses the Universal Plug N Play api in order to access the port forwarding settings of a router. This means you DONT need the routers login/pass but the router DOES need to have UPnP enabled, which might not always be the case.

Just run the above program and click the 'connect to router' button that appears. If it says it doesnt see a router that means UPnP is turned off and you'll need the login/pass and to use the routers web interface.

Modding / Thread crash when printing debug data on custom class
« on: January 10, 2013, 12:42:59 PM »

Im in the middle of refactoring my code and a class im using to hold building data is causing a crash.  Is this just too many print statements because I was just wanting the values to print off in a somewhat aesthetic manner instead of just a CSV list. Im probably not thinking of something simple since I havent really touched AS in a few months.

Scripting / [solved] Crash in handling empire stats and research web
« on: August 05, 2012, 09:31:00 PM »
[SOLVED] Code updated to reflect the change

I have all my scripted governors calling the following code in order to grab the tech levels of the empire owning the planet.
Code: [Select]
const string@ str_Science="Science", str_EnergyPhysics="EnergyPhysics",
str_Materials="Materials", str_ParticlePhysics="ParticlePhysics",
str_Gravitics="Gravitics", str_WarpPhysics="WarpPhysics",
str_Metallurgy="Metallurgy", str_Chemistry="Chemistry",
str_Economics="Economics", str_Sociology="Sociology",
str_Biology="Biology", str_BeamWeapons="BeamWeapons",
str_Shields="Shields", str_Stealth="Stealth",
str_ProjWeapons="ProjWeapons", str_Missiles="Missiles",
str_Engines="Engines", str_ShipConstruction="ShipConstruction",
str_Nanotech="Nanotech", str_ShipSystems="ShipSystems",
str_Cargo="Cargo", str_Computers="Computers",
str_Sensors="Sensors", str_Armor="Armor",

//when executed, will analyze an empires current tech levels and buffer those level
// values to empire state variables for more thread friendly read-only access.
void pushTechLvls( Empire@ emp ) {
ResearchWeb web;

//TODO: would an object lock benifit me here?
if( web.isTechVisible(str_Science) ) emp.setStat(str_Science, web.getItem(str_Science).level);
if( web.isTechVisible(str_EnergyPhysics) ) emp.setStat(str_EnergyPhysics, web.getItem(str_EnergyPhysics).level);
if( web.isTechVisible(str_Materials) ) emp.setStat(str_Materials, web.getItem(str_Materials).level);
if( web.isTechVisible(str_ParticlePhysics) ) emp.setStat(str_ParticlePhysics, web.getItem(str_ParticlePhysics).level);
if( web.isTechVisible(str_Gravitics) ) emp.setStat(str_Gravitics, web.getItem(str_Gravitics).level);
if( web.isTechVisible(str_WarpPhysics) ) emp.setStat(str_WarpPhysics, web.getItem(str_WarpPhysics).level);
if( web.isTechVisible(str_Metallurgy) ) emp.setStat(str_Metallurgy, web.getItem(str_Metallurgy).level);
if( web.isTechVisible(str_Chemistry) ) emp.setStat(str_Chemistry, web.getItem(str_Chemistry).level);
if( web.isTechVisible(str_Economics) ) emp.setStat(str_Economics, web.getItem(str_Economics).level);
if( web.isTechVisible(str_Sociology) ) emp.setStat(str_Sociology, web.getItem(str_Sociology).level);
if( web.isTechVisible(str_Biology) ) emp.setStat(str_Biology, web.getItem(str_Biology).level);
if( web.isTechVisible(str_BeamWeapons) ) emp.setStat(str_BeamWeapons, web.getItem(str_BeamWeapons).level);
if( web.isTechVisible(str_Shields) ) emp.setStat(str_Shields, web.getItem(str_Shields).level);
if( web.isTechVisible(str_Stealth) ) emp.setStat(str_Stealth, web.getItem(str_Stealth).level);
if( web.isTechVisible(str_ProjWeapons) ) emp.setStat(str_ProjWeapons, web.getItem(str_ProjWeapons).level);
if( web.isTechVisible(str_Missiles) ) emp.setStat(str_Missiles, web.getItem(str_Missiles).level);
if( web.isTechVisible(str_Engines) ) emp.setStat(str_Engines, web.getItem(str_Engines).level);
if( web.isTechVisible(str_ShipConstruction) ) emp.setStat(str_ShipConstruction, web.getItem(str_ShipConstruction).level);
if( web.isTechVisible(str_Nanotech) ) emp.setStat(str_Nanotech, web.getItem(str_Nanotech).level);
if( web.isTechVisible(str_ShipSystems) ) emp.setStat(str_ShipSystems, web.getItem(str_ShipSystems).level);
if( web.isTechVisible(str_Cargo) ) emp.setStat(str_Cargo, web.getItem(str_Cargo).level);
if( web.isTechVisible(str_Computers) ) emp.setStat(str_Computers, web.getItem(str_Computers).level);
if( web.isTechVisible(str_Sensors) ) emp.setStat(str_Sensors, web.getItem(str_Sensors).level);
if( web.isTechVisible(str_Armor) ) emp.setStat(str_Armor, web.getItem(str_Armor).level);
if( web.isTechVisible(str_MegaConstruction) ) emp.setStat(str_MegaConstruction, web.getItem(str_MegaConstruction).level);


const string@ str_TechUpdateAllowed="str_TechUpdateAllowed";

//thread lock friendly tech level assessment
void popTechLvls( Empire@ emp
, float &out rlvl_city, float &out rlvl_farm, float &out rlvl_prod, float &out rlvl_cnst
, float &out rlvl_port, float &out rlvl_crgo, float &out rlvl_scif ) {

//TODO: would an object lock benifit me in this method ?
double update = emp.getStat(str_TechUpdateAllowed);
if( update < gameTime ) {
emp.postMessage("Buffering current tech levels");
emp.setStat(str_TechUpdateAllowed, gameTime + 30.0f);

rlvl_city = max(1.00, emp.getStat(str_Sociology));
rlvl_farm = max(0.75, emp.getStat(str_Biology));
rlvl_prod = max(1.00, emp.getStat(str_Metallurgy));
rlvl_cnst = max(1.00, emp.getStat(str_ShipConstruction));
rlvl_port = max(1.00, emp.getStat(str_Economics));
rlvl_crgo = max(1.00, emp.getStat(str_Cargo));
rlvl_scif = max(1.00, emp.getStat(str_Science));

Instantly when turning a governor on the game will lock up and crash with no useful information in the log.txt file.  Effectively what is happening is that each time a governor checks the tech levels of an empire it will pull those values from a set of temporary stats assigned to the empire. Only if those temporary values have not been updated in over 30 seconds will it call the research web.

The purpose of this is that calling the research web performs a thread lock, which will cause multiple threads executing governors to temporarily stall each other. Anytime after early gave I have had horrible reaction time from my scripted governors and im trying to eliminate all possible sources of inefficiency.

If anyone can see what could be causing a crash (probably a simple oversight) please let me know

As of the time of this post the current version of Galactic Armory is 1.9.1b

This version of GA is known to have some pretty extreme requirements for both ram (due to the size of systems in Realistic Systems feature) and graphical memory (due to increased shipsets and other media assets). This causes instability on a lot of systems which can result in seemingly random crashes that occur as the game attempts to request more memory than is available.

First step is always double check your video drivers and make sure they are as up-to-date as is possible for your operating system and gpu manufacturer. Some crashes can be avoided by just having a more intelligent driver that is smart enough to handle these out of memory situations when its not too extreme.

Next you can try going into the Options menu before starting a new game and reduce the texture quality settings and even try lowering the display resolution. Reduced resolutions and texture quality means less video memory load which might be just enough to stop your crashes. Disabling 'full screen' and running in windowed mode can also help.

If you are still having crashes sometimes the installer can notice a version of the C Runtime Distribution or OpenAL already on your system and not install the version that comes with star ruler. An installer for each is located in the same folder as the star_ruler.exe and you should reinstall both of these.

This resolves most of the crash problems that are ABLE to be resolved. Sometimes your system just cant handle the current requirements that GA has. You can try using the Enhanced GA mod which has most the media assets memory already altered and a few other tweaks to take some load off your computer. If you still experience crashes after that feel free to create a NEW topic and ensure you mention you have already performed all these steps and list your system specs.

Operating system, 32 or 64 bit
Desktop or Laptop
Graphics card manufacturer and model
CPU model/cores/speed
Ram quantity/speed

When you make your post try to upload the save file that is experience the crash. You can do this with the 'attachments and other options' link below the text entry box of the post as you are writing it.

Modding / [MOD] StarGov v0.6.1 for SR
« on: July 31, 2012, 04:45:18 PM »
StarGov is meant to be a simple and efficient set of governors for vanilla Star Ruler, helping to offset some of the micromanagement and provide information to the player.

Quote from: ReadMe.txt
      All govs attempt to maintain 12mil population surplus so that building a new structure
      will not result in an offline building from lack of workers. If this threshold is not
      met then the next building constructed will be a city. If enough population has not yet
      been born to meet current worker demands the gov will wait to construct buildings so as
      not to use resources from the galactic bank when it wont have any benifit.
      Non-military govs will not build OR tear down planetary weapons, shields, engines or
      bunkers. The govs will take those buildings into account when determining population
      requirements and if the player has built so many that its impossible for the gov to
      meet worker requirements they will post a clickable message in the top status bar that
      will zoom in to the planet, giving the player a chance to make adjustments. Ship Yards
      are only built if there will be a half dozen slots remaining after construction so that
      the shipyard is useful. Once a planet has all its slots built up the shipyard will be
      torn back down to construct something else. Use Renovate gov if you wish to keep it.
      No governor will tear down farms unless 3 criteria are met. The empire has to control at
      least 12 planets. The galactic bank must be recieving more food than it's sending to other
      planets. The galactic bank must have enough food in storage to feed the empire for 1 to 2
      minutes if every single farming world is destroyed. Non-farming planets will also build 1
      to 2 farms if any of those criteria are not met. If you like math the threshold formula is:
         NumPlanets * squareRoot(CityLevel) * 500
      This means if your cities are tech 1 you will need 500 food per planet. If your cities are
      tech 16 you need 2000 food times your number of planets.
      All planets capable of exporting metal, electronics or advance parts will tear down extra
      space ports not required. Farming planets (only) also take into account food production.
      If a planet has an empty slot and does not have enough export capacity they will build a
      port. They will not tear down other buildings specifically to do this. Planets with 14 or
      more slots will avoid tearing down a single cargo bay in order to keep enough resources
      on hand to do renovations quickly if the player built one.
      The Metal Mining gov prioritizes a strip mining layout. Removes structures not related to
      this task. Will not build but will allow player built ammo depots to stay on world as long
      as their metal requirements are met with local production. Will attempt to keep enough
      cities to maximize the work rate bonus to make most efficient use of slots.
      The Research gov focuses on science labs and will tear down production buildings. If the
      planet has ore reserves it will also build mines to export the metal but always ensures it
      has twice as many science labs as mines ensuring its primary purpose is not neglected. It
      will not build bonus cities to improve work rate multiplier.
      The Farming gov builds farms and also removes production buildings. It has the exact same
      behavior as the Research gov in regards to building mines. It will not build fuel depots
      but will leave player built depots that have enough local grown food to meet demands.
      The Economic gov will build 2 science labs on the galactic capital but will remove them on
      any other planet. It attempts to build a number of Mines, Electronics Factories and AdvPart
      Factories to export those resources in a 6/3/2 ratio. As ore runs out on a planet it will
      continually tear down factories and rebuild mines as needed to maintain this production
      ratio. As long as at least 1 each of mines/elecfac/advpfacs are on planet it will build
      additional cities to take advantage of the work rate multiplier for effecient use of slots.
      The Renovation gov will never build or tear down structures. As with the vanilla version it
      will only renovate. This version just prioritizes which buildings get renovated first when
      multiple buildings need upgraded, and it does so in the following order: 
         Ports, Yards, City, SciFac, Farm, Metl, Elec, Advp, Cargo, all other.
      It will queue up to 1 of each of those buildings each time the gov runs, and if it doesnt
      have at least 3 buildings queued it will look at your logistical and military buildings to
      queue a few of them.
      The Electronics gov will focus on making electronics. It will maintain the fewest number of
      mines to accomplish this task and will remove advp factories and spare mines. It will build
      cities to take advantage of work rate multiplier.
      The Advanced Parts gov will focus on exporting advps. It will maintain the fewest number of
      mines and elec factories to avoid having to import. It will build cities to take advantage
      of work rate multiplier.
      The Luxuries gov is in charge of managing Goods and Luxuries factories on your planet. It
      is aware of ore reserves and will build mines but does not attempt to take advantage of
      the work rate multiplier with bonus cities. If your Goods and Luxuries needs are being met
      and there are spare slots, the gov will build science facilities instead. It will also periodically
      check your rates of production and consumption and tear down those sci facs when you are
      in need of more Goods/Luxuries factories. If no slots are available it will also convert your
      Luxury factories into Goods factories as a last resort.
      The Shipyard gov is designed to maximize resource import from the bank for on-planet
      construction. It will build 1 shipyard for every 8 slots the planet has available for buildings.
      It will take ore reserves into account to manage mines and bonus cities to maximize ore
      extraction and remove them as appropriate. It will maintain enough cargo bays so that the
      planets entire import rate from space ports can be taken advantage of each second. All of
      the planets spare slots will go to space ports to maximize that import rate.

github project
github downloads

Galactic Armory / He3 Usage
« on: July 29, 2012, 12:28:56 PM »
They should be colonizable as we aren't putting a colony on them, but on their moons.
And thats why I also think that we should be able to harvest He3 from a gas giant from ships. We wouldnt be disturbing a moon based colony in the process so no reason to disable it once the moons are colonized


I had actually never seen that page so i was highly confused why people keep getting the 1.9 copy of the mod instead of the 1.9.1b version.  Well the mediafire link you list at the above link is LABELED as being the new version but its still the old url.  Please fix this.

Galactic Armory / Why restrict ammo storage on fighter/bomber ?
« on: July 15, 2012, 03:40:02 PM »
Curious about the reasoning for not allowing ammo containers on fighter/bomber craft.  Seems like a pointless limitation to me and while it would be easy enough to remove the restriction tag from ammo containers I can also work around the limitation by using metal storage along with ammo fabricators (which ends up being more space effecient than ammo storage).

Modding / Seronis' Snippets
« on: July 13, 2012, 11:22:04 PM »
Im finding there are a lot of pretty small changes I want to make to the vanilla game or to GA. Rather than just publish one all comprehensive mod I think i'll just show the code changes required in here, giving each snippet its own post and linking to them all from the OP.

1. improved scuttle functionality
2. self destruct command
3. subsystem specific scale limits
4. fighter/bomber ammo subsys
5. extended mount

WARNING: as common sense requires, before editing any file make sure you make a backup of it just incase you mess up.

GA: Help & Support / Updating files for consistant variable usage
« on: July 12, 2012, 01:19:39 PM »
While doing some tweaks some of the weapon systems have inconsistent usage of variable names.  Currently I updated projectile_weapons.txt so that all the weapon systems make use of the vAmmoStorage variable name that is used in other files. This will allow subsystems that want to alter ammo storage to be more uniform in doing so.  If I find others i'll update them and upload a copy. Absolutely no other values were altered. Edits uploaded here will be GA 1.9.1b files that are functionally identical, just with proper variable usage for consistency.

Modding / [solved] Odd hint behavior on new subsystem design
« on: July 10, 2012, 06:54:36 PM »
Making an engine boost subsystem that is gonna have some extreme thrust gains at the cost of even greater ratio of fuel/antimatter/power/control.  Its meant to let you attain speeds you wouldnt otherwise be able to get on a given blueprint but will cost you infrastructure space for supplying the fuel/etc. First version has the following additions to GA files modifiers.txt and

Code: [Select]
System: SlipstreamFieldGen
Name: Slipstream Field Modulator
Description: Linked engine will have vastly boosted performance
Appearance: QuantumCompressor
Explosion: subsystem_destroyed

Tags: Link
Tied To: Engines 6

Available: Techs.Engines.Level > 5
Level: Techs.Engines.Level

Size: Object.Scale / 2
HPLevel: Techs.Engines.Level
Durability: GAME_SUBSYS_MULT * 15 * Size * pow(HEALTH_CURVE,HPLevel)
Mass: 50 * Size

Costs: Metals[50 * Size * pow(SUBS_COST_CRV, Level)], Electronics[75 * Size * pow(SUBS_COST_CRV, Level)], AdvParts[150 * Size * pow(SUBS_COST_CRV, Level)], Labr[10 * Size]
Complexity: 10

nLevel: floor(Level / 4)
nSizeMax: Object.Scale * nLevel
nSizeMin: Object.Scale * 0.25

nPower:   (25 * Size) + (10 * Scale)
nControl: (10 * Size) + (25 * Scale)

Alters: GASubSysAlterations::alterThrustFactor[Object.Scale][Scale][nLevel]

To Run:

To Run:

Hints: Power[-1 * nPower], Control[-1 * nControl]

Code: [Select]
const string@ str_vThrust = "vThrust";
void alterThrustFactor(subSystem@ subSys, const string@ name, float oScale, float pdScale, float limit ) {
if( name == str_vThrust ) {
float engRatio = pdScale / subSys.size;
float objRatio = pdScale / oScale;
float accel = subSys.getVariable(str_vThrust);
float bonus = accel * engRatio * objRatio;
subSys.setVariable(str_vThrust, accel + bonus );

As i said the subsystem WORKS, but i noticed in the blueprint editor that the power and control requirements that show up in the hint is different than the overlay values that show up if you mouseover the blueprints master control or power values in the right hand sidebar. One value is exactly double what the other one claims. Any suggestions why this happens cause I dont have any *2 multipliers anywhere that would be confusing anything.

Galactic Armory / Proof of Concept size restricted subsystems
« on: July 10, 2012, 08:18:00 AM »
I brought up the idea before about having external mounts be re-sizable based on your empires ship construction and materials tech levels. Was bored so figured i would go see how difficult it would be to implement.  I added a duplicate external mount entry to 'modifiers.txt' that looks like:

Code: [Select]
System: ExternalMount2
Name: External Mount 2
Appearance: ExternalMount
Explosion: small_explosion lasting 0.5

Tags: NegatesSpace, Link
Tied To: ShipConstruction 0

Available: true
Level: 1
Size: Scale
Mass: 40 * Size

nLevel: min(Techs.ShipConstruction.Level, Techs.Materials.Level)
nSizeMax: Object.Scale
nSizeMin: Object.Scale * decay(nLevel,4)

HPLevel: Techs.Materials.Level-1 As Level
Durability: 30 * Size * pow(HEALTH_CURVE,HPLevel) * HEALTH_MULT

Costs: Metals[Size * 275 * pow(SUBS_COST_CRV, Level)]
Alters: subSysAlterations::dummyAlter

PreDamageOrder: -8
Provides: DamageRedirection
Provides: DestroyLinked

To Run:

The reduced level limits were just for testing purposes. The key points was having calculated values of  nSizeMax and nSizeMin be part of the subsystems definition.  Then in I edited the definition of the subsystem instance class so that it looked like:

Code: [Select]

class subSysEntry {
uint sysID;
float scale;
float fSizeMax;
float fSizeMin;
pos2df position;

bool exists;
bool isLink;
subSysEntry@ linksTo;

// Some display settings anchored to this entry,
// should not impact anything else
bool hovered;
float statMod;
string@ statText;

//Finds the nearest integer power of two scale
float getNearestScaleTick(float forScale, bool findGreater) {
float log2 = log(forScale) / log(2.f);

return pow(2.f, findGreater ? ceil(log2) : floor(log2) );

//Scaling up functions
bool canScaleUp() {
return scale < fSizeMax;

//Snaps to the nearest integer power of two scale greater than the current scale
void scaleUp() {
scale = min( getNearestScaleTick(scale, false) * 2.f, fSizeMax);

//Steps up by the smallest scale step
void incrementScale() {
scale = min( scale + minScale, fSizeMax);

//Scaling Down functions
bool canScaleDown() {
return scale > fSizeMin;

//Snaps to the nearest integer power of two scale lesser than the current scale
void scaleDown() {
scale = max( getNearestScaleTick(scale, true) / 2.f, fSizeMin);

//Steps down by the smallest scale step
void decrementScale() {
scale = max( scale - minScale, fSizeMin);

bool setPosition(const pos2df &in newPos) {
//Make sure that the outer edge of the Sub System doesn't go beyond the bounds of the ship's circle
if( sqrt( sqr(newPos.x) + sqr(newPos.y)) <= maxRadius - sqrt(scale) / 2.f ) {
position = newPos;
return true;
return false;

void remove() {
exists = false;
if (linksTo !is null && linksTo.linksTo is this)
@linksTo.linksTo = null;

bool checkExists() {
return exists;

//NOTE: This is slow, don't call often
void updateCollision(subSysEntry@[]& subSystems) {
// Only links get to link to something
if (!isLink)

if (linksTo !is null) {
// If the link is still valid, keep it
pos2df relPos = linksTo.position - position;
if(sqrt((relPos.x * relPos.x) + (relPos.y * relPos.y)) < (sqrt(scale) + sqrt(linksTo.scale)) / 2.f)

// Discard invalid links
if (linksTo.linksTo is this)
@linksTo.linksTo = null;
@linksTo = null;

for(uint i = 0; i < subSystems.length(); ++i) {
subSysEntry@ subSys = @subSystems[i];
if (subSys is this || !subSys.checkExists() || subSys.isLink)
pos2df relPos = subSys.position - position;
if(sqrt((relPos.x * relPos.x) + (relPos.y * relPos.y)) < (sqrt(scale) + sqrt(subSys.scale)) / 2.f) {
// Don't link if it still has a valid link
if (subSys.linksTo !is null) {
pos2df relPos = subSys.linksTo.position - subSys.position;
if(sqrt((relPos.x * relPos.x) + (relPos.y * relPos.y)) < (sqrt(subSys.scale) + sqrt(subSys.linksTo.scale)) / 2.f)

@linksTo = subSys;
@subSys.linksTo = this;

int getCollision(subSysEntry@[]& subSystems) {
if (linksTo is null)
return -1;
for(uint i = 0; i < subSystems.length(); ++i) {
subSysEntry@ subSys = @subSystems[i];
if(subSys is linksTo) {
if (!subSys.checkExists())
return -1;
return i;
return -1;

subSysEntry(uint SubSysID, float Scale, const pos2df &in pos) {
sysID = SubSysID;
@linksTo = null;
@statText = null;
statMod = 0;
scale = Scale;
position = pos;
hovered = false;
exists = true;
isLink = hasTag("Link");

float tmp;
SubSystemFactory@ fact = SubSystemFactory();
fact.objectScale = scale;
const subSystem@ sys =;

tmp = sys.getVariable("nSizeMin");
if( tmp != 0 )  fSizeMin = tmp;
else fSizeMin = minScale;
tmp = sys.getVariable("nSizeMax");
if( tmp != 0 )  fSizeMax = tmp;
else fSizeMax = maxScale;

bool hasTag(const string@ tag) {
return getSubSystemDefByID(sysID).hasTag(tag);

const Texture@ getMaterial() {
return getSubSystemDefByID(sysID).getImage();

void generate(SubSystemFactory@ fact) {
fact.objectSizeFactor = 15.f;
fact.activeScale = scale;

if (linksTo !is null && linksTo.checkExists()) {
fact.linkedScale = linksTo.scale;
fact.generateSubSystems(getSubSystemDefByID(sysID), getSubSystemDefByID(linksTo.sysID));
else {
fact.generateSubSystems(getSubSystemDefByID(sysID), null);

Main points here is that the constructor now buffers the global min and max size values into local values specific to each subsystem instance. Then if it locates those two variable names I defined in the subsystems definition it overrides the global values.

The external mount in game was properly limited to scaling between  .8 and 1.0 units in size.  Of course the formula for the min size needs tweaked and a resizable mount shouldnt be unlocked till at least tech 4 but this _was_ a proof of concept.

GA: Help & Support / [Solved] Remnant God blueprint fails to load
« on: July 10, 2012, 07:45:31 AM »
In the verbose output one of the last things printed on every game of GA i start is:

Attempted to create invalid hull 'Remnant God'
 Error: Too much space taken by SubSystems

Never considered it important enough to post before but now that you have your own sub forum I might as well. Probably related to all your hull space changes in GA.

Modding / Where is the governor tick rate handled?
« on: June 26, 2012, 02:23:09 PM »
As a game progresses the rate that governors check the status of a fully developed planet seems to decrease.  I havent had issues with governors on a planet with empty slots but when a planet has buildings that should be tore down the game handles this fairly quickly at the beginning and gets slower and slower later on.

Is the code that tells the governor to be checked in a script somewhere or is this limited to the engine and not controllable?  Also what exactly does the  'waitempty/' tag in the xml file do?  My _assumption_ is that the handling for this tag is to blame for the slowness in completing tasks on developed planets.

Modding / [MOD] Galactic Ministries for SR 1.2.0 / GA 1.9.1b
« on: June 18, 2012, 01:09:46 PM »
Open up the zip file and copy the Data Files directory into your GA mod directory, choosing to overwrite files the two times you are prompted to do so. Currently I dont know how to package the mod to run side-by-side with GA so you have to do this.

Mod Description:
I have replaced the governors for Renovation, Economy, Metal  Mining, Research and Farming with more intelligent ministers. The renovation governor just prioritizes which buildings get renovated first. The other governors all ensure you have enough cities to get the most effecient production when taking into account your work rate bonus and that you have enough ports to export everything you produce. 

Farming and Research governors have been sent to remedial metallurgy school and now understand that ignoring a planets ore reserves is not benificial to the long term good of the Empire. They will build a number of metal mines based on just how much ore is left in planetary reserves, but will never build more mines than their primary building (farms,sci labs). They will also tear these mines down as ore runs out in order to build more of their primary building, adjusting ports when appropriate. These governors will also only  build a shipyard if there are over a half dozen empty slots left to be built up and will tear down the shipyard when all renovations are completed in order to make room for their main building. Cargo holds will not be built on worlds with less than a dozen slots as this would get in the way of their main purpose on these small worlds.

The economic governor was retrained and now knows that when planetary ore reserves run out they need to convert some of their electronics and advparts factories to mines in order to avoid having to import metal from the galactic reserves. He is also willing to build a few science facilities ONLY on the homeworld if employed there so that early game research isnt neglected prior to making dedicated research worlds. Any economic governor will build up to 2 farms per planet if space permits and either the empire is currently eating more food than it makes, OR he just notices that the food reserves in the bank dont meet a minimum safety threshold. He will never tear down a building to specifically build a farm. He will tear down farms automatically as long as the empire has at least 12 total systems under its control (enough to have dedicated farm worlds) and its both profiting food AND meets twice the minimum safety threshold of food reserves in the bank. He will then build more appropriate buildings. The player should keep in mind that a planet with under 25 slots does not have enough space to have a proper ratio of m/e/a factories and have enough cities to run at full efficiency when ore runs out and mines output is reduced. Consider converting these worlds to another governor once ore is depleted.

The Metal Mining governor prioritizes mines (with appropriate city numbers) over everything else but will leave farms in place until the same conditions the Economic governor leaves them. Will destroy when needed to build more mines/ports. On larger worlds he will build ammunition depots per half dozen mines. Similarly the farm gov will build a fuel depot per half dozen farms.

The Planet window has also been updated so that the [ and ] keys when pressed act as though you clicked the  Prev Planet or Next Planet buttons. This makes navigating between planets easier as you no longer require the mouse. On the teraforming page just pressing 'enter' will start teraforming if available.

I've been working on replacing the governors with ones that fit my own play style better. My renovation governor just prioritizes which buildings get renovated first (and will eventually make sure resources are already on hand before attempting any renovation to prevent stalling the economy). My farm and research governors are aware that metal is important too, and will keep a number of metal mines built based on how much ore is left in the planet, also keeping a 1-1 ratio of cities/mines for peak efficiency without building more mines than their primary building (farms/scilabs) regardless of how much ore is left. My metal mining governor attempts to build as many mines as it can, keeping the 1-1 city/mine ratio and all of my governors keep the minimum number of ports to guarantee exports are handled without waste. I had no problems getting these governors to do their job and hadnt run into any accidental patterns of tearing down and rebuilding things UNTIL i added an Economic governor.

His job is more complex trying to maintain an export ratio of 1-1-1 for metal/elecs/advpts and ports to handle the production rate. He will build up to two farms per planet _IF_ you are running a food deficit OR dont have what he considers a large enough safety buffer of reserve food stock in the bank. This starts at about 250 food / planet when you have very few planets and as your empire expands he wants a larger amount of food PER planet kept available. He will demolish these farms for other buildings once you are no longer running a deficit AND have twice the minimum food reserves so as you build farming worlds this will be done automatically. If this is your Homeworld he also prioritizes 2 slots for science facilities but will destroy them on any other planet.

The economic governor SEEMED to be following his build plan properly but i noticed that on some worlds once all the slots are filled he will demolish something random. I've seen him destroy the galactic capital on 2 test games. On one planet he got stuck in a loop of destroying and rebuilding a shipyard (a building I ONLY tear down if there is more than 1. NEVER tear down the last).  I read through the code a few times and logically there is a small chance of a destroy/rebuild loop when the final building puts you over the number of required workers but the governor is choosing to destroy things that shouldnt be what is getting destroyed. I'm a bit baffled and think a 2nd set of eyes on my code could be useful.

I'm looking to make my governors a little smarter about construction and renovations so that unless the planet has the resources on hand they wont automatically start building. Basically what i need would look similar to:

Code: [Select]
float cost_metl, cost_elec, cost_advp;

const subSystemDef@ struct = null;
@struct = structlist.getStructure(pos).get_type();
lvl_from = structlist.getStructure(pos).get_level();
lvl_to = //what our appropriate research allows;

calculateBuildCost( struct, lvl_from, lvl_to, cost_metl, cost_elec, cost_advp );

Does this method exist or is there some state I can access to pull the information form the engine?

Suggestions / Steam Sale
« on: June 03, 2012, 07:39:15 PM »
PLEASE make certain the game goes on sale during the yearly steam summer of gaming week. Its proven worth the full price i paid but steam sales always tend to pick up a bunch of budget concious players and if its cheap enough I have kids and nephews that I wouldnt mind getting copies for to try to get them into it.  (they already like Civ V and starcraft so are likely in your target audience)

Trying to get a little debugging feedback in some code i am writing and I had assumed that using


would send that output to either the console window in-game or to log.txt.  Messages did not show up in either location. Any advice?

I've already edited the structures file so that the capital buildings have a level based on the average of several research fields. When a NEW planet is being colonized the capital buildings created are of the appropriate level and perform as expected.  Capital buildings are 'stuck' at the level they are created though and after a renovation (which DOES attempt to run) the capital building is the same level it was before the attempt.

If i just destroy the capital building and let a governor build a new one the new one will be the correct level. Its only the renovations that are failing. Anyone with experience in this?

I've had a fair amount of success doing some tweaks to the standard game and to an improved governor mod I downloaded so i attempted to do a basic mod from scratch to just add some extra traits. Started with a fresh mod directory containing modinfo.txt and copied over  the files i thought would be needed along with the following changes to them:

Game Data/traits.xml
added following code in the Technology category section
Code: [Select]
<trait id="aioverlord" name="#RT_AIOVERLORD_NAME" desc="#RT_AIOVERLORD_DESC" flavor="#RT_AIOVERLORD_FLAVOR" cost="1">
<hook type="apply" func="Traits::levelComputers" arg0="1" />
<hook type="apply" func="Traits::levelScience" arg0="2" />

added at same location in file as the 'good biology' trait
Code: [Select]
#RT_AIOVERLORD_FLAVOR: An AI accidentally created in a government experiment luckily resulted in an entity willing to share its secrets with society and even benifit further research advancements.
#RT_AIOVERLORD_DESC: Computers start at level 1. General Science is increased 2 levels.

Game Data/scripts/server/
added this immediately after the similar method for biology
Code: [Select]

void levelScience(Empire@ emp, float Level) {
LevelTech(emp, "Science", Level);

void levelComputers(Empire@ emp, float Level) {
LevelTech(emp, "Computers", Level);

Thats what I gathered would be needed from what i've read of the code the past few days. When i choose this mod in a new game the entry for the new trait fails to display the localized name and instead has some garbage text mentioning the text style it thinks should be used (font italic etc). Its still selectable so I figured i just messed up the localization entry and forgot a piece somewhere but even in the game the computer tech is not unlocked to level 1 and general science has not been increased 2 levels.

I decided to download a few other mods that add traits and ALL of them (advanced traits, GA, some other random one) dont try to use localization tags where they added traits but instead just type the field contents directly into traits.xml.   Is there some reason other mods dont use the same localization that the vanilla files use?  Is it the failed localization that is causing the two technologies to not be improved or did i forget something else too ?

Bug Reports / How big does a bug need to be to be worth fixing?
« on: May 23, 2012, 09:29:10 PM »
In Economy::processOre() you're awarding 40% too much ore to an empire with the lossy_mining trait during the ONE tick that ore runs out on a planet. I'm on way to work soon so no time to do it now but is it worth posting a fix?

((sorry for the nitpick level issue, just reading through all the script files to familiarize myself with the code for some personal tweaks i want to do))

More specifically the lossy_mining penalty just doesnt apply to a planet that has run out of its 'base' ore with how the consumption/rate is computed in that method

Pages: [1] 2