summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/misc.lua10
-rw-r--r--src/cmd6.c7
-rw-r--r--src/modules.c20
-rw-r--r--src/types.h10
4 files changed, 37 insertions, 10 deletions
diff --git a/lib/mods/theme/scpt/misc.lua b/lib/mods/theme/scpt/misc.lua
index 9a3c37bb..6205678a 100644
--- a/lib/mods/theme/scpt/misc.lua
+++ b/lib/mods/theme/scpt/misc.lua
@@ -12,16 +12,6 @@ end
add_hook_script(HOOK_EAT, "food_vessel", "food_vessel")
--- Longbottom Leaf *is* a great stress reliever:
-function longbottom_leaf(object)
- if (object.tval == 80) and (object.sval == 45) then
- msg_print("What a stress reliever!")
- heal_insanity(1000)
- return FALSE
- end
-end
-add_hook_script(HOOK_EAT, "longbottom_leaf", "longbottom_leaf")
-
-- functions to check for Map and Key of Thror before proceeding in Erebor
-- Thank you, Massimiliano Marangio :-)
add_hooks
diff --git a/src/cmd6.c b/src/cmd6.c
index 32ad1868..5377ef38 100644
--- a/src/cmd6.c
+++ b/src/cmd6.c
@@ -963,10 +963,17 @@ void do_cmd_eat_food(void)
lev = k_info[o_ptr->k_idx].level;
/* Scripted foods */
+ hook_eat_in in = { o_ptr };
+ hook_eat_out out = { FALSE };
+
if (process_hooks_ret(HOOK_EAT, "d", "(O)", o_ptr))
{
ident = process_hooks_return[0].num;
}
+ else if (process_hooks_new(HOOK_EAT, &in, &out))
+ {
+ ident = out.ident;
+ }
/* (not quite) Normal foods */
else if (o_ptr->tval == TV_FOOD)
{
diff --git a/src/modules.c b/src/modules.c
index 552bc876..4d139397 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -585,6 +585,21 @@ static bool_ smeagol_ring(void *data, void *in_, void *out)
}
}
+static bool_ longbottom_leaf(void *data, void *in_, void *out_)
+{
+ hook_eat_in *in = (hook_eat_in *) in_;
+
+ if ((in->o_ptr->tval == TV_FOOD) &&
+ (in->o_ptr->sval == 45))
+ {
+ msg_print("What a stress reliever!");
+ heal_insanity(1000);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void init_hooks_module()
{
/*
@@ -622,6 +637,11 @@ void init_hooks_module()
"smeagol_ring",
NULL);
+ add_hook_new(HOOK_EAT,
+ longbottom_leaf,
+ "longbottom_leaf",
+ NULL);
+
break;
}
diff --git a/src/types.h b/src/types.h
index ae1adcae..f7dd6d40 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2293,6 +2293,16 @@ struct hook_give_in {
int item;
};
+typedef struct hook_eat_in hook_eat_in;
+struct hook_eat_in {
+ object_type *o_ptr;
+};
+
+typedef struct hook_eat_out hook_eat_out;
+struct hook_eat_out {
+ bool_ ident;
+};
+
/*
* Structure for the "quests"
*/