summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells1.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-28 06:11:16 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-28 06:11:16 +0000
commit0be145f708e49524707f5f046082b55b1d73de6e (patch)
treeb7471a7bc4707d3c84a802baf607b52e3d9efe27 /crawl-ref/source/spells1.cc
parent0d90fe40bb12d5ab66e7d1a2c4af950b3a697995 (diff)
downloadcrawl-ref-0be145f708e49524707f5f046082b55b1d73de6e.tar.gz
crawl-ref-0be145f708e49524707f5f046082b55b1d73de6e.zip
Rework Zin's Revitalisation so that it remembers which step it was on
after being used. Note that there is currently no check for its being used in succession yet. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4731 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells1.cc')
-rw-r--r--crawl-ref/source/spells1.cc97
1 files changed, 65 insertions, 32 deletions
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 377868f747..8fff179fb7 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -759,11 +759,24 @@ int cast_healing( int pow, int target_x, int target_y )
return (_healing_spell( pow + roll_dice( 2, pow ) - 2, target_x, target_y ));
}
-int cast_revitalisation(int pow, int type)
+int cast_revitalisation(int pow)
{
- const int max_steps = std::min(pow, 6);
- int steps = 0;
- int loss_amt;
+ static int step = 0;
+ static int step_max;
+ static int type;
+ static int hp_amt;
+ static int mp_amt;
+
+ // If the step counter has been reset, start from the beginning.
+ if (step == 0)
+ {
+ step_max = std::min(pow, 6);
+ type = random2(3);
+ hp_amt = 3;
+ mp_amt = 1;
+ }
+
+ bool success = false;
switch (type)
{
@@ -771,51 +784,71 @@ int cast_revitalisation(int pow, int type)
// Restore HP.
if (you.hp < you.hp_max)
{
- for (int hp_amt = 3;
- steps < max_steps && you.hp < you.hp_max;
- ++steps, hp_amt *= 2)
- {
- inc_hp(hp_amt, false);
-
- loss_amt = steps + 1 + (random2(3) - 1);
- if (loss_amt > 0)
- lose_piety(loss_amt);
- }
-
+ success = true;
+ inc_hp(hp_amt, false);
+ hp_amt *= 2;
break;
}
- // Deliberate fall through.
+ type = 1;
+ // Deliberate fall through.
case 1:
// Restore MP.
if (you.magic_points < you.max_magic_points)
{
- for (int mp_amt = 1;
- steps < max_steps && you.magic_points < you.max_magic_points;
- ++steps, mp_amt *= 2)
- {
- inc_mp(mp_amt, false);
-
- loss_amt = steps + 1 + (random2(3) - 1);
- if (loss_amt > 0)
- lose_piety(loss_amt);
- }
-
+ success = true;
+ inc_mp(mp_amt, false);
+ mp_amt *= 2;
break;
}
- // Deliberate fall through.
+ type = 2;
+ // Deliberate fall through.
default:
// Do nothing.
+ success = false;
break;
}
- if (steps > 0)
- mpr("You feel renewed.");
- else
+ // If revitalisation failed, reset the step counter and get out,
+ // indicating failure.
+ if (!success)
+ {
canned_msg(MSG_NOTHING_HAPPENS);
+ step = 0;
+ return 0;
+ }
+
+ // If it succeeded, display an appropriate message.
+ mprf("You feel %s %s.", (step == 0) ? "only nominally" :
+ (step == 1) ? "very slightly" :
+ (step == 2) ? "slightly" :
+ (step == 3) ? "somewhat" :
+ (step == 4) ? "appropriately"
+ : "impressively",
+ (type == 0) ? "invigorated"
+ : "powerful");
+
+ // The more the step counter has advanced, the greater the piety
+ // cost is.
+ int loss_amt = step + 1 + (random2(3) - 1);
+
+ if (loss_amt > 0)
+ lose_piety(loss_amt);
+
+ // Increment the step counter.
+ step++;
+
+ // If revitalisation went as far as possible, reset the step counter
+ // and get out, indicating maximum success.
+ if (step == step_max)
+ {
+ step = 0;
+ return step_max;
+ }
- return steps;
+ // Otherwise, get out, indicating normal success.
+ return step + 1;
}
bool cast_revivification(int pow)