-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARMOR.CPP
215 lines (192 loc) · 6.48 KB
/
ARMOR.CPP
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
/* ========================================================================
Copyright (c) 1990,1995 Synergistic Software
All Rights Reserved
========================================================================
Filename: ARMOR.c -
Author: Gary Powell
========================================================================
Contains the following general functions:
======================================================================== */
/* ------------------------------------------------------------------------
Includes
------------------------------------------------------------------------ */
#include <string.h>
#include "ARMOR.HXX"
//#include "gamestr.h"
#include "strenum.h"
/* ------------------------------------------------------------------------
Notes
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Defines and Compile Flags
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Macros
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Prototypes
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------ */
// Note: The Modifiers came from the p121 Table #52 of the AD&D Handbook.
// The Race limit information comes from Table 8 p.18 Birthright Rulebook.
// The race limitation only exists for initial character creation. Characters
// are allowed to buy or acquire other kinds of armor during the course of the game.
SBYTE m[][3] = {
{ 0, 0, 0 },
{ 2, 0, 1 },
{ 0, 1, 0 },
{ 1, 1, 0 },
{ 2, 1, 0 },
{ 3, 1, 0 },
{ 4, 3, 0 },
{ 2, 1, 0 },
{ 0, -2, 0 },
{ 0, 0, 0 },
{ 3, 0, 0 },
{ 1, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 2 },
{ 0, -2, 0 },
{ 0, -2, 0 },
{ 2, 1, 0 },
{ 2, 0, -2 }
};
SBYTE r[][11] = {
{ 1,1,1,1,1,1,1,1,1,1,1 },
{ 0,0,0,0,1,1,0,0,1,0,0 },
{ 0,0,0,0,1,0,0,0,0,0,0 },
{ 0,0,0,0,1,1,0,1,1,0,0 },
{ 0,0,0,0,0,0,0,0,0,0,0 },
{ 1,0,0,0,1,1,0,0,0,0,0 },
{ 1,0,0,0,1,0,0,0,0,0,0 },
{ 0,0,0,0,1,1,0,0,0,0,0 },
{ 0,0,0,0,0,0,0,0,0,1,1 },
{ 0,0,0,0,0,0,1,1,0,0,0 },
{ 1,1,0,0,1,1,0,0,1,0,0 },
{ 0,0,0,0,0,1,0,1,1,0,0 },
{ 0,0,0,0,0,0,1,0,0,0,0 },
{ 0,0,0,0,0,0,1,0,0,0,0 },
{ 1,1,1,1,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,1,1,1,1,1,1 }
};
const ARMOR_INFO::ARMOR_ITEM ARMOR_INFO::fpArmorInfoTable[] = {
{STR_ARMOR_NO_ARMOR, 10, m[0], r[0]},
{STR_ARMOR_BANDED_MAIL_ARMOR, 4, m[1], r[1]},
{STR_ARMOR_BREAST_PLATE, 6, m[2], r[2]}, // No Data for Modifiers
{STR_ARMOR_BRIGANDINE_ARMOR, 6, m[3], r[3]},
{STR_ARMOR_BRONZE_PLATE, 4, m[4], r[4]}, // No Data for Modifiers
{STR_ARMOR_FIELD_PLATE, 2, m[5], r[5]},
{STR_ARMOR_FULL_PLATE, 1, m[6], r[6]},
{STR_ARMOR_HALF_PLATE, 4, m[7], r[7]}, // No Data for Modifiers
{STR_ARMOR_HIDE_ARMOR, 5, m[8], r[8]},
{STR_ARMOR_IMPROVED_MAIL, 6, m[9], r[9]}, // No Data for Modifiers
{STR_ARMOR_PLATE_MAIL, 3, m[10], r[10]},
{STR_ARMOR_RING_MAIL, 7, m[11], r[11]},
{STR_ARMOR_SCALE_MAIL, 6, m[12], r[12]},
{STR_ARMOR_SPLINT_MAIL, 4, m[13], r[13]},
{STR_ARMOR_LEATHER_ARMOR, 8, m[14], r[14]},
{STR_ARMOR_PADDED_ARMOR, 8, m[15], r[15]},
{STR_ARMOR_STUDDED_LEATHER_ARMOR, 7, m[16], r[16]},
{STR_ARMOR_CHAIN_MAIL, 5, m[17], r[17]}
};
SBYTE shield[][11] = {
{ 1,1,1,1,1,1,1,1,1,1,1 },
{ 0,1,1,0,1,1,1,1,1,1,1 },
{ 1,1,1,1,1,1,1,1,1,1,1 } };
const SHIELD_INFO::SHIELD_ITEM SHIELD_INFO::fpShieldInfoTable[] = {
// Melee Attack, Missile Attack, races.
{"No Shield", 0, 0, shield[0]},
{"Body Shield", 1, 2, shield[1]},
{"Buckler Shield", 1, 0, shield[2]}
};
/* ========================================================================
Function - mfFindType
Description - Matchup the armor name to its type.
Returns -
======================================================================== */
const ARMOR_INFO::TYPE ARMOR_INFO::mfFindType(char * cpArmorName)
{
TYPE Result = NO_ARMOR;
LONG i;
for (i = FIRST_ARMOR; i < ARMOR_MAX_INDEX; i++)
{
if (0 == strncmp(ARMOR_INFO::mfGetName((TYPE)i), cpArmorName, strlen(ARMOR_INFO::mfGetName((TYPE) i))))
{
Result = (TYPE) i;
break;
}
}
return Result;
}
/* ========================================================================
Function - mfFindType
Description - Match up the shield name to its type.
Returns -
======================================================================== */
const SHIELD_INFO::TYPE SHIELD_INFO::mfFindType(char * cpShieldName)
{
TYPE Result = NO_SHIELD;
LONG i;
for (i = FIRST_SHIELD; i < SHIELD_MAX_INDEX; i++)
{
if (0 == strncmp(SHIELD_INFO::mfGetName((TYPE)i), cpShieldName, strlen(SHIELD_INFO::mfGetName((TYPE) i))))
{
Result = (TYPE) i;
break;
}
}
return Result;
}
/* ========================================================================
Function - mfGetWeaponAdjust
Description - For a given weapon style get the best adjustment.
Returns - A modifier for ToHit.
======================================================================== */
// Get the weapon adjustment for this armor.
const SBYTE ARMOR_INFO::mfGetWeaponAdjust(
const ARMOR_INFO::TYPE ArmorType,
const WEAPON_INFO::STYLE WeaponStyle)
{
SBYTE Result = 0;
if (WeaponStyle & WEAPON_INFO::SLASHING)
{
Result = fpArmorInfoTable[ArmorType].fbModifiers[0];
if (WeaponStyle & WEAPON_INFO::PIERCING)
{
if (Result > fpArmorInfoTable[ArmorType].fbModifiers[1])
{
Result = fpArmorInfoTable[ArmorType].fbModifiers[1];
}
}
else
if (WeaponStyle & WEAPON_INFO::BLUDGEONING)
{
if (Result > fpArmorInfoTable[ArmorType].fbModifiers[2])
{
Result = fpArmorInfoTable[ArmorType].fbModifiers[2];
}
}
}
else
if (WeaponStyle & WEAPON_INFO::PIERCING)
{
Result = fpArmorInfoTable[ArmorType].fbModifiers[1];
if (WeaponStyle & WEAPON_INFO::BLUDGEONING)
{
if (Result > fpArmorInfoTable[ArmorType].fbModifiers[2])
{
Result = fpArmorInfoTable[ArmorType].fbModifiers[2];
}
}
}
else
if (WeaponStyle & WEAPON_INFO::BLUDGEONING)
{
Result = fpArmorInfoTable[ArmorType].fbModifiers[2];
}
return Result;
}