diff options
author | Stefan O'Rear <stefanor@cox.net> | 2010-01-02 14:58:18 -0800 |
---|---|---|
committer | Stefan O'Rear <stefanor@cox.net> | 2010-01-02 15:08:50 -0800 |
commit | 74a7f0850963676d0ee82a427653562980694a78 (patch) | |
tree | 16d3afcc8c59176340347bdf860217950beaa953 /crawl-ref/source/effects.cc | |
parent | d54de77e23c945c5d34e7d9e04fefece29f9f7e2 (diff) | |
download | crawl-ref-74a7f0850963676d0ee82a427653562980694a78.tar.gz crawl-ref-74a7f0850963676d0ee82a427653562980694a78.zip |
Decouple rod recharge from availability of player MP (Mantis 300)
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r-- | crawl-ref/source/effects.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 3402037d7e..109539cc75 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -70,6 +70,7 @@ #include "stuff.h" #include "terrain.h" #include "traps.h" +#include "travel.h" #include "tutorial.h" #include "view.h" #include "shout.h" @@ -4237,6 +4238,7 @@ void update_level(double elapsedTime) update_corpses(elapsedTime); shoals_apply_tides(turns); + recharge_rods((long)turns, true); if (env.sanctuary_time) { @@ -4845,3 +4847,58 @@ void update_corpses(double elapsedTime) } } } + +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; + + rate *= (10 + skill_bump( SK_EVOCATIONS )); + 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 (rod.plus / ROD_CHARGE_MULT != (rod.plus + rate) / ROD_CHARGE_MULT) + { + if (item_is_equipped( rod, true )) + you.wield_change = true; + } + + rod.plus += rate; + if (rod.plus > rod.plus2) + rod.plus = rod.plus2; + + if (in_inv && rod.plus == rod.plus2) + { + msg::stream << "Your " << rod.name(DESC_QUALNAME) << " has recharged." + << std::endl; + if (is_resting()) + stop_running(); + } + + return; +} + +void recharge_rods(long aut, bool level_only) +{ + if (!level_only) + { + for (int item = 0; item < ENDOFPACK; ++item) + { + _recharge_rod( you.inv[item], aut, true ); + } + } + + for (int item = 0; item < MAX_ITEMS; ++item) + { + _recharge_rod( mitm[item], aut, false ); + } +} |