% % Auto Tasks % % Some useful auto tasks I use. Feel free to add more and/or improve % the existing ones. % % Needs PCC 1.1.2 or later. % Print "[auto.q 07/Oct/2002]" % Lady-Royale auto task: automatically unload ship, again and again. % Normally, one would set the Lady to "bdm" or "Beam down credits", % this spares the FC/mission slot for something more useful. % New 16/Aug/2002: when you set the base to "unload ships" (so the % colonists will be subject to growth and taxation), this will % automatically load the clans onto the Lady again. Sub AutoLady Local colo Do CargoUnload "10000$", "n" colo := Cargo.Colonists WaitOneTurn If Cargo.Colonists < colo Then colo := Min(colo - Cargo.Colonists, Planet(Orbit$).Colonists - 1) CargoUpload colo & "c", "n" EndIf Loop EndSub % Outpost Autobuilder: for small outposts, standard Auto Build is % suboptimal, because it just builds without paying attention to % sensor visibility. When I have an outpost deep in enemy territory % (e.g. from my HYPing probe), invisibility is paramount. The idea % of this algorithm is % - first build a few factories. Nothing goes without these. % - now "max out" mines and factories slowly up to the "scannable" % limit. In addition, try to build one defense post per turn % - when the defense posts reach "unscannable" level, we can resort % to normal auto build. This function sends you a notify message (and % continues with the next step in the auto task) when this happens. % The number of DPs to build per turn can be specified as optional % parameter. % New 06/Oct/2002: locking Sub AutoOutpostBuild (Optional n) Local AutoOutpostBuild_ok With Lock("p" & Id & ".build") Do Do OutpostBuild n If AutoOutpostBuild_ok Then Break WaitOneTurn Loop EndWith Notify "Defense goals reached on " & Name & "; you can start normal auto build now." EndSub % One turn's worth of outpost building. Sub OutpostBuild (Optional n) Local mt = Cfg("MinesForDetectable")-1 Local ft = Cfg("FactoriesForDetectable")-1 Local dt = Cfg("DefenseForUndetectable") Local Build.Remainder If IsEmpty(mt) Then mt := 20 If IsEmpty(ft) Then ft := 15 If IsEmpty(dt) Then dt := 15 Local minf = Min(ft, 5) If Factories < minf Then BuildFactories minf - Factories, "n" If Factories >= 5 Then BuildDefense If(IsEmpty(n),1,n), "n" If Factories < ft Then BuildFactories ft - Factories, "n" If Mines < mt Then BuildMines mt - Mines, "n" EndIf % this one's only successful when we already have reached the mi/fa % goals -> attempt to build up defense in one step If Defense < dt Then BuildDefense dt - Defense, "n" If Defense >= dt Then Try AutoOutpostBuild_ok:=1 EndSub