summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorShmuale Mark <shm.mark@gmail.com>2014-08-03 13:59:36 -0400
committerShmuale Mark <shm.mark@gmail.com>2014-08-03 14:17:14 -0400
commit2e52a0c19d866a6a15b36163fa145a94bbf9721f (patch)
tree1ad40aea10861227400db415ab1c2adaef44252b /crawl-ref
parent2091673ee858097442a1668a947626a489639ece (diff)
downloadcrawl-ref-2e52a0c19d866a6a15b36163fa145a94bbf9721f.tar.gz
crawl-ref-2e52a0c19d866a6a15b36163fa145a94bbf9721f.zip
Hide a hack better.
Ideally, we wouldn't be using special for unrands totally different from how items of the same type do, but that's less trivial than this commit. A centralised place to check for being an unrand should at least make such a change easier.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acquire.cc5
-rw-r--r--crawl-ref/source/areas.cc4
-rw-r--r--crawl-ref/source/art-func.h2
-rw-r--r--crawl-ref/source/artefact.cc13
-rw-r--r--crawl-ref/source/artefact.h2
-rw-r--r--crawl-ref/source/attack.cc14
-rw-r--r--crawl-ref/source/fight.cc3
-rw-r--r--crawl-ref/source/goditem.cc4
-rw-r--r--crawl-ref/source/godpassive.cc5
-rw-r--r--crawl-ref/source/item_use.cc2
-rw-r--r--crawl-ref/source/itemname.cc2
-rw-r--r--crawl-ref/source/itemprop.cc2
-rw-r--r--crawl-ref/source/melee_attack.cc3
-rw-r--r--crawl-ref/source/monster.cc5
-rw-r--r--crawl-ref/source/player-equip.cc2
-rw-r--r--crawl-ref/source/ranged_attack.cc3
-rw-r--r--crawl-ref/source/spl-summoning.cc2
-rw-r--r--crawl-ref/source/tilepick.cc3
-rw-r--r--crawl-ref/source/transform.cc2
19 files changed, 36 insertions, 42 deletions
diff --git a/crawl-ref/source/acquire.cc b/crawl-ref/source/acquire.cc
index b2912a4f95..49ab48658c 100644
--- a/crawl-ref/source/acquire.cc
+++ b/crawl-ref/source/acquire.cc
@@ -1256,9 +1256,8 @@ int acquirement_create_item(object_class_type class_wanted,
int brand = get_weapon_brand(acq_item);
if (brand == SPWPN_PAIN
- || is_unrandom_artefact(acq_item)
- && (acq_item.special == UNRAND_TROG
- || acq_item.special == UNRAND_WUCAD_MU))
+ || is_unrandom_artefact(acq_item, UNRAND_TROG)
+ || is_unrandom_artefact(acq_item, UNRAND_WUCAD_MU))
{
destroy_item(thing_created, true);
thing_created = NON_ITEM;
diff --git a/crawl-ref/source/areas.cc b/crawl-ref/source/areas.cc
index c5ff6afc84..34c44b76fa 100644
--- a/crawl-ref/source/areas.cc
+++ b/crawl-ref/source/areas.cc
@@ -607,7 +607,7 @@ int monster::halo_radius2() const
item_def* weap = mslot_item(MSLOT_WEAPON);
int size = -1;
- if (weap && is_unrandom_artefact(*weap) && weap->special == UNRAND_BRILLIANCE)
+ if (weap && is_unrandom_artefact(*weap, UNRAND_BRILLIANCE))
size = 10;
if (holiness() != MH_HOLY)
@@ -757,7 +757,7 @@ int player::umbra_radius2() const
int monster::umbra_radius2() const
{
item_def* ring = mslot_item(MSLOT_JEWELLERY);
- if (ring && is_unrandom_artefact(*ring) && ring->special == UNRAND_SHADOWS)
+ if (ring && is_unrandom_artefact(*ring, UNRAND_SHADOWS))
return 10;
if (holiness() != MH_UNDEAD)
diff --git a/crawl-ref/source/art-func.h b/crawl-ref/source/art-func.h
index 0cd22c1510..a20389ee82 100644
--- a/crawl-ref/source/art-func.h
+++ b/crawl-ref/source/art-func.h
@@ -1236,7 +1236,7 @@ static int _octorings_worn()
continue;
item_def& ring = you.inv[you.equip[i]];
- if (is_unrandom_artefact(ring) && ring.special == UNRAND_OCTOPUS_KING_RING)
+ if (is_unrandom_artefact(ring, UNRAND_OCTOPUS_KING_RING))
worn++;
}
diff --git a/crawl-ref/source/artefact.cc b/crawl-ref/source/artefact.cc
index 0aa8aa8ec8..4a2b26377b 100644
--- a/crawl-ref/source/artefact.cc
+++ b/crawl-ref/source/artefact.cc
@@ -343,10 +343,17 @@ bool is_random_artefact(const item_def &item)
return item.flags & ISFLAG_RANDART;
}
-// returns true if item in an unrandart
-bool is_unrandom_artefact(const item_def &item)
+/** Is this an unrandart, and if so which one?
+ *
+ * @param item The item to be checked.
+ * @param which The unrand enum to be checked against (default 0).
+ * @returns true if item is an unrand, and if which is not 0, if it is the unrand
+ * specfied by enum in which.
+ */
+bool is_unrandom_artefact(const item_def &item, unrand_type which)
{
- return item.flags & ISFLAG_UNRANDART;
+ return item.flags & ISFLAG_UNRANDART
+ && (!which || which == item.special);
}
bool is_special_unrandom_artefact(const item_def &item)
diff --git a/crawl-ref/source/artefact.h b/crawl-ref/source/artefact.h
index ad66e8d346..8f4eb641e9 100644
--- a/crawl-ref/source/artefact.h
+++ b/crawl-ref/source/artefact.h
@@ -74,7 +74,7 @@ struct unrandart_entry
bool is_known_artefact(const item_def &item);
bool is_artefact(const item_def &item);
bool is_random_artefact(const item_def &item);
-bool is_unrandom_artefact(const item_def &item);
+bool is_unrandom_artefact(const item_def &item, unrand_type which = 0);
bool is_special_unrandom_artefact(const item_def &item);
bool is_randapp_artefact(const item_def &item);
void autoid_unrand(item_def &item);
diff --git a/crawl-ref/source/attack.cc b/crawl-ref/source/attack.cc
index 30f7993fbd..715462fb3f 100644
--- a/crawl-ref/source/attack.cc
+++ b/crawl-ref/source/attack.cc
@@ -280,11 +280,8 @@ int attack::calc_to_hit(bool random)
if (attacker->confused())
mhit -= 5;
- if (using_weapon() && is_unrandom_artefact(*weapon)
- && weapon->special == UNRAND_WOE)
- {
+ if (using_weapon() && is_unrandom_artefact(*weapon, UNRAND_WOE))
return AUTOMATIC_HIT;
- }
// If no defender, we're calculating to-hit for debug-display
// purposes, so don't drop down to defender code below
@@ -1756,7 +1753,7 @@ bool attack::apply_damage_brand(const char *what)
|| attacker->is_player() && you.duration[DUR_DEATHS_DOOR]
|| !attacker->is_player()
&& attacker->as_monster()->has_ench(ENCH_DEATHS_DOOR)
- || (x_chance_in_y(2, 5) && !(weapon->special == UNRAND_LEECH)))
+ || (x_chance_in_y(2, 5) && !is_unrandom_artefact(*weapon, UNRAND_LEECH))
{
break;
}
@@ -1782,8 +1779,8 @@ bool attack::apply_damage_brand(const char *what)
}
}
- int hp_boost = weapon->special == UNRAND_VAMPIRES_TOOTH
- ? damage_done : 1 + random2(damage_done);
+ int hp_boost = is_unrandom_artefact(*weapon, UNRAND_VAMPIRES_TOOTH)
+ ? damage_done : 1 + random2(damage_done);
dprf(DIAG_COMBAT, "Vampiric Healing: damage %d, healed %d",
damage_done, hp_boost);
@@ -1853,8 +1850,7 @@ bool attack::apply_damage_brand(const char *what)
break;
default:
- if (using_weapon() && is_unrandom_artefact(*weapon)
- && weapon->special == UNRAND_HELLFIRE)
+ if (using_weapon() && is_unrandom_artefact(*weapon, UNRAND_HELLFIRE))
{
calc_elemental_brand_damage(BEAM_HELLFIRE,
defender->is_monster()
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index f3b5f16b6c..37667323a8 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -333,8 +333,7 @@ bool fight_jump(actor *attacker, actor *defender, coord_def attack_pos,
// On the first landing site, check the hit function for Devastator.
if (!check_landing_only && !conduct_prompted
- && weapon && is_unrandom_artefact(*weapon)
- && weapon->special == UNRAND_DEVASTATOR)
+ && weapon && is_unrandom_artefact(*weapon, UNRAND_DEVASTATOR))
{
const char* verb = "jump-attack";
string junk1, junk2;
diff --git a/crawl-ref/source/goditem.cc b/crawl-ref/source/goditem.cc
index ed3df3f28c..819cfd079f 100644
--- a/crawl-ref/source/goditem.cc
+++ b/crawl-ref/source/goditem.cc
@@ -400,7 +400,7 @@ bool is_poisoned_item(const item_def& item)
bool is_illuminating_item(const item_def& item)
{
// No halo for you!
- if (is_unrandom_artefact(item) && item.special == UNRAND_BRILLIANCE)
+ if (is_unrandom_artefact(item, UNRAND_BRILLIANCE))
return true;
switch (item.base_type)
@@ -448,7 +448,7 @@ static bool _is_potentially_fiery_item(const item_def& item)
bool is_fiery_item(const item_def& item)
{
// Flaming Death is handled through its fire brand.
- if (is_unrandom_artefact(item) && item.special == UNRAND_HELLFIRE)
+ if (is_unrandom_artefact(item, UNRAND_HELLFIRE))
return true;
switch (item.base_type)
diff --git a/crawl-ref/source/godpassive.cc b/crawl-ref/source/godpassive.cc
index 7bb7031207..7c524f8403 100644
--- a/crawl-ref/source/godpassive.cc
+++ b/crawl-ref/source/godpassive.cc
@@ -216,11 +216,8 @@ void ash_check_bondage(bool msg)
else
{
cursed[s]++;
- if (i == EQ_BODY_ARMOUR && is_unrandom_artefact(item)
- && item.special == UNRAND_LEAR)
- {
+ if (i == EQ_BODY_ARMOUR && is_unrandom_artefact(item, UNRAND_LEAR))
cursed[s] += 3;
- }
}
}
}
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index f8218ae84b..2cfca3750f 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -514,7 +514,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary)
}
// Lear's hauberk covers also head, hands and legs.
- if (is_unrandom_artefact(item) && item.special == UNRAND_LEAR)
+ if (is_unrandom_artefact(item, UNRAND_LEAR))
{
if (!player_has_feet(!ignore_temporary))
{
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 0a38c1858d..5a33428c4d 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1364,7 +1364,7 @@ string item_def::name_aux(description_level_type desc, bool terse, bool ident,
if (know_pluses)
{
- if (is_unrandom_artefact(*this) && special == UNRAND_WOE)
+ if (is_unrandom_artefact(*this, UNRAND_WOE))
buff << "+∞ ";
else
buff << make_stringf("%+d ", it_plus);
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index d213fb7929..e48616a924 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -1588,7 +1588,7 @@ skill_type range_skill(object_class_type wclass, int wtype)
// True if item is a staff that deals extra damage based on Evocations skill.
static bool _staff_uses_evocations(const item_def &item)
{
- if (is_unrandom_artefact(item) && item.special == UNRAND_ELEMENTAL_STAFF)
+ if (is_unrandom_artefact(item, UNRAND_ELEMENTAL_STAFF))
return true;
if (!item_type_known(item) || item.base_type != OBJ_STAVES)
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc
index e592b92261..36368910b4 100644
--- a/crawl-ref/source/melee_attack.cc
+++ b/crawl-ref/source/melee_attack.cc
@@ -147,8 +147,7 @@ bool melee_attack::handle_phase_attempted()
{
// These checks are handled in fight_jump() for jump attacks
if (!jumping_attack && weapon
- && is_unrandom_artefact(*weapon)
- && weapon->special == UNRAND_DEVASTATOR)
+ && is_unrandom_artefact(*weapon, UNRAND_DEVASTATOR))
{
const char* verb = "attack";
string junk1, junk2;
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 4a8365c6ec..50b12e93cd 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -1537,8 +1537,7 @@ static bool _is_signature_weapon(const monster* mons, const item_def &weapon)
{
return weapon.base_type == OBJ_STAVES
&& weapon.sub_type == STAFF_POISON
- || weapon.base_type == OBJ_WEAPONS
- && weapon.special == UNRAND_OLGREB;
+ || is_unrandom_artefact(weapon, UNRAND_OLGREB);
}
if (mons->type == MONS_FANNAR)
@@ -2978,7 +2977,7 @@ bool monster::go_berserk(bool intentional, bool /* potion */)
if (const item_def* w = weapon())
{
- if (is_unrandom_artefact(*w) && w->special == UNRAND_JIHAD)
+ if (is_unrandom_artefact(*w, UNRAND_JIHAD))
for (actor_near_iterator mi(pos(), LOS_NO_TRANS); mi; ++mi)
if (mons_aligned(this, *mi))
mi->go_berserk(false);
diff --git a/crawl-ref/source/player-equip.cc b/crawl-ref/source/player-equip.cc
index 468d8782c9..50b78eb81b 100644
--- a/crawl-ref/source/player-equip.cc
+++ b/crawl-ref/source/player-equip.cc
@@ -152,7 +152,7 @@ static void _assert_valid_slot(equipment_type eq, equipment_type slot)
if (slot >= r1 && slot <= r2)
return;
if (const item_def* amu = you.slot_item(EQ_AMULET, true))
- if (amu->special == UNRAND_FINGER_AMULET && slot == EQ_RING_AMULET)
+ if (is_unrandom_artefact(*amu, UNRAND_FINGER_AMULET) && slot == EQ_RING_AMULET)
return;
die("ring on invalid slot %d", slot);
#endif
diff --git a/crawl-ref/source/ranged_attack.cc b/crawl-ref/source/ranged_attack.cc
index 899ea8c417..d08bfdb751 100644
--- a/crawl-ref/source/ranged_attack.cc
+++ b/crawl-ref/source/ranged_attack.cc
@@ -832,8 +832,7 @@ void ranged_attack::player_stab_check()
{
attack::player_stab_check();
// Sometimes the blowgun of the Assassin lets you stab an aware target.
- if (!stab_attempt && is_unrandom_artefact(*weapon)
- && weapon->special == UNRAND_BLOWGUN_ASSASSIN
+ if (!stab_attempt && is_unrandom_artefact(*weapon, UNRAND_BLOWGUN_ASSASSIN)
&& one_chance_in(3))
{
stab_attempt = true;
diff --git a/crawl-ref/source/spl-summoning.cc b/crawl-ref/source/spl-summoning.cc
index cfa29f4df2..a1e67aed25 100644
--- a/crawl-ref/source/spl-summoning.cc
+++ b/crawl-ref/source/spl-summoning.cc
@@ -217,7 +217,7 @@ spret_type cast_summon_swarm(int pow, god_type god, bool fail)
int tries = 0;
do
{
- mon = random_choose_weighted(1, MONS_BUTTERFLY
+ mon = random_choose_weighted(1, MONS_BUTTERFLY,
1, MONS_WORM,
3, MONS_WORKER_ANT,
1, MONS_SCORPION,
diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc
index d71f552989..4ee63ba04f 100644
--- a/crawl-ref/source/tilepick.cc
+++ b/crawl-ref/source/tilepick.cc
@@ -2849,8 +2849,7 @@ static tileidx_t _tileidx_monster_no_props(const monster_info& mon)
if (!mon.inv[MSLOT_SHIELD].get() && weapon
&& (weapon->base_type == OBJ_STAVES
&& weapon->sub_type == STAFF_POISON
- || weapon->base_type == OBJ_WEAPONS
- && weapon->special == UNRAND_OLGREB))
+ || is_unrandom_artefact(*weapon, UNRAND_OLGREB)))
{
return TILEP_MONS_ARACHNE;
}
diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc
index 989fd75c83..940ebbf633 100644
--- a/crawl-ref/source/transform.cc
+++ b/crawl-ref/source/transform.cc
@@ -420,7 +420,7 @@ void unmeld_one_equip(equipment_type eq)
{
if (eq >= EQ_HELMET && eq <= EQ_BOOTS)
if (const item_def* arm = you.slot_item(EQ_BODY_ARMOUR, true))
- if (arm->special == UNRAND_LEAR)
+ if (is_unrandom_artefact(*arm, UNRAND_LEAR)
eq = EQ_BODY_ARMOUR;
set<equipment_type> e;