summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/monsters.lua37
-rw-r--r--src/modules.c50
2 files changed, 50 insertions, 37 deletions
diff --git a/lib/mods/theme/scpt/monsters.lua b/lib/mods/theme/scpt/monsters.lua
index 6c0cc197..df9c641d 100644
--- a/lib/mods/theme/scpt/monsters.lua
+++ b/lib/mods/theme/scpt/monsters.lua
@@ -1,42 +1,5 @@
-- This file holds various things that govern monster behaviour with respect to the player
--- Enables player to push past any monster who is >= MSTATUS_NEUTRAL.
--- Written by BauMog for the Intets Hevn module; permission granted to use in the Theme module
-
--- Adapted from defines.h
-function cave_floor_bold(y, x)
- local c_ptr = cave(y, x);
- if(cave_is(c_ptr, FF1_FLOOR) == TRUE) and (c_ptr.feat ~= FEAT_MON_TRAP) then
- return TRUE
- else
- return FALSE
- end
-end
-
--- Adapted from cmd1.c
-function __hook_push_past(y, x)
- local c_ptr = cave(y, x);
-
- if(c_ptr.m_idx > 0) then
- m_ptr = monster(c_ptr.m_idx);
- if(m_ptr.status >= MSTATUS_NEUTRAL) then
- if(cave_floor_bold(y, x) == TRUE) or (m_ptr.flags2 == RF2_PASS_WALL) then
- msg_print(format("You push past %s.", monster_desc(m_ptr, 0)));
- m_ptr.fy = player.py;
- m_ptr.fx = player.px;
- cave(player.py, player.px).m_idx = c_ptr.m_idx;
- c_ptr.m_idx = 0;
- else
- msg_print(format("%s is in your way!", monster_desc(m_ptr, 0)));
- energy_use = 0;
- end
- end
- end
-
-end
-
-add_hook_script(HOOK_MOVE, "__hook_push_past", "__hook_push_past");
-
-- Monster vs. Player Race alignment script
-- From T-Plus by Ingeborg S. Norden
diff --git a/src/modules.c b/src/modules.c
index d9c599d1..3368691a 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -699,6 +699,51 @@ static bool_ orthanc_stair(void *data, void *in_, void *out_)
return FALSE;
}
+/*
+ * Movement from Theme
+ */
+bool_ theme_push_past(void *data, void *in_, void *out_)
+{
+ hook_move_in *p = (hook_move_in *) in_;
+ cave_type *c_ptr = &cave[p->y][p->x];
+
+ if (c_ptr->m_idx > 0)
+ {
+ monster_type *m_ptr = &m_list[c_ptr->m_idx];
+ monster_race *mr_ptr = race_inf(m_ptr);
+
+ if (m_ptr->status >= MSTATUS_NEUTRAL)
+ {
+ if ((cave_floor_bold(p->y, p->x) == TRUE) ||
+ (mr_ptr->flags2 == RF2_PASS_WALL))
+ {
+ char buf[128];
+
+ monster_desc(buf, m_ptr, 0);
+ msg_print(format("You push past %s.", buf));
+
+ m_ptr->fy = p_ptr->py;
+ m_ptr->fx = p_ptr->px;
+ cave[p_ptr->py][p_ptr->px].m_idx = c_ptr->m_idx;
+ c_ptr->m_idx = 0;
+ }
+ else
+ {
+ char buf[128];
+
+ monster_desc(buf, m_ptr, 0);
+ msg_print(format("%s is in your way!", buf));
+ energy_use = 0;
+
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+
void init_hooks_module()
{
/*
@@ -756,6 +801,11 @@ void init_hooks_module()
"orthanc_stair",
NULL);
+ add_hook_new(HOOK_MOVE,
+ theme_push_past,
+ "__hook_push_past",
+ NULL);
+
break;
}