summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--crawl-ref/source/abl-show.cc3
-rw-r--r--crawl-ref/source/spells1.cc97
-rw-r--r--crawl-ref/source/spells1.h2
3 files changed, 67 insertions, 35 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 377477017a..16ff1479a9 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1370,8 +1370,7 @@ static bool _do_ability(const ability_def& abil)
case ABIL_ZIN_REVITALISATION:
{
- int result = cast_revitalisation(1 + (you.skills[SK_INVOCATIONS] / 4),
- random2(3));
+ int result = cast_revitalisation(1 + (you.skills[SK_INVOCATIONS] / 4));
if (result > 0)
exercise(SK_INVOCATIONS, 2 + random2(result));
break;
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)
diff --git a/crawl-ref/source/spells1.h b/crawl-ref/source/spells1.h
index 687b9f59f8..5f3d742f80 100644
--- a/crawl-ref/source/spells1.h
+++ b/crawl-ref/source/spells1.h
@@ -54,7 +54,7 @@ char cast_lesser_healing(void);
* called from: ability - spell
* *********************************************************************** */
int cast_healing(int pow, int target_x = -1, int target_y = -1);
-int cast_revitalisation(int pow, int type);
+int cast_revitalisation(int pow);
// last updated 24may2000 {dlb}
/* ***********************************************************************