diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-12-10 21:25:11 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-12-10 21:25:11 +0000 |
commit | 9020068a7cd2e62822fb32a2d54b60fe3ec27b35 (patch) | |
tree | fad885868a790e4f1371f21f204b35b6d3ba6e0d | |
parent | 1e79812dc4bcc00f7a00164300ff19f38abc0cc9 (diff) | |
download | crawl-ref-9020068a7cd2e62822fb32a2d54b60fe3ec27b35.tar.gz crawl-ref-9020068a7cd2e62822fb32a2d54b60fe3ec27b35.zip |
Helmets, helms, caps and wizard hats now have their own subtypes, as
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
-rw-r--r-- | crawl-ref/source/debug.cc | 27 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 78 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.cc | 113 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.h | 56 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 22 | ||||
-rw-r--r-- | crawl-ref/source/makeitem.cc | 94 | ||||
-rw-r--r-- | crawl-ref/source/mutation.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 22 | ||||
-rw-r--r-- | crawl-ref/source/shopping.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/tags.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/tutorial.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/unrand.h | 6 |
15 files changed, 138 insertions, 353 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index baa38dde2d..e950717e1e 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -1102,32 +1102,6 @@ void create_spec_object() return; } } - 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; - } - } if (!mitm[thing_created].sub_type) { @@ -1621,7 +1595,6 @@ void debug_item_scan( void ) || (mitm[i].base_type == OBJ_ARMOUR && (abs(mitm[i].plus) > 25 || (!is_random_artefact( mitm[i] ) - && mitm[i].sub_type != ARM_HELMET && mitm[i].special >= 30)))) { mpr( "Bad plus or special value:", MSGCH_WARN ); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 2013187ce3..fbc3be1a77 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1423,33 +1423,17 @@ static std::string describe_armour( const item_def &item, bool verbose ) description.reserve(200); - 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) { description += "$Armour rating: "; - - 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); description += "$Evasion modifier: "; append_value(description, property( item, PARM_EVASION ), true); + description += "$"; } diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index c678965712..77e572b386 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -770,16 +770,17 @@ bool melee_attack::player_aux_unarmed() // minotaurs used to get +5 damage here, now they get // +6 because of the horns. - if (you.equip[EQ_HELMET] != -1 - && (get_helmet_type(you.inv[you.equip[EQ_HELMET]]) == THELM_HELMET - || get_helmet_type(you.inv[you.equip[EQ_HELMET]]) == THELM_HELM)) + if (you.equip[EQ_HELMET] != -1) { - 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) ) { - aux_damage += 3; + aux_damage += 2; + if (get_helmet_desc(helmet) == THELM_DESC_SPIKED + || get_helmet_desc(helmet) == THELM_DESC_HORNED) + { + aux_damage += 3; + } } } break; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 6abc5a71ea..894a1723bf 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -845,9 +845,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary) // it fits return (true); } - else if (sub_type == ARM_HELMET - && (get_helmet_type(item) == THELM_CAP - || get_helmet_type(item) == THELM_WIZARD_HAT)) + else if (sub_type == ARM_CAP || sub_type == ARM_WIZARD_HAT) { // caps & wiz hats always fit return (true); @@ -881,9 +879,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary) || (sub_type >= ARM_GLOVES && sub_type <= ARM_BUCKLER) || sub_type == ARM_CRYSTAL_PLATE_MAIL - || (sub_type == ARM_HELMET - && (get_helmet_type(item) == THELM_HELM - || get_helmet_type(item) == THELM_HELMET))) + || is_hard_helmet(item)) { if (verbose) mpr("This armour doesn't fit on your body."); @@ -902,9 +898,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary) || sub_type == ARM_SHIELD || sub_type == ARM_LARGE_SHIELD || sub_type == ARM_CRYSTAL_PLATE_MAIL - || (sub_type == ARM_HELMET - && (get_helmet_type(item) == THELM_HELM - || get_helmet_type(item) == THELM_HELMET))) + || is_hard_helmet(item)) { if (verbose) mpr("This armour doesn't fit on your body."); diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 394a1c7160..bece148f39 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -1164,9 +1164,7 @@ std::string item_def::name_aux( description_level_type desc, break; if (item_typ == ARM_ROBE || item_typ == ARM_CLOAK || item_typ == ARM_GLOVES || item_typ == ARM_BOOTS - || (item_typ == ARM_HELMET && - (get_helmet_type( *this ) == THELM_CAP || - get_helmet_type( *this ) == THELM_WIZARD_HAT))) + || (item_typ == ARM_CAP || item_typ == ARM_WIZARD_HAT)) { buff << "embroidered "; } @@ -1197,25 +1195,21 @@ std::string item_def::name_aux( description_level_type desc, buff << racial_description_string(*this, terse); } - if (!basename && !dbname && sub_type == ARM_HELMET) + if (!basename && !dbname && is_hard_helmet(*this)) { - 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 "); } buff << item_base_name(*this); @@ -2206,12 +2200,6 @@ void init_item_name_cache() if (base_type == OBJ_JEWELLERY && name == "buggy jewellery") continue; - else if (item.base_type == OBJ_ARMOUR - && get_armour_slot( item ) == EQ_HELMET) - { - // Why do we handle helmets this way? - continue; - } else if (name.find("buggy") != std::string::npos) { crawl_state.add_startup_error("Bad name for item name " @@ -2228,42 +2216,6 @@ void init_item_name_cache() } ASSERT(item_names_cache.size() > 0); - - 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); } item_types_pair item_types_by_name(std::string name) diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 1bbb7861a4..840aed7a0c 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -126,9 +126,15 @@ static armour_def Armour_prop[NUM_ARMOURS] = { ARM_HELMET, "helmet", 1, 0, 80, false, EQ_HELMET, SIZE_SMALL, SIZE_MEDIUM }, + { ARM_HELM, "helm", 1, 0, 80, + false, EQ_HELMET, SIZE_SMALL, SIZE_MEDIUM }, + { ARM_CAP, "cap", 0, 0, 40, true, EQ_HELMET, SIZE_LITTLE, SIZE_LARGE }, + { ARM_WIZARD_HAT, "wizard hat", 0, 0, 40, + true, EQ_HELMET, SIZE_LITTLE, SIZE_LARGE }, + // Note that barding size is compared against torso so it currently // needs to fit medium, but that doesn't matter as much as race // and shapeshift status. @@ -745,81 +751,45 @@ void set_equip_desc( item_def &item, unsigned long flags ) // // These functions handle the description and subtypes for helmets/caps // -short get_helmet_type( const item_def &item ) -{ - ASSERT( item.base_type == OBJ_ARMOUR - && get_armour_slot( item ) == EQ_HELMET ); - - return (item.plus2 & THELM_TYPE_MASK); -} - short get_helmet_desc( const item_def &item ) { ASSERT( item.base_type == OBJ_ARMOUR && get_armour_slot( item ) == EQ_HELMET ); - return (item.plus2 & THELM_DESC_MASK); + return item.plus2; } -void set_helmet_type( item_def &item, short type ) +void set_helmet_desc( item_def &item, helmet_desc_type type ) { - ASSERT( (type & ~THELM_TYPE_MASK) == 0 ); - ASSERT( item.base_type == OBJ_ARMOUR - && get_armour_slot( item ) == EQ_HELMET ); + ASSERT( is_helmet(item) ); - // 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; - item.plus2 &= ~THELM_TYPE_MASK; - item.plus2 |= type; + item.plus2 = type; } -void set_helmet_desc( item_def &item, short type ) +bool is_helmet(const item_def& item) { - 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; } bool is_hard_helmet(const item_def &item) { return (item.base_type == OBJ_ARMOUR - && item.sub_type == ARM_HELMET - && (get_helmet_type(item) == THELM_HELM - || get_helmet_type(item) == THELM_HELMET)); + && (item.sub_type == ARM_HELMET || + item.sub_type == ARM_HELM)); } void set_helmet_random_desc( item_def &item ) { - ASSERT( item.base_type == OBJ_ARMOUR - && get_armour_slot( item ) == EQ_HELMET ); - - item.plus2 &= ~THELM_DESC_MASK; + ASSERT( is_helmet(item) ); if (is_hard_helmet(item)) - item.plus2 |= (random2(8) << 8); + item.plus2 = random2(THELM_NUM_DESCS); else - 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); } // @@ -1002,21 +972,14 @@ bool armour_not_shiny( const item_def &item ) case ARM_BOOTS: case ARM_NAGA_BARDING: case ARM_CENTAUR_BARDING: - case ARM_CAP: case ARM_LEATHER_ARMOUR: case ARM_STUDDED_LEATHER_ARMOUR: case ARM_ANIMAL_SKIN: case ARM_TROLL_HIDE: case ARM_TROLL_LEATHER_ARMOUR: + case ARM_CAP: + case ARM_WIZARD_HAT: return (true); - - case ARM_HELMET: - { - const int helmtype = get_helmet_type(item); - return (helmtype == THELM_CAP || helmtype == THELM_WIZARD_HAT); - } - default: - break; } return (false); @@ -1195,9 +1158,7 @@ bool check_armour_shape( const item_def &item, bool quiet ) break; case EQ_HELMET: - if (item.sub_type == ARM_CAP - || get_helmet_type(item) == THELM_CAP - || get_helmet_type(item) == THELM_WIZARD_HAT) + if (item.sub_type == ARM_CAP || item.sub_type == ARM_WIZARD_HAT) break; if (you.species == SP_KENKU) @@ -2337,10 +2298,13 @@ size_type item_size( const item_def &item ) { case ARM_GLOVES: case ARM_HELMET: + case ARM_HELM: case ARM_CAP: + case ARM_WIZARD_HAT: case ARM_BOOTS: case ARM_BUCKLER: // tiny armour + size = SIZE_TINY; break; case ARM_SHIELD: @@ -2411,9 +2375,7 @@ bool is_colourful_item( const item_def &item ) bool is_shield(const item_def &item) { return item.base_type == OBJ_ARMOUR - && (item.sub_type == ARM_SHIELD - || item.sub_type == ARM_BUCKLER - || item.sub_type == ARM_LARGE_SHIELD); + && get_armour_slot(item) == EQ_SHIELD; } // Returns true if the given item cannot be wielded with the given shield. @@ -2439,26 +2401,7 @@ std::string item_base_name(const item_def &item) case OBJ_MISSILES: return Missile_prop[Missile_index[item.sub_type]].name; case OBJ_ARMOUR: - 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; default: return ""; } diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h index 4c5763afe9..6873ac5ab3 100644 --- a/crawl-ref/source/itemprop.h +++ b/crawl-ref/source/itemprop.h @@ -16,42 +16,44 @@ enum armour_type { - ARM_ROBE, // 0 + ARM_ROBE, ARM_LEATHER_ARMOUR, ARM_RING_MAIL, ARM_SCALE_MAIL, ARM_CHAIN_MAIL, - ARM_SPLINT_MAIL, // 5 + ARM_SPLINT_MAIL, ARM_BANDED_MAIL, ARM_PLATE_MAIL, ARM_SHIELD, ARM_CLOAK, - ARM_HELMET, // 10 + ARM_HELMET, + ARM_HELM, + ARM_CAP, + ARM_WIZARD_HAT, ARM_GLOVES, ARM_BOOTS, ARM_BUCKLER, ARM_LARGE_SHIELD, - ARM_DRAGON_HIDE, // 15 + ARM_DRAGON_HIDE, ARM_TROLL_HIDE, ARM_CRYSTAL_PLATE_MAIL, ARM_DRAGON_ARMOUR, ARM_TROLL_LEATHER_ARMOUR, - ARM_ICE_DRAGON_HIDE, // 20 + ARM_ICE_DRAGON_HIDE, ARM_ICE_DRAGON_ARMOUR, ARM_STEAM_DRAGON_HIDE, ARM_STEAM_DRAGON_ARMOUR, ARM_MOTTLED_DRAGON_HIDE, - ARM_MOTTLED_DRAGON_ARMOUR, // 25 + ARM_MOTTLED_DRAGON_ARMOUR, ARM_STORM_DRAGON_HIDE, ARM_STORM_DRAGON_ARMOUR, ARM_GOLD_DRAGON_HIDE, ARM_GOLD_DRAGON_ARMOUR, - ARM_ANIMAL_SKIN, // 30 + ARM_ANIMAL_SKIN, ARM_SWAMP_DRAGON_HIDE, ARM_SWAMP_DRAGON_ARMOUR, ARM_STUDDED_LEATHER_ARMOUR, - ARM_CAP, - ARM_CENTAUR_BARDING, // 35 + ARM_CENTAUR_BARDING, ARM_NAGA_BARDING, NUM_ARMOURS @@ -142,27 +144,18 @@ enum hands_reqd_type HANDS_DOUBLE // not a level, marks double ended weapons (== half) }; -enum helmet_type +enum helmet_desc_type { - 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 }; enum jewellery_type @@ -594,14 +587,13 @@ unsigned long get_equip_race( const item_def &item ); unsigned long get_equip_desc( const item_def &item ); // helmet functions: -void set_helmet_type( item_def &item, short flags ); void set_helmet_desc( item_def &item, short flags ); void set_helmet_random_desc( item_def &item ); -short get_helmet_type( const item_def &item ); short get_helmet_desc( const item_def &item ); -bool is_helmet_type( const item_def &item, short val ); +bool is_helmet( const item_def& item ); +bool is_hard_helmet( const item_def& item ); // ego items: bool set_item_ego_type( item_def &item, int item_type, int ego_type ); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 2399c68080..e5520d430b 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -3067,28 +3067,6 @@ static bool find_subtype_by_name(item_def &item, item.quantity = 1; set_ident_flags( item, ISFLAG_KNOW_TYPE | ISFLAG_KNOW_PROPERTIES ); - 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; - } - } - - if (item.sub_type != OBJ_RANDOM) - return (true); - int type_wanted = -1; for (int i = 0; i < ntypes; i++) diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index fdc9578a8e..cf8ff56ffe 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -257,18 +257,13 @@ static int newwave_armour_colour(const item_def &item) item_colour = RED; break; case ARM_CAP: + case ARM_WIZARD_HAT: item_colour = MAGENTA; break; case ARM_HELMET: - 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; break; - case ARM_BOOTS: item_colour = BLUE; break; @@ -305,20 +300,13 @@ static int classic_armour_colour(const item_def &item) case ARM_NAGA_BARDING: case ARM_CENTAUR_BARDING: case ARM_CAP: + case ARM_WIZARD_HAT: item_colour = random_colour(); break; - + case ARM_HELM: case ARM_HELMET: - // caps and wizard's hats are random coloured - if (get_helmet_type(item) == THELM_CAP - || get_helmet_type(item) == THELM_WIZARD_HAT) - { - item_colour = random_colour(); - } - else - item_colour = LIGHTCYAN; + item_colour = LIGHTCYAN; break; - case ARM_BOOTS: // maybe more interesting boot colours? case ARM_GLOVES: case ARM_LEATHER_ARMOUR: @@ -1828,18 +1816,6 @@ static bool try_make_armour_artefact(item_def& item, int force_type, return false; } -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 ); -} - static item_status_flag_type determine_armour_race(const item_def& item, int item_race) { @@ -1894,21 +1870,18 @@ static item_status_flag_type determine_armour_race(const item_def& item, rc = ISFLAG_DWARVEN; break; + case ARM_CAP: + case ARM_WIZARD_HAT: + if (one_chance_in(6)) + rc = ISFLAG_ELVEN; + break; + + case ARM_HELM: case ARM_HELMET: - 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; break; case ARM_ROBE: @@ -1969,14 +1942,16 @@ static special_armour_type determine_armour_ego(const item_def& item, break; } + case ARM_WIZARD_HAT: + if ( coinflip() ) + rc = (one_chance_in(3) ? + SPARM_MAGIC_RESISTANCE : SPARM_INTELLIGENCE); + break; + case ARM_HELMET: - 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; break; case ARM_GLOVES: @@ -2049,8 +2024,8 @@ static void generate_armour_item(item_def& item, bool allow_uniques, if (allow_uniques && try_make_armour_artefact(item, force_type, item_level)) return; - if (item.sub_type == ARM_HELMET) - determine_helmet_types(item); + if ( is_helmet(item) && one_chance_in(3) ) + set_helmet_random_desc(item); if (item_race == MAKE_ITEM_RANDOM_RACE && item.sub_type == ARM_BOOTS) { @@ -2068,8 +2043,7 @@ static void generate_armour_item(item_def& item, bool allow_uniques, const bool force_good = (item_level == MAKE_GOOD_ITEM); - if (force_good || (item.sub_type == ARM_HELMET - && get_helmet_type(item) == THELM_WIZARD_HAT) + if (force_good || item.sub_type == ARM_WIZARD_HAT || 50 + item_level >= random2(250)) { // Make a good item... @@ -4068,13 +4042,14 @@ armour_type get_random_armour_type(int item_level) } if (random2(60) <= item_level + 10) - armtype = random2(8); + armtype = random2(ARM_SHIELD); // body armour of some kind if (10 + item_level >= random2(400) && one_chance_in(20)) - armtype = ARM_DRAGON_HIDE + random2(7); + armtype = ARM_DRAGON_HIDE + random2(7); // (ice) dragon/troll/crystal if (10 + item_level >= random2(500) && one_chance_in(20)) { + // other dragon hides/armour or animal skin armtype = ARM_STEAM_DRAGON_HIDE + random2(11); if (armtype == ARM_ANIMAL_SKIN && one_chance_in(20)) @@ -4085,6 +4060,11 @@ armour_type get_random_armour_type(int item_level) if (one_chance_in(5)) { armtype = ARM_SHIELD + random2(5); + if ( armtype > ARM_HELMET ) + armtype += 3; + + if ( armtype == ARM_HELMET && one_chance_in(3) ) + armtype = ARM_HELMET + random2(4); if (armtype == ARM_SHIELD) // 33.3% { diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index ad6feac024..c826468563 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -1804,8 +1804,8 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation, mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION); if (you.equip[EQ_HELMET] != -1 && - (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)) { break; // horns don't push caps/wizard hats off } diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index bd9d374cd9..f18ca8208f 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1739,28 +1739,20 @@ int player_AC(void) for (i = EQ_CLOAK; i <= EQ_BODY_ARMOUR; i++) { - const int item = you.equip[i]; + if ( i == EQ_SHIELD ) + continue; - if (item == -1 || i == EQ_SHIELD) + if ( you.equip[i] == -1 ) continue; - AC += you.inv[ item ].plus * 100; + const item_def& item = you.inv[you.equip[i]]; - // 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; // additional *half*-levels of armour skill. int racial_bonus = 0; - 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; // Dwarven armour is universally good -- bwr if (armour_race == ISFLAG_DWARVEN) diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index f3f8440ba2..7d8353897f 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -893,6 +893,9 @@ unsigned int item_value( item_def item, bool ident ) break; case ARM_HELMET: + case ARM_HELM: + case ARM_CAP: + case ARM_WIZARD_HAT: case ARM_BUCKLER: valued += 25; break; diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 53f856911f..91787d9ac9 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1618,11 +1618,6 @@ void unmarshallItem(tagHeader &th, item_def &item) item.y = unmarshallShort(th); item.flags = (unsigned long) unmarshallLong(th); - // [dshaligram] FIXME, remove this kludge when ARM_CAP is fully - // integrated. - if (item.base_type == OBJ_ARMOUR && item.sub_type == ARM_CAP) - item.sub_type = ARM_HELMET; - unmarshallShort(th); // mitm[].link -- unused unmarshallShort(th); // igrd[item.x][item.y] -- unused diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 879c72e06f..a0a0803e63 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -1693,9 +1693,7 @@ void tutorial_describe_item(const item_def &item) "and innate abilities.)"; wearable = false; } - else if (you.species == SP_MINOTAUR && item.sub_type == ARM_HELMET - && get_helmet_type(item) != THELM_CAP - && get_helmet_type(item) != THELM_WIZARD_HAT) + else if (you.species == SP_MINOTAUR && is_hard_helmet(item)) { ostr << "As a Minotaur you cannot wear helmets. " "(Type <w>A<magenta> to see a list of your mutations " diff --git a/crawl-ref/source/unrand.h b/crawl-ref/source/unrand.h index 375d2a128f..3b5e818e9f 100644 --- a/crawl-ref/source/unrand.h +++ b/crawl-ref/source/unrand.h @@ -339,7 +339,7 @@ /* 11 */ { "crown of Dyrovepreva", "jewelled bronze crown", - OBJ_ARMOUR, ARM_HELMET, +3, THELM_SPECIAL, BROWN, + OBJ_ARMOUR, ARM_HELMET, +3, 0, BROWN, { 0, 0, 0, 0, 2, 0, // int 0, 0, 1, 0, 0, 0, // res elec @@ -893,7 +893,7 @@ /* 41 */ { "mask of the Dragon", "blue mask", - OBJ_ARMOUR, ARM_HELMET, +0, THELM_SPECIAL, BLUE, + OBJ_ARMOUR, ARM_CAP, +0, 0, BLUE, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, // res magic @@ -1057,7 +1057,7 @@ /* 50 */ { "hat of the Alchemist", "dirty hat", - OBJ_ARMOUR, ARM_HELMET, +2, THELM_WIZARD_HAT, MAGENTA, + OBJ_ARMOUR, ARM_WIZARD_HAT, +2, 0, MAGENTA, { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 30, // res fire, cold, elec, magic |