forked from jwvhewitt/gearhead-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghholder.pp
101 lines (79 loc) · 2.6 KB
/
ghholder.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
unit ghholder;
{ This unit defines hands and weapon mounts. }
{
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;
{ *** HOLDER FORMAT *** }
{ G = GG_Holder }
{ S = Holder Type }
{ V = Undefined }
const
GS_Hand = 0;
GS_Mount = 1;
function HolderName( Part: GearPtr ): String;
Procedure CheckHolderRange( Part: GearPtr );
Function IsLegalHolderInv( Slot, Equip: GearPtr ): Boolean;
implementation
function HolderName( Part: GearPtr ): String;
{ Return a default name for this part type. }
begin
if Part^.S = GS_Hand then
HolderName := 'Hand'
else if Part^.S = GS_Mount then
HolderName := 'Mounting Point';
end;
Procedure CheckHolderRange( Part: GearPtr );
{ Examine everything about this part and make sure the values }
{ fall within the acceptable range. }
var
T: Integer;
begin
{ Check S - Holder Type }
if Part^.S < 0 then Part^.S := 1
else if Part^.S > ( 1 ) then Part^.S := 1;
{ Check V - Undefined }
Part^.V := 1;
{ Check Stats - No Stats are defined. }
for t := 1 to NumGearStats do Part^.Stat[ T ] := 0;
end;
Function IsLegalHolderInv( Slot, Equip: GearPtr ): Boolean;
{ Check EQUIP to see if it can be stored in SLOT. }
{ INPUTS: Slot and Equip must both be properly allocated gears. }
{ Mounting Points may mount weapons, movesys. }
{ Hands may hold weapons, sensors. }
var
it: Boolean;
begin
if Slot^.S = GS_Hand then begin
Case Equip^.G of
GG_Weapon: it := true;
else it := False;
end;
end else begin
Case Equip^.G of
GG_Weapon: it := true;
GG_MoveSys: it := true;
else it := False;
end;
end;
{ If the item is of a different scale than the holder, }
{ it can't be held. }
if Equip^.Scale <> Slot^.Scale then it := False;
IsLegalHolderInv := it;
end;
end.