summaryrefslogtreecommitdiff
path: root/src/q_god.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-09 00:47:44 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-09 09:54:40 +0200
commitd497a80b25bb612d63daa70582fca5eeaa708fec (patch)
tree64a3faf0fd5550d4df4ab57d5b3be259a329d01a /src/q_god.c
parent7fc396e625a96e48419b60359f721ad082d7f475 (diff)
Lua: God quests: Move HOOK_GET code to C
Diffstat (limited to 'src/q_god.c')
-rw-r--r--src/q_god.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/q_god.c b/src/q_god.c
index 020b8ca1..bc2920a9 100644
--- a/src/q_god.c
+++ b/src/q_god.c
@@ -122,6 +122,16 @@ static int get_dun_minplev()
return get_lua_int("god_quest.dun_minplev");
}
+static int get_relics_found()
+{
+ return get_lua_int("god_quest.relics_found");
+}
+
+static void set_relics_found(int v)
+{
+ exec_lua(format("god_quest.relics_found = %d", v));
+}
+
static void setup_relic_number()
{
exec_lua("setup_relic_number()");
@@ -824,3 +834,57 @@ void quest_god_player_level_hook(int gained)
set_dun_maxdepth(get_dun_mindepth() + 4);
}
}
+
+bool_ quest_god_get_hook(int item)
+{
+ object_type *o_ptr = NULL;
+
+ item = -item; /* Workaround */
+ o_ptr = get_object(item);
+
+ /* -- Is it the relic, and check to make sure the relic hasn't already been identified */
+ if ((get_status() == QUEST_STATUS_TAKEN) &&
+ (o_ptr->tval == TV_JUNK) &&
+ (o_ptr->sval == get_relic_num()) &&
+ (o_ptr->pval != TRUE) &&
+ (get_relics_found() < get_quests_given()))
+ {
+ cmsg_format(TERM_L_BLUE, "%s speaks to you:", deity_info[p_ptr->pgod].name);
+
+ /* Is it the last piece of the relic? */
+ if (get_quests_given() == MAX_NUM_GOD_QUESTS())
+ {
+ cmsg_print(TERM_YELLOW, "'At last! Thou hast found all of the relic pieces.");
+
+ /* reward player by increasing prayer skill */
+ cmsg_print(TERM_YELLOW, "Thou hast done exceptionally well! I shall increase thy prayer skill even more!'");
+ s_info[SKILL_PRAY].value += (10 * s_info[SKILL_PRAY].mod);
+ }
+ else
+ {
+ cmsg_print(TERM_YELLOW, "'Well done! Thou hast found part of the relic.");
+ cmsg_print(TERM_YELLOW, "I shall surely ask thee to find more of it later!");
+ cmsg_print(TERM_YELLOW, "I will take it from thee for now'");
+
+ /* reward player by increasing prayer skill */
+ cmsg_print(TERM_YELLOW, "'As a reward, I shall teach thee how to pray better'");
+ s_info[SKILL_PRAY].value += (5 * s_info[SKILL_PRAY].mod);
+ }
+
+ /* Take the relic piece */
+ inc_stack_size_ex(item, -1, OPTIMIZE, NO_DESCRIBE);
+
+ /* relic piece has been identified */
+ o_ptr->pval = TRUE;
+ set_relics_found(get_relics_found() + 1);
+
+ /* Make sure quests can be given again if neccesary */
+ set_status(QUEST_STATUS_UNTAKEN);
+
+ /* Prevent further processing of 'take' action; we've
+ destroyed the item. */
+ return TRUE;
+ }
+
+ return FALSE;
+}