summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-06-09 22:01:58 +0200
committerBardur Arantsson <bardur@scientician.net>2012-06-09 22:03:47 +0200
commitf586b932a44f06bc17336cd8332bec43f17d3d88 (patch)
tree25425694afa1ff4558a68fe39c4d646f61d5d112 /src
parentabd9ab4c46bab7ccd3475a31b542873130682b81 (diff)
Lua: Move "Hobbits like food" code to C
Diffstat (limited to 'src')
-rw-r--r--src/modules.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/modules.c b/src/modules.c
index bd2a1acb..6b476fd2 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -543,6 +543,27 @@ static bool_ drunk_takes_wine(void *data, void *in_, void *out)
}
}
+static bool_ hobbit_food(void *data, void *in_, void *out)
+{
+ hook_give_in *in = (hook_give_in *) in_;
+ monster_type *m_ptr = &m_list[in->m_idx];
+ object_type *o_ptr = get_object(in->item);
+
+ if ((m_ptr->r_idx == test_monster_name("Scruffy-looking hobbit")) &&
+ (o_ptr->tval == TV_FOOD))
+ {
+ cmsg_print(TERM_YELLOW, "'Yum!'");
+
+ inc_stack_size_ex(in->item, -1, OPTIMIZE, NO_DESCRIBE);
+
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
void init_hooks_module()
{
/*
@@ -570,6 +591,11 @@ void init_hooks_module()
"auto_stat_gain",
NULL);
+ add_hook_new(HOOK_GIVE,
+ hobbit_food,
+ "hobbit_food",
+ NULL);
+
break;
}