summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-05-10 21:07:52 +0200
committerBardur Arantsson <bardur@scientician.net>2012-05-10 21:30:10 +0200
commit226d3565889f551c00d4fccf184c98edb12c07c7 (patch)
treea8c76716fb1f2ca9a4b5aa8c6a210013050e5461
parent9c849217091714882ab73d03c6f11efb7f610924 (diff)
Lua: Move "Tulkas" spell functions to C
-rw-r--r--lib/mods/theme/scpt/s_tulkas.lua34
-rw-r--r--lib/scpt/s_tulkas.lua34
-rw-r--r--src/externs.h11
-rw-r--r--src/spells.pkg11
-rw-r--r--src/spells3.c59
5 files changed, 93 insertions, 56 deletions
diff --git a/lib/mods/theme/scpt/s_tulkas.lua b/lib/mods/theme/scpt/s_tulkas.lua
index 4afa8082..6659aee9 100644
--- a/lib/mods/theme/scpt/s_tulkas.lua
+++ b/lib/mods/theme/scpt/s_tulkas.lua
@@ -12,19 +12,8 @@ TULKAS_AIM = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local dur = get_level(TULKAS_AIM, 50) + randint(10)
- local obvious
-
- obvious = set_strike(dur)
- if get_level(TULKAS_AIM) >= 20 then
- obvious = is_obvious(set_tim_deadly(dur), obvious)
- end
- return obvious
- end,
- ["info"] = function()
- return "dur "..(get_level(TULKAS_AIM, 50)).."+d10"
- end,
+ ["spell"] = function() return tulkas_divine_aim() end,
+ ["info"] = function() return tulkas_divine_aim_info() end,
["desc"] = {
"It makes you more accurate in combat",
"At level 20 all your blows are critical hits",
@@ -43,15 +32,8 @@ TULKAS_WAVE = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- return fire_bolt(GF_ATTACK, dir, get_level(TULKAS_WAVE, player.num_blow))
- end,
- ["info"] = function()
- return "blows "..(get_level(TULKAS_WAVE, player.num_blow))
- end,
+ ["spell"] = function() return tulkas_wave_of_power() end,
+ ["info"] = function() return tulkas_wave_of_power_info() end,
["desc"] = {
"It allows you to project a number of melee blows across a distance",
}
@@ -69,12 +51,8 @@ TULKAS_SPIN = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- return fire_ball(GF_ATTACK, 0, 1, 1)
- end,
- ["info"] = function()
- return ""
- end,
+ ["spell"] = function() return tulkas_whirlwind() end,
+ ["info"] = function() return tulkas_whirlwind_info() end,
["desc"] = {
"It allows you to spin around and hit all monsters nearby",
}
diff --git a/lib/scpt/s_tulkas.lua b/lib/scpt/s_tulkas.lua
index 4afa8082..6659aee9 100644
--- a/lib/scpt/s_tulkas.lua
+++ b/lib/scpt/s_tulkas.lua
@@ -12,19 +12,8 @@ TULKAS_AIM = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local dur = get_level(TULKAS_AIM, 50) + randint(10)
- local obvious
-
- obvious = set_strike(dur)
- if get_level(TULKAS_AIM) >= 20 then
- obvious = is_obvious(set_tim_deadly(dur), obvious)
- end
- return obvious
- end,
- ["info"] = function()
- return "dur "..(get_level(TULKAS_AIM, 50)).."+d10"
- end,
+ ["spell"] = function() return tulkas_divine_aim() end,
+ ["info"] = function() return tulkas_divine_aim_info() end,
["desc"] = {
"It makes you more accurate in combat",
"At level 20 all your blows are critical hits",
@@ -43,15 +32,8 @@ TULKAS_WAVE = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- local ret, dir = get_aim_dir()
- if ret == FALSE then return end
-
- return fire_bolt(GF_ATTACK, dir, get_level(TULKAS_WAVE, player.num_blow))
- end,
- ["info"] = function()
- return "blows "..(get_level(TULKAS_WAVE, player.num_blow))
- end,
+ ["spell"] = function() return tulkas_wave_of_power() end,
+ ["info"] = function() return tulkas_wave_of_power_info() end,
["desc"] = {
"It allows you to project a number of melee blows across a distance",
}
@@ -69,12 +51,8 @@ TULKAS_SPIN = add_spell
["piety"] = TRUE,
["stat"] = A_WIS,
["random"] = SKILL_SPIRITUALITY,
- ["spell"] = function()
- return fire_ball(GF_ATTACK, 0, 1, 1)
- end,
- ["info"] = function()
- return ""
- end,
+ ["spell"] = function() return tulkas_whirlwind() end,
+ ["info"] = function() return tulkas_whirlwind_info() end,
["desc"] = {
"It allows you to spin around and hit all monsters nearby",
}
diff --git a/src/externs.h b/src/externs.h
index 6db58e36..dd83e876 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1655,6 +1655,17 @@ char *tempo_essence_of_speed_info();
bool_ *tempo_banishment();
char *tempo_banishment_info();
+extern s32b TULKAS_AIM;
+extern s32b TULKAS_WAVE;
+extern s32b TULKAS_SPIN;
+
+bool_ *tulkas_divine_aim();
+char *tulkas_divine_aim_info();
+bool_ *tulkas_wave_of_power();
+char *tulkas_wave_of_power_info();
+bool_ *tulkas_whirlwind();
+char *tulkas_whirlwind_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 eeae6e7d..3b7ce060 100644
--- a/src/spells.pkg
+++ b/src/spells.pkg
@@ -2660,3 +2660,14 @@ bool_ *tempo_essence_of_speed();
char *tempo_essence_of_speed_info();
bool_ *tempo_banishment();
char *tempo_banishment_info();
+
+extern s32b TULKAS_AIM;
+extern s32b TULKAS_WAVE;
+extern s32b TULKAS_SPIN;
+
+bool_ *tulkas_divine_aim();
+char *tulkas_divine_aim_info();
+bool_ *tulkas_wave_of_power();
+char *tulkas_wave_of_power_info();
+bool_ *tulkas_whirlwind();
+char *tulkas_whirlwind_info();
diff --git a/src/spells3.c b/src/spells3.c
index 9cca482a..6220cd25 100644
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -90,6 +90,10 @@ s32b SLOWMONSTER;
s32b ESSENCESPEED;
s32b BANISHMENT;
+s32b TULKAS_AIM;
+s32b TULKAS_WAVE;
+s32b TULKAS_SPIN;
+
/* 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
@@ -2776,3 +2780,58 @@ char *tempo_banishment_info()
tempo_banishment_power());
return buf;
}
+
+bool_ *tulkas_divine_aim()
+{
+ s32b dur = get_level_s(TULKAS_AIM, 50) + randint(10);
+
+ set_strike(dur);
+ if (get_level_s(TULKAS_AIM, 50) >= 20)
+ {
+ set_tim_deadly(dur);
+ }
+
+ return CAST;
+}
+
+char *tulkas_divine_aim_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "dur " FMTs32b "+d10",
+ get_level_s(TULKAS_AIM, 50));
+ return buf;
+}
+
+bool_ *tulkas_wave_of_power()
+{
+ int dir;
+
+ if (!get_aim_dir(&dir))
+ {
+ return NO_CAST;
+ }
+
+ fire_bolt(GF_ATTACK, dir, get_level_s(TULKAS_WAVE, p_ptr->num_blow));
+ return CAST;
+}
+
+char *tulkas_wave_of_power_info()
+{
+ static char buf[128];
+ sprintf(buf,
+ "blows " FMTs32b,
+ get_level_s(TULKAS_WAVE, p_ptr->num_blow));
+ return buf;
+}
+
+bool_ *tulkas_whirlwind()
+{
+ fire_ball(GF_ATTACK, 0, 1, 1);
+ return CAST;
+}
+
+char *tulkas_whirlwind_info()
+{
+ return "";
+}