opposed to the old model where they had subtype ARM_HELMET. Breaks savefiles, might be buggy.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3035 c06c8d41-db1a-0410-9941-cceddc491573
MNYDF64QY6NHYKOAFOGBQJFYU7TZDILXRV23EXJPN4IZOCLSJ2AQC
NH3RJG3CNJVBJURYHMUSTKRYSQU6TJJ6VRFGP3VPNE3OPQ7AMXXQC
PEM6HRZOMW2BZFBNQAF4554RNFNAC6WWPT26CQ6NYKI2PRLGFWNAC
V3GWLMX6JL3YOYB427VLHPOTGHGWZK64HI6LLUU4X6CFMD2MEQMQC
EEZCC5GUYHETFQV4KSZJSJ6BTTWZHKS7RXQ25XQ6ODGKLDD4XFRAC
BKU2GWFNG6H74G76JX4RP3WVMU4IKTHPSKRMLWZAGA6BXMMZ227AC
KQNIGKATHT4YSPJFPJGIGPD6VNR5B753SE2JN2LCXZZJNHCGY3DQC
W2GGBR7YSYKHFT3LWDSDVZEUCTFESSNQFVYTIR7YJAYEEL53GKCAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
Z6XF4AIERIW4U4AR3HU2ILYFZ54IK4K4ORQ6JKCEWRO5LZODWDDAC
77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC
7KWDC7XFNMBLSUO2HISIROBINZBX5T67LJEEXTAORXW2YZ7VWFGAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
74LQ7JXVLAFSHLI7LCBKFX47CNTYSKGUQSXNX5FCIUIGCC2JTR3QC
L6SQXI6VUPDACCYYJAOHBRDPXMIBLLVVDSRADTEIEPJSZMYRBNRQC
3HC3DCSQIGQHMWDMLI2MR6QECCZOS6GIRJKJWJYK7WOHPQ3SIXFAC
DTO3EUKWHZ5RJNGNCFYXSOVTIPVXPP637F2W7WFGYKJ7JK7VNKNQC
Q3DNEB5OOJ34P5ML4CMK3L6SCP7RLW7DDOZEG24KZBX3C7BJRQDAC
XKHW7SK7SAAICCEKIK5N2U2XITOZQL2Q5X3V43WAH7U2RTZ5K5EQC
KFULGQQOHWUTXOM3BXCCYPGGVGGY4Z6265XUFRCBPNLTZAEHJZSQC
34C4U6EQWERY75GZJKUCM5KVGU2OUICETS5LGZF6RMKMZT4R5SQAC
SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC
VCG3BRIYRTNNWYC3LOXD6KFGXOX37HAFW2HNV7WXVG2V7EUHLDZQC
H7BW6SEIQ57X6V4BM2RX54W42W6BH5XJBAS6FYCYKLQQG43ZMU4QC
KAL42YT6OQXFPMKKKHE2NQM47W5KMLSRI6KWFRTJFAO4WKP4MMLAC
BWAQ3FHBBM6G3K3KYP75CRTR343RDQZJRYX5ZGYUEXYBAC3APDLAC
R22TTMI6WXWULC7ODKFF3QCB7MOTETQQ6IR4BUCUPOCQKQNCTT5AC
J5AAA4LUTW6PLS2DBKGTXPSW2SGOBMICEOA3VDHRSKVLU36EGQMAC
// Note that helms and boots have a sub-sub classing system
// which uses "plus2"... since not all members have the same
// AC value, we use special cases. -- bwr
if (i == EQ_HELMET
&& (get_helmet_type(you.inv[ item ]) == THELM_CAP
|| get_helmet_type(you.inv[ item ]) == THELM_WIZARD_HAT
|| get_helmet_type(you.inv[ item ]) == THELM_SPECIAL))
{
continue;
}
AC += item.plus * 100;
const unsigned long armour_race = get_equip_race( you.inv[ item ] );
const int ac_value = property( you.inv[ item ], PARM_AC ) * 100;
const unsigned long armour_race = get_equip_race(item);
const int ac_value = property(item, PARM_AC ) * 100;
(get_helmet_type(you.inv[you.equip[EQ_HELMET]]) == THELM_CAP ||
get_helmet_type(you.inv[you.equip[EQ_HELMET]]) == THELM_WIZARD_HAT))
(you.inv[you.equip[EQ_HELMET]].sub_type == ARM_CAP ||
you.inv[you.equip[EQ_HELMET]].sub_type == ARM_WIZARD_HAT))
if (get_helmet_type(item) == THELM_CAP
|| get_helmet_type(item) == THELM_WIZARD_HAT)
{
item_colour = MAGENTA;
}
else
item_colour = DARKGREY;
case ARM_HELM:
item_colour = DARKGREY;
static void determine_helmet_types(item_def& item)
{
set_helmet_type( item, THELM_HELMET );
set_helmet_desc( item, THELM_DESC_PLAIN );
if (one_chance_in(3))
set_helmet_type( item, random2( THELM_NUM_TYPES ) );
if (one_chance_in(3))
set_helmet_random_desc( item );
}
if (get_helmet_type(item) == THELM_CAP
|| get_helmet_type(item) == THELM_WIZARD_HAT)
{
if (one_chance_in(6))
rc = ISFLAG_ELVEN;
}
else
{
// helms and helmets
if (one_chance_in(8))
rc = ISFLAG_ORCISH;
if (one_chance_in(6))
rc = ISFLAG_DWARVEN;
}
if (one_chance_in(8))
rc = ISFLAG_ORCISH;
if (one_chance_in(6))
rc = ISFLAG_DWARVEN;
if (get_helmet_type(item) == THELM_WIZARD_HAT && coinflip())
{
rc = one_chance_in(3) ?
SPARM_MAGIC_RESISTANCE : SPARM_INTELLIGENCE;
}
else
rc = coinflip() ? SPARM_SEE_INVISIBLE : SPARM_INTELLIGENCE;
case ARM_HELM:
case ARM_CAP:
rc = coinflip() ? SPARM_SEE_INVISIBLE : SPARM_INTELLIGENCE;
if (base_type == OBJ_ARMOUR)
{
if (name.find("wizard's hat") != std::string::npos)
{
item.sub_type = ARM_HELMET;
item.plus2 = THELM_WIZARD_HAT;
}
else if (name == "cap") // Don't search - too many possible collisions
{
item.sub_type = ARM_HELMET;
item.plus2 = THELM_CAP;
}
else if (name == "helm") // Don't search.
{
item.sub_type = ARM_HELMET;
item.plus2 = THELM_HELM;
}
}
THELM_HELMET = 0x0000,
THELM_HELM = 0x0001,
THELM_CAP = 0x0002,
THELM_WIZARD_HAT = 0x0003,
THELM_NUM_TYPES = 4,
THELM_SPECIAL = 0x0004, // type used only for artefacts (mask, hat)
THELM_TYPE_MASK = 0x00ff,
THELM_DESC_PLAIN = 0x0000,
THELM_DESC_WINGED = 0x0100,
THELM_DESC_HORNED = 0x0200,
THELM_DESC_CRESTED = 0x0300,
THELM_DESC_PLUMED = 0x0400,
THELM_DESC_SPIKED = 0x0500,
THELM_DESC_VISORED = 0x0600,
THELM_DESC_JEWELLED = 0x0700,
THELM_DESC_MASK = 0xff00
THELM_DESC_PLAIN = 0,
THELM_DESC_WINGED,
THELM_DESC_HORNED,
THELM_DESC_CRESTED,
THELM_DESC_PLUMED,
THELM_DESC_MAX_SOFT = THELM_DESC_PLUMED,
THELM_DESC_SPIKED,
THELM_DESC_VISORED,
THELM_DESC_JEWELLED,
THELM_NUM_DESCS
// make sure we have the right sub_type (to get properties correctly)
if (type == THELM_HELMET || type == THELM_HELM)
item.sub_type = ARM_HELMET;
else
item.sub_type = ARM_CAP;
if ((item.sub_type == ARM_CAP || item.sub_type == ARM_WIZARD_HAT)
&& type > THELM_DESC_PLUMED)
type = THELM_DESC_PLAIN;
ASSERT( (type & ~THELM_DESC_MASK) == 0 );
ASSERT( item.base_type == OBJ_ARMOUR
&& get_armour_slot( item ) == EQ_HELMET );
const int helmtype = get_helmet_type(item);
if ((helmtype == THELM_CAP || helmtype == THELM_WIZARD_HAT)
&& type > THELM_DESC_PLUMED)
type = THELM_DESC_PLAIN;
item.plus2 &= ~THELM_DESC_MASK;
item.plus2 |= type;
return item.base_type == OBJ_ARMOUR && get_armour_slot(item) == EQ_HELMET;
item.plus2 |= (random2(5) << 8);
}
bool is_helmet_type( const item_def &item, short val )
{
if (item.base_type != OBJ_ARMOUR || get_armour_slot( item ) != EQ_HELMET)
return (false);
return (get_helmet_type( item ) == val);
item.plus2 = random2(THELM_DESC_MAX_SOFT + 1);
if ( item.sub_type != ARM_HELMET && item.sub_type != ARM_CAP )
{
return Armour_prop[Armour_index[item.sub_type]].name;
}
else
{
std::string result;
const short helm_type = get_helmet_type( item );
if (helm_type == THELM_HELM)
result += "helm";
else if (helm_type == THELM_CAP)
result += "cap";
else if (helm_type == THELM_WIZARD_HAT)
result += "wizard's hat";
else
result += "helmet";
return result;
}
return Armour_prop[Armour_index[item.sub_type]].name;
if (get_helmet_type(*this) == THELM_HELM ||
get_helmet_type(*this) == THELM_HELMET)
{
const short dhelm = get_helmet_desc( *this );
buff <<
(
(dhelm == THELM_DESC_PLAIN) ? "" :
(dhelm == THELM_DESC_WINGED) ? "winged " :
(dhelm == THELM_DESC_HORNED) ? "horned " :
(dhelm == THELM_DESC_CRESTED) ? "crested " :
(dhelm == THELM_DESC_PLUMED) ? "plumed " :
(dhelm == THELM_DESC_SPIKED) ? "spiked " :
(dhelm == THELM_DESC_VISORED) ? "visored " :
(dhelm == THELM_DESC_JEWELLED) ? "jewelled "
: "buggy ");
}
const short dhelm = get_helmet_desc( *this );
buff <<
(
(dhelm == THELM_DESC_PLAIN) ? "" :
(dhelm == THELM_DESC_WINGED) ? "winged " :
(dhelm == THELM_DESC_HORNED) ? "horned " :
(dhelm == THELM_DESC_CRESTED) ? "crested " :
(dhelm == THELM_DESC_PLUMED) ? "plumed " :
(dhelm == THELM_DESC_SPIKED) ? "spiked " :
(dhelm == THELM_DESC_VISORED) ? "visored " :
(dhelm == THELM_DESC_JEWELLED) ? "jewelled "
: "buggy ");
int o = items(0, OBJ_ARMOUR, ARM_HELMET, true, 1,
MAKE_ITEM_NO_RACE);
if (o == NON_ITEM)
{
crawl_state.add_startup_error("Couldn't cache helmet names.");
return;
}
item_def &item(mitm[o]);
// Make sure item isn't an artifact
item.flags &= ~ISFLAG_ARTEFACT_MASK;
item.special = 0;
// Now handle the helmets
for (int i = 0; i < THELM_NUM_TYPES; i++)
{
set_helmet_type(item, i);
item_types_pair pair = {item.base_type, item.sub_type};
std::string name = item.name(DESC_DBNAME, true, true);
unsigned glyph;
unsigned short colour;
get_item_glyph(&item, &glyph, &colour);
lowercase(name);
if (item_names_cache.find(name) == item_names_cache.end())
{
item_names_cache[name] = pair;
item_names_by_glyph_cache[glyph].push_back(name);
}
}
destroy_item(o, true);
aux_damage += 2;
if (get_helmet_desc(you.inv[you.equip[EQ_HELMET]]) == THELM_DESC_SPIKED
|| get_helmet_desc(you.inv[you.equip[EQ_HELMET]]) == THELM_DESC_HORNED)
const item_def& helmet = you.inv[you.equip[EQ_HELMET]];
if ( is_hard_helmet(helmet) )
if (verbose
&& item.sub_type != ARM_SHIELD
&& item.sub_type != ARM_BUCKLER
&& item.sub_type != ARM_LARGE_SHIELD)
if (verbose
&& item.sub_type != ARM_SHIELD
&& item.sub_type != ARM_BUCKLER
&& item.sub_type != ARM_LARGE_SHIELD)
if (item.sub_type == ARM_HELMET
&& (get_helmet_type( item ) == THELM_CAP
|| get_helmet_type( item ) == THELM_WIZARD_HAT))
{
// caps and wizard hats don't have a base AC
append_value(description, 0, false);
}
else if (item.sub_type == ARM_NAGA_BARDING
|| item.sub_type == ARM_CENTAUR_BARDING)
{
// Barding has AC value 4.
append_value(description, 4, false);
}
else
{
append_value(description, property( item, PARM_AC ), false);
}
append_value(description, property( item, PARM_AC ), false);
else if (class_wanted == OBJ_ARMOUR)
{
if (strstr( "naga barding", specs ))
{
mitm[thing_created].sub_type = ARM_NAGA_BARDING;
}
else if (strstr( "centaur barding", specs ))
{
mitm[thing_created].sub_type = ARM_CENTAUR_BARDING;
}
else if (strstr( "wizard's hat", specs ))
{
mitm[thing_created].sub_type = ARM_HELMET;
mitm[thing_created].plus2 = THELM_WIZARD_HAT;
}
else if (strstr( "cap", specs ))
{
mitm[thing_created].sub_type = ARM_HELMET;
mitm[thing_created].plus2 = THELM_CAP;
}
else if (strstr( "helm", specs ))
{
mitm[thing_created].sub_type = ARM_HELMET;
mitm[thing_created].plus2 = THELM_HELM;
}
}