diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-06-10 06:06:04 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-06-10 06:19:33 +0200 |
commit | 9d06a4324a7f5daac169c0b2b1640696578aee08 (patch) | |
tree | 28ed64ae3bab7871c2e384ced9061d2fee021397 /src | |
parent | e8a7753c88541e45a1b9d1b80be2ad227b179e20 (diff) |
Lua: Move Theme's Longbottom Leaf code to C
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd6.c | 7 | ||||
-rw-r--r-- | src/modules.c | 20 | ||||
-rw-r--r-- | src/types.h | 10 |
3 files changed, 37 insertions, 0 deletions
@@ -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" */ |