summaryrefslogtreecommitdiff
path: root/src/xtra1.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-06 13:23:52 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:26 +0200
commitd5712602c95caccc32dd73fa54592370b91cc398 (patch)
treec4c58f98b8162095afef4dff1e8b8a7e2c3ea793 /src/xtra1.c
parent09c56bf058a10fcaaff2e88e3259477557f00cc9 (diff)
Lua: Move "powers granted by corruptions" calculation from Lua to C.
Diffstat (limited to 'src/xtra1.c')
-rw-r--r--src/xtra1.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/xtra1.c b/src/xtra1.c
index 9a2c2d42..54c079b8 100644
--- a/src/xtra1.c
+++ b/src/xtra1.c
@@ -1516,6 +1516,52 @@ static void calc_spells(void)
p_ptr->new_spells = 0;
}
+
+/*
+ * Calculate powers of player given the current set of corruptions.
+ */
+static void calc_powers_corruption()
+{
+ /* Map of corruptions to a power */
+ s16b power_by_corruption[][2] =
+ { { CORRUPT_BALROG_FORM , PWR_BALROG },
+ { CORRUPT_DEMON_BREATH , PWR_BR_FIRE },
+ { CORRUPT_ANTI_TELEPORT , POWER_COR_SPACE_TIME },
+ { MUT1_SPIT_ACID , PWR_SPIT_ACID },
+ { MUT1_BR_FIRE , PWR_BR_FIRE },
+ { MUT1_HYPN_GAZE , PWR_HYPN_GAZE },
+ { MUT1_TELEKINES , PWR_TELEKINES },
+ { MUT1_VTELEPORT , PWR_VTELEPORT },
+ { MUT1_MIND_BLST , PWR_MIND_BLST },
+ { MUT1_VAMPIRISM , PWR_VAMPIRISM },
+ { MUT1_SMELL_MET , PWR_SMELL_MET },
+ { MUT1_SMELL_MON , PWR_SMELL_MON },
+ { MUT1_BLINK , PWR_BLINK },
+ { MUT1_EAT_ROCK , PWR_EAT_ROCK },
+ { MUT1_SWAP_POS , PWR_SWAP_POS },
+ { MUT1_SHRIEK , PWR_SHRIEK },
+ { MUT1_ILLUMINE , PWR_ILLUMINE },
+ { MUT1_DET_CURSE , PWR_DET_CURSE },
+ { MUT1_BERSERK , PWR_BERSERK },
+ { MUT1_MIDAS_TCH , PWR_MIDAS_TCH },
+ { MUT1_GROW_MOLD , PWR_GROW_MOLD },
+ { MUT1_RESIST , PWR_RESIST },
+ { MUT1_EARTHQUAKE , PWR_EARTHQUAKE },
+ { -1 , -1 },
+ };
+ int i;
+
+ /* Grant powers according to whatever corruptions the player has */
+ for (i = 0; power_by_corruption[i][0] >= 0; i++)
+ {
+ if (player_has_corruption(power_by_corruption[i][0]))
+ {
+ p_ptr->powers[power_by_corruption[i][1]] = TRUE;
+ }
+ }
+}
+
+
/* Ugly hack */
bool_ calc_powers_silent = FALSE;
@@ -1540,6 +1586,9 @@ static void calc_powers(void)
for (i = 0; i < POWER_MAX_INIT; i++) p_ptr->powers[i] = p_ptr->powers_mod[i];
for (; i < power_max; i++) p_ptr->powers[i] = 0;
+ /* Calculate powers granted by corruptions */
+ calc_powers_corruption();
+
/* Hooked powers */
process_hooks(HOOK_CALC_POWERS, "()");