diff options
-rw-r--r-- | lib/mods/theme/scpt/misc.lua | 19 | ||||
-rw-r--r-- | src/modules.c | 26 |
2 files changed, 26 insertions, 19 deletions
diff --git a/lib/mods/theme/scpt/misc.lua b/lib/mods/theme/scpt/misc.lua index 21a81f83..3658b528 100644 --- a/lib/mods/theme/scpt/misc.lua +++ b/lib/mods/theme/scpt/misc.lua @@ -22,25 +22,6 @@ function longbottom_leaf(object) end add_hook_script(HOOK_EAT, "longbottom_leaf", "longbottom_leaf") --- Hobbits like food -function hobbit_food(m_idx, item) - - m_ptr = monster(m_idx) - o_ptr = get_object(item) - - if (m_ptr.r_idx == test_monster_name("Scruffy-looking hobbit")) - and (o_ptr.tval == TV_FOOD) then - cmsg_print(TERM_YELLOW, "'Yum!'") - inven_item_increase(item, -1) - inven_item_optimize(item) - return TRUE - else - return FALSE - end -end - -add_hook_script(HOOK_GIVE, "hobbit_food", "hobbit_food") - -- Smeagol likes rings function smeagol_ring(m_idx, item) 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; } |