summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan O'Rear <stefanor@cox.net>2010-01-02 17:46:08 -0800
committerStefan O'Rear <stefanor@cox.net>2010-01-02 17:50:56 -0800
commit22019ceee8c3df285becfd98445aaec91055c6df (patch)
tree91c26482c566be2399b049b863f919c803f27222
parent985744902fd6c56fe3c30a2d1a00aeacfffba475 (diff)
downloadcrawl-ref-22019ceee8c3df285becfd98445aaec91055c6df.tar.gz
crawl-ref-22019ceee8c3df285becfd98445aaec91055c6df.zip
Rods have an intrinsic recharge rate (#300)
Using Eronarn's proposed system. Rods get a baseline of 4 MP per 100 turns; every rod has an enchantment, which adds to this. On top of that, you get the old Evocations bonus. At maxed Evocations with a +9 rod, you gain 52 MP per 100 turns. Unfortunately, all four of the multi-purpose fields were already used for rods, so I had to spill enchantment into props.
-rw-r--r--crawl-ref/source/effects.cc16
-rw-r--r--crawl-ref/source/itemname.cc12
-rw-r--r--crawl-ref/source/makeitem.cc23
3 files changed, 40 insertions, 11 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 109539cc75..49702e489c 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -4853,18 +4853,16 @@ static void _recharge_rod( item_def &rod, long aut, bool in_inv )
if (!item_is_rod(rod) || rod.plus >= rod.plus2)
return;
- const int charge = rod.plus / ROD_CHARGE_MULT;
-
- int rate = ((charge + 1) * ROD_CHARGE_MULT) / 10;
+ long rate = 4 + short(rod.props["rod_enchantment"]);
rate *= (10 + skill_bump( SK_EVOCATIONS ));
+ rate *= aut;
rate = div_rand_round( rate, 100 );
- rate = div_rand_round( rate * aut, 10 );
- if (rate < 5)
- rate = 5;
- else if (rate > ROD_CHARGE_MULT / 2)
- rate = ROD_CHARGE_MULT / 2;
+ if (rate > rod.plus2 - rod.plus) // Prevent overflow
+ rate = rod.plus2 - rod.plus;
+
+ // With this, a +0 rod with no skill gets 1 mana per 25.0 turns
if (rod.plus / ROD_CHARGE_MULT != (rod.plus + rate) / ROD_CHARGE_MULT)
{
@@ -4873,8 +4871,6 @@ static void _recharge_rod( item_def &rod, long aut, bool in_inv )
}
rod.plus += rate;
- if (rod.plus > rod.plus2)
- rod.plus = rod.plus2;
if (in_inv && rod.plus == rod.plus2)
{
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index d39e16abf2..81bb850f16 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1618,7 +1618,17 @@ std::string item_def::name_aux(description_level_type desc,
}
else
{
- buff << (item_is_rod(*this) ? "rod" : "staff")
+ if (item_is_rod(*this) && know_type && know_pluses
+ && !basename && !qualname && !dbname)
+ {
+ short rmod = 0;
+ if (props.exists("rod_enchantment"))
+ rmod = props["rod_enchantment"];
+
+ output_with_sign(buff, rmod);
+ }
+
+ buff << (item_is_rod(*this) ? " rod" : " staff")
<< " of " << staff_type_name(item_typ);
}
break;
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index 7e991e5c83..5f78853508 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -3275,19 +3275,42 @@ int items(int allow_uniques, // not just true-false,
return (p);
}
+// Formula from Eronarn on ##crawl-dev; subject to revision
+static int _roll_rod_enchant()
+{
+ int total_prob = 0, cur_ench = 0;
+
+ for (int i = -3; i <= 9; ++i)
+ {
+ int extremeness = (i < 0) ? (21 - i) : (15 + i);
+
+ int prob = 600 - extremeness * extremeness;
+
+ if (random2(total_prob += prob) < prob)
+ cur_ench = i;
+ }
+
+ return cur_ench;
+}
+
void init_rod_mp(item_def &item, int ncharges)
{
if (!item_is_rod(item))
return;
if (ncharges != -1)
+ {
item.plus2 = ncharges * ROD_CHARGE_MULT;
+ item.props["rod_enchantment"] = (short)0;
+ }
else
{
if (item.sub_type == STAFF_STRIKING)
item.plus2 = random_range(6, 9) * ROD_CHARGE_MULT;
else
item.plus2 = random_range(9, 14) * ROD_CHARGE_MULT;
+
+ item.props["rod_enchantment"] = (short)_roll_rod_enchant();
}
item.plus = item.plus2;