summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-06-09 19:47:10 +0200
committerBardur Arantsson <bardur@scientician.net>2012-06-09 19:47:44 +0200
commitd69d91b33a2e833e8b32baa29af22809ade406ba (patch)
treef7c2cbedb10da018471c230d483414f83cdfb8d7
parentca63c6bf6fa6d72b93b53cc48d06cc69b3bebe9e (diff)
Lua: Move "Far Reaching Attack" ability to C
-rw-r--r--lib/core/player.lua26
-rw-r--r--lib/mods/theme/core/player.lua26
-rw-r--r--lib/mods/theme/scpt/init.lua3
-rw-r--r--lib/mods/theme/scpt/mkeys.lua35
-rw-r--r--lib/scpt/init.lua3
-rw-r--r--lib/scpt/mkeys.lua35
-rw-r--r--src/defines.h2
-rw-r--r--src/skills.c44
-rw-r--r--src/util.pkg8
9 files changed, 44 insertions, 138 deletions
diff --git a/lib/core/player.lua b/lib/core/player.lua
index cb1b5cab..f5c7c13b 100644
--- a/lib/core/player.lua
+++ b/lib/core/player.lua
@@ -56,32 +56,6 @@ function player.get_wild_coord()
end
---- Mkeys
-
--- Create a new power
-__mkey_fct = {}
-function add_mkey(p)
- local i
-
- assert(p.mkey, "No mkey mkey!")
- assert(p.fct, "No mkeey fct!")
-
- __mkey_fct[p.mkey] = p.fct
-end
-
-function __mkey_fct_activate(power)
- if __mkey_fct[power] then
- __mkey_fct[power]()
- return TRUE
- else
- return FALSE
- end
-end
-
--- Register in the hook list
-add_hook_script(HOOK_MKEY, "__mkey_fct_activate", "__mkey_fct_activate")
-
-
-- Subraces
function subrace(racem)
return race_mod_info[racem + 1]
diff --git a/lib/mods/theme/core/player.lua b/lib/mods/theme/core/player.lua
index cb1b5cab..f5c7c13b 100644
--- a/lib/mods/theme/core/player.lua
+++ b/lib/mods/theme/core/player.lua
@@ -56,32 +56,6 @@ function player.get_wild_coord()
end
---- Mkeys
-
--- Create a new power
-__mkey_fct = {}
-function add_mkey(p)
- local i
-
- assert(p.mkey, "No mkey mkey!")
- assert(p.fct, "No mkeey fct!")
-
- __mkey_fct[p.mkey] = p.fct
-end
-
-function __mkey_fct_activate(power)
- if __mkey_fct[power] then
- __mkey_fct[power]()
- return TRUE
- else
- return FALSE
- end
-end
-
--- Register in the hook list
-add_hook_script(HOOK_MKEY, "__mkey_fct_activate", "__mkey_fct_activate")
-
-
-- Subraces
function subrace(racem)
return race_mod_info[racem + 1]
diff --git a/lib/mods/theme/scpt/init.lua b/lib/mods/theme/scpt/init.lua
index 85099e19..0d59bfd2 100644
--- a/lib/mods/theme/scpt/init.lua
+++ b/lib/mods/theme/scpt/init.lua
@@ -5,9 +5,6 @@
-- Load the class specific stuff
tome_dofile("player.lua")
--- Add the mkey activations
-tome_dofile("mkeys.lua")
-
-- Add the schools of magic
schools_init()
school_spells_init()
diff --git a/lib/mods/theme/scpt/mkeys.lua b/lib/mods/theme/scpt/mkeys.lua
deleted file mode 100644
index 82fe4ede..00000000
--- a/lib/mods/theme/scpt/mkeys.lua
+++ /dev/null
@@ -1,35 +0,0 @@
--- Mkeys for skills & abilities
-
--- Far reaching attack of polearms
-add_mkey
-{
- ["mkey"] = 102,
- ["fct"] = function()
- local weapon = get_object(INVEN_WIELD);
- if weapon.tval == TV_POLEARM then
- else
- msg_print("You will need a long polearm for this!")
- return
- end
-
- ret, dir = get_rep_dir()
- if ret == FALSE then return end
-
- local dy, dx = explode_dir(dir)
- dy = dy * 2
- dx = dx * 2
- targety = player.py + dy
- targetx = player.px + dx
-
- local max_blows = get_skill_scale(SKILL_POLEARM, player.num_blow / 2)
- if max_blows == 0 then max_blows = 1 end
-
- if get_skill(SKILL_POLEARM) >= 40 then
- energy_use = energy_use + 200
- return project(0, 0, targety, targetx, max_blows, GF_ATTACK, bor(PROJECT_BEAM, PROJECT_KILL))
- else
- energy_use = energy_use + 200
- return project(0, 0, targety, targetx, max_blows, GF_ATTACK, bor(PROJECT_BEAM, PROJECT_STOP, PROJECT_KILL))
- end
- end,
-}
diff --git a/lib/scpt/init.lua b/lib/scpt/init.lua
index 3be0887c..b3c73304 100644
--- a/lib/scpt/init.lua
+++ b/lib/scpt/init.lua
@@ -5,9 +5,6 @@
-- Load the class specific stuff
tome_dofile("player.lua")
--- Add the mkey activations
-tome_dofile("mkeys.lua")
-
-- Add the schools of magic
schools_init()
school_spells_init()
diff --git a/lib/scpt/mkeys.lua b/lib/scpt/mkeys.lua
deleted file mode 100644
index 82fe4ede..00000000
--- a/lib/scpt/mkeys.lua
+++ /dev/null
@@ -1,35 +0,0 @@
--- Mkeys for skills & abilities
-
--- Far reaching attack of polearms
-add_mkey
-{
- ["mkey"] = 102,
- ["fct"] = function()
- local weapon = get_object(INVEN_WIELD);
- if weapon.tval == TV_POLEARM then
- else
- msg_print("You will need a long polearm for this!")
- return
- end
-
- ret, dir = get_rep_dir()
- if ret == FALSE then return end
-
- local dy, dx = explode_dir(dir)
- dy = dy * 2
- dx = dx * 2
- targety = player.py + dy
- targetx = player.px + dx
-
- local max_blows = get_skill_scale(SKILL_POLEARM, player.num_blow / 2)
- if max_blows == 0 then max_blows = 1 end
-
- if get_skill(SKILL_POLEARM) >= 40 then
- energy_use = energy_use + 200
- return project(0, 0, targety, targetx, max_blows, GF_ATTACK, bor(PROJECT_BEAM, PROJECT_KILL))
- else
- energy_use = energy_use + 200
- return project(0, 0, targety, targetx, max_blows, GF_ATTACK, bor(PROJECT_BEAM, PROJECT_STOP, PROJECT_KILL))
- end
- end,
-}
diff --git a/src/defines.h b/src/defines.h
index c1dafdf4..2907d2a2 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -611,6 +611,7 @@
#define MKEY_PIERCING 23
#define MKEY_DEATH_TOUCH 100
#define MKEY_GEOMANCY 101
+#define MKEY_REACH_ATTACK 102
/*** Screen Locations ***/
@@ -4486,7 +4487,6 @@
#define HOOK_KEYPRESS 31
#define HOOK_CHAT 32
#define HOOK_MON_SPEAK 33
-#define HOOK_MKEY 34
#define HOOK_BIRTH_OBJECTS 35
#define HOOK_ACTIVATE_DESC 36
#define HOOK_INIT_GAME 37
diff --git a/src/skills.c b/src/skills.c
index 1dc65fea..4de0b047 100644
--- a/src/skills.c
+++ b/src/skills.c
@@ -1102,8 +1102,50 @@ void do_cmd_activate_skill()
break;
}
+ case MKEY_REACH_ATTACK:
+ {
+ object_type *o_ptr = NULL;
+ int dir, dy, dx, targetx, targety, max_blows, flags;
+
+ o_ptr = get_object(INVEN_WIELD);
+ if (o_ptr->tval == TV_POLEARM)
+ {
+ msg_print("You will need a long polearm for this!");
+ return;
+ }
+
+ if (!get_rep_dir(&dir))
+ {
+ return;
+ }
+
+ dy = ddy[dir];
+ dx = ddx[dir];
+ dy = dy * 2;
+ dx = dx * 2;
+ targety = p_ptr->py + dy;
+ targetx = p_ptr->px + dx;
+
+ max_blows = get_skill_scale(SKILL_POLEARM, p_ptr->num_blow / 2);
+ if (max_blows == 0)
+ {
+ max_blows = 1;
+ }
+
+ energy_use = energy_use + 200;
+
+ flags = PROJECT_BEAM | PROJECT_KILL;
+ if (get_skill(SKILL_POLEARM) < 40)
+ {
+ flags |= PROJECT_STOP;
+ }
+
+ project(0, 0, targety, targetx,
+ max_blows, GF_ATTACK, flags);
+
+ break;
+ }
default:
- process_hooks(HOOK_MKEY, "(d)", x_idx);
break;
}
}
diff --git a/src/util.pkg b/src/util.pkg
index 4e3b6117..33f60a59 100644
--- a/src/util.pkg
+++ b/src/util.pkg
@@ -426,14 +426,6 @@ typedef unsigned int u32b;
*/
#define HOOK_MON_SPEAK 33
-/** @def HOOK_MKEY
- * @brief Player uses skill.\n
- * @param Number x_idx \n the skill to execute.
- * @brief Skill index
- * @note (see file skills.c)
- */
-#define HOOK_MKEY 34
-
/** @def HOOK_BIRTH_OBJECTS
* @brief Player receives objects at birth.
* @note (see file birth.c)