summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-08 22:09:25 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-08 22:09:25 +0000
commitf55a8b913e4fb43166f6a3cbd083a4a0f5154358 (patch)
treeeb282082a88a6f133eeefc11651769d856dacbf0 /crawl-ref/source/effects.cc
parent1b7c5aa3c413b3469ada00e521b37aeca57abdd5 (diff)
downloadcrawl-ref-f55a8b913e4fb43166f6a3cbd083a4a0f5154358.tar.gz
crawl-ref-f55a8b913e4fb43166f6a3cbd083a4a0f5154358.zip
Implement FR 2489034: Disallow known scrolls of enchant
armour/recharging on armour that cannot be enchanted or items that cannot be recharged, respectively. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8337 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc152
1 files changed, 84 insertions, 68 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 025c97d392..34fb13bc91 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1875,99 +1875,115 @@ bool acquirement(object_class_type class_wanted, int agent,
bool recharge_wand(int item_slot)
{
- if (item_slot == -1)
+ do
{
- item_slot = prompt_invent_item( "Charge which item?", MT_INVLIST,
- OSEL_RECHARGE, true, true, false );
- }
+ if (item_slot == -1)
+ {
+ item_slot = prompt_invent_item( "Charge which item?", MT_INVLIST,
+ OSEL_RECHARGE, true, true, false );
+ }
+ if (prompt_failed(item_slot))
+ return (false);
- if (prompt_failed(item_slot))
- return (false);
+ item_def &wand = you.inv[ item_slot ];
- item_def &wand = you.inv[ item_slot ];
+ if (!item_is_rechargeable(wand, true, true))
+ {
+ mpr("Choose an item to recharge, or Esc to abort.");
+ if (Options.auto_list)
+ more();
- // Weapons of electrocution can be "charged", i.e. gain +1 damage.
- if (wand.base_type == OBJ_WEAPONS
- && get_weapon_brand(wand) == SPWPN_ELECTROCUTION)
- {
- // Might fail because of already high enchantment.
- if (enchant_weapon( ENCHANT_TO_DAM, false, wand ))
+ // Try again.
+ item_slot = -1;
+ continue;
+ }
+
+ // Weapons of electrocution can be "charged", i.e. gain +1 damage.
+ if (wand.base_type == OBJ_WEAPONS
+ && get_weapon_brand(wand) == SPWPN_ELECTROCUTION)
{
- you.wield_change = true;
+ // Might fail because of already high enchantment.
+ if (enchant_weapon( ENCHANT_TO_DAM, false, wand ))
+ {
+ you.wield_change = true;
- if (!item_ident(wand, ISFLAG_KNOW_TYPE))
- set_ident_flags(wand, ISFLAG_KNOW_TYPE);
+ if (!item_ident(wand, ISFLAG_KNOW_TYPE))
+ set_ident_flags(wand, ISFLAG_KNOW_TYPE);
- return (true);
+ return (true);
+ }
+ return (false);
}
- return (false);
- }
- if (wand.base_type != OBJ_WANDS && !item_is_rod(wand))
- return (false);
+ if (wand.base_type != OBJ_WANDS && !item_is_rod(wand))
+ return (false);
- int charge_gain = 0;
- if (wand.base_type == OBJ_WANDS)
- {
- charge_gain = wand_charge_value(wand.sub_type);
+ int charge_gain = 0;
+ if (wand.base_type == OBJ_WANDS)
+ {
+ charge_gain = wand_charge_value(wand.sub_type);
- // Reinitialize zap counts.
- wand.plus2 = ZAPCOUNT_RECHARGED;
+ // Reinitialize zap counts.
+ wand.plus2 = ZAPCOUNT_RECHARGED;
- const int new_charges =
- std::max<int>(
- wand.plus,
- std::min(charge_gain * 3,
- wand.plus +
- 1 + random2avg( ((charge_gain - 1) * 3) + 1, 3 )));
+ const int new_charges =
+ std::max<int>(
+ wand.plus,
+ std::min(charge_gain * 3,
+ wand.plus +
+ 1 + random2avg( ((charge_gain - 1) * 3) + 1, 3 )));
- const bool charged = (new_charges > wand.plus);
+ const bool charged = (new_charges > wand.plus);
- std::string desc;
- if (charged && item_ident(wand, ISFLAG_KNOW_PLUSES))
- {
- snprintf(info, INFO_SIZE, " and now has %d charges", new_charges);
- desc = info;
+ std::string desc;
+ if (charged && item_ident(wand, ISFLAG_KNOW_PLUSES))
+ {
+ snprintf(info, INFO_SIZE, " and now has %d charges", new_charges);
+ desc = info;
+ }
+ mprf("%s %s for a moment%s.",
+ wand.name(DESC_CAP_YOUR).c_str(),
+ charged? "glows" : "flickers",
+ desc.c_str());
+
+ wand.plus = new_charges;
+
+ if (!charged)
+ wand.plus2 = ZAPCOUNT_MAX_CHARGED;
}
- mprf("%s %s for a moment%s.",
- wand.name(DESC_CAP_YOUR).c_str(),
- charged? "glows" : "flickers",
- desc.c_str());
+ else // It's a rod.
+ {
+ bool work = false;
- wand.plus = new_charges;
+ if (wand.plus2 < MAX_ROD_CHARGE * ROD_CHARGE_MULT)
+ {
+ wand.plus2 += ROD_CHARGE_MULT;
- if (!charged)
- wand.plus2 = ZAPCOUNT_MAX_CHARGED;
- }
- else // It's a rod.
- {
- bool work = false;
+ if (wand.plus2 > MAX_ROD_CHARGE * ROD_CHARGE_MULT)
+ wand.plus2 = MAX_ROD_CHARGE * ROD_CHARGE_MULT;
- if (wand.plus2 < MAX_ROD_CHARGE * ROD_CHARGE_MULT)
- {
- wand.plus2 += ROD_CHARGE_MULT;
+ work = true;
+ }
- if (wand.plus2 > MAX_ROD_CHARGE * ROD_CHARGE_MULT)
- wand.plus2 = MAX_ROD_CHARGE * ROD_CHARGE_MULT;
+ if (wand.plus < wand.plus2)
+ {
+ wand.plus = wand.plus2;
+ work = true;
+ }
- work = true;
- }
+ if (!work)
+ return (false);
- if (wand.plus < wand.plus2)
- {
- wand.plus = wand.plus2;
- work = true;
+ mprf("%s glows for a moment.", wand.name(DESC_CAP_YOUR).c_str());
}
- if (!work)
- return (false);
-
- mprf("%s glows for a moment.", wand.name(DESC_CAP_YOUR).c_str());
+ you.wield_change = true;
+ return (true);
}
+ while (true);
- you.wield_change = true;
- return (true);
-} // end recharge_wand()
+ return (false);
+}
// Sets foe target of friendly monsters.
// If allow_patrol is true, patrolling monsters get MHITNOT instead.