summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/core/crpt_aux.lua22
-rw-r--r--lib/mods/theme/core/crpt_aux.lua22
-rw-r--r--lib/mods/theme/scpt/corrupt.lua3
-rw-r--r--lib/mods/theme/scpt/player.lua6
-rw-r--r--lib/scpt/corrupt.lua3
-rw-r--r--lib/scpt/player.lua6
-rw-r--r--src/externs.h5
-rw-r--r--src/lua_bind.c39
-rw-r--r--src/player.pkg5
9 files changed, 56 insertions, 55 deletions
diff --git a/lib/core/crpt_aux.lua b/lib/core/crpt_aux.lua
index 369cf5d1..24b71860 100644
--- a/lib/core/crpt_aux.lua
+++ b/lib/core/crpt_aux.lua
@@ -5,20 +5,8 @@ __corruptions_max = 0
__corruptions_callbacks_max = 0
-- Get the corruption
-function player.corruption(c, set)
- if set then
- player.corruptions_aux[c + 1] = set
- player.redraw = bor(player.redraw, PR_BASIC)
- player.update = bor(player.update, PU_BONUS, PU_TORCH, PU_BODY, PU_POWERS)
- if (set == TRUE) and (__corruptions[c].gain) then
- __corruptions[c].gain()
- end
- if (set == FALSE) and (__corruptions[c].lose) then
- __corruptions[c].lose()
- end
- else
- return player.corruptions_aux[c + 1]
- end
+function player.corruption(c)
+ return player.corruptions_aux[c + 1]
end
-- Test if we have that corruption
@@ -76,7 +64,7 @@ function gain_corruption(group)
if (max > 0) then
local ret = rand_int(max)
- player.corruption(pos[ret], TRUE)
+ player_gain_corruption(pos[ret])
cmsg_print(TERM_L_RED, __corruptions[pos[ret]].get_text)
return pos[ret]
@@ -103,13 +91,13 @@ function lose_corruption()
if (max > 0) then
local ret = rand_int(max)
- player.corruption(pos[ret], FALSE)
+ player_lose_corruption(pos[ret])
cmsg_print(TERM_L_RED, __corruptions[pos[ret]].lose_text)
-- Ok now lets see if it broke some dependancies
for i = 0, max - 1 do
if player.corruption(pos[i]) ~= test_depend_corrupt(pos[i]) then
- player.corruption(pos[i], FALSE)
+ player_lose_corruption(pos[i])
cmsg_print(TERM_L_RED, __corruptions[pos[i]].lose_text)
end
end
diff --git a/lib/mods/theme/core/crpt_aux.lua b/lib/mods/theme/core/crpt_aux.lua
index 369cf5d1..24b71860 100644
--- a/lib/mods/theme/core/crpt_aux.lua
+++ b/lib/mods/theme/core/crpt_aux.lua
@@ -5,20 +5,8 @@ __corruptions_max = 0
__corruptions_callbacks_max = 0
-- Get the corruption
-function player.corruption(c, set)
- if set then
- player.corruptions_aux[c + 1] = set
- player.redraw = bor(player.redraw, PR_BASIC)
- player.update = bor(player.update, PU_BONUS, PU_TORCH, PU_BODY, PU_POWERS)
- if (set == TRUE) and (__corruptions[c].gain) then
- __corruptions[c].gain()
- end
- if (set == FALSE) and (__corruptions[c].lose) then
- __corruptions[c].lose()
- end
- else
- return player.corruptions_aux[c + 1]
- end
+function player.corruption(c)
+ return player.corruptions_aux[c + 1]
end
-- Test if we have that corruption
@@ -76,7 +64,7 @@ function gain_corruption(group)
if (max > 0) then
local ret = rand_int(max)
- player.corruption(pos[ret], TRUE)
+ player_gain_corruption(pos[ret])
cmsg_print(TERM_L_RED, __corruptions[pos[ret]].get_text)
return pos[ret]
@@ -103,13 +91,13 @@ function lose_corruption()
if (max > 0) then
local ret = rand_int(max)
- player.corruption(pos[ret], FALSE)
+ player_lose_corruption(pos[ret])
cmsg_print(TERM_L_RED, __corruptions[pos[ret]].lose_text)
-- Ok now lets see if it broke some dependancies
for i = 0, max - 1 do
if player.corruption(pos[i]) ~= test_depend_corrupt(pos[i]) then
- player.corruption(pos[i], FALSE)
+ player_lose_corruption(pos[i])
cmsg_print(TERM_L_RED, __corruptions[pos[i]].lose_text)
end
end
diff --git a/lib/mods/theme/scpt/corrupt.lua b/lib/mods/theme/scpt/corrupt.lua
index f1d83c26..e303803b 100644
--- a/lib/mods/theme/scpt/corrupt.lua
+++ b/lib/mods/theme/scpt/corrupt.lua
@@ -189,7 +189,6 @@ CORRUPT_VAMPIRE_TEETH = add_corruption
["allow"] = function()
if test_race_flags(1, PR1_NO_SUBRACE_CHANGE) == FALSE then return not nil else return nil end
end,
- ["gain"] = function() player_gain_vampire_teeth() end,
}
CORRUPT_VAMPIRE_STRENGTH = add_corruption
{
@@ -209,7 +208,6 @@ CORRUPT_VAMPIRE_STRENGTH = add_corruption
{
[CORRUPT_VAMPIRE_TEETH] = TRUE,
},
- ["gain"] = function() player_gain_vampire_strength() end,
}
CORRUPT_VAMPIRE_VAMPIRE = add_corruption
{
@@ -228,7 +226,6 @@ CORRUPT_VAMPIRE_VAMPIRE = add_corruption
{
[CORRUPT_VAMPIRE_STRENGTH] = TRUE,
},
- ["gain"] = function() player_gain_vampire() end,
}
-- The old activable corruptions / mutations
diff --git a/lib/mods/theme/scpt/player.lua b/lib/mods/theme/scpt/player.lua
index de04052d..0e9faff6 100644
--- a/lib/mods/theme/scpt/player.lua
+++ b/lib/mods/theme/scpt/player.lua
@@ -8,9 +8,9 @@ function __birth_hook_objects()
-- Start the undeads, as undeads with the corruptions
if get_subrace_name() == "Vampire" then
- player.corruption(CORRUPT_VAMPIRE_TEETH, TRUE)
- player.corruption(CORRUPT_VAMPIRE_STRENGTH, TRUE)
- player.corruption(CORRUPT_VAMPIRE_VAMPIRE, TRUE)
+ player_gain_corruption(CORRUPT_VAMPIRE_TEETH)
+ player_gain_corruption(CORRUPT_VAMPIRE_STRENGTH)
+ player_gain_corruption(CORRUPT_VAMPIRE_VAMPIRE)
end
end
diff --git a/lib/scpt/corrupt.lua b/lib/scpt/corrupt.lua
index a1bc98a4..19957668 100644
--- a/lib/scpt/corrupt.lua
+++ b/lib/scpt/corrupt.lua
@@ -188,7 +188,6 @@ CORRUPT_VAMPIRE_TEETH = add_corruption
["allow"] = function()
if test_race_flags(1, PR1_NO_SUBRACE_CHANGE) == FALSE then return not nil else return nil end
end,
- ["gain"] = function() player_gain_vampire_teeth() end,
}
CORRUPT_VAMPIRE_STRENGTH = add_corruption
{
@@ -208,7 +207,6 @@ CORRUPT_VAMPIRE_STRENGTH = add_corruption
{
[CORRUPT_VAMPIRE_TEETH] = TRUE,
},
- ["gain"] = function() player_gain_vampire_strength() end,
}
CORRUPT_VAMPIRE_VAMPIRE = add_corruption
{
@@ -227,7 +225,6 @@ CORRUPT_VAMPIRE_VAMPIRE = add_corruption
{
[CORRUPT_VAMPIRE_STRENGTH] = TRUE,
},
- ["gain"] = function() player_gain_vampire() end,
}
diff --git a/lib/scpt/player.lua b/lib/scpt/player.lua
index e8fb7e25..1c8da791 100644
--- a/lib/scpt/player.lua
+++ b/lib/scpt/player.lua
@@ -5,9 +5,9 @@ function __birth_hook_objects()
-- Start the undeads, as undeads with the corruptions
if get_subrace_name() == "Vampire" then
- player.corruption(CORRUPT_VAMPIRE_TEETH, TRUE)
- player.corruption(CORRUPT_VAMPIRE_STRENGTH, TRUE)
- player.corruption(CORRUPT_VAMPIRE_VAMPIRE, TRUE)
+ player_gain_corruption(CORRUPT_VAMPIRE_TEETH)
+ player_gain_corruption(CORRUPT_VAMPIRE_STRENGTH)
+ player_gain_corruption(CORRUPT_VAMPIRE_VAMPIRE)
end
end
diff --git a/src/externs.h b/src/externs.h
index 579ed463..3f48098c 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1870,9 +1870,8 @@ extern void lua_display_list(int y, int x, int h, int w, cptr title, list_type *
extern bool_ player_has_corruption(int corruption_idx);
extern bool_ player_can_gain_corruption(int corruption_idx);
-extern void player_gain_vampire_teeth();
-extern void player_gain_vampire_strength();
-extern void player_gain_vampire();
+extern void player_gain_corruption(int corruption_idx);
+extern void player_lose_corruption(int corruption_idx);
extern cptr compass(int y, int x, int y2, int x2);
extern cptr approximate_distance(int y, int x, int y2, int x2);
diff --git a/src/lua_bind.c b/src/lua_bind.c
index ded66b21..1add61e3 100644
--- a/src/lua_bind.c
+++ b/src/lua_bind.c
@@ -657,7 +657,7 @@ static void subrace_add_power(player_race_mod *rmp_ptr, int power)
}
}
-void player_gain_vampire_teeth()
+static void player_gain_vampire_teeth()
{
player_race_mod *rmp_ptr = NULL;
@@ -671,7 +671,7 @@ void player_gain_vampire_teeth()
| PR1_NO_SUBRACE_CHANGE;
}
-void player_gain_vampire_strength()
+static void player_gain_vampire_strength()
{
player_race_mod *rmp_ptr = &race_mod_info[SUBRACE_SAVE];
/* Apply the bonuses/penalities */
@@ -690,7 +690,7 @@ void player_gain_vampire_strength()
cmsg_print(TERM_L_DARK, "You feel death slipping inside.");
}
-void player_gain_vampire()
+static void player_gain_vampire()
{
player_race_mod *rmp_ptr = &race_mod_info[SUBRACE_SAVE];
@@ -721,6 +721,39 @@ void player_gain_vampire()
| TR3_LITE1;
}
+static void player_set_corruption(int c, bool_ set)
+{
+ p_ptr->corruptions[c] = set;
+ p_ptr->redraw = p_ptr->redraw | PR_BASIC;
+ p_ptr->update = p_ptr->update | PU_BONUS | PU_TORCH | PU_BODY | PU_POWERS;
+
+}
+
+void player_gain_corruption(int corruption_idx)
+{
+ player_set_corruption(corruption_idx, TRUE);
+
+ if (corruption_idx == CORRUPT_VAMPIRE_TEETH)
+ {
+ player_gain_vampire_teeth();
+ }
+ else if (corruption_idx == CORRUPT_VAMPIRE_STRENGTH)
+ {
+ player_gain_vampire_strength();
+ }
+ else if (corruption_idx == CORRUPT_VAMPIRE_VAMPIRE)
+ {
+ player_gain_vampire();
+ }
+}
+
+void player_lose_corruption(int corruption_idx)
+{
+ player_set_corruption(corruption_idx, FALSE);
+ /* Currently no corruptions need
+ any special handling when lost */
+}
+
/*
* Gods
*/
diff --git a/src/player.pkg b/src/player.pkg
index 5e693c9b..ad01e9eb 100644
--- a/src/player.pkg
+++ b/src/player.pkg
@@ -1854,9 +1854,8 @@ extern s16b MUT1_RESIST;
extern s16b MUT1_EARTHQUAKE;
extern bool player_can_gain_corruption(int corruption_idx);
-extern void player_gain_vampire_teeth();
-extern void player_gain_vampire_strength();
-extern void player_gain_vampire();
+extern void player_gain_corruption(int corruption_idx);
+extern void player_lose_corruption(int corruption_idx);
/** @name Spellbinder triggers
* @{ */