summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-06 19:24:21 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:27 +0200
commit41b6617e992d3fedda4c0a93ddd0fa4ad834a2ae (patch)
tree14828062fd2d5faf7947feecae48ef6be1efcd00 /lib
parent1de4221b9e906ce8324237943165c161f78b5e07 (diff)
Lua: Refactor the "set" part of player.corruption() to C
Diffstat (limited to 'lib')
-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
6 files changed, 16 insertions, 46 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