File: ghswag.pp

package info (click to toggle)
gearhead 1.310-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 10,028 kB
  • sloc: pascal: 36,375; makefile: 78
file content (221 lines) | stat: -rw-r--r-- 6,623 bytes parent folder | download | duplicates (5)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
unit ghswag;
	{ This unit handles various items that will probably be }
	{ carried around by adventurers, but not might be found }
	{ in the tactical game. }
{
	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;

	{ SWAG format }
	{ G = GG_Swag               }
	{ S = Swag Exponent         }
	{ V = Swag Value            }
	{   Treasure:    V = Unscaled value in credits }

	{ USABLE format }
	{ G = GG_Usable             }
	{ S = Action Type           }
	{ V = Gear Value            }
	{ STAT 1 -> Skill Roll Bonus }
	{ STAT 2 -> Damage Rating    }

	{ REPAIRFUEL format }
	{ G = GG_Usable             }
	{ S = Repair Type           }
	{ V = DP Capacity           }

	{ CONSUMABLE format }
	{ G = GG_CONSUMABLE         }
	{ S = NA                    }
	{ V = Hunger Points         }

Const
	STAT_MoraleBoost = 1;
	STAT_FoodEffectValue = 2;
	STAT_FoodQuantity = 3;

	NumUsableType = 1;
	GS_Instrument = 1;
	STAT_UseBonus = 1;
	STAT_UseRange = 2;


Function SwagName( Part: GearPtr ): String;
Function SwagBaseMass( Part: GearPtr ): Integer;
Procedure CheckSwagRange( Part: GearPtr );
Function SwagValue( Part: GearPtr ): LongInt;

Function UsableName( Part: GearPtr ): String;
Function UsableDamage( Part: GearPtr ): Integer;
Function UsableValue( Part: GearPtr ): Integer;
Procedure CheckUsableRange( Part: GearPtr );

Function RepairFuelName( Part: GearPtr ): String;
Procedure CheckRepairFuelRange( Part: GearPtr );

Procedure CheckFoodRange( Part: GearPtr );
Function FoodMass( Part: GearPtr ): Integer;
Function FoodValue( Part: GearPtr ): LongInt;

implementation

uses ghchars;

Const
	UsableTypeName: Array [1..NumUsableType] of String = (
	'Instrument'
	);


Function SwagName( Part: GearPtr ): String;
	{ This function will make up a default name for the provided item. }
begin
	SwagName := 'Thing';
end;

Function SwagBaseMass( Part: GearPtr ): Integer;
	{ This function will find the mass of the provided item. }
begin
	SwagBaseMass := 1;
end;

Procedure CheckSwagRange( Part: GearPtr );
	{ Examine the various bits of this gear to make sure everything }
	{ is all nice and legal. }
begin
	{ Check S - Swag Exponent }
	if Part^.S < 0 then Part^.S := 0
	else if Part^.S > 6 then Part^.S := 6;
end;

Function SwagValue( Part: GearPtr ): LongInt;
	{ This function will find the cost of the provided item. }
var
	it,T: LongInt;
begin
	it := Part^.V;
	for t := 1 to Part^.S do it := it * 10;
	SwagValue := it;
end;

Function UsableName( Part: GearPtr ): String;
	{ This function will make up a default name for the provided item. }
begin
	UsableName := UsableTypeName[ Part^.S ];
end;

Function UsableDamage( Part: GearPtr ): Integer;
	{ Return how much damage this usable gear can withstand. }
begin
	UsableDamage := Part^.V + 1;
end;

Function UsableValue( Part: GearPtr ): Integer;
	{ Return the value of this usavle gear. }
begin
	UsableValue := ( 50 + Part^.Stat[ STAT_UseBonus ] * Part^.Stat[ STAT_UseBonus ] * Part^.Stat[ STAT_UseBonus ] * 10 + Part^.V * 5 ) * ( Part^.Stat[ STAT_UseRange ] + 5 ) div 10;
end;

Procedure CheckUsableRange( Part: GearPtr );
	{ Examine the various bits of this gear to make sure everything }
	{ is all nice and legal. }
begin
	{ Check S - Swag Type }
	if Part^.S < 1 then Part^.S := 1
	else if Part^.S > NumUsableType then Part^.S := NumUsableType;

	{ Check V - Damage Capacity }
	if Part^.V < 1 then Part^.V := 1
	else if Part^.V > 20 then Part^.V := 20;

	{ Check STAT 1 - Ability Bonus }
	if Part^.Stat[ STAT_UseBonus ] < 0 then Part^.Stat[ STAT_UseBonus ] := 0
	else if Part^.Stat[ STAT_UseBonus ] > 5 then Part^.Stat[ STAT_UseBonus ] := 5;

	{ Check stat 2 - Range }
	if Part^.Stat[ STAT_UseRange ] < 1 then Part^.Stat[ STAT_UseRange ] := 1
	else if Part^.Stat[ STAT_UseRange ] > 10 then Part^.Stat[ STAT_UseRange ] := 10;
end;

Function RepairFuelName( Part: GearPtr ): String;
	{ Returns a default name for some repairfuel. }
begin
	RepairFuelName := SkillMan[ Part^.S ].Name + ' Kit';
end;

Procedure CheckRepairFuelRange( Part: GearPtr );
	{ Examine the various bits of this gear to make sure everything }
	{ is all nice and legal. }
begin
	{ Check S - Skill Type }
	if Part^.S < 1 then Part^.S := 23
	else if Part^.S > NumSkill then Part^.S := 23;
end;

Procedure CheckFoodRange( Part: GearPtr );
	{ Check the range for this consumable gear. }
begin
	{ V = Hunger Value }
	if Part^.V < 0 then Part^.V := 0
	else if Part^.V > 60 then Part^.V := 60;

	{ Stat 1 = Morale Boost }
	if Part^.Stat[ STAT_MoraleBoost ] > 10 then Part^.Stat[ STAT_MoraleBoost ] := 10
	else if Part^.Stat[ STAT_MoraleBoost ] < -5 then Part^.Stat[ STAT_MoraleBoost ] := -5;

	{ Stat 2 - Extra Value }
	if Part^.Stat[ STAT_FoodEffectValue ] < 0 then Part^.Stat[ STAT_FoodEffectValue ] := 0;

	{ Stat 3 - Quantity }
	if Part^.Stat[ STAT_FoodQuantity ] > 50 then Part^.Stat[ STAT_FoodQuantity ] := 50
	else if Part^.Stat[ STAT_FoodQuantity ] < 1 then Part^.Stat[ STAT_FoodQuantity ] := 1;
end;

Function FoodMass( Part: GearPtr ): Integer;
	{ Return the basic mass value for this food. }
begin
	FoodMass := ( Part^.V * Part^.Stat[ STAT_FoodQuantity ] ) div 5;
end;

Function FoodValue( Part: GearPtr ): LongInt;
	{ Return the cost of this food. }
var
	it,M: LongInt;
begin
	it := Part^.V + Part^.Stat[ Stat_FoodEffectValue ];

	if Part^.Stat[ STAT_MoraleBoost ] > 0 then begin
		it := it + ( Part^.Stat[ STAT_MoraleBoost ] * ( 150 - 2 * Part^.V ) );
	end else begin
		M := it * ( Part^.Stat[ STAT_MoraleBoost ] + 10 ) div 10;
		if M < ( it div 2 ) then M := it div 2;
		it := M;
	end;

	it := it * Part^.Stat[ sTAT_FoodQuantity ];

	FoodValue := it;
end;

end.