-
Notifications
You must be signed in to change notification settings - Fork 18
/
ghsensor.pp
172 lines (135 loc) · 5.01 KB
/
ghsensor.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
unit ghsensor;
{ This unit covers sensors and electronics. }
{
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
}
interface
uses gears;
{ *** SENSOR FORMAT *** }
{ G = GG_Sensor }
{ S = Sensor Type }
{ V = Sensor Rating / Sensor Function (depending on type) }
{ *** ELECTRONICS FORMAT *** }
{ G = GG_Electronics }
{ S = Electronics Type }
{ V = Electronics Rating / Function }
const
NumSensorType = 3;
GS_MainSensor = 1;
GS_TarCom = 2;
GS_ECM = 3;
NumElectronicsType = 1;
GS_PCS = 1; { Personal Communications System }
GV_Memo = 1; { Can view adventure memos }
GV_Email = 2; { Can view email messages }
GV_Comm = 3; { Can receive communications from NPCs }
GV_News = 5; { Can view internet global news }
Function SensorBaseDamage( Part: GearPtr ): Integer;
Function SensorName( Part: GearPtr ): String;
Function SensorBaseMass( Part: GearPtr ): Integer;
Function SensorValue( Part: GearPtr ): LongInt;
Procedure CheckSensorRange( Part: GearPtr );
Function ElecBaseDamage( Part: GearPtr ): Integer;
Function ElecName( Part: GearPtr ): String;
Function ElecBaseMass( Part: GearPtr ): Integer;
Function ElecValue( Part: GearPtr ): LongInt;
Procedure CheckElecRange( Part: GearPtr );
implementation
uses texutil;
Function SensorBaseDamage( Part: GearPtr ): Integer;
{ Return the amount of damage this sensor can withstand. }
begin
if Part^.S = GS_MainSensor then begin
{ Higer grade sensors are more succeptable to damage. }
SensorBaseDamage := 60 - ( 5 * Part^.V );
end else begin
SensorBaseDamage := 25;
end;
end;
Function SensorName( Part: GearPtr ): String;
{ Return a name for this particular sensor. }
begin
if Part^.S = GS_MainSensor then begin
SensorName := 'Class ' + BStr( Part^.V ) + ' Sensor';
end else if Part^.S = GS_ECM then begin
SensorName := 'Class ' + BStr( Part^.V ) + ' ECM Suite';
end else begin
SensorName := 'Class ' + BStr( Part^.V ) + ' Targeting Computer';
end;
end;
Function SensorBaseMass( Part: GearPtr ): Integer;
{ Return the amount of damage this sensor can withstand. }
begin
{ As with most other components, the weight of a sensor is }
{ equal to the amount of damage it can withstand. }
SensorBaseMass := SensorBaseDamage( Part );
end;
Function SensorValue( Part: GearPtr ): LongInt;
{ Calculate the base cost of this sensor type. }
begin
if Part^.S = GS_MainSensor then begin
SensorValue := Part^.V * Part^.V * 50 + 50;
end else if Part^.S = GS_TarCom then begin
SensorValue := Part^.V * Part^.V * 125;
end else if Part^.S = GS_ECM then begin
SensorValue := Part^.V * Part^.V * Part^.V * 500 - Part^.V * Part^.V * 350;
end else SensorValue := 0;
end;
Procedure CheckSensorRange( Part: GearPtr );
{ Examine this sensor to make sure everything is legal. }
begin
{ Check S - Sensor Type }
if Part^.S < 1 then Part^.S := 1
else if Part^.S > NumSensorType then Part^.S := 1;
{ Check V - Sensor Rating / Sensor Function }
if Part^.V < 1 then Part^.V := 1
else if Part^.V > 10 then Part^.V := 10;
{ Check Scale - Sensors are always SF:0 }
if Part^.Scale <> 0 then Part^.Scale := 0;
{ Check Stats - No Stats Defined. }
end;
Function ElecBaseDamage( Part: GearPtr ): Integer;
{ Return the base damage score of this electronic device. }
begin
ElecBaseDamage := 1;
end;
Function ElecName( Part: GearPtr ): String;
{ Return the default name for this electronic device. }
begin
ElecName := 'Electronic Device';
end;
Function ElecBaseMass( Part: GearPtr ): Integer;
{ Return the basic mass score for this electronic device. }
begin
ElecBaseMass := Part^.V;
end;
Function ElecValue( Part: GearPtr ): LongInt;
{ Return the value score for this electronic device. }
begin
ElecValue := Part^.V * Part^.V * Part^.V * 5 + Part^.V * 10 + 15;
end;
Procedure CheckElecRange( Part: GearPtr );
{ Examine this device to make sure everything is legal. }
begin
{ Check S - Electronics Type }
if Part^.S < 1 then Part^.S := 1
else if Part^.S > NumElectronicsType then Part^.S := 1;
{ Check V - Sensor Rating / Sensor Function }
if Part^.V < 1 then Part^.V := 1
else if Part^.V > 10 then Part^.V := 10;
{ Check Stats - No Stats Defined. }
end;
end.