diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-06 19:24:21 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:28:27 +0200 |
commit | 41b6617e992d3fedda4c0a93ddd0fa4ad834a2ae (patch) | |
tree | 14828062fd2d5faf7947feecae48ef6be1efcd00 /lib/mods/theme | |
parent | 1de4221b9e906ce8324237943165c161f78b5e07 (diff) |
Lua: Refactor the "set" part of player.corruption() to C
Diffstat (limited to 'lib/mods/theme')
-rw-r--r-- | lib/mods/theme/core/crpt_aux.lua | 22 | ||||
-rw-r--r-- | lib/mods/theme/scpt/corrupt.lua | 3 | ||||
-rw-r--r-- | lib/mods/theme/scpt/player.lua | 6 |
3 files changed, 8 insertions, 23 deletions
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 |