% % Cloaked Ship Detection using `bum'/`btm' % % First attempt to detect (cloaked) ships. If a cloaked ship orbits % your planet, and your have the FCode set to `bum', the cloaked ship % will receive your money, and you'll know that there was a cloaked % ship (because the money is gone). This also works with ships and `btm'. % This is a (simple) attempt of doing this in a script. To use, % + start the routine `BumDet' from the planet, or `BtmDet' from a ship. % Either, by invoking it from the calculator, or by making an auto task. % + ensure that this subroutine gets to see your final turn. % Unfortunately, this can't yet (PCC 1.1) be automated. Right now, % PCC runs sleeping scripts when it starts. So either reload your % turn into PCC and exit again just before MakeTurn, or manually run % all `BumDet' processes (using the process manager) just before you % exit PCC; % + you'll get a notify message when this routine thinks it succeeded; % + to end this, kill the process in the process manager, or change the % friendly code. % % History: % + 03/Dec/2000 First version, after an idea by Piotr Winiarczyk % + 08/Apr/2002 updated for PCC 1.0.18; include tax gain in predictions % + 03/Jul/2002 works with `btm', too % + 09/Aug/2002 don't get confused by growth % + 25/Aug/2002 fixed stupid typo on BtmDet % % Needs PCC 1.0.18 or higher. % Print "[bum.q 25/Aug/2002]" % `btm' on ships Sub BtmDet Local mc, t, x, y SetFCode "btm" Do t = Turn mc = Cargo.Money x = Loc.x % must save location in case ship moves y = Loc.y Stop If t<>Turn And Cargo.Money"btm" Then Print "Ship ", Id, ": fcode changed -- exiting `btm' detector." End EndIf Loop EndSub % `bum' on planets Sub BumDet Local mc, t, ctax, ntax, cpop, npop SetFCode "bum" Do t = Turn mc = Money cpop = Colonists npop = Natives Stop BumDet.CalcTaxes If t<>Turn And Money"bum" Then Print "Planet ", Id, ": fcode changed -- exiting `bum' detector." End EndIf Loop EndSub % Compute tax gain. Must be less or equal to actual income to not yield % false alerts. We don't bother getting rounding behaviour correct. Sub BumDet.CalcTaxes Local ntr = Cfg('NativeTaxRate') If IsEmpty(ntr) Then ntr := Cfg('ColonistTaxRate') ctax := If(Colonists.Happy$ <= 30, 0, Cfg('ColonistTaxRate') * (cpop * Colonists.Tax \ 1000) \ 100) If Natives And Natives.Race$<>5 Then ntax := If(Natives.Happy$ <= 30, 0, ntr * Min(cpop, Natives.Tax * Natives.Gov$ * npop \ 5000) \ 100) If Natives.Race$=6 Then ntax := 2*ntax Else ntax := 0 EndIf EndSub