It consists of the homeworld appearing in wrong orbits. I've introduced much more detailed temperature falloff generation of planets - that works like a charm. The homeworld however does not always generate in the goldilock zone, where planets of it's type appears. About 50% of the time it's either too close to the star or so far away making the system so large, that the zoom is broken. The other half of the time it generates perfect. The same applies for the secondary planet starting option.

This is the code for it.

`// {{{ Homeworld Generation`

int[] playerTeams;

vector[] playerPositions;

Planet@ setupStandardHomeworld(System@ sys, Empire@ emp) {

if(!emp.isValid() || emp.ID < 0)

return null;

Empire@ space = getEmpireByID(-1);

float homeworldYear = 0.f;

Planet@ planet = null;

int team = int(emp.getStat("Team"));

int redos = 50;

int pass = 4;

do {

Planet@ newPlanet = getRandomPlanet(sys);

bool livable = sys.toObject().getStat(space, strLivable) > 0.f;

if (pass > 0 && livable) {

// Player distance

float glxRadius = getGalaxy().toObject().radius;

float minPlayerDist = 1.f * glxRadius * 2.f;

float maxAllyDist = 0.f;

float fuzz = 1.f / float(5 - pass);

vector pos = sys.toObject().getPosition();

uint playerCnt = playerTeams.length();

for (uint i = 0; i < playerCnt; ++i) {

int otherTeam = playerTeams[i];

float otherDist = playerPositions[i].getDistanceFrom(pos);

if (otherTeam == team && team != 0)

maxAllyDist = max(maxAllyDist, otherDist);

else

minPlayerDist = min(minPlayerDist, otherDist);

}

livable = (minPlayerDist > playerDist * glxRadius * 2.f * fuzz)

&& (maxAllyDist < allyDist * glxRadius * 2.f * fuzz);

}

if(livable && !(newPlanet is null)) {

@planet = @newPlanet;

break;

}

System@ newSys = getRandomSystem();

if(newSys is null)

continue;

@sys = @newSys;

@planet = @newPlanet;

if (pass >= 0 && redos == 1) {

if (pass == 1)

warning("Couldn't find a fitting system for "+emp.getName()+" in the first passes.");

redos = 25;

pass -= 1;

}

} while(redos-- > 0);

// Record this player's position

uint n = playerTeams.length();

playerTeams.resize(n+1);

playerPositions.resize(n+1);

playerTeams[n] = team;

playerPositions[n] = sys.toObject().getPosition();

updateLoadScreen(emp.getName()+" born.");

if(sys.hasTag("JumpSystem") && balancedStart)

sys.removeTag("JumpSystem");

Orbit_Desc orbDesc;

sys.toObject().setStat(space, strLivable, 0.f);

Planet_Desc plDesc;

float pRad = homeworldPlanetRadius;

plDesc.PlanetRadius = pRad;

plDesc.RandomConditions = false;

string@ name = "";

orbDesc.Eccentricity = 1.f;

if (planet is null) {

// Just creating a new planet, this may cause colliding planet syndrome. Right smack in the greenzone

orbDesc.Radius = (tempFalloffRadius * starDesc.Temperature * starDesc.Radius) / 850.f;//784.f;

}

else {

// We are swapping a random planet from the system with our own

orbDesc.Radius = (tempFalloffRadius * starDesc.Temperature * starDesc.Radius) / 850.f; //784.f;

Object@ plObj = planet.toObject();

disregardPlanets.insert(plObj.uid);

name += plObj.getName();

// Destroy the planet without showing an explosion

planet.eradicate();

}

float YYawOffset = 0;

float YPitchOffset = 0;

if(randomf(1.f) < 0.5f)

orbDesc.Eccentricity += randomf(0.05f, 0.1f);

else

orbDesc.Eccentricity -= randomf(0.05f, 0.1f);

orbDesc.Yaw = randomf(-0.11f,0.11f);

YYawOffset += sin(orbDesc.Yaw * (180/Pi)) * orbDesc.Yaw * orbDesc.Radius;

orbDesc.Offset.z += (orbDesc.Yaw * orbDesc.Radius) - (YYawOffset * cos(orbDesc.Yaw * (180/Pi)));

orbDesc.Pitch = randomf(-0.11f,0.11f);

YPitchOffset += sin(orbDesc.Pitch * (180/Pi)) * orbDesc.Pitch * orbDesc.Radius;

orbDesc.Offset.x += (orbDesc.Pitch * orbDesc.Radius) - (YPitchOffset * cos(orbDesc.Pitch * (180/Pi)));

orbDesc.Offset.y += YYawOffset + YPitchOffset;

//Change for random OLD terran

plDesc.setPlanetType( getPlanetTypeID( "gaianterran1" ));

// plDesc.setPlanetType(getPlanetTypeID("rock"+rand(1, 16)));

//Setup orbit information based on the star

SysObjList children; children.prepare(sys);

if(children.childCount > 0) {

Object@ child = children.getChild(0);

Star@ star = @child;

if(@star != null) {

//float radiusGrab = orbDesc.Radius;

//orbDesc.Radius += -1.f * radiusGrab;

orbDesc.Radius = (tempFalloffRadius * starDesc.Temperature * starDesc.Radius) / 784.f;

orbDesc.MassRadius = sqrt(sqrt(child.radius)) * 100.f;

orbDesc.Mass = sqrt(sqrt(child.radius)) * starMassFactor * 100.f;

float YYawOffset = 0;

float YPitchOffset = 0;

if(randomf(1.f) < 0.5f)

orbDesc.Eccentricity += randomf(0.05f, 0.1f);

else

orbDesc.Eccentricity -= randomf(0.05f, 0.1f);

orbDesc.Yaw = randomf(-0.11f,0.11f);

YYawOffset += sin(orbDesc.Yaw * (180/Pi)) * orbDesc.Yaw * orbDesc.Radius;

orbDesc.Offset.z += (orbDesc.Yaw * orbDesc.Radius) - (YYawOffset * cos(orbDesc.Yaw * (180/Pi)));

orbDesc.Pitch = randomf(-0.11f,0.11f);

YPitchOffset += sin(orbDesc.Pitch * (180/Pi)) * orbDesc.Pitch * orbDesc.Radius;

orbDesc.Offset.x += (orbDesc.Pitch * orbDesc.Radius) - (YPitchOffset * cos(orbDesc.Pitch * (180/Pi)));

orbDesc.Offset.y += YYawOffset + YPitchOffset;

}

}

children.prepare(null);

plDesc.setOrbit(orbDesc);

Planet@ pl = sys.makePlanet(plDesc);

Object@ obj = pl.toObject();

obj.setOwner(emp);