From 6987232c337535eb3b7f7de14ae0637d6f4b3d1d Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 9 Jun 2012 09:29:06 +0200 Subject: Lua: Move "identify object with spell slot" help to C --- lib/mods/theme/scpt/help.lua | 19 ------------------- lib/scpt/help.lua | 19 ------------------- src/help.c | 28 +++++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/lib/mods/theme/scpt/help.lua b/lib/mods/theme/scpt/help.lua index d827e5dc..d9f637bd 100644 --- a/lib/mods/theme/scpt/help.lua +++ b/lib/mods/theme/scpt/help.lua @@ -219,25 +219,6 @@ ingame_help end, } -ingame_help -{ - ["hook"] = HOOK_IDENTIFY, - ["event"] = function(i, mode) - if mode == "full" then - local obj = get_object(i) - local f1, f2, f3, f4, f5, esp = object_flags(obj) - if band(f5, TR5_SPELL_CONTAIN) ~= 0 then return TRUE end - end - end, - ["desc"] = - { - "Ah, an item that can contain a spell. To use it you must have some levels of", - "Magic skill and then you get the option to copy a spell when pressing m.", - "Then just select which spell to copy and to which object. Note that doing so", - "is permanent; the spell cannot be removed or changed later.", - } -} - ingame_help { ["hook"] = HOOK_RECALC_SKILLS, diff --git a/lib/scpt/help.lua b/lib/scpt/help.lua index bbda148d..0ee307cb 100644 --- a/lib/scpt/help.lua +++ b/lib/scpt/help.lua @@ -185,25 +185,6 @@ ingame_help end, } -ingame_help -{ - ["hook"] = HOOK_IDENTIFY, - ["event"] = function(i, mode) - if mode == "full" then - local obj = get_object(i) - local f1, f2, f3, f4, f5, esp = object_flags(obj) - if band(f5, TR5_SPELL_CONTAIN) ~= 0 then return TRUE end - end - end, - ["desc"] = - { - "Ah, an item that can contain a spell. To use it you must have some levels of", - "Magic skill and then you get the option to copy a spell when pressing m.", - "Then just select which spell to copy and to which object. Note that doing so", - "is permanent; the spell cannot be removed or changed later.", - } -} - ingame_help { ["hook"] = HOOK_RECALC_SKILLS, diff --git a/src/help.c b/src/help.c index 73892ff7..bee5c480 100644 --- a/src/help.c +++ b/src/help.c @@ -14,7 +14,7 @@ #include "angband.h" #define DESC_MAX 14 -#define TRIGGERED_HELP_MAX 16 +#define TRIGGERED_HELP_MAX 17 #define HELP_VOID_JUMPGATE 0 #define HELP_FOUNTAIN 1 @@ -32,6 +32,7 @@ #define HELP_GAME_THEME 13 #define HELP_1ST_LEVEL 14 #define HELP_20TH_LEVEL 15 +#define HELP_ID_SPELL_ITM 16 /** * Struct for help triggered by a boolean condition @@ -132,6 +133,21 @@ static bool_ trigger_20th_level(void *in, void *out) { return (p_ptr->lev >= 20); } +static bool_ trigger_identify_spell_item(void *in_, void *out) { + hook_identify_in *in = (hook_identify_in *) in_; + + if (in->mode == IDENT_FULL) + { + u32b f1, f2, f3, f4, f5, esp; + object_flags(in->o_ptr, &f1, &f2, &f3, &f4, &f5, &esp); + if (f5 & TR5_SPELL_CONTAIN) + { + return TRUE; + } + } + return FALSE; +} + /** * Trigger-based help items */ @@ -296,6 +312,16 @@ static triggered_help_type triggered_help[TRIGGERED_HELP_MAX] = "http://angband.oook.cz/ where it will end up in the ladder.", NULL } + }, + { HELP_ID_SPELL_ITM, + HOOK_IDENTIFY, + trigger_identify_spell_item, + { "Ah, an item that can contain a spell. To use it you must have some levels of", + "Magic skill and then you get the option to copy a spell when pressing m.", + "Then just select which spell to copy and to which object. Note that doing so", + "is permanent; the spell cannot be removed or changed later.", + NULL + } } }; -- cgit v1.2.3