From d5712602c95caccc32dd73fa54592370b91cc398 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 6 Apr 2012 13:23:52 +0200 Subject: Lua: Move "powers granted by corruptions" calculation from Lua to C. --- src/xtra1.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src') 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, "()"); -- cgit v1.2.3