summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-05 21:03:18 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:25 +0200
commit46498dfaab2cb0698822397b43039e3ecf605a1e (patch)
treeee758d0906ef96311bdaa4b5f392f9704553ab48 /lib
parentc92f7bf932d6e36c1aecd704a2a69d742ef7748d (diff)
Lua: Move geomancy spell effects to C
Diffstat (limited to 'lib')
-rw-r--r--lib/core/dungeon.lua26
-rw-r--r--lib/mods/theme/core/dungeon.lua26
-rw-r--r--lib/mods/theme/scpt/s_geom.lua252
-rw-r--r--lib/scpt/s_geom.lua252
4 files changed, 4 insertions, 552 deletions
diff --git a/lib/core/dungeon.lua b/lib/core/dungeon.lua
index d91d785b..ba4fd38a 100644
--- a/lib/core/dungeon.lua
+++ b/lib/core/dungeon.lua
@@ -20,32 +20,6 @@ function explode_dir(dir)
return ddy[dir + 1], ddx[dir + 1]
end
-function rotate_dir(dir, mov)
- if mov > 0 then
- if dir == 7 then dir = 8
- elseif dir == 8 then dir = 9
- elseif dir == 9 then dir = 6
- elseif dir == 6 then dir = 3
- elseif dir == 3 then dir = 2
- elseif dir == 2 then dir = 1
- elseif dir == 1 then dir = 4
- elseif dir == 4 then dir = 7
- end
- elseif mov < 0 then
- if dir == 7 then dir = 4
- elseif dir == 4 then dir = 1
- elseif dir == 1 then dir = 2
- elseif dir == 2 then dir = 3
- elseif dir == 3 then dir = 6
- elseif dir == 6 then dir = 9
- elseif dir == 9 then dir = 8
- elseif dir == 8 then dir = 7
- end
- end
-
- return dir
-end
-
-- Place a trap for a specific level
function place_trap(y, x, level)
local old_dun = dun_level
diff --git a/lib/mods/theme/core/dungeon.lua b/lib/mods/theme/core/dungeon.lua
index d91d785b..ba4fd38a 100644
--- a/lib/mods/theme/core/dungeon.lua
+++ b/lib/mods/theme/core/dungeon.lua
@@ -20,32 +20,6 @@ function explode_dir(dir)
return ddy[dir + 1], ddx[dir + 1]
end
-function rotate_dir(dir, mov)
- if mov > 0 then
- if dir == 7 then dir = 8
- elseif dir == 8 then dir = 9
- elseif dir == 9 then dir = 6
- elseif dir == 6 then dir = 3
- elseif dir == 3 then dir = 2
- elseif dir == 2 then dir = 1
- elseif dir == 1 then dir = 4
- elseif dir == 4 then dir = 7
- end
- elseif mov < 0 then
- if dir == 7 then dir = 4
- elseif dir == 4 then dir = 1
- elseif dir == 1 then dir = 2
- elseif dir == 2 then dir = 3
- elseif dir == 3 then dir = 6
- elseif dir == 6 then dir = 9
- elseif dir == 9 then dir = 8
- elseif dir == 8 then dir = 7
- end
- end
-
- return dir
-end
-
-- Place a trap for a specific level
function place_trap(y, x, level)
local old_dun = dun_level
diff --git a/lib/mods/theme/scpt/s_geom.lua b/lib/mods/theme/scpt/s_geom.lua
index 52ebd49a..d152bc25 100644
--- a/lib/mods/theme/scpt/s_geom.lua
+++ b/lib/mods/theme/scpt/s_geom.lua
@@ -1,75 +1,5 @@
-- Geomancy school
-function geomancy_random_wall(y, x)
- local c_ptr = cave(y, x)
-
- -- Do not destroy permanent things
- if cave_is(c_ptr, FF1_PERMANENT) ~= FALSE then return end
-
- local feat = nil
- local table =
- {
- [1] = { SKILL_FIRE, FEAT_SANDWALL, 1},
-
- [2] = { SKILL_WATER, FEAT_TREES, 1},
- [3] = { SKILL_WATER, FEAT_ICE_WALL, 12},
-
- [4] = { SKILL_EARTH, FEAT_WALL_EXTRA, 1},
- }
-
- while feat == nil do
- local t = table[randint(getn(table))]
-
- -- Do we meet the requirements ?
- -- And then select the features based on skill proportions
- if get_skill(t[1]) >= t[3] and magik(get_skill_scale(t[1], 100)) == TRUE then
- feat = t[2]
- end
- end
-
- cave_set_feat(y, x, feat)
-end
-
-
-function geomancy_random_floor(y, x, kill_wall)
- local c_ptr = cave(y, x)
-
- -- Do not destroy permanent things
- if cave_is(c_ptr, FF1_PERMANENT) ~= FALSE then return end
- if not kill_wall then
- if cave_is(c_ptr, FF1_FLOOR) ~= TRUE then return end
- end
-
- local feat = nil
- local table =
- {
- [1] = { SKILL_FIRE, FEAT_SAND, 1},
- [2] = { SKILL_FIRE, FEAT_SHAL_LAVA, 8},
- [3] = { SKILL_FIRE, FEAT_DEEP_LAVA, 18},
-
- [4] = { SKILL_WATER, FEAT_SHAL_WATER, 1},
- [5] = { SKILL_WATER, FEAT_DEEP_WATER, 8},
- [6] = { SKILL_WATER, FEAT_ICE, 18},
-
- [7] = { SKILL_EARTH, FEAT_GRASS, 1},
- [8] = { SKILL_EARTH, FEAT_FLOWER, 8},
- [9] = { SKILL_EARTH, FEAT_DARK_PIT, 18},
- }
-
- while feat == nil do
- local t = table[randint(getn(table))]
-
- -- Do we meet the requirements ?
- -- And then select the features based on skill proportions
- if get_skill(t[1]) >= t[3] and magik(get_skill_scale(t[1], 100)) == TRUE then
- feat = t[2]
- end
- end
-
- cave_set_feat(y, x, feat)
-end
-
-
CALL_THE_ELEMENTS = add_spell
{
["name"] = "Call the Elements",
@@ -103,114 +33,6 @@ CALL_THE_ELEMENTS = add_spell
}
}
--- Seperate function because an other spell needs it
-function channel_the_elements(y, x, level, silent)
- local t =
- {
- -- Earth stuff
- [FEAT_GRASS] = function()
- hp_player(player.mhp * (5 + get_skill_scale(SKILL_EARTH, 20)) / 100)
- end,
- [FEAT_FLOWER] = function()
- hp_player(player.mhp * (5 + get_skill_scale(SKILL_EARTH, 30)) / 100)
- end,
- [FEAT_DARK_PIT] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- local type = GF_DARK
- if get_skill(SKILL_EARTH) >= 18 then type = GF_NETHER end
- fire_bolt(type, dir, damroll(10, get_skill(SKILL_EARTH)))
- end,
-
- -- Water stuff
- [FEAT_SHAL_WATER] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- local type = GF_WATER
- if get_skill(SKILL_WATER) >= 18 then type = GF_WAVE end
-
- if get_skill(SKILL_WATER) >= 8 then
- fire_beam(type, dir, damroll(3, get_skill(SKILL_WATER)))
- else
- fire_bolt(type, dir, damroll(3, get_skill(SKILL_WATER)))
- end
- end,
- [FEAT_DEEP_WATER] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- local type = GF_WATER
- if get_skill(SKILL_WATER) >= 18 then type = GF_WAVE end
-
- if get_skill(SKILL_WATER) >= 8 then
- fire_beam(type, dir, damroll(5, get_skill(SKILL_WATER)))
- else
- fire_bolt(type, dir, damroll(5, get_skill(SKILL_WATER)))
- end
- end,
- [FEAT_ICE] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- if get_skill(SKILL_WATER) >= 12 then
- fire_ball(GF_ICE, dir, get_skill_scale(SKILL_WATER, 340), 3)
- else
- fire_bolt(GF_ICE, dir, damroll(3, get_skill(SKILL_WATER)))
- end
- end,
-
- -- Fire stuff
- [FEAT_SAND] = function()
- local type
- if (get_level(FIERYAURA, 50) >= 8) then
- type = SHIELD_GREAT_FIRE
- else
- type = SHIELD_FIRE
- end
- local dur = randint(20) + %level + get_skill(SKILL_AIR)
- set_shield(dur, 0, type, 5 + get_skill_scale(SKILL_FIRE, 20), 5 + get_skill_scale(SKILL_FIRE, 14))
- set_blind(dur)
- end,
- [FEAT_SHAL_LAVA] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- if get_skill(SKILL_FIRE) >= 15 then
- fire_bolt(GF_HELL_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15))
- else
- fire_bolt(GF_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15))
- end
- end,
- [FEAT_DEEP_LAVA] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- if get_skill(SKILL_FIRE) >= 15 then
- fire_ball(GF_HELL_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15), 3)
- else
- fire_ball(GF_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15), 3)
- end
- end,
- }
-
- if t[cave(y, x).feat] then
- t[cave(y, x).feat]()
-
- if magik(100 - level) == TRUE then
- if cave(y, x).feat == FEAT_FLOWER then
- cave_set_feat(y, x, FEAT_GRASS)
- else
- cave_set_feat(y, x, FEAT_FLOOR)
- end
- msg_print("The area is drained.")
- end
- elseif not silent then
- msg_print("You cannot channel this area.")
- end
-end
-
CHANNEL_ELEMENTS = add_spell
{
["name"] = "Channel Elements",
@@ -223,7 +45,7 @@ CHANNEL_ELEMENTS = add_spell
["blind"] = FALSE,
["random"] = 0,
["spell"] = function()
- channel_the_elements(player.py, player.px, get_level(CHANNEL_ELEMENTS), nil)
+ channel_the_elements(player.py, player.px, get_level(CHANNEL_ELEMENTS))
return TRUE
end,
["info"] = function()
@@ -364,76 +186,6 @@ VAPORIZE = add_spell
}
}
-geomancy_can_tunnel =
-{
- [FEAT_WALL_EXTRA] = TRUE,
- [FEAT_WALL_OUTER] = TRUE,
- [FEAT_WALL_INNER] = TRUE,
- [FEAT_WALL_SOLID] = TRUE,
-
- [FEAT_MAGMA] = TRUE,
- [FEAT_QUARTZ] = TRUE,
- [FEAT_MAGMA_H] = TRUE,
- [FEAT_QUARTZ_H] = TRUE,
- [FEAT_MAGMA_K] = TRUE,
- [FEAT_QUARTZ_K] = TRUE,
-
- [FEAT_TREES] = TRUE,
- [FEAT_DEAD_TREE] = TRUE,
-
- [FEAT_SANDWALL] = TRUE,
- [FEAT_SANDWALL_H] = TRUE,
- [FEAT_SANDWALL_K] = TRUE,
-
- [FEAT_ICE_WALL] = TRUE,
-}
-
--- Dig & sprew
-function geomancy_dig(oy, ox, dir, length)
- local dy, dx = explode_dir(dir)
- local y = dy + oy
- local x = dx + ox
-
- for i = 1, length do
- local c_ptr = cave(y, x)
- local ox = x - dx
- local oy = y - dy
-
- -- stop at the end of tunnelable things
- if not geomancy_can_tunnel[c_ptr.feat] then break end
-
- if geomancy_can_tunnel[cave(y - 1, x - 1).feat] then geomancy_random_wall(y - 1, x - 1) end
- if geomancy_can_tunnel[cave(y - 1, x).feat] then geomancy_random_wall(y - 1, x) end
- if geomancy_can_tunnel[cave(y - 1, x + 1).feat] then geomancy_random_wall(y - 1, x + 1) end
-
- if geomancy_can_tunnel[cave(y, x - 1).feat] then geomancy_random_wall(y, x - 1) end
- if geomancy_can_tunnel[cave(y, x + 1).feat] then geomancy_random_wall(y, x + 1) end
-
- if geomancy_can_tunnel[cave(y + 1, x - 1).feat] then geomancy_random_wall(y + 1, x - 1) end
- if geomancy_can_tunnel[cave(y + 1, x).feat] then geomancy_random_wall(y + 1, x) end
- if geomancy_can_tunnel[cave(y + 1, x + 1).feat] then geomancy_random_wall(y + 1, x + 1) end
-
- y = y + dy
- x = x + dx
- end
-
- y = y - dy
- x = x - dx
- while (y ~= oy) or (x ~= ox) do
- geomancy_random_floor(y, x, TRUE)
-
- -- Should we branch ?
- if magik(20) == TRUE then
- local rot = 1
- if magik(50) == TRUE then rot = -1 end
- geomancy_dig(y, x, rotate_dir(dir, rot), length / 3)
- end
-
- y = y - dy
- x = x - dx
- end
-end
-
GEOLYSIS = add_spell
{
["name"] = "Geolysis",
@@ -473,7 +225,7 @@ add_hooks
{
[HOOK_MOVED] = function(oy, ox)
if player.dripping_tread > 0 then
- geomancy_random_floor(oy, ox)
+ geomancy_random_floor(oy, ox, FALSE)
player.dripping_tread = player.dripping_tread - 1
if player.dripping_tread == 0 then
msg_print("You stop dripping raw elemental energies.")
diff --git a/lib/scpt/s_geom.lua b/lib/scpt/s_geom.lua
index 52ebd49a..d152bc25 100644
--- a/lib/scpt/s_geom.lua
+++ b/lib/scpt/s_geom.lua
@@ -1,75 +1,5 @@
-- Geomancy school
-function geomancy_random_wall(y, x)
- local c_ptr = cave(y, x)
-
- -- Do not destroy permanent things
- if cave_is(c_ptr, FF1_PERMANENT) ~= FALSE then return end
-
- local feat = nil
- local table =
- {
- [1] = { SKILL_FIRE, FEAT_SANDWALL, 1},
-
- [2] = { SKILL_WATER, FEAT_TREES, 1},
- [3] = { SKILL_WATER, FEAT_ICE_WALL, 12},
-
- [4] = { SKILL_EARTH, FEAT_WALL_EXTRA, 1},
- }
-
- while feat == nil do
- local t = table[randint(getn(table))]
-
- -- Do we meet the requirements ?
- -- And then select the features based on skill proportions
- if get_skill(t[1]) >= t[3] and magik(get_skill_scale(t[1], 100)) == TRUE then
- feat = t[2]
- end
- end
-
- cave_set_feat(y, x, feat)
-end
-
-
-function geomancy_random_floor(y, x, kill_wall)
- local c_ptr = cave(y, x)
-
- -- Do not destroy permanent things
- if cave_is(c_ptr, FF1_PERMANENT) ~= FALSE then return end
- if not kill_wall then
- if cave_is(c_ptr, FF1_FLOOR) ~= TRUE then return end
- end
-
- local feat = nil
- local table =
- {
- [1] = { SKILL_FIRE, FEAT_SAND, 1},
- [2] = { SKILL_FIRE, FEAT_SHAL_LAVA, 8},
- [3] = { SKILL_FIRE, FEAT_DEEP_LAVA, 18},
-
- [4] = { SKILL_WATER, FEAT_SHAL_WATER, 1},
- [5] = { SKILL_WATER, FEAT_DEEP_WATER, 8},
- [6] = { SKILL_WATER, FEAT_ICE, 18},
-
- [7] = { SKILL_EARTH, FEAT_GRASS, 1},
- [8] = { SKILL_EARTH, FEAT_FLOWER, 8},
- [9] = { SKILL_EARTH, FEAT_DARK_PIT, 18},
- }
-
- while feat == nil do
- local t = table[randint(getn(table))]
-
- -- Do we meet the requirements ?
- -- And then select the features based on skill proportions
- if get_skill(t[1]) >= t[3] and magik(get_skill_scale(t[1], 100)) == TRUE then
- feat = t[2]
- end
- end
-
- cave_set_feat(y, x, feat)
-end
-
-
CALL_THE_ELEMENTS = add_spell
{
["name"] = "Call the Elements",
@@ -103,114 +33,6 @@ CALL_THE_ELEMENTS = add_spell
}
}
--- Seperate function because an other spell needs it
-function channel_the_elements(y, x, level, silent)
- local t =
- {
- -- Earth stuff
- [FEAT_GRASS] = function()
- hp_player(player.mhp * (5 + get_skill_scale(SKILL_EARTH, 20)) / 100)
- end,
- [FEAT_FLOWER] = function()
- hp_player(player.mhp * (5 + get_skill_scale(SKILL_EARTH, 30)) / 100)
- end,
- [FEAT_DARK_PIT] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- local type = GF_DARK
- if get_skill(SKILL_EARTH) >= 18 then type = GF_NETHER end
- fire_bolt(type, dir, damroll(10, get_skill(SKILL_EARTH)))
- end,
-
- -- Water stuff
- [FEAT_SHAL_WATER] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- local type = GF_WATER
- if get_skill(SKILL_WATER) >= 18 then type = GF_WAVE end
-
- if get_skill(SKILL_WATER) >= 8 then
- fire_beam(type, dir, damroll(3, get_skill(SKILL_WATER)))
- else
- fire_bolt(type, dir, damroll(3, get_skill(SKILL_WATER)))
- end
- end,
- [FEAT_DEEP_WATER] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- local type = GF_WATER
- if get_skill(SKILL_WATER) >= 18 then type = GF_WAVE end
-
- if get_skill(SKILL_WATER) >= 8 then
- fire_beam(type, dir, damroll(5, get_skill(SKILL_WATER)))
- else
- fire_bolt(type, dir, damroll(5, get_skill(SKILL_WATER)))
- end
- end,
- [FEAT_ICE] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- if get_skill(SKILL_WATER) >= 12 then
- fire_ball(GF_ICE, dir, get_skill_scale(SKILL_WATER, 340), 3)
- else
- fire_bolt(GF_ICE, dir, damroll(3, get_skill(SKILL_WATER)))
- end
- end,
-
- -- Fire stuff
- [FEAT_SAND] = function()
- local type
- if (get_level(FIERYAURA, 50) >= 8) then
- type = SHIELD_GREAT_FIRE
- else
- type = SHIELD_FIRE
- end
- local dur = randint(20) + %level + get_skill(SKILL_AIR)
- set_shield(dur, 0, type, 5 + get_skill_scale(SKILL_FIRE, 20), 5 + get_skill_scale(SKILL_FIRE, 14))
- set_blind(dur)
- end,
- [FEAT_SHAL_LAVA] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- if get_skill(SKILL_FIRE) >= 15 then
- fire_bolt(GF_HELL_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15))
- else
- fire_bolt(GF_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15))
- end
- end,
- [FEAT_DEEP_LAVA] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- if get_skill(SKILL_FIRE) >= 15 then
- fire_ball(GF_HELL_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15), 3)
- else
- fire_ball(GF_FIRE, dir, damroll(get_skill_scale(SKILL_FIRE, 30), 15), 3)
- end
- end,
- }
-
- if t[cave(y, x).feat] then
- t[cave(y, x).feat]()
-
- if magik(100 - level) == TRUE then
- if cave(y, x).feat == FEAT_FLOWER then
- cave_set_feat(y, x, FEAT_GRASS)
- else
- cave_set_feat(y, x, FEAT_FLOOR)
- end
- msg_print("The area is drained.")
- end
- elseif not silent then
- msg_print("You cannot channel this area.")
- end
-end
-
CHANNEL_ELEMENTS = add_spell
{
["name"] = "Channel Elements",
@@ -223,7 +45,7 @@ CHANNEL_ELEMENTS = add_spell
["blind"] = FALSE,
["random"] = 0,
["spell"] = function()
- channel_the_elements(player.py, player.px, get_level(CHANNEL_ELEMENTS), nil)
+ channel_the_elements(player.py, player.px, get_level(CHANNEL_ELEMENTS))
return TRUE
end,
["info"] = function()
@@ -364,76 +186,6 @@ VAPORIZE = add_spell
}
}
-geomancy_can_tunnel =
-{
- [FEAT_WALL_EXTRA] = TRUE,
- [FEAT_WALL_OUTER] = TRUE,
- [FEAT_WALL_INNER] = TRUE,
- [FEAT_WALL_SOLID] = TRUE,
-
- [FEAT_MAGMA] = TRUE,
- [FEAT_QUARTZ] = TRUE,
- [FEAT_MAGMA_H] = TRUE,
- [FEAT_QUARTZ_H] = TRUE,
- [FEAT_MAGMA_K] = TRUE,
- [FEAT_QUARTZ_K] = TRUE,
-
- [FEAT_TREES] = TRUE,
- [FEAT_DEAD_TREE] = TRUE,
-
- [FEAT_SANDWALL] = TRUE,
- [FEAT_SANDWALL_H] = TRUE,
- [FEAT_SANDWALL_K] = TRUE,
-
- [FEAT_ICE_WALL] = TRUE,
-}
-
--- Dig & sprew
-function geomancy_dig(oy, ox, dir, length)
- local dy, dx = explode_dir(dir)
- local y = dy + oy
- local x = dx + ox
-
- for i = 1, length do
- local c_ptr = cave(y, x)
- local ox = x - dx
- local oy = y - dy
-
- -- stop at the end of tunnelable things
- if not geomancy_can_tunnel[c_ptr.feat] then break end
-
- if geomancy_can_tunnel[cave(y - 1, x - 1).feat] then geomancy_random_wall(y - 1, x - 1) end
- if geomancy_can_tunnel[cave(y - 1, x).feat] then geomancy_random_wall(y - 1, x) end
- if geomancy_can_tunnel[cave(y - 1, x + 1).feat] then geomancy_random_wall(y - 1, x + 1) end
-
- if geomancy_can_tunnel[cave(y, x - 1).feat] then geomancy_random_wall(y, x - 1) end
- if geomancy_can_tunnel[cave(y, x + 1).feat] then geomancy_random_wall(y, x + 1) end
-
- if geomancy_can_tunnel[cave(y + 1, x - 1).feat] then geomancy_random_wall(y + 1, x - 1) end
- if geomancy_can_tunnel[cave(y + 1, x).feat] then geomancy_random_wall(y + 1, x) end
- if geomancy_can_tunnel[cave(y + 1, x + 1).feat] then geomancy_random_wall(y + 1, x + 1) end
-
- y = y + dy
- x = x + dx
- end
-
- y = y - dy
- x = x - dx
- while (y ~= oy) or (x ~= ox) do
- geomancy_random_floor(y, x, TRUE)
-
- -- Should we branch ?
- if magik(20) == TRUE then
- local rot = 1
- if magik(50) == TRUE then rot = -1 end
- geomancy_dig(y, x, rotate_dir(dir, rot), length / 3)
- end
-
- y = y - dy
- x = x - dx
- end
-end
-
GEOLYSIS = add_spell
{
["name"] = "Geolysis",
@@ -473,7 +225,7 @@ add_hooks
{
[HOOK_MOVED] = function(oy, ox)
if player.dripping_tread > 0 then
- geomancy_random_floor(oy, ox)
+ geomancy_random_floor(oy, ox, FALSE)
player.dripping_tread = player.dripping_tread - 1
if player.dripping_tread == 0 then
msg_print("You stop dripping raw elemental energies.")