summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/corrupt.c57
-rw-r--r--src/externs.h1
-rw-r--r--src/types.h1
-rw-r--r--src/xtra1.c36
4 files changed, 66 insertions, 29 deletions
diff --git a/src/corrupt.c b/src/corrupt.c
index 25570303..9c707a67 100644
--- a/src/corrupt.c
+++ b/src/corrupt.c
@@ -104,6 +104,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ -1,
},
{ /* 1 */
@@ -118,6 +119,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ -1,
},
{ /* 2 */
@@ -132,6 +134,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ -1,
},
{ /* 3 */
@@ -146,6 +149,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ CORRUPT_BALROG_AURA, CORRUPT_BALROG_WINGS, CORRUPT_BALROG_STRENGTH },
{ -1 },
NULL,
+ PWR_BALROG,
},
/*
@@ -163,6 +167,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ -1,
},
{ /* 5 */
@@ -178,6 +183,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ -1,
},
{ /* 6 */
@@ -192,6 +198,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_BR_FIRE,
},
{ /* 7 */
@@ -206,6 +213,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ CORRUPT_DEMON_SPIRIT, CORRUPT_DEMON_HIDE, CORRUPT_DEMON_BREATH },
{ -1 },
NULL,
+ -1,
},
/*
@@ -223,6 +231,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ CORRUPT_ANTI_TELEPORT, -1 },
NULL,
+ -1,
},
{ /* 9 */
@@ -236,6 +245,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ CORRUPT_RANDOM_TELEPORT, -1 },
NULL,
+ POWER_COR_SPACE_TIME,
},
/*
@@ -255,6 +265,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ -1,
},
/*
@@ -273,6 +284,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
player_gain_vampire_teeth,
+ -1,
},
{ /* 12 */
@@ -288,6 +300,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ CORRUPT_VAMPIRE_TEETH, -1 },
{ -1 },
player_gain_vampire_strength,
+ -1,
},
{ /* 13 */
@@ -302,6 +315,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ CORRUPT_VAMPIRE_STRENGTH, -1 },
{ -1 },
player_gain_vampire,
+ -1,
},
/*
@@ -321,6 +335,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_SPIT_ACID,
},
{ /* 15 */
@@ -336,6 +351,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_BR_FIRE,
},
{ /* 16 */
@@ -351,6 +367,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_HYPN_GAZE,
},
{ /* 17 */
@@ -366,6 +383,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_TELEKINES,
},
{ /* 18 */
@@ -381,6 +399,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_VTELEPORT,
},
{ /* 19 */
@@ -396,6 +415,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_MIND_BLST,
},
{ /* 20 */
@@ -412,6 +432,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_VAMPIRISM,
},
{ /* 21 */
@@ -427,6 +448,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_SMELL_MET,
},
{ /* 22 */
@@ -442,6 +464,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_SMELL_MON,
},
{ /* 23 */
@@ -456,6 +479,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_BLINK,
},
{ /* 24 */
@@ -471,6 +495,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_EAT_ROCK,
},
{ /* 25 */
@@ -486,6 +511,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_SWAP_POS,
},
{ /* 26 */
@@ -501,6 +527,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_SHRIEK,
},
{ /* 27 */
@@ -516,6 +543,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_ILLUMINE,
},
{ /* 28 */
@@ -531,6 +559,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_DET_CURSE,
},
{ /* 29 */
@@ -546,6 +575,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_BERSERK,
},
{ /* 30 */
@@ -561,6 +591,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_MIDAS_TCH,
},
{ /* 31 */
@@ -576,6 +607,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_GROW_MOLD,
},
{ /* 32 */
@@ -592,6 +624,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_RESIST,
},
{ /* 33 */
@@ -607,6 +640,7 @@ corruption_type corruptions[CORRUPTIONS_MAX] =
{ -1 },
{ -1 },
NULL,
+ PWR_EARTHQUAKE,
},
};
@@ -914,3 +948,26 @@ void dump_corruptions(FILE *fff, bool_ color, bool_ header)
}
}
+/*
+ * Get the power granted by a corruption. Returns -1
+ * if the given corruption does not grant a power.
+ */
+s16b get_corruption_power(int corruption_idx)
+{
+ corruption_type *c_ptr = NULL;
+
+ assert(corruption_idx >= 0);
+ assert(corruption_idx < CORRUPTIONS_MAX);
+
+ c_ptr = &corruptions[corruption_idx];
+
+ if ((c_ptr->power >= 0) && (c_ptr->power < POWER_MAX))
+ {
+ return c_ptr->power;
+ }
+ else
+ {
+ assert(c_ptr->power == -1); /* Sanity check: Should always be the case. */
+ return -1;
+ }
+}
diff --git a/src/externs.h b/src/externs.h
index 1d2a9c79..d53ba409 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -873,6 +873,7 @@ extern void dump_corruptions(FILE *OutFile, bool_ color, bool_ header);
extern void lose_corruption();
extern bool_ player_has_corruption(int corruption_idx);
extern void player_gain_corruption(int corruption_idx);
+extern s16b get_corruption_power(int corruption_idx);
/* dungeon.c */
extern byte value_check_aux1(object_type *o_ptr);
diff --git a/src/types.h b/src/types.h
index 1c9df3f8..df2c4f40 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2600,4 +2600,5 @@ struct corruption_type
s16b depends[5]; /* terminated by a -1 entry */
s16b opposes[5]; /* terminated by a -1 entry */
void (*gain_callback)(); /* callback to invoke when gained */
+ s16b power; /* index of granted power if >= 0, ignored otherwise */
};
diff --git a/src/xtra1.c b/src/xtra1.c
index 029aa1a5..66f5ddd7 100644
--- a/src/xtra1.c
+++ b/src/xtra1.c
@@ -1523,40 +1523,18 @@ static void calc_spells(void)
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++)
+ for (i = 0; i < CORRUPTIONS_MAX; i++)
{
- if (player_has_corruption(power_by_corruption[i][0]))
+ if (player_has_corruption(i))
{
- p_ptr->powers[power_by_corruption[i][1]] = TRUE;
+ int p = get_corruption_power(i);
+ if (p >= 0)
+ {
+ p_ptr->powers[p] = TRUE;
+ }
}
}
}