From ca30fc5a6f92d75ee1c7eec2dd863776fe7afb5f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 16 Apr 2012 20:20:43 +0200 Subject: Lua: Move "Geomancy" spell functions to C --- lib/mods/theme/scpt/s_geom.lua | 235 +++-------------------------------------- 1 file changed, 16 insertions(+), 219 deletions(-) (limited to 'lib/mods/theme') diff --git a/lib/mods/theme/scpt/s_geom.lua b/lib/mods/theme/scpt/s_geom.lua index d152bc25..d4ce4437 100644 --- a/lib/mods/theme/scpt/s_geom.lua +++ b/lib/mods/theme/scpt/s_geom.lua @@ -11,20 +11,8 @@ CALL_THE_ELEMENTS = add_spell -- Unnafected by blindness ["blind"] = FALSE, ["random"] = 0, - ["spell"] = function() - local ret, dir = 0, 0 - - if get_level(CALL_THE_ELEMENTS) >= 17 then - ret, dir = get_aim_dir() - if ret == FALSE then return end - end - - fire_ball(GF_ELEMENTAL_GROWTH, dir, 1, 1 + get_level(CALL_THE_ELEMENTS, 5, 0)) - return TRUE - end, - ["info"] = function() - return "rad "..(1 + get_level(CALL_THE_ELEMENTS, 5, 0)) - end, + ["spell"] = function() return geomancy_call_the_elements() end, + ["info"] = function() return geomancy_call_the_elements_info() end, ["desc"] = { "Randomly creates various elements around you", "Each type of element chance is controlled by your level", @@ -44,13 +32,8 @@ CHANNEL_ELEMENTS = add_spell -- Unnafected by blindness ["blind"] = FALSE, ["random"] = 0, - ["spell"] = function() - channel_the_elements(player.py, player.px, get_level(CHANNEL_ELEMENTS)) - return TRUE - end, - ["info"] = function() - return "" - end, + ["spell"] = function() return geomancy_channel_elements() end, + ["info"] = function() return geomancy_channel_elements_info() end, ["desc"] = { "Draws on the caster's immediate environs to form an attack or other effect.", "Grass/Flower heals.", @@ -79,50 +62,8 @@ ELEMENTAL_WAVE = add_spell -- Unnafected by blindness ["blind"] = FALSE, ["random"] = 0, - ["spell"] = function() - local ret, dir = get_rep_dir() - if ret == FALSE then return end - - local y, x = explode_dir(dir) - y = y + player.py - x = x + player.px - - local t = - { - -- Earth stuff - [FEAT_GRASS] = { GF_POIS, GF_POIS, 10 + get_skill_scale(SKILL_EARTH, 200) }, - [FEAT_FLOWER] = { GF_POIS, GF_POIS, 10 + get_skill_scale(SKILL_EARTH, 300) }, - -- cannot turn chasm into a wave - - -- Water stuff - [FEAT_SHAL_WATER] = { GF_WATER, GF_WATER, 10 + get_skill_scale(SKILL_WATER, 200) }, - [FEAT_DEEP_WATER] = { GF_WATER, GF_WATER, 10 + get_skill_scale(SKILL_WATER, 300) }, - [FEAT_ICE] = { GF_ICE, GF_ICE, 10 + get_skill_scale(SKILL_WATER, 200) }, - - -- Fire stuff - [FEAT_SAND] = { GF_LITE, GF_LITE, 10 + get_skill_scale(SKILL_FIRE, 400) }, - [FEAT_SHAL_LAVA] = { GF_FIRE, GF_HOLY_FIRE, 10 + get_skill_scale(SKILL_FIRE, 200) }, - [FEAT_DEEP_LAVA] = { GF_FIRE, GF_HOLY_FIRE, 10 + get_skill_scale(SKILL_FIRE, 300) }, - } - - - local effect = t[cave(y, x).feat] - if not effect then - msg_print("You cannot channel this area.") - else - local typ = effect[1] - if get_level(ELEMENTAL_WAVE) >= 20 then typ = effect[2] end - - cave_set_feat(y, x, FEAT_FLOOR) - - fire_wave(typ, 0, effect[3], 0, 6 + get_level(ELEMENTAL_WAVE, 20), EFF_WAVE + EFF_LAST + getglobal("EFF_DIR"..dir)) - end - - return TRUE - end, - ["info"] = function() - return "" - end, + ["spell"] = function() return geomancy_elemental_wave() end, + ["info"] = function() return geomancy_elemental_wave_info() end, ["desc"] = { "Draws on an adjacent special square to project a slow-moving", "wave of that element in that direction", @@ -145,42 +86,8 @@ VAPORIZE = add_spell ["depend"] = function() if get_skill(SKILL_AIR) >= 4 then return TRUE end end, - ["spell"] = function() - local t = - { - -- Earth stuff - [FEAT_GRASS] = { GF_POIS, GF_POIS, 5 + get_skill_scale(SKILL_EARTH, 100) }, - [FEAT_FLOWER] = { GF_POIS, GF_POIS, 5 + get_skill_scale(SKILL_EARTH, 150) }, - [FEAT_DARK_PIT] = { GF_DARK, GF_DARK, 5 + get_skill_scale(SKILL_EARTH, 200) }, - - -- Water stuff - [FEAT_SHAL_WATER] = { GF_WATER, GF_WATER, 5 + get_skill_scale(SKILL_WATER, 100) }, - [FEAT_DEEP_WATER] = { GF_WATER, GF_WATER, 5 + get_skill_scale(SKILL_WATER, 150) }, - [FEAT_ICE] = { GF_ICE, GF_ICE, 5 + get_skill_scale(SKILL_WATER, 100) }, - - -- Fire stuff - [FEAT_SAND] = { GF_LITE, GF_LITE, 5 + get_skill_scale(SKILL_FIRE, 200) }, - [FEAT_SHAL_LAVA] = { GF_FIRE, GF_HOLY_FIRE, 5 + get_skill_scale(SKILL_FIRE, 100) }, - [FEAT_DEEP_LAVA] = { GF_FIRE, GF_HOLY_FIRE, 5 + get_skill_scale(SKILL_FIRE, 150) }, - } - - local effect = t[cave(player.py, player.px).feat] - if not effect then - msg_print("You cannot channel this area.") - else - local typ = effect[1] - if get_level(VAPORIZE) >= 20 then typ = effect[2] end - - cave_set_feat(player.py, player.px, FEAT_FLOOR) - - fire_cloud(typ, 0, effect[3], 1 + get_level(VAPORIZE, 4), 10 + get_level(VAPORIZE, 20)) - end - - return TRUE - end, - ["info"] = function() - return "rad "..(1 + get_level(VAPORIZE, 4)).." dur "..(10 + get_level(VAPORIZE, 20)) - end, + ["spell"] = function() return geomancy_vaporize() end, + ["info"] = function() return geomancy_vaporize_info() end, ["desc"] = { "Draws upon your immediate environs to form a cloud of damaging vapors", } @@ -201,38 +108,14 @@ GEOLYSIS = add_spell ["depend"] = function() if get_skill(SKILL_EARTH) >= 7 then return TRUE end end, - ["spell"] = function() - local ret, dir = get_rep_dir() - if ret == FALSE then return end - - msg_print("Elements recombine before you, laying down an open path.") - geomancy_dig(player.py, player.px, dir, 5 + get_level(GEOLYSIS, 12)) - - return TRUE - end, - ["info"] = function() - return "length "..(5 + get_level(GEOLYSIS, 12)) - end, + ["spell"] = function() return geomancy_geolysis() end, + ["info"] = function() return geomancy_geolysis_info() end, ["desc"] = { "Burrows deeply and slightly at random into a wall,", "leaving behind tailings of various different sorts of walls in the passage.", } } -player.dripping_tread = 0 -add_loadsave("player.dripping_tread", 0) -add_hooks -{ - [HOOK_MOVED] = function(oy, ox) - if player.dripping_tread > 0 then - 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.") - end - end - end -} DRIPPING_TREAD = add_spell { ["name"] = "Dripping Tread", @@ -248,19 +131,8 @@ DRIPPING_TREAD = add_spell ["depend"] = function() if get_skill(SKILL_WATER) >= 10 then return TRUE end end, - ["spell"] = function() - if player.dripping_tread == 0 then - player.dripping_tread = randint(15) + 10 + get_level(DRIPPING_TREAD) - msg_print("You start dripping raw elemental energies.") - else - player.dripping_tread = 0 - msg_print("You stop dripping raw elemental energies.") - end - return TRUE - end, - ["info"] = function() - return "dur "..(10 + get_level(DRIPPING_TREAD)).."+d15 movs" - end, + ["spell"] = function() return geomancy_dripping_tread() end, + ["info"] = function() return geomancy_dripping_tread_info() end, ["desc"] = { "Causes you to leave random elemental forms behind as you walk", } @@ -281,20 +153,8 @@ GROW_BARRIER = add_spell ["depend"] = function() if get_skill(SKILL_EARTH) >= 12 then return TRUE end end, - ["spell"] = function() - local ret, dir = 0, 0 - - if get_level(GROW_BARRIER) >= 20 then - ret, dir = get_aim_dir() - if ret == FALSE then return end - end - - fire_ball(GF_ELEMENTAL_WALL, dir, 1, 1) - return TRUE - end, - ["info"] = function() - return "" - end, + ["spell"] = function() return geomancy_grow_barrier() end, + ["info"] = function() return geomancy_grow_barrier_info() end, ["desc"] = { "Creates impassable terrain (walls, trees, etc.) around you.", "At level 20 it can be projected around another area.", @@ -312,71 +172,8 @@ ELEMENTAL_MINION = add_spell -- Unnafected by blindness ["random"] = 0, -- Must have at least 12 Earth - ["spell"] = function() - local ret, dir = 0, 0 - - ret, dir = get_rep_dir() - if ret == FALSE then return end - - local t = - { - [FEAT_WALL_EXTRA] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_WALL_OUTER] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_WALL_INNER] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_WALL_SOLID] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_MAGMA] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_QUARTZ] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_MAGMA_H] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_QUARTZ_H] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_MAGMA_K] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - [FEAT_QUARTZ_K] = { SKILL_EARTH, { "Earth elemental", "Xorn", "Xaren" } }, - - [FEAT_DARK_PIT] = { SKILL_AIR, { "Air elemental", "Ancient blue dragon", "Great Storm Wyrm", "Sky Drake" } }, - - [FEAT_SANDWALL] = { SKILL_FIRE, { "Fire elemental", "Ancient red dragon" } }, - [FEAT_SANDWALL_H] = { SKILL_FIRE, { "Fire elemental", "Ancient red dragon" } }, - [FEAT_SANDWALL_K] = { SKILL_FIRE, { "Fire elemental", "Ancient red dragon" } }, - [FEAT_SHAL_LAVA] = { SKILL_FIRE, { "Fire elemental", "Ancient red dragon" } }, - [FEAT_DEEP_LAVA] = { SKILL_FIRE, { "Fire elemental", "Ancient red dragon" } }, - - [FEAT_ICE_WALL] = { SKILL_WATER, { "Water elemental", "Water troll", "Water demon" } }, - [FEAT_SHAL_WATER] = { SKILL_WATER, { "Water elemental", "Water troll", "Water demon" } }, - [FEAT_DEEP_WATER] = { SKILL_WATER, { "Water elemental", "Water troll", "Water demon" } }, - } - - local y, x = explode_dir(dir) - y = y + player.py - x = x + player.px - - local effect = t[cave(y, x).feat] - if not effect then - msg_print("You cannot summon from this area.") - else - local skill = effect[1] - local types = effect[2] - - local max = get_skill_scale(skill, getn(types)) - if max == 0 then max = 1 end - - local r_idx = test_monster_name(types[rand_range(1, max)]) - - -- Summon it - local my, mx = find_position(y, x) - local m_idx = place_monster_one(my, mx, r_idx, 0, FALSE, MSTATUS_FRIEND) - - -- level it - if m_idx ~= 0 then - monster_set_level(m_idx, 10 + get_level(ELEMENTAL_MINION, 120)) - end - - cave_set_feat(y, x, FEAT_FLOOR) - end - - return TRUE - end, - ["info"] = function() - return "min level "..(10 + get_level(ELEMENTAL_MINION, 120)) - end, + ["spell"] = function() return geomancy_elemental_minion() end, + ["info"] = function() return geomancy_elemental_minion_info() end, ["desc"] = { "Summons a minion from a nearby element.", "Walls can summon Earth elmentals, Xorns and Xarens", -- cgit v1.2.3