forked from jwvhewitt/gearhead-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghmecha.pp
142 lines (112 loc) · 4.24 KB
/
ghmecha.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
unit ghmecha;
{This unit handles stuff for MECHA GEARS.}
{
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
}
{ G = GG_MECHA }
{ S = Mecha Form (Transformation Mode) }
{ V = Size Class of Mecha }
interface
uses gears;
Const
NumForm = 9; { The number of different FORMs which exist in the game.}
GS_Battroid = 0; { Default form }
GS_Zoanoid = 1; { Animal Form Mecha }
GS_GroundHugger = 2; { Land Vehicle - Heavy Armor }
GS_Arachnoid = 3; { Walker type tank }
GS_AeroFighter = 4; { Fighter Jet type }
GS_Ornithoid = 5; { Bird Form Mecha }
GS_Gerwalk = 6; { Half robot half plane }
GS_HoverFighter = 7; { Helicopter, etc. }
GS_GroundCar = 8; { Land Vehicle - High Speed }
FormName: Array[ 0 .. ( NumForm - 1 ) ] of String = (
'Battroid','Zoanoid','GroundHugger','Arachnoid','AeroFighter',
'Ornithoid','Gerwalk','HoverFighter','GroundCar'
);
FormMVBonus: Array [ 0 .. ( NumForm - 1 ) ] of SmallInt = (
1, 2, -1, 0, -5,
-1, -3, -3, -1
);
FormTRBonus: Array [ 0 .. ( NumForm - 1 ) ] of SmallInt = (
1, -1, 2, 1 , -1,
-2, 0, 0, 1
);
Procedure InitMecha(Part: GearPtr);
Function MechaName(Part: GearPtr): String;
Procedure CheckMechaRange( Mek: GearPtr );
Function IsLegalMechaSubCom( Part, Equip: GearPtr ): Boolean;
Function MechaTraitDesc( Mek: GearPtr ): String;
implementation
uses texutil;
Procedure InitMecha(Part: GearPtr);
{Part is a newly created Mecha record.}
{Initialize fields to default values.}
begin
{Default Scale = 2}
Part^.Scale := 2;
end;
Function MechaName(Part: GearPtr): String;
{Figure out a default name for a mecha.}
begin
{Error Check - if the thing isn't a mecha, return smartass answer.}
if Part^.G <> GG_Mecha then Exit('Not A Mecha');
MechaName := FormName[Part^.S];
end;
Procedure CheckMechaRange( Mek: GearPtr );
{ Check a MECHA gear to make sure all values are within appropriate }
{ range. }
var
T: Integer;
begin
{ Check S - Mecha Form }
if Mek^.S < 0 then Mek^.S := 0
else if Mek^.S > ( NumForm - 1 ) then Mek^.S := GS_Battroid;
{ Check V - Mecha Size }
if Mek^.V < 1 then Mek^.V := 1
else if Mek^.V > 10 then Mek^.V := 10;
{ Check Stats - No Stats are defined. }
for t := 1 to NumGearStats do Mek^.Stat[ T ] := 0;
end;
Function IsLegalMechaSubCom( Part, Equip: GearPtr ): Boolean;
{ Return TRUE if EQUIP can be installed as a subcomponent }
{ of PART, FALSE otherwise. Both inputs should be properly }
{ defined & initialized. }
begin
if Equip^.G = GG_Module then begin
{ The size of a module may not exceed the declared }
{ size of the mecha by more than one, and the size }
{ of the BODY module must exactly match the size of }
{ the mecha. }
if Equip^.S = 1 then begin
if Equip^.V = Part^.V then IsLegalMechaSubCom := True
else IsLegalMechaSubCom := False;
end else begin
if Equip^.V <= ( Part^.V + 1 ) then IsLegalMechaSubCom := True
else IsLegalMechaSubCom := False;
end;
{ Mecha can mount modification gears. }
end else if Equip^.G = GG_Modifier then begin
IsLegalMechaSubCom := AStringHasBString( SAttValue( Equip^.SA , 'TYPE' ) , 'MECHA' );
{ No other components may be subcoms of a mecha. }
end else IsLegalMechaSubCom := False;
end;
Function MechaTraitDesc( Mek: GearPtr ): String;
{ Create a string describing the traits of this mecha. }
{ At the moment, this only contains form name. }
begin
MechaTraitDesc := FormName[ Mek^.S ];
end;
end.