summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-05 23:42:13 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:26 +0200
commit62e385cb769000cfefa052b1ab3e155314e7ac37 (patch)
treea3f9acc5147789393128df51dadd0599c4aacb5e /lib
parenta9b597979d99a53c56d2fa5b8498834364fef7a9 (diff)
Lua: Move HOOK_CALC_BONUS corruption code to C
Diffstat (limited to 'lib')
-rw-r--r--lib/core/crpt_aux.lua21
-rw-r--r--lib/mods/theme/core/crpt_aux.lua21
-rw-r--r--lib/mods/theme/scpt/corrupt.lua63
-rw-r--r--lib/scpt/corrupt.lua63
4 files changed, 22 insertions, 146 deletions
diff --git a/lib/core/crpt_aux.lua b/lib/core/crpt_aux.lua
index 97f8d4b6..c1772c04 100644
--- a/lib/core/crpt_aux.lua
+++ b/lib/core/crpt_aux.lua
@@ -140,7 +140,6 @@ function add_corruption(c)
assert(c.get_text, "No corruption get_text")
assert(c.lose_text, "No corruption lose_text")
assert(c.desc, "No corruption desc")
- assert(c.hooks, "Nothing to do for corruption")
if not c.random then c.random = TRUE end
if not c.removable then c.removable = TRUE end
if not c.allow then c.allow = function() return not nil end end
@@ -155,16 +154,18 @@ function add_corruption(c)
end
local index, h
- for index, h in c.hooks do
- add_hook_script(index, "__lua__corrupt_callback"..__corruptions_callbacks_max, "__lua__corrupt_callback"..__corruptions_callbacks_max)
- setglobal("__lua__corrupt_callback"..__corruptions_callbacks_max,
- function (...)
- if test_depend_corrupt(%__corruptions_max) == TRUE then
- return call(%h, arg)
+ if type(c.hooks) == "table" then
+ for index, h in c.hooks do
+ add_hook_script(index, "__lua__corrupt_callback"..__corruptions_callbacks_max, "__lua__corrupt_callback"..__corruptions_callbacks_max)
+ setglobal("__lua__corrupt_callback"..__corruptions_callbacks_max,
+ function (...)
+ if test_depend_corrupt(%__corruptions_max) == TRUE then
+ return call(%h, arg)
+ end
end
- end
- )
- __corruptions_callbacks_max = __corruptions_callbacks_max + 1
+ )
+ __corruptions_callbacks_max = __corruptions_callbacks_max + 1
+ end
end
if type(c.desc) == "table" then
diff --git a/lib/mods/theme/core/crpt_aux.lua b/lib/mods/theme/core/crpt_aux.lua
index 97f8d4b6..c1772c04 100644
--- a/lib/mods/theme/core/crpt_aux.lua
+++ b/lib/mods/theme/core/crpt_aux.lua
@@ -140,7 +140,6 @@ function add_corruption(c)
assert(c.get_text, "No corruption get_text")
assert(c.lose_text, "No corruption lose_text")
assert(c.desc, "No corruption desc")
- assert(c.hooks, "Nothing to do for corruption")
if not c.random then c.random = TRUE end
if not c.removable then c.removable = TRUE end
if not c.allow then c.allow = function() return not nil end end
@@ -155,16 +154,18 @@ function add_corruption(c)
end
local index, h
- for index, h in c.hooks do
- add_hook_script(index, "__lua__corrupt_callback"..__corruptions_callbacks_max, "__lua__corrupt_callback"..__corruptions_callbacks_max)
- setglobal("__lua__corrupt_callback"..__corruptions_callbacks_max,
- function (...)
- if test_depend_corrupt(%__corruptions_max) == TRUE then
- return call(%h, arg)
+ if type(c.hooks) == "table" then
+ for index, h in c.hooks do
+ add_hook_script(index, "__lua__corrupt_callback"..__corruptions_callbacks_max, "__lua__corrupt_callback"..__corruptions_callbacks_max)
+ setglobal("__lua__corrupt_callback"..__corruptions_callbacks_max,
+ function (...)
+ if test_depend_corrupt(%__corruptions_max) == TRUE then
+ return call(%h, arg)
+ end
end
- end
- )
- __corruptions_callbacks_max = __corruptions_callbacks_max + 1
+ )
+ __corruptions_callbacks_max = __corruptions_callbacks_max + 1
+ end
end
if type(c.desc) == "table" then
diff --git a/lib/mods/theme/scpt/corrupt.lua b/lib/mods/theme/scpt/corrupt.lua
index f402add3..51d7233b 100644
--- a/lib/mods/theme/scpt/corrupt.lua
+++ b/lib/mods/theme/scpt/corrupt.lua
@@ -15,10 +15,6 @@ CORRUPT_BALROG_AURA = add_corruption
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- player.xtra_f3 = bor(player.xtra_f3, TR3_SH_FIRE)
- player.xtra_f3 = bor(player.xtra_f3, TR3_LITE1)
- end,
[HOOK_READ] = function(obj)
if magik(5) == TRUE then
msg_print("Your demon aura burns the scroll before you read it!")
@@ -41,14 +37,6 @@ CORRUPT_BALROG_WINGS = add_corruption
" Creates ugly, but working, wings allowing you to fly",
" But it reduces charisma by 4 and dexterity by 2"
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.xtra_f4 = bor(player.xtra_f4, TR4_FLY)
- player.modify_stat(A_CHR, -4)
- player.modify_stat(A_DEX, -2)
- end,
- },
}
CORRUPT_BALROG_STRENGTH = add_corruption
@@ -62,15 +50,6 @@ CORRUPT_BALROG_STRENGTH = add_corruption
" Provides 3 strength and 1 constitution",
" But it reduces charisma by 1 and dexterity by 3"
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.modify_stat(A_STR, 3)
- player.modify_stat(A_CON, 1)
- player.modify_stat(A_DEX, -3)
- player.modify_stat(A_CHR, -1)
- end,
- },
}
CORRUPT_BALROG_FORM = add_corruption
@@ -120,13 +99,6 @@ CORRUPT_DEMON_SPIRIT = add_corruption
return not nil
end
end,
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.modify_stat(A_INT, 1)
- player.modify_stat(A_CHR, -2)
- end,
- },
}
CORRUPT_DEMON_HIDE = add_corruption
@@ -150,15 +122,6 @@ CORRUPT_DEMON_HIDE = add_corruption
return not nil
end
end,
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.to_a = player.to_a + player.lev
- player.dis_to_a = player.dis_to_a + player.lev
- player.pspeed = player.pspeed - (player.lev / 7)
- if player.lev >= 40 then player.xtra_f2 = bor(player.xtra_f2, TR2_IM_FIRE) end
- end,
- },
}
CORRUPT_DEMON_BREATH = add_corruption
@@ -214,15 +177,6 @@ CORRUPT_DEMON_REALM = add_corruption
return not nil
end
end,
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- -- 1500 may seem a lot, but people are rather unlikely to get the corruption very soon
- -- due to the dependencies
- if s_info[SKILL_DAEMON + 1].mod == 0 then s_info[SKILL_DAEMON + 1].mod = 1500 end
- s_info[SKILL_DAEMON + 1].hidden = FALSE;
- end,
- },
}
@@ -252,9 +206,6 @@ CORRUPT_RANDOM_TELEPORT = add_corruption
-- No oppose field, it will be automatically set when we declare the anti-telep corruption to oppose us
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- player.xtra_f3 = bor(player.xtra_f3, TR3_TELEPORT)
- end,
[HOOK_PROCESS_WORLD] = function()
if rand_int(300) == 1 then
if magik(70) == TRUE then
@@ -303,11 +254,6 @@ CORRUPT_ANTI_TELEPORT = add_corruption
[HOOK_CALC_POWERS] = function()
player.add_power(POWER_COR_SPACE_TIME)
end,
- [HOOK_CALC_BONUS] = function()
- if player.corrupt_anti_teleport_stopped == FALSE then
- player.resist_continuum = TRUE
- end
- end,
[HOOK_PROCESS_WORLD] = function()
if player.corrupt_anti_teleport_stopped == TRUE then
local amt = player.msp + player.csp
@@ -347,13 +293,6 @@ CORRUPT_TROLL_BLOOD = add_corruption
return not nil
end
end,
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.xtra_f3 = bor(player.xtra_f3, TR3_REGEN, TR3_AGGRAVATE)
- player.xtra_esp = bor(player.xtra_esp, ESP_TROLL)
- end,
- },
}
-- The vampire corruption set
@@ -1082,8 +1021,6 @@ CORRUPT_ = add_corruption
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- end,
},
}
]]
diff --git a/lib/scpt/corrupt.lua b/lib/scpt/corrupt.lua
index 550f8bc0..1435df6e 100644
--- a/lib/scpt/corrupt.lua
+++ b/lib/scpt/corrupt.lua
@@ -14,10 +14,6 @@ CORRUPT_BALROG_AURA = add_corruption
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- player.xtra_f3 = bor(player.xtra_f3, TR3_SH_FIRE)
- player.xtra_f3 = bor(player.xtra_f3, TR3_LITE1)
- end,
[HOOK_READ] = function(obj)
if magik(5) == TRUE then
msg_print("Your demon aura burns the scroll before you read it!")
@@ -40,14 +36,6 @@ CORRUPT_BALROG_WINGS = add_corruption
" Creates ugly, but working, wings allowing you to fly",
" But it reduces charisma by 4 and dexterity by 2"
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.xtra_f4 = bor(player.xtra_f4, TR4_FLY)
- player.modify_stat(A_CHR, -4)
- player.modify_stat(A_DEX, -2)
- end,
- },
}
CORRUPT_BALROG_STRENGTH = add_corruption
@@ -61,15 +49,6 @@ CORRUPT_BALROG_STRENGTH = add_corruption
" Provides 3 strength and 1 constitution",
" But it reduces charisma by 1 and dexterity by 3"
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.modify_stat(A_STR, 3)
- player.modify_stat(A_CON, 1)
- player.modify_stat(A_DEX, -3)
- player.modify_stat(A_CHR, -1)
- end,
- },
}
CORRUPT_BALROG_FORM = add_corruption
@@ -110,13 +89,6 @@ CORRUPT_DEMON_SPIRIT = add_corruption
" Increases your intelligence by 1",
" But reduce your charisma by 2",
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.modify_stat(A_INT, 1)
- player.modify_stat(A_CHR, -2)
- end,
- },
}
CORRUPT_DEMON_HIDE = add_corruption
@@ -131,15 +103,6 @@ CORRUPT_DEMON_HIDE = add_corruption
" Provides immunity to fire at level 40",
" But reduces speed by your level / 7",
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.to_a = player.to_a + player.lev
- player.dis_to_a = player.dis_to_a + player.lev
- player.pspeed = player.pspeed - (player.lev / 7)
- if player.lev >= 40 then player.xtra_f2 = bor(player.xtra_f2, TR2_IM_FIRE) end
- end,
- },
}
CORRUPT_DEMON_BREATH = add_corruption
@@ -186,15 +149,6 @@ CORRUPT_DEMON_REALM = add_corruption
[CORRUPT_DEMON_HIDE] = TRUE,
[CORRUPT_DEMON_BREATH] = TRUE
},
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- -- 1500 may seem a lot, but people are rather unlikely to get the corruption very soon
- -- due to the dependencies
- if s_info[SKILL_DAEMON + 1].mod == 0 then s_info[SKILL_DAEMON + 1].mod = 1500 end
- s_info[SKILL_DAEMON + 1].hidden = FALSE;
- end,
- },
}
@@ -215,9 +169,6 @@ CORRUPT_RANDOM_TELEPORT = add_corruption
-- No oppose field, it will be automatically set when we declare the anti-telep corruption to oppose us
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- player.xtra_f3 = bor(player.xtra_f3, TR3_TELEPORT)
- end,
[HOOK_PROCESS_WORLD] = function()
if rand_int(300) == 1 then
if magik(70) == TRUE then
@@ -257,11 +208,6 @@ CORRUPT_ANTI_TELEPORT = add_corruption
[HOOK_CALC_POWERS] = function()
player.add_power(POWER_COR_SPACE_TIME)
end,
- [HOOK_CALC_BONUS] = function()
- if player.corrupt_anti_teleport_stopped == FALSE then
- player.resist_continuum = TRUE
- end
- end,
[HOOK_PROCESS_WORLD] = function()
if player.corrupt_anti_teleport_stopped == TRUE then
local amt = player.msp + player.csp
@@ -300,13 +246,6 @@ CORRUPT_TROLL_BLOOD = add_corruption
return not nil
end
end,
- ["hooks"] =
- {
- [HOOK_CALC_BONUS] = function()
- player.xtra_f3 = bor(player.xtra_f3, TR3_REGEN, TR3_AGGRAVATE)
- player.xtra_esp = bor(player.xtra_esp, ESP_TROLL)
- end,
- },
}
-- The vampire corruption set
@@ -426,8 +365,6 @@ CORRUPT_ = add_corruption
},
["hooks"] =
{
- [HOOK_CALC_BONUS] = function()
- end,
},
}
]]