summaryrefslogtreecommitdiff
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
parent09c56bf058a10fcaaff2e88e3259477557f00cc9 (diff)
Lua: Move "powers granted by corruptions" calculation from Lua to C.
-rw-r--r--lib/mods/theme/scpt/corrupt.lua135
-rw-r--r--lib/scpt/corrupt.lua15
-rw-r--r--src/xtra1.c49
3 files changed, 49 insertions, 150 deletions
diff --git a/lib/mods/theme/scpt/corrupt.lua b/lib/mods/theme/scpt/corrupt.lua
index 440a1d81..81b87847 100644
--- a/lib/mods/theme/scpt/corrupt.lua
+++ b/lib/mods/theme/scpt/corrupt.lua
@@ -58,12 +58,6 @@ CORRUPT_BALROG_FORM = add_corruption
[CORRUPT_BALROG_WINGS] = TRUE,
[CORRUPT_BALROG_STRENGTH] = TRUE
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BALROG)
- end,
- },
}
@@ -106,12 +100,6 @@ CORRUPT_DEMON_BREATH = add_corruption
" Provides fire breath",
" But gives a small chance to spoil potions when you quaff them",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BR_FIRE)
- end,
- },
}
CORRUPT_DEMON_REALM = add_corruption
@@ -187,9 +175,6 @@ CORRUPT_ANTI_TELEPORT = add_corruption
[HOOK_BIRTH_OBJECTS] = function()
player.corrupt_anti_teleport_stopped = FALSE
end,
- [HOOK_CALC_POWERS] = function()
- player.add_power(POWER_COR_SPACE_TIME)
- end,
[HOOK_PROCESS_WORLD] = function()
if player.corrupt_anti_teleport_stopped == TRUE then
local amt = player.msp + player.csp
@@ -339,12 +324,6 @@ MUT1_SPIT_ACID = add_corruption
" Damage=level Radius 1+(level/30)",
" Level=9, Cost=9, Stat=DEX, Difficulty=15",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_SPIT_ACID)
- end,
- },
}
MUT1_BR_FIRE = add_corruption
@@ -359,12 +338,6 @@ MUT1_BR_FIRE = add_corruption
" Damage=2*level Radius 1+(level/20)",
" Level=20, Cost=10, Stat=CON, Difficulty=18",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BR_FIRE)
- end,
- },
}
MUT1_HYPN_GAZE = add_corruption
@@ -379,12 +352,6 @@ MUT1_HYPN_GAZE = add_corruption
" Power=level",
" Level=12, Cost=12, Stat=CHR, Difficulty=18",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_HYPN_GAZE)
- end,
- },
}
MUT1_TELEKINES = add_corruption
@@ -399,12 +366,6 @@ MUT1_TELEKINES = add_corruption
" Max weight equal to (level) pounds",
" Level=9, Cost=9, Stat=WIS, Difficulty=14",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_TELEKINES)
- end,
- },
}
MUT1_VTELEPORT = add_corruption
@@ -419,12 +380,6 @@ MUT1_VTELEPORT = add_corruption
" Distance 10+4*level squares",
" Level=7, Cost=7, Stat=WIS, Difficulty=15",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_VTELEPORT)
- end,
- },
}
MUT1_MIND_BLST = add_corruption
@@ -439,12 +394,6 @@ MUT1_MIND_BLST = add_corruption
" Psi Damage (3+(level-1)/5)d3",
" Level=5, Cost=3, Stat=WIS, Difficulty=15",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_MIND_BLST)
- end,
- },
}
MUT1_VAMPIRISM = add_corruption
@@ -460,12 +409,6 @@ MUT1_VAMPIRISM = add_corruption
" heals you and satiates you. Doesn't work on all monsters",
" Level=4, Cost=5, Stat=CON, Difficulty=9",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_VAMPIRISM)
- end,
- },
}
MUT1_SMELL_MET = add_corruption
@@ -480,12 +423,6 @@ MUT1_SMELL_MET = add_corruption
" Radius 25",
" Level=3, Cost=2, Stat=INT, Difficulty=12",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_SMELL_MET)
- end,
- },
}
MUT1_SMELL_MON = add_corruption
@@ -500,12 +437,6 @@ MUT1_SMELL_MON = add_corruption
" Radius 25",
" Level=5, Cost=4, Stat=INT, Difficulty=15",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_SMELL_MON)
- end,
- },
}
MUT1_BLINK = add_corruption
@@ -519,12 +450,6 @@ MUT1_BLINK = add_corruption
" You can teleport yourself short distances (10 squares).",
" Level=3, Cost=3, Stat=WIS, Difficulty=12",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BLINK)
- end,
- },
}
MUT1_EAT_ROCK = add_corruption
@@ -539,12 +464,6 @@ MUT1_EAT_ROCK = add_corruption
" leaving an empty space behind.",
" Level=8, Cost=12, Stat=CON, Difficulty=18",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_EAT_ROCK)
- end,
- },
}
MUT1_SWAP_POS = add_corruption
@@ -559,12 +478,6 @@ MUT1_SWAP_POS = add_corruption
" unless it resists teleportation.",
" Level=15, Cost=12, Stat=DEX, Difficulty=16",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_SWAP_POS)
- end,
- },
}
MUT1_SHRIEK = add_corruption
@@ -579,12 +492,6 @@ MUT1_SHRIEK = add_corruption
" Damage=level*4, Radius=8, centered on player",
" Level=4, Cost=4, Stat=CON, Difficulty=6",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_SHRIEK)
- end,
- },
}
MUT1_ILLUMINE = add_corruption
@@ -599,12 +506,6 @@ MUT1_ILLUMINE = add_corruption
" Damage=2d(level/2) Radius=(level/10)+1",
" Level=3, Cost=2, Stat=INT, Difficulty=10",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_ILLUMINE)
- end,
- },
}
MUT1_DET_CURSE = add_corruption
@@ -619,12 +520,6 @@ MUT1_DET_CURSE = add_corruption
" It detects cursed items in the inventory",
" Level=7, Cost=14, Stat=WIS, Difficulty=14",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_DET_CURSE)
- end,
- },
}
MUT1_BERSERK = add_corruption
@@ -639,12 +534,6 @@ MUT1_BERSERK = add_corruption
" It grants super-heroism. Duration=10+1d(level)",
" Level=8, Cost=8, Stat=STR, Difficulty=14",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BERSERK)
- end,
- },
}
@@ -660,12 +549,6 @@ MUT1_MIDAS_TCH = add_corruption
" Turns a non-artifact object into 1/3 its value in gold",
" Level=10, Cost=5, Stat=INT, Difficulty=12",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_MIDAS_TCH)
- end,
- },
}
MUT1_GROW_MOLD = add_corruption
@@ -680,12 +563,6 @@ MUT1_GROW_MOLD = add_corruption
" Summons up to 8 molds around the player",
" Level=1, Cost=6, Stat=CON, Difficulty=14",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_GROW_MOLD)
- end,
- },
}
MUT1_RESIST = add_corruption
@@ -701,12 +578,6 @@ MUT1_RESIST = add_corruption
" elements and poison. Duration=20 + d20",
" Level=10, Cost=12, Stat=CON, Difficulty=12",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_RESIST)
- end,
- },
}
MUT1_EARTHQUAKE = add_corruption
@@ -721,12 +592,6 @@ MUT1_EARTHQUAKE = add_corruption
" Radius=10, center on the player",
" Level=12, Cost=12, Stat=STR, Difficulty=16",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_EARTHQUAKE)
- end,
- },
}
--[[
CORRUPT_ = add_corruption
diff --git a/lib/scpt/corrupt.lua b/lib/scpt/corrupt.lua
index f72ddf2d..c58c8414 100644
--- a/lib/scpt/corrupt.lua
+++ b/lib/scpt/corrupt.lua
@@ -57,12 +57,6 @@ CORRUPT_BALROG_FORM = add_corruption
[CORRUPT_BALROG_WINGS] = TRUE,
[CORRUPT_BALROG_STRENGTH] = TRUE
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BALROG)
- end,
- },
}
@@ -105,12 +99,6 @@ CORRUPT_DEMON_BREATH = add_corruption
" Provides fire breath",
" But gives a small chance to spoil potions when you quaff them",
},
- ["hooks"] =
- {
- [HOOK_CALC_POWERS] = function()
- player.add_power(PWR_BR_FIRE)
- end,
- },
}
CORRUPT_DEMON_REALM = add_corruption
@@ -186,9 +174,6 @@ CORRUPT_ANTI_TELEPORT = add_corruption
[HOOK_BIRTH_OBJECTS] = function()
player.corrupt_anti_teleport_stopped = FALSE
end,
- [HOOK_CALC_POWERS] = function()
- player.add_power(POWER_COR_SPACE_TIME)
- end,
[HOOK_PROCESS_WORLD] = function()
if player.corrupt_anti_teleport_stopped == TRUE then
local amt = player.msp + player.csp
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, "()");