summaryrefslogtreecommitdiff
path: root/src/modules.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-06-09 21:34:30 +0200
committerBardur Arantsson <bardur@scientician.net>2012-06-09 22:02:48 +0200
commitabd9ab4c46bab7ccd3475a31b542873130682b81 (patch)
tree50f8644cd46f8e009cedd9275fa80a15f0476221 /src/modules.c
parenta0107d942872735f1faa0e857174a6c467180d75 (diff)
Lua: Move "Drunk takes wine" code to C
Diffstat (limited to 'src/modules.c')
-rw-r--r--src/modules.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/modules.c b/src/modules.c
index ff8a24fb..bd2a1acb 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -513,8 +513,49 @@ static bool_ auto_stat_gain_hook(void *data, void *in, void *out)
return FALSE;
}
+static bool_ drunk_takes_wine(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("Singing, happy drunk")) &&
+ (o_ptr->tval == TV_FOOD) &&
+ ((o_ptr->sval == 38) ||
+ (o_ptr->sval == 39)))
+ {
+ cmsg_print(TERM_YELLOW, "'Hic!'");
+
+ /* Destroy item */
+ inc_stack_size_ex(in->item, -1, OPTIMIZE, NO_DESCRIBE);
+
+ /* Create empty bottle */
+ {
+ object_type forge;
+ object_prep(&forge, lookup_kind(TV_BOTTLE,1));
+ drop_near(&forge, 50, p_ptr->py, p_ptr->px);
+ return TRUE;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
void init_hooks_module()
{
+ /*
+ * Common hooks
+ */
+ add_hook_new(HOOK_GIVE,
+ drunk_takes_wine,
+ "drunk_takes_wine",
+ NULL);
+
+ /*
+ * Module-specific hooks
+ */
switch (game_module_idx)
{
case MODULE_TOME: