From 60d422ca9be29752ffb7d6d3a734845c46a89e28 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 24 Mar 2013 19:03:20 +0100 Subject: Split "Wolves!" quest from plots.c --- src/q_wolves.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/q_wolves.c') diff --git a/src/q_wolves.c b/src/q_wolves.c index 2ec14cc2..badbd319 100644 --- a/src/q_wolves.c +++ b/src/q_wolves.c @@ -1,4 +1,5 @@ -#undef cquest +#include "q_wolves.h" + #define cquest (quest[QUEST_WOLVES]) bool_ quest_wolves_gen_hook(char *fmt) -- cgit v1.2.3 From eb657ada4c1ec432fc0e3aec0b9f4d796efed428 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 25 Mar 2013 13:10:24 +0100 Subject: Split hooks into separate header --- src/q_wolves.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/q_wolves.c') diff --git a/src/q_wolves.c b/src/q_wolves.c index badbd319..5da28ee7 100644 --- a/src/q_wolves.c +++ b/src/q_wolves.c @@ -1,8 +1,9 @@ #include "q_wolves.h" +#include "hooks.h" #define cquest (quest[QUEST_WOLVES]) -bool_ quest_wolves_gen_hook(char *fmt) +static bool_ quest_wolves_gen_hook(const char *fmt) { int x, y, i; int xstart = 2; @@ -70,7 +71,7 @@ bool_ quest_wolves_gen_hook(char *fmt) return TRUE; } -bool_ quest_wolves_death_hook(char *fmt) +static bool_ quest_wolves_death_hook(const char *fmt) { int i, mcnt = 0; @@ -102,7 +103,7 @@ bool_ quest_wolves_death_hook(char *fmt) return FALSE; } -bool_ quest_wolves_finish_hook(char *fmt) +static bool_ quest_wolves_finish_hook(const char *fmt) { s32b q_idx; -- cgit v1.2.3 From cbef37bd5bfb938a2303ee3887520c08be85d8e8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Mar 2013 17:10:10 +0100 Subject: Switch almost everything over to C++ --- src/q_wolves.c | 132 --------------------------------------------------------- 1 file changed, 132 deletions(-) delete mode 100644 src/q_wolves.c (limited to 'src/q_wolves.c') diff --git a/src/q_wolves.c b/src/q_wolves.c deleted file mode 100644 index 5da28ee7..00000000 --- a/src/q_wolves.c +++ /dev/null @@ -1,132 +0,0 @@ -#include "q_wolves.h" -#include "hooks.h" - -#define cquest (quest[QUEST_WOLVES]) - -static bool_ quest_wolves_gen_hook(const char *fmt) -{ - int x, y, i; - int xstart = 2; - int ystart = 2; - - if (p_ptr->inside_quest != QUEST_WOLVES) return FALSE; - - /* Just in case we didnt talk the the mayor */ - if (cquest.status == QUEST_STATUS_UNTAKEN) - cquest.status = QUEST_STATUS_TAKEN; - - /* Start with perm walls */ - for (y = 0; y < cur_hgt; y++) - { - for (x = 0; x < cur_wid; x++) - { - cave_set_feat(y, x, FEAT_PERM_SOLID); - } - } - - dun_level = quest[p_ptr->inside_quest].level; - - /* Set the correct monster hook */ - set_mon_num_hook(); - - /* Prepare allocation table */ - get_mon_num_prep(); - - init_flags = INIT_CREATE_DUNGEON; - process_dungeon_file("wolves.map", &ystart, &xstart, cur_hgt, cur_wid, TRUE, FALSE); - dungeon_flags2 |= DF2_NO_GENO; - - /* Place some random wolves */ - for (i = damroll(4, 4); i > 0; ) - { - int m_idx, flags; - y = rand_int(21) + 3; - x = rand_int(31) + 3; - flags = f_info[cave[y][x].feat].flags1; - if (!(flags & FF1_PERMANENT) && (flags & FF1_FLOOR)) - { - m_idx = place_monster_one(y, x, 196, 0, magik(50), MSTATUS_ENEMY); - if (m_idx) m_list[m_idx].mflag |= MFLAG_QUEST; - --i; - } - } - - /* Place some random wargs */ - for (i = damroll(4, 4); i > 0; ) - { - int m_idx, flags; - y = rand_int(21) + 3; - x = rand_int(31) + 3; - flags = f_info[cave[y][x].feat].flags1; - if (!(flags & FF1_PERMANENT) && (flags & FF1_FLOOR)) - { - m_idx = place_monster_one(y, x, 257, 0, magik(50), MSTATUS_ENEMY); - if (m_idx) m_list[m_idx].mflag |= MFLAG_QUEST; - --i; - } - } - - process_hooks_restart = TRUE; - - return TRUE; -} - -static bool_ quest_wolves_death_hook(const char *fmt) -{ - int i, mcnt = 0; - - if (p_ptr->inside_quest != QUEST_WOLVES) return FALSE; - - /* Process the monsters (backwards) */ - for (i = m_max - 1; i >= 1; i--) - { - /* Access the monster */ - monster_type *m_ptr = &m_list[i]; - - /* Ignore "dead" monsters */ - if (!m_ptr->r_idx) continue; - - if (m_ptr->status <= MSTATUS_ENEMY) mcnt++; - } - - /* Nobody left ? */ - if (mcnt <= 1) - { - quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED; - del_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook); - del_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook); - process_hooks_restart = TRUE; - - cmsg_print(TERM_YELLOW, "Lothlorien is safer now."); - return (FALSE); - } - return FALSE; -} - -static bool_ quest_wolves_finish_hook(const char *fmt) -{ - s32b q_idx; - - q_idx = get_next_arg(fmt); - - if (q_idx != QUEST_WOLVES) return FALSE; - - c_put_str(TERM_YELLOW, "Thank you for killing the pack of wolves!", 8, 0); - c_put_str(TERM_YELLOW, "You can use the hut as your house as a reward.", 9, 0); - - /* Continue the plot */ - *(quest[q_idx].plot) = QUEST_SPIDER; - - return TRUE; -} - -bool_ quest_wolves_init_hook(int q_idx) -{ - if ((cquest.status >= QUEST_STATUS_UNTAKEN) && (cquest.status < QUEST_STATUS_FINISHED)) - { - add_hook(HOOK_MONSTER_DEATH, quest_wolves_death_hook, "wolves_monster_death"); - add_hook(HOOK_QUEST_FINISH, quest_wolves_finish_hook, "wolves_finish"); - add_hook(HOOK_GEN_QUEST, quest_wolves_gen_hook, "wolves_geb"); - } - return (FALSE); -} -- cgit v1.2.3