summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-12 20:16:45 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-13 00:33:57 -0700
commit9b6b733bccd0de2af35eb6c28e94e4708a92004d (patch)
tree30400b1991c700b09fff5dc4644dc43a2c693121
parent3663d864c83a72c7cf624617e9a9a5b8b5deaf6a (diff)
downloadcrawl-ref-9b6b733bccd0de2af35eb6c28e94e4708a92004d.tar.gz
crawl-ref-9b6b733bccd0de2af35eb6c28e94e4708a92004d.zip
Refactor weapon_skill()
This function was misleadingly named (it only provided the skill used for melee weapons, not ranged weapons), and incomplete; code along the lines of "is_ranged_weapon(*it) ? range_skill(*it) : weapon_skill(*it)" was scattered in about half a dozen different functions. I've corrected both of those problems (renaming weapon_ skill() to melee_skill() and adding item_weapon_skill()), and also possibly fixed two bugs in the process - an l_you.cc function that claimed to provide the skill used for the starting weapon (but actually only gave the melee skill), and unrand creation code that checked if a potential unrand swap used the same (melee) skill as the weapon type being generated.
-rw-r--r--crawl-ref/source/acquire.cc4
-rw-r--r--crawl-ref/source/artefact.cc4
-rw-r--r--crawl-ref/source/attack.cc5
-rw-r--r--crawl-ref/source/describe.cc9
-rw-r--r--crawl-ref/source/fight.cc4
-rw-r--r--crawl-ref/source/ghost.cc2
-rw-r--r--crawl-ref/source/godabil.cc2
-rw-r--r--crawl-ref/source/godpassive.cc3
-rw-r--r--crawl-ref/source/hints.cc2
-rw-r--r--crawl-ref/source/itemname.cc6
-rw-r--r--crawl-ref/source/itemprop.cc63
-rw-r--r--crawl-ref/source/itemprop.h7
-rw-r--r--crawl-ref/source/items.cc2
-rw-r--r--crawl-ref/source/l_item.cc4
-rw-r--r--crawl-ref/source/l_you.cc2
-rw-r--r--crawl-ref/source/main.cc2
-rw-r--r--crawl-ref/source/makeitem.cc77
-rw-r--r--crawl-ref/source/mon-behv.cc2
-rw-r--r--crawl-ref/source/monster.cc10
-rw-r--r--crawl-ref/source/ng-setup.cc2
-rw-r--r--crawl-ref/source/player-act.cc4
-rw-r--r--crawl-ref/source/player-equip.cc2
-rw-r--r--crawl-ref/source/player.cc2
-rw-r--r--crawl-ref/source/spl-summoning.cc2
-rw-r--r--crawl-ref/source/spl-wpnench.cc2
-rw-r--r--crawl-ref/source/wiz-fsim.cc6
26 files changed, 118 insertions, 112 deletions
diff --git a/crawl-ref/source/acquire.cc b/crawl-ref/source/acquire.cc
index 25fb7a1906..6661f3b1dc 100644
--- a/crawl-ref/source/acquire.cc
+++ b/crawl-ref/source/acquire.cc
@@ -463,9 +463,7 @@ static int _acquirement_weapon_subtype(bool divine, int & /*quantity*/)
// 0% or 100% in the above formula. At skill 25 that's *3.5 .
for (int i = 0; i < NUM_WEAPONS; ++i)
{
- int wskill = range_skill(OBJ_WEAPONS, i);
- if (wskill == SK_THROWING)
- wskill = weapon_skill(OBJ_WEAPONS, i);
+ const int wskill = item_attack_skill(OBJ_WEAPONS, i);
if (wskill != skill)
continue;
diff --git a/crawl-ref/source/artefact.cc b/crawl-ref/source/artefact.cc
index be835b3d22..5e088e6e16 100644
--- a/crawl-ref/source/artefact.cc
+++ b/crawl-ref/source/artefact.cc
@@ -1577,8 +1577,8 @@ int find_okay_unrandart(uint8_t aclass, uint8_t atype, bool in_abyss)
|| atype != OBJ_RANDOM && entry->sub_type != atype
// Acquirement.
&& (aclass != OBJ_WEAPONS
- || weapon_skill(entry->base_type, atype) !=
- weapon_skill(entry->base_type, entry->sub_type)
+ || item_attack_skill(entry->base_type, atype) !=
+ item_attack_skill(entry->base_type, entry->sub_type)
|| hands_reqd(&you, entry->base_type,
atype) !=
hands_reqd(&you, entry->base_type,
diff --git a/crawl-ref/source/attack.cc b/crawl-ref/source/attack.cc
index deb8492474..04aa655d61 100644
--- a/crawl-ref/source/attack.cc
+++ b/crawl-ref/source/attack.cc
@@ -393,10 +393,7 @@ void attack::init_attack(skill_type unarmed_skill, int attack_number)
weapon = attacker->weapon(attack_number);
damage_brand = attacker->damage_brand(attack_number);
- wpn_skill = weapon
- ? (is_range_weapon(*weapon) ? range_skill(*weapon)
- : weapon_skill(*weapon))
- : unarmed_skill;
+ wpn_skill = weapon ? item_attack_skill(*weapon) : unarmed_skill;
if (attacker->is_player() && you.form_uses_xl())
wpn_skill = SK_FIGHTING; // for stabbing, mostly
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 6f848ba368..b41eea483e 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -853,7 +853,7 @@ static string _describe_weapon(const item_def &item, bool verbose)
if (verbose)
{
- switch (weapon_skill(item))
+ switch (item_attack_skill(item))
{
case SK_POLEARMS:
description += "\n\nIt can be evoked to extend its reach.";
@@ -897,8 +897,8 @@ static string _describe_weapon(const item_def &item, bool verbose)
"particularly susceptible opponents.";
if (damtype == DVORP_SLICING || damtype == DVORP_CHOPPING)
{
- description += " Big, fiery blades are also staple armaments "
- "of hydra-hunters.";
+ description += " Big, fiery blades are also staple "
+ "armaments of hydra-hunters.";
}
}
break;
@@ -1045,8 +1045,7 @@ static string _describe_weapon(const item_def &item, bool verbose)
{
description += "\n\nThis weapon falls into the";
- const skill_type skill =
- is_range_weapon(item)? range_skill(item) : weapon_skill(item);
+ const skill_type skill = item_attack_skill(item);
description +=
make_stringf(" '%s' category. ",
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index e097d1b4ae..71bb9c3a25 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -591,7 +591,7 @@ bool wielded_weapon_check(item_def *weapon, bool no_message)
const int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] - 1;
const item_def &wpn = you.inv[weap];
if (is_melee_weapon(wpn)
- && you.skill(weapon_skill(wpn)) > you.skill(SK_UNARMED_COMBAT))
+ && you.skill(melee_skill(wpn)) > you.skill(SK_UNARMED_COMBAT))
{
unarmed_warning = true;
}
@@ -705,7 +705,7 @@ int weapon_min_delay(const item_def &weapon)
int min_delay = base/2;
// Short blades can get up to at least unarmed speed.
- if (weapon_skill(weapon) == SK_SHORT_BLADES && min_delay > 5)
+ if (melee_skill(weapon) == SK_SHORT_BLADES && min_delay > 5)
min_delay = 5;
// All weapons have min delay 7 or better
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc
index bc1a2a6f16..5c5f1d626b 100644
--- a/crawl-ref/source/ghost.cc
+++ b/crawl-ref/source/ghost.cc
@@ -416,7 +416,7 @@ void ghost_demon::init_player_ghost()
{
damage = property(weapon, PWPN_DAMAGE);
- damage *= 25 + you.skills[weapon_skill(weapon)];
+ damage *= 25 + you.skills[melee_skill(weapon)];
damage /= 25;
if (weapon.base_type == OBJ_WEAPONS)
diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc
index 22b4e40ce7..871a5bd061 100644
--- a/crawl-ref/source/godabil.cc
+++ b/crawl-ref/source/godabil.cc
@@ -3673,7 +3673,7 @@ monster* shadow_monster(bool equip)
mon->hit_points = you.hp;
mon->hit_dice = min(27, max(1,
you.skill_rdiv(wpn_index != NON_ITEM
- ? weapon_skill(mitm[wpn_index])
+ ? melee_skill(mitm[wpn_index])
: SK_UNARMED_COMBAT, 10, 20)
+ you.skill_rdiv(SK_FIGHTING, 10, 20)));
mon->set_position(you.pos());
diff --git a/crawl-ref/source/godpassive.cc b/crawl-ref/source/godpassive.cc
index bca90752aa..f9cdc53f25 100644
--- a/crawl-ref/source/godpassive.cc
+++ b/crawl-ref/source/godpassive.cc
@@ -592,8 +592,7 @@ map<skill_type, int8_t> ash_get_boosted_skills(eq_type type)
// Boost weapon skill.
if (wpn->base_type == OBJ_WEAPONS)
{
- boost[is_range_weapon(*wpn) ? range_skill(*wpn)
- : weapon_skill(*wpn)] = bondage;
+ boost[item_attack_skill(*wpn)] = bondage;
}
// Those staves don't benefit from evocation.
diff --git a/crawl-ref/source/hints.cc b/crawl-ref/source/hints.cc
index d2311c169c..a6d02815cb 100644
--- a/crawl-ref/source/hints.cc
+++ b/crawl-ref/source/hints.cc
@@ -3197,7 +3197,7 @@ void hints_describe_item(const item_def &item)
else
{
// Compare with other melee weapons.
- curr_wpskill = weapon_skill(item);
+ curr_wpskill = melee_skill(item);
best_wpskill = best_skill(SK_SHORT_BLADES, SK_STAVES);
// Maybe unarmed is better.
if (you.skills[SK_UNARMED_COMBAT] > you.skills[best_wpskill])
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index b2aff04408..0158b9e0c5 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -86,7 +86,7 @@ static const char* _interesting_origin(const item_def &item)
switch (item.orig_monnum)
{
case MONS_SONJA:
- if (weapon_skill(item) == SK_SHORT_BLADES)
+ if (melee_skill(item) == SK_SHORT_BLADES)
return "Sonja";
case MONS_PSYCHE:
if (item.base_type == OBJ_WEAPONS && item.sub_type == WPN_DAGGER)
@@ -1327,9 +1327,9 @@ string item_def::name_aux(description_level_type desc, bool terse, bool ident,
// need a separate flag for this, so they can still have
// their holy weapons.
buff << "Blessed ";
- if (weapon_skill(*this) == SK_MACES_FLAILS)
+ if (melee_skill(*this) == SK_MACES_FLAILS)
buff << "Scourge";
- else if (weapon_skill(*this) == SK_POLEARMS)
+ else if (melee_skill(*this) == SK_POLEARMS)
buff << "Trishula";
else
buff << "Blade";
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index b680455ed1..cee9fbfc28 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -1484,7 +1484,7 @@ bool is_blessed_convertible(const item_def &item)
&& (is_demonic(item)
|| item.sub_type == WPN_SACRED_SCOURGE
|| item.sub_type == WPN_TRISHULA
- || weapon_skill(item) == SK_LONG_BLADES));
+ || melee_skill(item) == SK_LONG_BLADES));
}
bool convert2good(item_def &item)
@@ -1566,8 +1566,46 @@ int weapon_str_weight(const item_def &wpn)
return Weapon_prop[ Weapon_index[wpn.sub_type] ].str_weight;
}
-// Returns melee skill of item.
-skill_type weapon_skill(const item_def &item)
+/**
+ * Returns the skill used by the given item to attack.
+ *
+ * @param item The item under consideration.
+ * @return The skill used to attack with the given item; defaults to
+ * SK_FIGHTING if no melee or ranged skill applies.
+ */
+skill_type item_attack_skill(const item_def &item)
+{
+ return is_range_weapon(item) ? range_skill(item) : melee_skill(item);
+}
+
+/**
+ * Returns the skill used by the given item type to attack.
+ *
+ * @param wclass The item base type under consideration.
+ * @param wtype The item subtype under consideration.
+ * @return The skill used to attack with the given item type; defaults to
+ * SK_FIGHTING if no melee skill applies.
+ */
+skill_type item_attack_skill(object_class_type wclass, int wtype)
+{
+ item_def wpn;
+
+ wpn.base_type = wclass;
+ wpn.sub_type = wtype;
+
+ return item_attack_skill(wpn);
+}
+
+
+
+/**
+ * Returns the skill used by the given item to attack in melee.
+ *
+ * @param item The item under consideration.
+ * @return The skill used to attack with the given item; defaults to
+ * SK_FIGHTING if no melee skill applies.
+ */
+skill_type melee_skill(const item_def &item)
{
if (item.base_type == OBJ_WEAPONS && !is_range_weapon(item))
return Weapon_prop[ Weapon_index[item.sub_type] ].skill;
@@ -1580,15 +1618,22 @@ skill_type weapon_skill(const item_def &item)
return SK_FIGHTING;
}
-// Front function for the above when we don't have a physical item to check.
-skill_type weapon_skill(object_class_type wclass, int wtype)
+/**
+ * Returns the skill used by the given item type to attack in melee.
+ *
+ * @param wclass The item base type under consideration.
+ * @param wtype The item subtype under consideration.
+ * @return The skill used to attack with the given item type; defaults to
+ * SK_FIGHTING if no melee skill applies.
+ */
+skill_type melee_skill(object_class_type wclass, int wtype)
{
item_def wpn;
wpn.base_type = wclass;
wpn.sub_type = wtype;
- return weapon_skill(wpn);
+ return melee_skill(wpn);
}
// Returns range skill of the item.
@@ -1680,7 +1725,7 @@ bool item_skills(const item_def &item, set<skill_type> &skills)
skills.insert(SK_EVOCATIONS);
}
- skill_type sk = weapon_skill(item);
+ skill_type sk = melee_skill(item);
if (sk != SK_FIGHTING)
skills.insert(sk);
@@ -1704,7 +1749,7 @@ bool is_weapon_wieldable(const item_def &item, size_type size)
// Staves and rods are currently wieldable for everyone just to be nice.
if (item.base_type == OBJ_STAVES || item.base_type == OBJ_RODS
- || weapon_skill(item) == SK_STAVES)
+ || melee_skill(item) == SK_STAVES)
{
return true;
}
@@ -1871,7 +1916,7 @@ int ammo_type_damage(int missile_type)
//
reach_type weapon_reach(const item_def &item)
{
- if (weapon_skill(item) == SK_POLEARMS)
+ if (melee_skill(item) == SK_POLEARMS)
return REACH_TWO;
return REACH_NONE;
}
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 1a29f3f305..a3711284d6 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -104,8 +104,11 @@ bool is_brandable_weapon(const item_def &wpn, bool allow_ranged, bool divine = f
int weapon_str_weight(const item_def &wpn) PURE;
-skill_type weapon_skill(const item_def &item) PURE;
-skill_type weapon_skill(object_class_type wclass, int wtype) IMMUTABLE;
+skill_type item_attack_skill(const item_def &item) PURE;
+skill_type item_attack_skill(object_class_type wclass, int wtype) IMMUTABLE;
+
+skill_type melee_skill(const item_def &item) PURE;
+skill_type melee_skill(object_class_type wclass, int wtype) IMMUTABLE;
skill_type range_skill(const item_def &item) PURE;
skill_type range_skill(object_class_type wclass, int wtype) IMMUTABLE;
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 83372fdc42..983b067b4f 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2785,7 +2785,7 @@ static bool _similar_equip(const item_def& pickup_item,
if (is_ranged_weapon_type(pickup_item.sub_type))
return pickup_item.sub_type != inv_item.sub_type;
- return (weapon_skill(pickup_item) == weapon_skill(inv_item))
+ return (melee_skill(pickup_item) == melee_skill(inv_item))
&& (get_damage_type(pickup_item) == get_damage_type(inv_item));
}
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc
index bfb47913da..413f086c4c 100644
--- a/crawl-ref/source/l_item.cc
+++ b/crawl-ref/source/l_item.cc
@@ -501,9 +501,7 @@ IDEF(weap_skill)
if (!item || !item->defined())
return 0;
- skill_type skill = range_skill(*item);
- if (skill == SK_THROWING)
- skill = weapon_skill(*item);
+ const skill_type skill = item_attack_skill(*item);
if (skill == SK_FIGHTING)
return 0;
diff --git a/crawl-ref/source/l_you.cc b/crawl-ref/source/l_you.cc
index 1e3c2decbf..54da83e2e1 100644
--- a/crawl-ref/source/l_you.cc
+++ b/crawl-ref/source/l_you.cc
@@ -709,7 +709,7 @@ LUAFN(you_init)
setup_game(ng);
you.save->unlink();
you.save = NULL;
- PLUARET(string, skill_name(weapon_skill(OBJ_WEAPONS, ng.weapon)));
+ PLUARET(string, skill_name(item_attack_skill(OBJ_WEAPONS, ng.weapon)));
}
LUARET1(you_exp_needed, number, exp_needed(luaL_checkint(ls, 1)));
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index 3b5f5d4841..0e5fca3055 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -2580,7 +2580,7 @@ static bool _untrap_target(const coord_def move, bool check_confused)
else
{
list<actor*> cleave_targets;
- if (you.weapon() && weapon_skill(*you.weapon()) == SK_AXES
+ if (you.weapon() && melee_skill(*you.weapon()) == SK_AXES
&& !you.confused())
{
get_all_cleave_targets(&you, target, cleave_targets);
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 48b3ba3699..e2216efbf6 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -77,7 +77,6 @@ static int _exciting_colour()
static int _weapon_colour(const item_def &item)
{
- int item_colour = BLACK;
// fixed artefacts get predefined colours
string itname = item.name(DESC_PLAIN);
@@ -89,58 +88,32 @@ static int _weapon_colour(const item_def &item)
if (is_demonic(item))
return LIGHTRED;
- if (is_range_weapon(item))
- {
- switch (range_skill(item))
- {
- case SK_BOWS:
- item_colour = BLUE;
- break;
- case SK_CROSSBOWS:
- item_colour = LIGHTBLUE;
- break;
- case SK_THROWING:
- item_colour = WHITE;
- break;
- case SK_SLINGS:
- item_colour = BROWN;
- break;
- default:
- // huh?
- item_colour = LIGHTGREEN;
- break;
- }
- }
- else
- {
- switch (weapon_skill(item))
- {
- case SK_SHORT_BLADES:
- item_colour = CYAN;
- break;
- case SK_LONG_BLADES:
- item_colour = LIGHTCYAN;
- break;
- case SK_AXES:
- item_colour = MAGENTA;
- break;
- case SK_MACES_FLAILS:
- item_colour = LIGHTGREY;
- break;
- case SK_POLEARMS:
- item_colour = RED;
- break;
- case SK_STAVES:
- item_colour = GREEN;
- break;
- default:
- // huh?
- item_colour = LIGHTGREEN;
- break;
- }
+ switch (item_attack_skill(item))
+ {
+ case SK_BOWS:
+ return BLUE;
+ case SK_CROSSBOWS:
+ return LIGHTBLUE;
+ case SK_THROWING:
+ return WHITE;
+ case SK_SLINGS:
+ return BROWN;
+ case SK_SHORT_BLADES:
+ return CYAN;
+ case SK_LONG_BLADES:
+ return LIGHTCYAN;
+ case SK_AXES:
+ return MAGENTA;
+ case SK_MACES_FLAILS:
+ return LIGHTGREY;
+ case SK_POLEARMS:
+ return RED;
+ case SK_STAVES:
+ return GREEN;
+ default:
+ // huh?
+ return LIGHTGREEN;
}
-
- return item_colour;
}
static int _missile_colour(const item_def &item)
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
index c87aa51f7a..f5978d52e0 100644
--- a/crawl-ref/source/mon-behv.cc
+++ b/crawl-ref/source/mon-behv.cc
@@ -1598,7 +1598,7 @@ bool monster_can_hit_monster(monster* mons, const monster* targ)
return false;
const item_def *weapon = mons->weapon();
- return weapon && weapon_skill(*weapon) == SK_POLEARMS;
+ return weapon && melee_skill(*weapon) == SK_POLEARMS;
}
// Friendly summons can't attack out of the player's LOS, it's too abusable.
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 569bd88615..0162d2cfab 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -1447,7 +1447,7 @@ static bool _is_signature_weapon(const monster* mons, const item_def &weapon)
{
// Don't pick up items that would interfere with our special ability
if (mons->type == MONS_RED_DEVIL)
- return weapon_skill(weapon) == SK_POLEARMS;
+ return melee_skill(weapon) == SK_POLEARMS;
// Some other uniques have a signature weapon, usually because they
// always spawn with it, or because it is referenced in their speech
@@ -1502,15 +1502,15 @@ static bool _is_signature_weapon(const monster* mons, const item_def &weapon)
return get_vorpal_type(weapon) == DVORP_SLASHING;
if (mons->type == MONS_WIGLAF)
- return weapon_skill(weapon) == SK_AXES;
+ return melee_skill(weapon) == SK_AXES;
if (mons->type == MONS_NIKOLA)
return get_weapon_brand(weapon) == SPWPN_ELECTROCUTION;
if (mons->type == MONS_DUVESSA)
{
- return weapon_skill(weapon) == SK_SHORT_BLADES
- || weapon_skill(weapon) == SK_LONG_BLADES;
+ return melee_skill(weapon) == SK_SHORT_BLADES
+ || melee_skill(weapon) == SK_LONG_BLADES;
}
if (mons->type == MONS_IGNACIO)
@@ -4153,7 +4153,7 @@ int monster::skill(skill_type sk, int scale, bool real, bool drained) const
case SK_STAVES:
ret = hd;
if (weapon()
- && sk == weapon_skill(*weapon())
+ && sk == melee_skill(*weapon())
&& _is_signature_weapon(this, *weapon()))
{
// generally slightly skilled if it's a signature weapon
diff --git a/crawl-ref/source/ng-setup.cc b/crawl-ref/source/ng-setup.cc
index 981c7712be..401d81cecb 100644
--- a/crawl-ref/source/ng-setup.cc
+++ b/crawl-ref/source/ng-setup.cc
@@ -990,7 +990,7 @@ static void _give_items_skills(const newgame_def& ng)
if (!you.weapon())
you.skills[SK_UNARMED_COMBAT] = weap_skill;
else
- you.skills[weapon_skill(*you.weapon())] = weap_skill;
+ you.skills[melee_skill(*you.weapon())] = weap_skill;
}
if (you.species == SP_FELID)
diff --git a/crawl-ref/source/player-act.cc b/crawl-ref/source/player-act.cc
index c4b4c57e26..4890b519c6 100644
--- a/crawl-ref/source/player-act.cc
+++ b/crawl-ref/source/player-act.cc
@@ -320,9 +320,7 @@ random_var player::attack_delay(item_def *weap, item_def *projectile,
|| projectile
&& is_launched(this, weap, *projectile) == LRET_LAUNCHED))
{
- const skill_type wpn_skill = is_range_weapon(*weap)
- ? range_skill(*weap)
- : weapon_skill(*weap);
+ const skill_type wpn_skill = item_attack_skill(*weap);
attk_delay = constant(property(*weap, PWPN_SPEED));
attk_delay -=
div_rand_round(constant(you.skill(wpn_skill, 10)), 20);
diff --git a/crawl-ref/source/player-equip.cc b/crawl-ref/source/player-equip.cc
index 94a077c85f..aa9dd272fe 100644
--- a/crawl-ref/source/player-equip.cc
+++ b/crawl-ref/source/player-equip.cc
@@ -394,7 +394,7 @@ static void _wield_cursed(item_def& item, bool known_cursed, bool unmeld)
if (origin_is_god_gift(item, &god) && god == GOD_XOM)
amusement *= 2;
}
- const int wpn_skill = weapon_skill(item.base_type, item.sub_type);
+ const int wpn_skill = item_attack_skill(item.base_type, item.sub_type);
if (wpn_skill != SK_FIGHTING && you.skills[wpn_skill] == 0)
amusement *= 2;
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index a33a36fb8c..84164a2a96 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1266,7 +1266,7 @@ bool player_can_hit_monster(const monster* mon)
return false;
const item_def *weapon = you.weapon();
- return weapon && weapon_skill(*weapon) == SK_POLEARMS;
+ return weapon && melee_skill(*weapon) == SK_POLEARMS;
}
bool player_can_hear(const coord_def& p, int hear_distance)
diff --git a/crawl-ref/source/spl-summoning.cc b/crawl-ref/source/spl-summoning.cc
index 2514c48a9a..bbd6672b65 100644
--- a/crawl-ref/source/spl-summoning.cc
+++ b/crawl-ref/source/spl-summoning.cc
@@ -3184,7 +3184,7 @@ spret_type cast_spectral_weapon(actor *agent, int pow, god_type god, bool fail)
agent->mindex(),
0, god);
- int skill_with_weapon = agent->skill(weapon_skill(*wpn), 10, false);
+ int skill_with_weapon = agent->skill(melee_skill(*wpn), 10, false);
mg.props[TUKIMA_WEAPON] = cp;
mg.props[TUKIMA_POWER] = pow;
diff --git a/crawl-ref/source/spl-wpnench.cc b/crawl-ref/source/spl-wpnench.cc
index 59ffd2b5e4..a0d4add111 100644
--- a/crawl-ref/source/spl-wpnench.cc
+++ b/crawl-ref/source/spl-wpnench.cc
@@ -306,7 +306,7 @@ spret_type cast_sure_blade(int power, bool fail)
{
if (!you.weapon())
mpr("You aren't wielding a weapon!");
- else if (weapon_skill(you.weapon()->base_type,
+ else if (melee_skill(you.weapon()->base_type,
you.weapon()->sub_type) != SK_SHORT_BLADES)
{
mpr("You cannot bond with this weapon.");
diff --git a/crawl-ref/source/wiz-fsim.cc b/crawl-ref/source/wiz-fsim.cc
index fdf54e4102..ee41b1bfe9 100644
--- a/crawl-ref/source/wiz-fsim.cc
+++ b/crawl-ref/source/wiz-fsim.cc
@@ -70,11 +70,7 @@ static skill_type _equipped_skill()
const int missile = you.m_quiver->get_fire_item();
if (iweap && iweap->base_type == OBJ_WEAPONS)
- {
- if (is_range_weapon(*iweap))
- return range_skill(*iweap);
- return weapon_skill(*iweap);
- }
+ return item_attack_skill(*iweap);
if (missile != -1)
return range_skill(you.inv[missile]);