{$A+$B+$D+$E-$F+$G-$I+$K-$L+$N+$O-$P-$Q+$R+$S+$T+$V+$W-$X-$Y-} UNIT KRandMax; INTERFACE USES hstutils; CONST ini_MinColClansToBeTaxed=5000; ini_MinNatClansToBeTaxed=100; cfg_CrystalsLikeDesert=TRUE; {DA SOSTITUIRE!!!!} None= 0; Humanoid= 1; Bovinoid= 2; Reptilian= 3; Avian= 4; Amorphous= 5; Insectoid= 6; Amphibian= 7; Ghipsoldal= 8; Siliconoid= 9; Anarchy= 1; PreTribal= 2; EarlyTribal= 3; Tribal= 4; Feudal= 5; Monarchy= 6; Representative= 7; Participatory= 8; Unity= 9; Fed= 1; Lizard= 2; BirdMan= 3; Fascist= 4; Privateer= 5; Cyborg= 6; Crystal= 7; Empire= 8; Robotic= 9; Rebel= 10; Colonial= 11; FUNCTION FMaxNatClans(ppianeta:ppdata):LONGINT; FUNCTION FMaxColClans(ppianeta:ppdata):LONGINT; FUNCTION FCalcColTaxSafe(ppianeta:ppdata):BYTE; FUNCTION FCalcColTaxGrow(ppianeta:ppdata):BYTE; FUNCTION FCalcNatTaxSafe(ppianeta:ppdata):BYTE; FUNCTION FCalcNatTaxGrow(ppianeta:ppdata):BYTE; FUNCTION FGovRate(govtype:BYTE):REAL; FUNCTION FNatFeelChange(ppianeta:ppdata):INTEGER; FUNCTION FColFeelChange(ppianeta:ppdata):INTEGER; FUNCTION FMaxTaxCollected(ppianeta:ppdata):BYTE; FUNCTION FNatTaxWithFeelChange(feelchange:INTEGER;ppianeta:ppdata):BYTE; FUNCTION FColTaxWithFeelChange(feelchange:INTEGER;ppianeta:ppdata):BYTE; FUNCTION FNatTaxNotToFallBelow(limit:INTEGER;ppianeta:ppdata):BYTE; FUNCTION FColTaxNotToFallBelow(limit:INTEGER;ppianeta:ppdata):BYTE; {--------------------------------------------------------------------------} IMPLEMENTATION CONST FeelGrowLimit= 70; FeelTaxLimit= 40; FUNCTION FMaxNatClans(ppianeta:ppdata):LONGINT; BEGIN FMaxNatClans := TRUNC((15159000*SIN(ppianeta^.temperature * PI / 100))/100) END; FUNCTION FMaxColClans(ppianeta:ppdata):LONGINT; BEGIN FMaxColClans := 100000; END; FUNCTION FGovRate(govtype:BYTE):REAL; BEGIN CASE govtype OF Anarchy : FGovRate := 0.2; PreTribal : FGovRate := 0.4; EarlyTribal : FGovRate := 0.6; Tribal : FGovRate := 0.8; Feudal : FGovRate := 1.0; Monarchy : FGovRate := 1.2; Representative : FGovRate := 1.4; Participatory : FGovRate := 1.6; Unity : FGovRate := 1.8; END; END; FUNCTION FNatFeelChange(ppianeta:ppdata):INTEGER; VAR temp:INTEGER; BEGIN WITH ppianeta^ DO BEGIN temp := TRUNC( 5 + government/2 - SQRT(clansnative/10000.0) - (mines+factories)/200); IF raceNative=avian THEN INC(temp,10); END; FNatFeelChange := temp; END; FUNCTION FColFeelChange(ppianeta:ppdata):INTEGER; VAR TargetTemp,TempDivisor:BYTE; temp:INTEGER; BEGIN WITH ppianeta^ DO BEGIN IF ((race=Crystal) AND cfg_CrystalsLikeDesert) THEN BEGIN TargetTemp := 100; TempDivisor := 66; END ELSE BEGIN TargetTemp := 50; TempDivisor := 33; END; FColFeelChange := TRUNC (10 - SQRT(clans / 10000.0) - ABS(temperature - TargetTemp)/TempDivisor - (mines+factories)/300); END; END; FUNCTION FMaxTaxCollected(ppianeta:ppdata):BYTE; VAR govrate:REAL; BEGIN WITH ppianeta^ DO BEGIN govrate := FGovRate(government); IF (clans >= (clansnative*0.1*govrate)) THEN FMaxTaxCollected := 100 ELSE FMaxTaxCollected := ROUND((clans/(clansnative*0.1*govrate))*100); END; END; FUNCTION FNatTaxWithFeelChange(feelchange:INTEGER;ppianeta:ppdata):BYTE; VAR AvianGain:BYTE; BEGIN WITH ppianeta^ DO BEGIN IF RaceNative=Avian THEN AvianGain := 10 ELSE AvianGain := 0; FNatTaxWithFeelChange := ABS(ROUND( ( feelchange - (5 + government/2 - SQRT(clansnative/10000.0) - (mines + factories)/200 + AvianGain ) ) / 0.85 ) ); END; END; FUNCTION FColTaxWithFeelChange(feelchange:INTEGER;ppianeta:ppdata):BYTE; VAR TargetTemp,TempDivisor: BYTE; BEGIN WITH ppianeta^ DO BEGIN IF ((race=Crystal) AND cfg_CrystalsLikeDesert) THEN BEGIN TargetTemp := 100; TempDivisor := 66; END ELSE BEGIN TargetTemp := 50; TempDivisor := 33; END; FColTaxWithFeelChange := ABS( ROUND( (-feelchange + (10 - SQRT(clans/10000.0) - ABS(temperature - TargetTemp)/TempDivisor - (mines + factories)/300 ) ) / 0.8 ) ); END; END; FUNCTION FNatTaxNotToFallBelow(limit:INTEGER;ppianeta:ppdata):BYTE; BEGIN FNatTaxNotToFallBelow := FNatTaxWithFeelChange(limit - ppianeta^.feelnative,ppianeta) END; FUNCTION FColTaxNotToFallBelow(limit:INTEGER;ppianeta:ppdata):BYTE; BEGIN FColTaxNotToFallBelow := FColTaxWithFeelChange(limit - ppianeta^.feel,ppianeta) END; FUNCTION FCalcColTaxSafe(ppianeta:ppdata):BYTE; BEGIN FCalcColTaxSafe := FColTaxNotToFallBelow(FeelTaxLimit,ppianeta); END; FUNCTION FCalcColTaxGrow(ppianeta:ppdata):BYTE; VAR fchange : INTEGER; BEGIN fchange := FColFeelChange(ppianeta); WITH ppianeta^ DO IF (feel+fchange) >= 100 THEN FCalcColTaxGrow := FColTaxNotToFallBelow (FeelGrowLimit-fchange,ppianeta) ELSE FCalcColTaxGrow := 0; END; FUNCTION FCalcNatTaxSafe(ppianeta:ppdata):BYTE; VAR maxposstax,maxgrowtax:BYTE; BEGIN WITH ppianeta^ DO BEGIN IF racenative=Amorphous THEN FCalcNatTaxSafe := 0 ELSE BEGIN maxposstax := FMaxTaxCollected(ppianeta); maxgrowtax := FNatTaxNotToFallBelow(FeelTaxLimit,ppianeta); IF maxposstax < maxgrowtax THEN FCalcNatTaxSafe := maxposstax ELSE FCalcNatTaxSafe := maxgrowtax; END; END; END; FUNCTION FCalcNatTaxGrow(ppianeta:ppdata):BYTE; VAR maxposstax,maxgrowtax:BYTE; fchange:INTEGER; BEGIN fchange := FNatFeelChange(ppianeta); WITH ppianeta^ DO BEGIN IF racenative=Amorphous THEN FCalcNatTaxGrow := 0 ELSE IF (feelnative+fchange) >= 100 THEN BEGIN maxposstax := FMaxTaxCollected(ppianeta); maxgrowtax := FNatTaxNotToFallBelow (FeelGrowLimit - fchange,ppianeta); IF maxposstax < maxgrowtax THEN FCalcNatTaxGrow := maxposstax ELSE FCalcNatTaxGrow := maxgrowtax END ELSE FCalcNatTaxGrow := 0; END; END; {--------------------------------------------------------------------------} BEGIN END.