diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-09 10:17:39 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-09 10:17:51 +0200 |
commit | b89a8b18c480f6c96b5f8ba1f67a29c45ab2007d (patch) | |
tree | 84f2e9f45e1e064b7d1de68cb5de538f5272cc1a | |
parent | d497a80b25bb612d63daa70582fca5eeaa708fec (diff) |
Lua: God quests: Move HOOK_CHAR_DUMP code to C
-rw-r--r-- | lib/mods/theme/scpt/god.lua | 21 | ||||
-rw-r--r-- | lib/scpt/god.lua | 21 | ||||
-rw-r--r-- | src/plots.h | 1 | ||||
-rw-r--r-- | src/q_god.c | 33 | ||||
-rw-r--r-- | src/quest.pkg | 1 |
5 files changed, 37 insertions, 40 deletions
diff --git a/lib/mods/theme/scpt/god.lua b/lib/mods/theme/scpt/god.lua index 7a03f49f..d05d5ce1 100644 --- a/lib/mods/theme/scpt/god.lua +++ b/lib/mods/theme/scpt/god.lua @@ -141,26 +141,7 @@ add_quest return quest_god_get_hook(item) end, [HOOK_CHAR_DUMP] = function() - - if (god_quest.quests_given > 0) then - - local relics = god_quest.relics_found - local append_text = "" - if (god_quest.relics_found == god_quest.MAX_NUM_GOD_QUESTS) then - relics = "all" - append_text = " and pleased your god" - else - if (god_quest.relics_found == 0) then - relics = "none" - end - if (quest(GOD_QUEST).status == QUEST_STATUS_FAILED) then - append_text = " and failed in your quest" - end - end - - print_hook("\n You found "..(relics).." of the relic pieces"..(append_text)..".") - - end + return quest_god_char_dump() end, }, } diff --git a/lib/scpt/god.lua b/lib/scpt/god.lua index 9e1f2039..e8b4fe74 100644 --- a/lib/scpt/god.lua +++ b/lib/scpt/god.lua @@ -133,26 +133,7 @@ add_quest return quest_god_get_hook(item) end, [HOOK_CHAR_DUMP] = function() - - if (god_quest.quests_given > 0) then - - local relics = god_quest.relics_found - local append_text = "" - if (god_quest.relics_found == god_quest.MAX_NUM_GOD_QUESTS) then - relics = "all" - append_text = " and pleased your god" - else - if (god_quest.relics_found == 0) then - relics = "none" - end - if (quest(GOD_QUEST).status == QUEST_STATUS_FAILED) then - append_text = " and failed in your quest" - end - end - - print_hook("\n You found "..(relics).." of the relic pieces"..(append_text)..".") - - end + return quest_god_char_dump() end, }, } diff --git a/src/plots.h b/src/plots.h index 27cf25f0..4631d3cd 100644 --- a/src/plots.h +++ b/src/plots.h @@ -78,3 +78,4 @@ extern void quest_god_set_god_dungeon_attributes_mandos(); extern void quest_god_level_end_gen_hook(); extern void quest_god_player_level_hook(int gained); extern bool_ quest_god_get_hook(int o_idx); +extern void quest_god_char_dump(); diff --git a/src/q_god.c b/src/q_god.c index bc2920a9..a83deb40 100644 --- a/src/q_god.c +++ b/src/q_god.c @@ -1,6 +1,8 @@ #include "angband.h" #include <assert.h> +#define print_hook(fmt,...) do { fprintf(hook_file, fmt, ##__VA_ARGS__); } while (0) + /* d_idx of the god_quest (Lost Temple) dungeon */ #define DUNGEON_GOD 30 #define CHANCE_OF_GOD_QUEST 21 @@ -888,3 +890,34 @@ bool_ quest_god_get_hook(int item) return FALSE; } + +void quest_god_char_dump() +{ + if (get_quests_given() > 0) + { + int relics = get_relics_found(); + char relics_text[128]; + cptr append_text = ""; + + snprintf(relics_text, sizeof(relics_text), "%d", relics); + + if (relics == MAX_NUM_GOD_QUESTS()) + { + strcpy(relics_text, "all"); + append_text = " and pleased your god"; + } + else + { + if (relics == 0) + { + strcpy(relics_text, "none"); + } + if (get_status() == QUEST_STATUS_FAILED) + { + append_text = " and failed in your quest"; + } + } + + print_hook("\n You found %s of the relic pieces%s.", relics_text, append_text); + } +} diff --git a/src/quest.pkg b/src/quest.pkg index dc5a91fc..fb2f3b84 100644 --- a/src/quest.pkg +++ b/src/quest.pkg @@ -177,3 +177,4 @@ extern void quest_god_set_god_dungeon_attributes_mandos(); extern void quest_god_level_end_gen_hook(); extern void quest_god_player_level_hook(int gained); extern bool quest_god_get_hook(int o_idx); +extern void quest_god_char_dump(); |