-
Notifications
You must be signed in to change notification settings - Fork 18
/
ghsupport.pp
129 lines (102 loc) · 3.56 KB
/
ghsupport.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
unit ghsupport;
{ This unit handles support gears - various things needed for a }
{ mecha's operation which don't fit in elsewhere. }
{
GearHead: Arena, a roguelike mecha CRPG
Copyright (C) 2005 Joseph Hewitt
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
The full text of the LGPL can be found in license.txt.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
{ *** RULES *** }
{ - Support gears may only be installed in the BODY module. }
{ - Every mecha needs an engine. }
interface
uses gears;
{ *** SUPPORT FORMAT *** }
{ G = GG_Support }
{ S = System Type }
{ V = System Rating }
{ Stat[1] = Armor Rating }
{ Stat[2] = Engine Subtype }
const
NumSupportType = 2;
GS_Gyro = 1;
GS_Engine = 2;
STAT_EngineSubType = 2;
EST_HighOutput = 1;
Function SupportBaseDamage( Part: GearPtr ): Integer;
Function SupportName( Part: GearPtr ): String;
Function SupportBaseMass( Part: GearPtr ): Integer;
Function SupportValue( Part: GearPtr ): LongInt;
Procedure CheckSupportRange( Part: GearPtr );
implementation
const
SupName: Array [1..NumSupportType] of String = (
'Gyroscope','Engine'
);
Function SupportBaseDamage( Part: GearPtr ): Integer;
{ Return the amount of damage this system can withstand. }
begin
if Part^.S = GS_Engine then begin
SupportBaseDamage := 3;
end else begin
SupportBaseDamage := 1;
end;
end;
Function SupportName( Part: GearPtr ): String;
{ Return a name for this particular sensor. }
begin
SupportName := SupName[ Part^.S ];
end;
Function SupportBaseMass( Part: GearPtr ): Integer;
{ Return the mass of this system. }
begin
{ The mass is equal to the armor value }
SupportBaseMass := Part^.Stat[1];
end;
Function SupportValue( Part: GearPtr ): LongInt;
{ Calculate the base cost of this sensor type. }
var
it: LongInt;
begin
if Part^.S = GS_Gyro then begin
it := Part^.V * Part^.V * 30;
end else if Part^.S = GS_Engine then begin
case Part^.Stat[ STAT_EngineSubType ] of
EST_HighOutput: it := Part^.V * 1000;
else it := Part^.V * 45;
end;
end else it := Part^.V * 45;
{ Add the armor cost. }
it := it + Part^.Stat[1] * 25;
SupportValue := it;
end;
Procedure CheckSupportRange( Part: GearPtr );
{ Examine this support system to make sure everything is legal. }
begin
{ Check S - System Type }
if Part^.S < 1 then Part^.S := 1
else if Part^.S > NumSupportType then Part^.S := 1;
{ Check V - System Rating. Must be in the range from 1 to 10. }
if ( Part^.S = GS_Engine ) and ( Part^.Parent <> Nil ) then begin
if Part^.V <> Part^.Parent^.V then Part^.V := Part^.Parent^.V;
if Part^.Scale <> Part^.Parent^.Scale then Part^.Scale := Part^.Parent^.Scale;
end else begin
if Part^.V < 1 then Part^.V := 1
else if Part^.V > 10 then Part^.V := 10;
end;
{ Check Stats - Stat 1 is armor. }
if Part^.Stat[1] < 0 then Part^.Stat[1] := 0
else if Part^.Stat[1] > 2 then Part^.Stat[2] := 2;
end;
end.