summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-13 22:05:41 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-14 11:02:52 +0200
commitcf9afa2063fa9123f8653e76d17404775a34313d (patch)
treec91ff1882cd27c8ea6828deb794eef5838a16561
parent1e3740888ab90fe2e0ef04b1ae4e3b85c4b5b9b8 (diff)
Lua: Move "Fire" spell functions to C
-rw-r--r--lib/mods/theme/scpt/s_fire.lua113
-rw-r--r--lib/scpt/s_fire.lua113
-rw-r--r--src/externs.h17
-rw-r--r--src/spells.pkg20
-rw-r--r--src/spells3.c190
5 files changed, 247 insertions, 206 deletions
diff --git a/lib/mods/theme/scpt/s_fire.lua b/lib/mods/theme/scpt/s_fire.lua
index dbbf7604..37a75032 100644
--- a/lib/mods/theme/scpt/s_fire.lua
+++ b/lib/mods/theme/scpt/s_fire.lua
@@ -19,27 +19,8 @@ GLOBELIGHT = add_spell
},
},
["inertia"] = { 1, 40 },
- ["spell"] = function()
- local obvious
- if get_level(GLOBELIGHT, 50) >= 3 then
- obvious = lite_area(10, 4)
- else
- lite_room(player.py, player.px)
- obvious = TRUE
- end
- if get_level(GLOBELIGHT, 50) >= 15 then
- obvious = is_obvious(fire_ball(GF_LITE, 0, 10 + get_level(GLOBELIGHT, 100), 5 + get_level(GLOBELIGHT, 6)), obvious)
- player.update = bor(player.update, PU_VIEW)
- end
- return obvious
- end,
- ["info"] = function()
- if get_level(GLOBELIGHT, 50) >= 15 then
- return "dam "..(10 + get_level(GLOBELIGHT, 100)).." rad "..(5 + get_level(GLOBELIGHT, 6))
- else
- return ""
- end
- end,
+ ["spell"] = function() return fire_globe_of_light() end,
+ ["info"] = function() return fire_globe_of_light_info() end,
["desc"] = {
"Creates a globe of pure light",
"At level 3 it starts damaging monsters",
@@ -65,20 +46,8 @@ FIREFLASH = add_spell
["max_level"] = { 15, 35 },
},
},
- ["spell"] = function()
- local ret, dir, type
- if (get_level(FIREFLASH, 50) >= 20) then
- type = GF_HOLY_FIRE
- else
- type = GF_FIRE
- end
- ret, dir = get_aim_dir()
- if ret == FALSE then return end
- return fire_ball(type, dir, 20 + get_level(FIREFLASH, 500), 2 + get_level(FIREFLASH, 5))
- end,
- ["info"] = function()
- return "dam "..(20 + get_level(FIREFLASH, 500)).." rad "..(2 + get_level(FIREFLASH, 5))
- end,
+ ["spell"] = function() return fire_fireflash() end,
+ ["info"] = function() return fire_fireflash_info() end,
["desc"] = {
"Conjures a ball of fire to burn your foes to ashes",
"At level 20 it turns into a ball of holy fire"
@@ -104,18 +73,8 @@ FIERYAURA = add_spell
},
},
["inertia"] = { 2, 15 },
- ["spell"] = function()
- local type
- if (get_level(FIERYAURA, 50) >= 8) then
- type = SHIELD_GREAT_FIRE
- else
- type = SHIELD_FIRE
- end
- return set_shield(randint(20) + 10 + get_level(FIERYAURA, 70), 10, type, 5 + get_level(FIERYAURA, 10), 5 + get_level(FIERYAURA, 7))
- end,
- ["info"] = function()
- return "dam "..(5 + get_level(FIERYAURA, 15)).."d"..(5 + get_level(FIERYAURA, 7)).." dur "..(10 + get_level(FIERYAURA, 70)).."+d20"
- end,
+ ["spell"] = function() return fire_fiery_shield() end,
+ ["info"] = function() return fire_fiery_shield_info() end,
["desc"] = {
"Creates a shield of fierce flames around you",
"At level 8 it turns into a greater kind of flame that can not be resisted"
@@ -140,21 +99,8 @@ FIREWALL = add_spell
["max_level"] = { 5, 40 },
},
},
- ["spell"] = function()
- local ret, dir, type
- if (get_level(FIREWALL, 50) >= 6) then
- type = GF_HELL_FIRE
- else
- type = GF_FIRE
- end
- ret, dir = get_aim_dir()
- if ret == FALSE then return end
- fire_wall(type, dir, 40 + get_level(FIREWALL, 150), 10 + get_level(FIREWALL, 14))
- return TRUE
- end,
- ["info"] = function()
- return "dam "..(40 + get_level(FIREWALL, 150)).." dur "..(10 + get_level(FIREWALL, 14))
- end,
+ ["spell"] = function() return fire_firewall() end,
+ ["info"] = function() return fire_firewall_info() end,
["desc"] = {
"Creates a fiery wall to incinerate monsters stupid enough to attack you",
"At level 6 it turns into a wall of hell fire"
@@ -169,47 +115,8 @@ FIREGOLEM = add_spell
["mana"] = 16,
["mana_max"] = 70,
["fail"] = 40,
- ["spell"] = function()
- local m_idx, y, x, ret, item
-
- -- Can we reconnect ?
- if do_control_reconnect() == TRUE then
- msg_print("Control re-established.")
- return
- end
-
- ret, item = get_item("Which light source do you want to use to create the golem?",
- "You have no light source for the golem",
- bor(USE_INVEN, USE_EQUIP),
- function (obj)
- if (obj.tval == TV_LITE) and ((obj.sval == SV_LITE_TORCH) or (obj.sval == SV_LITE_LANTERN)) then
- return TRUE
- end
- return FALSE
- end
- )
- if ret == FALSE then return TRUE end
- inven_item_increase(item, -1)
- inven_item_describe(item)
- inven_item_optimize(item)
-
- -- Summon it
- m_allow_special[1043 + 1] = TRUE
- y, x = find_position(player.py, player.px)
- m_idx = place_monster_one(y, x, 1043, 0, FALSE, MSTATUS_FRIEND)
- m_allow_special[1043 + 1] = FALSE
-
- -- level it
- if m_idx ~= 0 then
- monster_set_level(m_idx, 7 + get_level(FIREGOLEM, 70))
- player.control = m_idx
- monster(m_idx).mflag = bor(monster(m_idx).mflag, MFLAG_CONTROL)
- end
- return TRUE
- end,
- ["info"] = function()
- return "golem level "..(7 + get_level(FIREGOLEM, 70))
- end,
+ ["spell"] = function() return fire_golem() end,
+ ["info"] = function() return fire_golem_info() end,
["desc"] = {
"Creates a fiery golem and controls it",
"During the control the available keylist is:",
diff --git a/lib/scpt/s_fire.lua b/lib/scpt/s_fire.lua
index dbbf7604..37a75032 100644
--- a/lib/scpt/s_fire.lua
+++ b/lib/scpt/s_fire.lua
@@ -19,27 +19,8 @@ GLOBELIGHT = add_spell
},
},
["inertia"] = { 1, 40 },
- ["spell"] = function()
- local obvious
- if get_level(GLOBELIGHT, 50) >= 3 then
- obvious = lite_area(10, 4)
- else
- lite_room(player.py, player.px)
- obvious = TRUE
- end
- if get_level(GLOBELIGHT, 50) >= 15 then
- obvious = is_obvious(fire_ball(GF_LITE, 0, 10 + get_level(GLOBELIGHT, 100), 5 + get_level(GLOBELIGHT, 6)), obvious)
- player.update = bor(player.update, PU_VIEW)
- end
- return obvious
- end,
- ["info"] = function()
- if get_level(GLOBELIGHT, 50) >= 15 then
- return "dam "..(10 + get_level(GLOBELIGHT, 100)).." rad "..(5 + get_level(GLOBELIGHT, 6))
- else
- return ""
- end
- end,
+ ["spell"] = function() return fire_globe_of_light() end,
+ ["info"] = function() return fire_globe_of_light_info() end,
["desc"] = {
"Creates a globe of pure light",
"At level 3 it starts damaging monsters",
@@ -65,20 +46,8 @@ FIREFLASH = add_spell
["max_level"] = { 15, 35 },
},
},
- ["spell"] = function()
- local ret, dir, type
- if (get_level(FIREFLASH, 50) >= 20) then
- type = GF_HOLY_FIRE
- else
- type = GF_FIRE
- end
- ret, dir = get_aim_dir()
- if ret == FALSE then return end
- return fire_ball(type, dir, 20 + get_level(FIREFLASH, 500), 2 + get_level(FIREFLASH, 5))
- end,
- ["info"] = function()
- return "dam "..(20 + get_level(FIREFLASH, 500)).." rad "..(2 + get_level(FIREFLASH, 5))
- end,
+ ["spell"] = function() return fire_fireflash() end,
+ ["info"] = function() return fire_fireflash_info() end,
["desc"] = {
"Conjures a ball of fire to burn your foes to ashes",
"At level 20 it turns into a ball of holy fire"
@@ -104,18 +73,8 @@ FIERYAURA = add_spell
},
},
["inertia"] = { 2, 15 },
- ["spell"] = function()
- local type
- if (get_level(FIERYAURA, 50) >= 8) then
- type = SHIELD_GREAT_FIRE
- else
- type = SHIELD_FIRE
- end
- return set_shield(randint(20) + 10 + get_level(FIERYAURA, 70), 10, type, 5 + get_level(FIERYAURA, 10), 5 + get_level(FIERYAURA, 7))
- end,
- ["info"] = function()
- return "dam "..(5 + get_level(FIERYAURA, 15)).."d"..(5 + get_level(FIERYAURA, 7)).." dur "..(10 + get_level(FIERYAURA, 70)).."+d20"
- end,
+ ["spell"] = function() return fire_fiery_shield() end,
+ ["info"] = function() return fire_fiery_shield_info() end,
["desc"] = {
"Creates a shield of fierce flames around you",
"At level 8 it turns into a greater kind of flame that can not be resisted"
@@ -140,21 +99,8 @@ FIREWALL = add_spell
["max_level"] = { 5, 40 },
},
},
- ["spell"] = function()
- local ret, dir, type
- if (get_level(FIREWALL, 50) >= 6) then
- type = GF_HELL_FIRE
- else
- type = GF_FIRE
- end
- ret, dir = get_aim_dir()
- if ret == FALSE then return end
- fire_wall(type, dir, 40 + get_level(FIREWALL, 150), 10 + get_level(FIREWALL, 14))
- return TRUE
- end,
- ["info"] = function()
- return "dam "..(40 + get_level(FIREWALL, 150)).." dur "..(10 + get_level(FIREWALL, 14))
- end,
+ ["spell"] = function() return fire_firewall() end,
+ ["info"] = function() return fire_firewall_info() end,
["desc"] = {
"Creates a fiery wall to incinerate monsters stupid enough to attack you",
"At level 6 it turns into a wall of hell fire"
@@ -169,47 +115,8 @@ FIREGOLEM = add_spell
["mana"] = 16,
["mana_max"] = 70,
["fail"] = 40,
- ["spell"] = function()
- local m_idx, y, x, ret, item
-
- -- Can we reconnect ?
- if do_control_reconnect() == TRUE then
- msg_print("Control re-established.")
- return
- end
-
- ret, item = get_item("Which light source do you want to use to create the golem?",
- "You have no light source for the golem",
- bor(USE_INVEN, USE_EQUIP),
- function (obj)
- if (obj.tval == TV_LITE) and ((obj.sval == SV_LITE_TORCH) or (obj.sval == SV_LITE_LANTERN)) then
- return TRUE
- end
- return FALSE
- end
- )
- if ret == FALSE then return TRUE end
- inven_item_increase(item, -1)
- inven_item_describe(item)
- inven_item_optimize(item)
-
- -- Summon it
- m_allow_special[1043 + 1] = TRUE
- y, x = find_position(player.py, player.px)
- m_idx = place_monster_one(y, x, 1043, 0, FALSE, MSTATUS_FRIEND)
- m_allow_special[1043 + 1] = FALSE
-
- -- level it
- if m_idx ~= 0 then
- monster_set_level(m_idx, 7 + get_level(FIREGOLEM, 70))
- player.control = m_idx
- monster(m_idx).mflag = bor(monster(m_idx).mflag, MFLAG_CONTROL)
- end
- return TRUE
- end,
- ["info"] = function()
- return "golem level "..(7 + get_level(FIREGOLEM, 70))
- end,
+ ["spell"] = function() return fire_golem() end,
+ ["info"] = function() return fire_golem_info() end,
["desc"] = {
"Creates a fiery golem and controls it",
"During the control the available keylist is:",
diff --git a/src/externs.h b/src/externs.h
index abf9473b..fd156286 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1521,6 +1521,23 @@ char *eru_know_the_music_info();
bool_ *eru_lay_of_protection();
char *eru_lay_of_protection_info();
+extern s32b GLOBELIGHT;
+extern s32b FIREFLASH;
+extern s32b FIERYAURA;
+extern s32b FIREWALL;
+extern s32b FIREGOLEM;
+
+bool_ *fire_globe_of_light();
+char *fire_globe_of_light_info();
+bool_ *fire_fireflash();
+char *fire_fireflash_info();
+bool_ *fire_fiery_shield();
+char *fire_fiery_shield_info();
+bool_ *fire_firewall();
+char *fire_firewall_info();
+bool_ *fire_golem();
+char *fire_golem_info();
+
/* randart.c */
extern int get_activation_power(void);
extern void build_prob(cptr learn);
diff --git a/src/spells.pkg b/src/spells.pkg
index d7206b41..260cdf50 100644
--- a/src/spells.pkg
+++ b/src/spells.pkg
@@ -2559,3 +2559,23 @@ bool_ *eru_know_the_music();
char *eru_know_the_music_info();
bool_ *eru_lay_of_protection();
char *eru_lay_of_protection_info();
+
+/*
+ * Fire
+ */
+extern s32b GLOBELIGHT;
+extern s32b FIREFLASH;
+extern s32b FIERYAURA;
+extern s32b FIREWALL;
+extern s32b FIREGOLEM;
+
+bool_ *fire_globe_of_light();
+char *fire_globe_of_light_info();
+bool_ *fire_fireflash();
+char *fire_fireflash_info();
+bool_ *fire_fiery_shield();
+char *fire_fiery_shield_info();
+bool_ *fire_firewall();
+char *fire_firewall_info();
+bool_ *fire_golem();
+char *fire_golem_info();
diff --git a/src/spells3.c b/src/spells3.c
index 3faefc97..7c8173ea 100644
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -42,6 +42,12 @@ s32b ERU_LISTEN;
s32b ERU_UNDERSTAND;
s32b ERU_PROT;
+s32b GLOBELIGHT;
+s32b FIREFLASH;
+s32b FIERYAURA;
+s32b FIREWALL;
+s32b FIREGOLEM;
+
/* FIXME: Hackish workaround while we're still tied to Lua. This lets
us return Lua's "nil" and a non-nil value (which is all the s_aux.lua
cares about). */
@@ -1097,3 +1103,187 @@ char *eru_lay_of_protection_info()
(1 + get_level(ERU_PROT, 2, 0)));
return buf;
}
+
+bool_ *fire_globe_of_light()
+{
+ if (get_level_s(GLOBELIGHT, 50) >= 3)
+ {
+ lite_area(10, 4);
+ }
+ else
+ {
+ lite_room(p_ptr->py, p_ptr->px);
+ }
+
+ if (get_level_s(GLOBELIGHT, 50) >= 15)
+ {
+ fire_ball(GF_LITE,
+ 0,
+ 10 + get_level_s(GLOBELIGHT, 100),
+ 5 + get_level_s(GLOBELIGHT, 6));
+ p_ptr->update |= PU_VIEW;
+ }
+ return CAST;
+}
+
+char *fire_globe_of_light_info()
+{
+ static char buf[128];
+
+ if (get_level_s(GLOBELIGHT, 50) >= 15)
+ {
+ sprintf(buf, "dam %d rad %d",
+ (10 + get_level_s(GLOBELIGHT, 100)),
+ (5 + get_level_s(GLOBELIGHT, 6)));
+ }
+ else
+ {
+ buf[0] = '\0';
+ }
+
+ return buf;
+}
+
+bool_ *fire_fireflash()
+{
+ int dir;
+ int type = GF_FIRE;
+
+ if (get_level_s(FIREFLASH, 50) >= 20)
+ {
+ type = GF_HOLY_FIRE;
+ }
+
+ if (!get_aim_dir(&dir))
+ {
+ return NO_CAST;
+ }
+
+ fire_ball(type, dir,
+ 20 + get_level_s(FIREFLASH, 500),
+ 2 + get_level_s(FIREFLASH, 5));
+ return CAST;
+}
+
+char *fire_fireflash_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "dam %d rad %d",
+ (20 + get_level_s(FIREFLASH, 500)),
+ (2 + get_level_s(FIREFLASH, 5)));
+ return buf;
+}
+
+bool_ *fire_fiery_shield()
+{
+ int type = SHIELD_FIRE;
+ if (get_level_s(FIERYAURA, 50) >= 8)
+ {
+ type = SHIELD_GREAT_FIRE;
+ }
+
+ set_shield(randint(20) + 10 + get_level_s(FIERYAURA, 70),
+ 10,
+ type,
+ 5 + get_level_s(FIERYAURA, 10),
+ 5 + get_level_s(FIERYAURA, 7));
+ return CAST;
+}
+
+char *fire_fiery_shield_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "dam %dd%d dur %d+d20",
+ (5 + get_level_s(FIERYAURA, 15)),
+ (5 + get_level_s(FIERYAURA, 7)),
+ (10 + get_level_s(FIERYAURA, 70)));
+ return buf;
+}
+
+bool_ *fire_firewall()
+{
+ int dir;
+ int type = GF_FIRE;
+ if (get_level_s(FIREWALL, 50) >= 6)
+ {
+ type = GF_HELL_FIRE;
+ }
+
+ if (!get_aim_dir(&dir))
+ {
+ return NO_CAST;
+ }
+
+ fire_wall(type, dir,
+ 40 + get_level_s(FIREWALL, 150),
+ 10 + get_level_s(FIREWALL, 14));
+ return CAST;
+}
+
+char *fire_firewall_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "dam %d dur %d",
+ (40 + get_level_s(FIREWALL, 150)),
+ (10 + get_level_s(FIREWALL, 14)));
+ return buf;
+}
+
+bool_ item_tester_hook_fire_golem(object_type *o_ptr)
+{
+ return ((o_ptr->tval == TV_LITE) &&
+ ((o_ptr->sval == SV_LITE_TORCH) ||
+ (o_ptr->sval == SV_LITE_LANTERN)));
+}
+
+bool_ *fire_golem()
+{
+ int item, x, y, m_idx;
+
+ /* Can we reconnect ? */
+ if (do_control_reconnect())
+ {
+ msg_print("Control re-established.");
+ return NO_CAST;
+ }
+
+ item_tester_hook = item_tester_hook_fire_golem;
+ if (!get_item(&item,
+ "Which light source do you want to use to create the golem?",
+ "You have no light source for the golem",
+ USE_INVEN | USE_EQUIP))
+ {
+ return NO_CAST;
+ }
+
+ /* Destroy the source object */
+ inc_stack_size(item, -1);
+
+ /* Summon it */
+ m_allow_special[1043 + 1] = TRUE;
+ find_position(p_ptr->py, p_ptr->px, &y, &x);
+ m_idx = place_monster_one(y, x, 1043, 0, FALSE, MSTATUS_FRIEND);
+ m_allow_special[1043 + 1] = FALSE;
+
+ /* level it */
+ if (m_idx != 0)
+ {
+ monster_set_level(m_idx, 7 + get_level_s(FIREGOLEM, 70));
+ p_ptr->control = m_idx;
+ m_list[m_idx].mflag |= MFLAG_CONTROL;
+ }
+
+ return CAST;
+}
+
+char *fire_golem_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "golem level %d",
+ (7 + get_level_s(FIREGOLEM, 70)));
+ return buf;
+}