home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
BBSONLIN
/
SUPDOM1.ZIP
/
MAINTAIN.DOM
< prev
next >
Wrap
Text File
|
1991-03-13
|
16KB
|
437 lines
{ for Dominions! version 2.00TC - October 1989 }
{ for Super Dominions v 0.10 - August 1990 }
{+!+!+!+!+!+!+!+!+!+!+ Maintenance Procedures +!+!+!+!+!+!+!+!+!+!+!+!+}
procedure Production;
Var
LoopPro, Owner_Temp : Integer;
Technology_Percent : Byte;
Begin
print ('Producing goods');
for LoopPro := 1 to Number_of_Planets do
if (Planet[LoopPro].Owner > 0) and (Planet[LoopPro].Owner <= Number_of_Players) then
Begin
Owner_Temp := Planet[LoopPro].Owner;
Empire[Owner_Temp].Industry_Units :=
Empire[Owner_Temp].Industry_Units + RoundOff (Planet[LoopPro].Population / 1000 *
(Planet[LoopPro].Industry_Percent / 100) * sqrt(Planet[LoopPro].Industrial_Level));
Technology_Percent := 100 - Planet[LoopPro].Industry_Percent;
Empire[Owner_Temp].Technology_Units :=
Empire[Owner_Temp].Technology_Units + RoundOff (Planet[LoopPro].Population / 2500 *
(Technology_Percent / 100) * sqrt(Planet[LoopPro].Industrial_Level));
End;
End;
procedure Reproduce;
Var
LoopRep : Integer;
Begin
print ('Increasing populations');
for LoopRep := 1 to Number_of_Planets do
Begin
if (Planet[LoopRep].Owner > 0) and (Planet[LoopRep].Owner <= Number_of_Players) then
Planet[LoopRep].Population := RoundOff (Planet[LoopRep].Population *
(Planet[LoopRep].Habitability / 1000 + 1.05));
if (Planet[LoopRep].Owner = 0) or (Planet[LoopRep].Owner = 31) then
Planet[LoopRep].Population := RoundOff (Planet[LoopRep].Population *
(Planet[LoopRep].Habitability / 2000 + 1.05));
End;
End;
procedure Change_Date;
Var
NewDate_File : File of Integer;
Begin
print ('Changing Date');
CurMonth := CurMonth + 1;
if CurMonth = 13 then
Begin
Year := Year + 1;
CurMonth := 1;
End;
End;
procedure Change_Happenings;
Var
Happenings_File : Text;
Begin
print ('Updating Happenings');
assign (Happenings_File, 'Yesterda.Dom');
Erase (Happenings_File);
Add_On (' ');
assign (Happenings_File, 'Today.Dom');
Rename (Happenings_File, 'Yesterda.Dom');
assign (Happenings_File, 'Today.Dom');
rewrite (Happenings_File);
write (Happenings_File, Month[CurMonth],' ',Year, ^M, ^J);
write (Happenings_File, '~~~~~~~~~~~~~', ^M, ^J);
close (Happenings_File);
End;
procedure Determine_Losses (Attack_Damage,Defense_Damage,LoopMS,Destination : Integer);
Var
LoopDL, Which_Lost, Total_Ships : Integer;
Which_Type_Lost : Byte;
k : real;
Begin
Repeat
with Squadron[LoopMS] do
Total_Ships := Ships[1]+Ships[2]+Ships[3]+Ships[4]+Ships[5]+Ships[6]+Ships[7];
Which_Lost := Random(Total_Ships) + 1;
with Squadron[LoopMS] do
Begin
if Which_Lost <= Ships[1] then Which_Type_Lost := 1;
total_ships:=ships[1];
for LoopDL := 2 to Number_of_Ships do
Begin
if (Which_Lost>Total_Ships) and (Which_Lost<=Total_Ships+Ships[LoopDL]) then
Which_Type_Lost := LoopDL;
Total_Ships := Total_Ships + Ships[LoopDL];
End;
end;
k := Random(100);
if k <= Defense_Damage / Ship_Damage[Which_Type_Lost] * 100 then
Squadron[LoopMS].Ships[Which_Type_Lost] :=
Squadron[LoopMS].Ships[Which_Type_Lost] - 1;
Defense_Damage := Defense_Damage - Ship_Damage[Which_Type_Lost];
if (Squadron[LoopMS].Ships[1] = 0) and (Squadron[LoopMS].Ships[2] = 0)
and (Squadron[LoopMS].Ships[3] = 0) and (Squadron[LoopMS].Ships[4] = 0)
and (Squadron[LoopMS].Ships[5] = 0) and (Squadron[LoopMS].Ships[6] = 0)
and (Squadron[LoopMS].Ships[7] = 0)
then Defense_Damage := 0
Until Defense_Damage < 1;
Repeat
with Planet[Destination] do
Total_Ships := Ships[1]+Ships[2]+Ships[3]+Ships[4]+Ships[5]+Ships[6]+Ships[7]+Defense_Bases;
Which_Lost := Random(Total_Ships) + 1;
with Planet[Destination] do
Begin
if Which_Lost > (Total_Ships - Defense_Bases) then { PDB Hit }
begin
if (Attack_Damage / PDB_Damage) > 0.75 then
Defense_Bases := Defense_Bases - 1;
Attack_Damage := Attack_Damage - PDB_Damage;
end
else
begin
if Which_Lost <= Ships[1] then Which_Type_Lost := 1;
Total_Ships := Ships[1];
for LoopDL := 2 to Number_of_Ships do
Begin
if (Which_Lost>Total_Ships) and (Which_Lost<=Total_Ships+Ships[LoopDL]) then
Which_Type_Lost := LoopDL;
Total_Ships := Total_Ships + Ships[LoopDL];
end;
k := Random(100);
if k <= Attack_Damage / Ship_Damage[Which_Type_Lost] * 100 then
Planet[Destination].Ships[Which_Type_Lost] := Planet[Destination].Ships[Which_Type_Lost] - 1;
Attack_Damage := Attack_Damage - Ship_Damage[Which_Type_Lost];
end;
if (Ships[1] = 0) and (Ships[2] = 0)
and (Ships[3] = 0) and (Ships[4] = 0)
and (Ships[5] = 0) and (Ships[6] = 0)
and (Ships[7] = 0)
then Attack_Damage := 0;
End;
Until Attack_Damage < 1;
End;
procedure New_Owner (Which_Planet, Owner, ExOwner : Integer);
Begin
if Planet[Which_Planet].Radar = 1 then
Empire[ExOwner].Radars[1] := Empire[ExOwner].Radars[1] - 1;
if Planet[Which_Planet].Radar = 2 then
Empire[ExOwner].Radars[2] := Empire[ExOwner].Radars[2] - 1;
if Planet[Which_Planet].Radar = 3 then
Empire[ExOwner].Radars[3] := Empire[ExOwner].Radars[3] - 1;
Planet[Which_Planet].Radar := 0;
End;
procedure Fight (Owner, LoopMS, Destination : Integer; Var Messages : Messagerecs);
Var
Attack_Damage, Defense_Damage, LoopF, LoopRF, ExOwner, Winner : Integer;
temp_owner : byte;
Begin
Repeat
temp_owner := owner + 30;
Attack_Damage := 0;
Defense_Damage := 0;
Winner := 0;
for LoopRF := 1 to Number_of_Ships do
begin
if Squadron[LoopMS].Ships[LoopRF] > 0 then
for LoopF := 1 to Squadron[LoopMS].Ships[LoopRF] do
Attack_Damage := Attack_Damage + Random(Ship_Attack[LoopRF]+1)+Ship_Attack[LoopRF];
if Planet[Destination].Ships[LoopRF] > 0 then
for LoopF := 1 to Planet[Destination].Ships[LoopRF] do
Defense_Damage := Defense_Damage + Random(Ship_Defense[LoopRF]+1)+Ship_Defense[LoopRF];
end;
if Planet[Destination].Defense_Bases > 0 then
for LoopF := 1 to Planet[Destination].Defense_Bases do
Defense_Damage := Defense_Damage + Random(PDB_Defense+1)+PDB_Defense;
if (Planet[Destination].Ships[1] = 0) and (Planet[Destination].Ships[2] = 0)
and (Planet[Destination].Ships[3] = 0) and (Planet[Destination].Ships[4] = 0)
and (Planet[Destination].Ships[5] = 0) and (Planet[Destination].Ships[6] = 0)
and (Planet[Destination].Ships[7] = 0)
then Winner := temp_Owner;
if Winner=0 then Determine_Losses(Attack_Damage,Defense_Damage,LoopMS,Destination);
if (Planet[Destination].Ships[1] = 0) and (Planet[Destination].Ships[2] = 0)
and (Planet[Destination].Ships[3] = 0) and (Planet[Destination].Ships[4] = 0)
and (Planet[Destination].Ships[5] = 0) and (Planet[Destination].Ships[6] = 0)
and (Planet[Destination].Ships[7] = 0)
then Winner := temp_Owner;
if (Squadron[LoopMS].Ships[1] = 0) and (Squadron[LoopMS].Ships[2] = 0)
and (Squadron[LoopMS].Ships[3] = 0) and (Squadron[LoopMS].Ships[4] = 0)
and (Squadron[LoopMS].Ships[5] = 0) and (Squadron[LoopMS].Ships[6] = 0)
and (Squadron[LoopMS].Ships[7] = 0)
then Winner := Destination;
Until Winner > 0;
if Winner = Destination then
Begin
if (Planet[Destination].Owner > 0) and (Planet[Destination].Owner < 31) then
begin
Send_Message (0,Planet[Destination].Owner,Empire[Owner].Empire_Name+' attacked planet '+St(Destination),Messages);
Send_Message (0,Owner,'You were defeated by #' +
st(Planet[Destination].Owner) +
' at planet '+St(Destination),Messages);
Add_On (Empire[Owner].Empire_Name + ' [' + St(Owner) +
'] was defeated by #' + st(Planet[Destination].Owner) +
' at planet ' + St(Destination));
end
else
begin
Send_Message (0,Owner,'You were defeated at planet '+St(Destination),Messages);
Add_On (Empire[Owner].Empire_Name + ' [' + St(Owner) + '] was defeated at planet ' + St(Destination));
end;
winner := 0;
End;
if Winner = temp_Owner then
Begin
if (Planet[Destination].Owner > 0) and (Planet[Destination].Owner < 31) then
begin
Send_Message (0,Planet[Destination].Owner,Empire[Owner].Empire_Name
+ ' captured planet '+St(Destination),Messages);
Send_Message (0,Owner,'You captured planet ' +St(Destination) +
' from #'+st(Planet[Destination].Owner)+'!',Messages);
Add_On (Empire[Owner].Empire_Name+' ['+St(Owner)+'] captured planet '
+St(Destination) + ' from #' +
st(Planet[Destination].Owner)+'!');
end
else
begin
Send_Message (0,Owner,'You captured planet ' +St(Destination) +
'!',Messages);
Add_On (Empire[Owner].Empire_Name+' ['+St(Owner)+'] captured planet '
+St(Destination) + '!');
end;
ExOwner := Planet[Destination].Owner;
Planet[Destination].Owner := Owner;
New_Owner (Destination, Owner, ExOwner);
End;
End;
procedure Add_Ships(LoopMS, Destination : Integer);
Var
LoopAS : Integer;
Begin
for LoopAS := 1 to Number_of_Ships do
Planet[Destination].Ships[LoopAS]:=Planet[Destination].Ships[LoopAS]+Squadron[LoopMS].Ships[LoopAS];
End;
procedure Update_Empire_Stats;
Var
LoopTES, LoopTES2, LoopTJ : Integer;
Begin
print ('Update Empires');
for LoopTES := 1 to Number_of_Players do
Begin
Empire[LoopTES].Total_Population := 0;
Empire[LoopTES].Planets := 0;
for LoopTJ := 1 to Number_of_Ships do
Empire[LoopTES].Ships[LoopTJ] := 0;
for LoopTJ := 1 to Number_of_Radars do
Empire[LoopTES].Radars[LoopTJ] := 0;
Empire[LoopTES].Defense_Bases := 0;
Empire[LoopTES].Intel_Reports := 10;
for LoopTES2 := 1 to Number_of_Squads do
with Squadron[LoopTES2] do
Begin
if Owner = LoopTES then
for LoopTJ := 1 to Number_of_Ships do
Empire[LoopTES].Ships[LoopTJ]:=Empire[LoopTES].Ships[LoopTJ]+Ships[LoopTJ];
End;
for LoopTES2 := 1 to Number_of_Planets do
Begin
if Planet[LoopTES2].Owner = LoopTES then
Begin
Empire[LoopTES].Total_Population := Empire[LoopTES].Total_Population
+Planet[LoopTES2].Population;
Empire[LoopTES].Planets := Empire[LoopTES].Planets + 1;
for LoopTJ := 1 to Number_of_Ships do
Empire[LoopTES].Ships[LoopTJ] := Empire[LoopTES].Ships[LoopTJ]
+Planet[LoopTES2].Ships[LoopTJ];
Empire[LoopTES].Defense_Bases := Empire[LoopTES].Defense_Bases
+ Planet[LoopTES2].Defense_Bases;
if Planet[LoopTES2].Radar > 0 then
Empire[LoopTES].Radars[Planet[LoopTES2].Radar] :=
Empire[LoopTES].Radars[Planet[LoopTES2].Radar] + 1; {-AtA.}
End;
End;
End;
End;
procedure Total_Scores;
Var
LoopTS : Integer;
Begin
print ('Scoring');
for LoopTS := 1 to Number_of_Players do
Empire[LoopTS].Points := Score (LoopTS);
End;
procedure Save_Status (Var Messages : Messagerecs); { -AtA. }
Var
EmpireFile , OldEmpireFile : File of Empirerecord;
Loop_Empire : Integer;
PlanetFile , OldPlanetFile : File of Planetrecord;
Loop_Planet : Integer;
begin
print ('Saving Status');
assign (EmpireFile, 'Empires.dom');
assign (OldEmpireFile, 'oldempir.dom');
Rewrite (EmpireFile);
Rewrite (OldEmpireFile);
For Loop_Empire := 1 to Number_of_Players do
begin
Write (EmpireFIle,Empire[Loop_Empire]);
Write (OldEmpireFile,Empire[Loop_Empire]);
End;
Close (EmpireFile);
Close (OldEmpireFile);
assign (PlanetFile, 'Planets.dom');
assign (OldPlanetFile, 'oldplnts.dom');
Rewrite (PlanetFile);
Rewrite (OldPlanetFile);
For Loop_Planet := 1 to Number_of_Planets do
begin
Write (PlanetFIle,Planet[Loop_Planet]);
Write (OldPlanetFile,Planet[Loop_Planet]);
End;
Close (PlanetFile);
Close (OldPlanetFile);
Save_Messages (Messages);
Save_Fleets;
Save_Info;
End;
procedure Arrived (Owner, LoopMS, Destination : Integer; Var Messages: Messagerecs);
Var LoopARR : Integer;
Begin
if Planet[Destination].Owner <> Owner then Fight(Owner, LoopMS, Destination, Messages);
if Planet[Destination].Owner = Owner then Add_Ships(LoopMS, Destination);
with squadron[loopms] do
begin
destination := 0;
planet_from := 0;
owner := 0;
speed := 0;
distance_left := 0;
for LoopARR := 1 to Number_of_Ships do Ships[LoopARR] := 0;
end;
End;
procedure Move_Squads(Var Messages : Messagerecs) ;
Var
LoopMS, Start : Integer;
up : Boolean;
Begin
print ('Moving Squadrons');
ansic(6);
print (' Could take a few minutes...');
Start := Random(Number_Of_Squads) + 1;
if Random(100) > 50 then up := true
else up := false;
LoopMS := Start;
while true do
begin
with Squadron[LoopMS] do
if Owner > 0 then
Begin
print ('Moved Squadron '+ St(LoopMS));
Distance_Left := Distance_Left - Speed;
if Distance_Left <= 0 then
Arrived(Owner, LoopMS, Destination, Messages);
End;
if up then LoopMS := LoopMS + 1
else LoopMS := LoopMS - 1;
if LoopMS = Start then
Exit;
if LoopMS = 0 then LoopMS := Number_of_Squads;
if LoopMS = Number_of_Squads + 1 then LoopMS := 1;
end;
End;
procedure Maintenence;
Var
Messages: Messagerecs;
Begin
cls;
writeln;
print ('Maintenance Program is now running...');
print ('Simply amazing what we''re willing to');
print ('do for you users.');
writeln;
Load_Messages (Messages);
Production;
Reproduce;
Change_Date;
Change_Happenings;
Move_Squads(Messages);
Update_Empire_Stats;
Total_Scores;
Save_Status(Messages);
writeln;
print ('All done!');
End;