summaryrefslogtreecommitdiff
path: root/src/q_shroom.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/q_shroom.cc')
-rw-r--r--src/q_shroom.cc88
1 files changed, 63 insertions, 25 deletions
diff --git a/src/q_shroom.cc b/src/q_shroom.cc
index 89b576d8..627f2b39 100644
--- a/src/q_shroom.cc
+++ b/src/q_shroom.cc
@@ -1,6 +1,7 @@
#include "q_shroom.hpp"
#include "cave.hpp"
+#include "game.hpp"
#include "hook_chat_in.hpp"
#include "hook_give_in.hpp"
#include "hook_monster_death_in.hpp"
@@ -22,15 +23,15 @@
#define cquest (quest[QUEST_SHROOM])
-static bool_ quest_shroom_speak_hook(void *, void *, void *);
-static bool_ quest_shroom_chat_hook(void *, void *, void *);
+static bool quest_shroom_speak_hook(void *, void *, void *);
+static bool quest_shroom_chat_hook(void *, void *, void *);
GENERATE_MONSTER_LOOKUP_FN(get_grip, "Grip, Farmer Maggot's dog")
GENERATE_MONSTER_LOOKUP_FN(get_wolf, "Wolf, Farmer Maggot's dog")
GENERATE_MONSTER_LOOKUP_FN(get_fang, "Fang, Farmer Maggot's dog")
GENERATE_MONSTER_LOOKUP_FN(get_farmer_maggot, "Farmer Maggot")
-static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *)
+static bool quest_shroom_town_gen_hook(void *, void *in_, void *)
{
struct hook_wild_gen_in *in = static_cast<struct hook_wild_gen_in *>(in_);
int m_idx, x = 1, y = 1, tries = 10000;
@@ -41,8 +42,12 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *)
{
/* Create the field */
for (x = (cur_wid / 2) - 7; x <= (cur_wid / 2) + 7; x++)
+ {
for (y = (cur_hgt / 2) - 5; y <= (cur_hgt / 2) + 5; y++)
+ {
cave_set_feat(y, x, 181);
+ }
+ }
/* Throw in some 'shrooms */
for (x = 0; x < (cquest.data[1] - cquest.data[0]); x++)
@@ -82,7 +87,10 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *)
}
/* Generate maggot in town, in daylight */
- if ((bst(HOUR, turn) < 6) || (bst(HOUR, turn) >= 18) || (cquest.status > QUEST_STATUS_COMPLETED) || (small) || (p_ptr->town_num != 1)) return (FALSE);
+ if ((bst(HOUR, turn) < 6) || (bst(HOUR, turn) >= 18) || (cquest.status > QUEST_STATUS_COMPLETED) || (small) || (p_ptr->town_num != 1))
+ {
+ return false;
+ }
/* Find a good position */
while (tries)
@@ -94,7 +102,10 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *)
/* Is it a good spot ? */
/* Not in player los, and avoid shop grids */
if (!los(p_ptr->py, p_ptr->px, y, x) && cave_empty_bold(y, x) &&
- cave_plain_floor_bold(y, x)) break;
+ cave_plain_floor_bold(y, x))
+ {
+ break;
+ }
/* One less try */
tries--;
@@ -105,16 +116,19 @@ static bool_ quest_shroom_town_gen_hook(void *, void *in_, void *)
place_monster_one(y, x, get_farmer_maggot(), 0, FALSE, MSTATUS_ENEMY);
m_allow_special[get_farmer_maggot()] = FALSE;
- return FALSE;
+ return false;
}
-static bool_ quest_shroom_death_hook(void *, void *in_, void *)
+static bool quest_shroom_death_hook(void *, void *in_, void *)
{
struct hook_monster_death_in *in = static_cast<struct hook_monster_death_in *>(in_);
s32b m_idx = in->m_idx;
s32b r_idx = m_list[m_idx].r_idx;
- if (cquest.status > QUEST_STATUS_COMPLETED) return FALSE;
+ if (cquest.status > QUEST_STATUS_COMPLETED)
+ {
+ return false;
+ }
if ((r_idx == get_wolf()) ||
(r_idx == get_grip()) ||
@@ -123,11 +137,13 @@ static bool_ quest_shroom_death_hook(void *, void *in_, void *)
msg_print("The dog yells a last time and drops dead on the grass.");
}
- return FALSE;
+ return false;
}
-static bool_ quest_shroom_give_hook(void *, void *in_, void *)
+static bool quest_shroom_give_hook(void *, void *in_, void *)
{
+ auto const &r_info = game->edit_data.r_info;
+
struct hook_give_in *in = static_cast<struct hook_give_in *>(in_);
object_type *o_ptr;
monster_type *m_ptr;
@@ -138,7 +154,10 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *)
o_ptr = &p_ptr->inventory[item];
m_ptr = &m_list[m_idx];
- if (m_ptr->r_idx != get_farmer_maggot()) return (FALSE);
+ if (m_ptr->r_idx != get_farmer_maggot())
+ {
+ return false;
+ }
/* If one is dead .. its bad */
if ((r_info[get_grip()].max_num == 0) ||
@@ -154,10 +173,13 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *)
del_hook_new(HOOK_CHAT, quest_shroom_speak_hook);
del_hook_new(HOOK_WILD_GEN, quest_shroom_town_gen_hook);
process_hooks_restart = TRUE;
- return TRUE;
+ return true;
}
- if ((o_ptr->tval != TV_FOOD) || (o_ptr->pval2 != 1)) return (FALSE);
+ if ((o_ptr->tval != TV_FOOD) || (o_ptr->pval2 != 1))
+ {
+ return false;
+ }
/* Take a mushroom */
inc_stack_size_ex(item, -1, OPTIMIZE, NO_DESCRIBE);
@@ -181,9 +203,13 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *)
q_ptr->discount = 100;
q_ptr->ident |= IDENT_STOREB;
if (inven_carry_okay(q_ptr))
+ {
inven_carry(q_ptr, FALSE);
+ }
else
+ {
drop_near(q_ptr, 0, p_ptr->py, p_ptr->px);
+ }
/* The sling of farmer maggot */
q_ptr = &forge;
@@ -196,7 +222,7 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *)
object_known(q_ptr);
q_ptr->discount = 100;
q_ptr->ident |= IDENT_STOREB;
- (void)inven_carry(q_ptr, FALSE);
+ inven_carry(q_ptr, FALSE);
delete_monster_idx(m_idx);
@@ -206,13 +232,17 @@ static bool_ quest_shroom_give_hook(void *, void *in_, void *)
process_hooks_restart = TRUE;
}
else
+ {
msg_format("Oh thank you, but you still have %d mushrooms to bring back!", cquest.data[1] - cquest.data[0]);
+ }
- return TRUE;
+ return true;
}
static void check_dogs_alive(s32b m_idx)
{
+ auto const &r_info = game->edit_data.r_info;
+
if ((r_info[get_grip()].max_num == 0) ||
(r_info[get_wolf()].max_num == 0) ||
(r_info[get_fang()].max_num == 0))
@@ -234,12 +264,15 @@ static void check_dogs_alive(s32b m_idx)
}
}
-static bool_ quest_shroom_speak_hook(void *, void *in_, void *)
+static bool quest_shroom_speak_hook(void *, void *in_, void *)
{
struct hook_mon_speak_in *in = static_cast<struct hook_mon_speak_in *>(in_);
s32b m_idx = in->m_idx;
- if (m_list[m_idx].r_idx != get_farmer_maggot()) return (FALSE);
+ if (m_list[m_idx].r_idx != get_farmer_maggot())
+ {
+ return false;
+ }
if (cquest.status == QUEST_STATUS_UNTAKEN)
{
@@ -250,16 +283,20 @@ static bool_ quest_shroom_speak_hook(void *, void *in_, void *)
{
check_dogs_alive(m_idx);
}
- return (TRUE);
+
+ return true;
}
-static bool_ quest_shroom_chat_hook(void *, void *in_, void *)
+static bool quest_shroom_chat_hook(void *, void *in_, void *)
{
struct hook_chat_in *in = static_cast<struct hook_chat_in *>(in_);
s32b m_idx = in->m_idx;
monster_type *m_ptr = &m_list[m_idx];
- if (m_ptr->r_idx != get_farmer_maggot()) return (FALSE);
+ if (m_ptr->r_idx != get_farmer_maggot())
+ {
+ return false;
+ }
if (cquest.status == QUEST_STATUS_UNTAKEN)
{
@@ -270,18 +307,20 @@ static bool_ quest_shroom_chat_hook(void *, void *in_, void *)
msg_print("to the west of Bree? Please try to not harm my dogs. They are so lovely...");
cquest.status = QUEST_STATUS_TAKEN;
- quest[QUEST_SHROOM].init(QUEST_SHROOM);
+ quest[QUEST_SHROOM].init();
}
else
{
check_dogs_alive(m_idx);
}
- return TRUE;
+ return true;
}
-bool_ quest_shroom_init_hook(int q_idx)
+void quest_shroom_init_hook()
{
+ auto &messages = game->messages;
+
/* Get a number of 'shrooms */
if (!cquest.data[1])
{
@@ -289,7 +328,7 @@ bool_ quest_shroom_init_hook(int q_idx)
cquest.data[1] = rand_range(7, 14);
if (wizard)
{
- message_add(format("Shrooms number %d", cquest.data[1]), TERM_BLUE);
+ messages.add(format("Shrooms number %d", cquest.data[1]), TERM_BLUE);
}
}
@@ -307,5 +346,4 @@ bool_ quest_shroom_init_hook(int q_idx)
add_hook_new(HOOK_WILD_GEN, quest_shroom_town_gen_hook, "shroom_town_gen", NULL);
add_hook_new(HOOK_CHAT, quest_shroom_chat_hook, "shroom_chat", NULL);
}
- return (FALSE);
}