From 74a7f0850963676d0ee82a427653562980694a78 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sat, 2 Jan 2010 14:58:18 -0800 Subject: Decouple rod recharge from availability of player MP (Mantis 300) --- crawl-ref/source/effects.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'crawl-ref/source/effects.cc') 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 ); + } +} -- cgit v1.2.3-54-g00ecf