forked from jwvhewitt/gearhead-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghmovers.pp
145 lines (119 loc) · 3.67 KB
/
ghmovers.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
unit ghmovers;
{This unit holds constants and functions relating to}
{movement systems - wheels, hover jets, etc.}
{
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;
{ *** MOVEMENT SYSTEM FORMAT *** }
{ G = GG_MoveSys }
{ S = Movement System Type }
{ V = Movement System Size }
Type
MoveSysDesc = Record
Name: String;
Dmg: SmallInt; { How much damage can it take? }
Cost: SmallInt; { How much does it cost? }
end;
Const
NumMoveSys = 6;
MovesysMan: Array [1..NumMoveSys] of MoveSysDesc = (
( name: 'Wheels';
dmg: 1;
cost: 10;
),
( name: 'Tracks';
dmg: 2;
cost: 10;
),
( name: 'Hover Jets';
dmg: 0;
cost: 45;
),
( name: 'Flight Jets';
dmg: 0;
cost: 65;
),
( name: 'Arc Thrusters';
dmg: 0;
cost: 100;
),
( name: 'Overchargers';
dmg: 0;
cost: 30;
)
);
GS_Wheels = 1;
GS_Tracks = 2;
GS_HoverJets = 3;
GS_FlightJets = 4;
GS_Overchargers = 6;
Function MovesysBaseDamage( Part: GearPtr ): Integer;
Function MovesysBaseMass( Part: GearPtr ): Integer;
Function MovesysName( Part: GearPtr ): String;
Function MoveSysValue( Part: GearPtr ): LongInt;
Procedure CheckMoverRange( Part: GearPtr );
implementation
uses texutil;
Function MovesysBaseDamage( Part: GearPtr ): Integer;
{Calculate the number of damage points that may be}
{sustained by the movement system provided.}
{PRECONDITION: Part points to a valid movement system record.}
var
it: Integer;
begin
if MovesysMan[ Part^.S ].DMG = 0 then begin
{This part has one DP, regardless of value.}
it := 1;
end else begin
it := Part^.V * MovesysMan[ Part^.S ].DMG;
end;
MoveSysBaseDamage := it;
end;
Function MovesysBaseMass( Part: GearPtr ): Integer;
{Calculate the basic mass of this movement system.}
{In general, this is equal to its damage points.}
{PRECONDITION: Part points to a valid movement system record.}
begin
MovesysBaseMass := MovesysBaseDamage(Part);
end;
Function MovesysName( Part: GearPtr ): String;
{Return a default name for the movement system in question.}
begin
MovesysName := 'Class ' + BStr(Part^.V) + ' '
+ MoveSysMan[ Part^.S ].Name;
end;
Function MoveSysValue( Part: GearPtr ): LongInt;
{ Return the unscaled cost of this movement system. }
begin
MoveSysValue := Part^.V * MoveSysMan[ Part^.S ].Cost;
end;
Procedure CheckMoverRange( Part: GearPtr );
{ Examine everything about this part and make sure the values }
{ fall within the acceptable range. }
var
T: Integer;
begin
{ Check S - Movement System Type }
if Part^.S < 1 then Part^.S := 1
else if Part^.S > NumMoveSys then Part^.S := NumMoveSys;
{ Check V - Movement System Size }
if Part^.V < 1 then Part^.V := 1;
{ Check Stats - No Stats are defined. }
for t := 1 to NumGearStats do Part^.Stat[ T ] := 0;
end;
end.