1 #include "store/rumor.h"
2 #include "dungeon/dungeon.h"
3 #include "flavor/flavor-describer.h"
4 #include "flavor/object-flavor-types.h"
5 #include "floor/floor-town.h"
6 #include "floor/wild.h"
7 #include "io/files-util.h"
8 #include "io/tokenizer.h"
9 #include "monster-race/monster-race.h"
10 #include "object-enchant/special-object-flags.h"
11 #include "object/object-kind-hook.h"
12 #include "system/artifact-type-definition.h"
13 #include "system/monster-race-definition.h"
14 #include "system/object-type-definition.h"
15 #include "system/player-type-definition.h"
16 #include "view/display-messages.h"
17 #include "world/world.h"
20 * Display a rumor and apply its effects
23 IDX rumor_num(char *zz, IDX max_idx)
25 if (strcmp(zz, "*") == 0)
26 return randint1(max_idx - 1);
30 concptr rumor_bind_name(char *base, concptr fullname)
33 s = strstr(base, "{Name}");
36 v = format("%s%s%s", base, fullname, (s + 6));
44 void display_rumor(player_type *player_ptr, bool ex)
47 int section = (ex && (randint0(3) == 0)) ? 1 : 0;
48 errr err = _(get_rnd_line_jonly("rumors_j.txt", section, rumor, 10), get_rnd_line("rumors.txt", section, rumor));
50 strcpy(rumor, _("嘘の噂もある。", "Some rumors are wrong."));
52 if (strncmp(rumor, "R:", 2) != 0) {
53 msg_format("%s", rumor);
58 if (tokenize(rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) != 3) {
59 msg_print(_("この情報は間違っている。", "This information is wrong."));
63 concptr rumor_eff_format = NULL;
64 char fullname[1024] = "";
65 if (strcmp(zz[0], "ARTIFACT") == 0) {
69 a_idx = rumor_num(zz[1], max_a_idx);
71 a_ptr = &a_info[a_idx];
72 if (!a_ptr->name.empty())
76 KIND_OBJECT_IDX k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
78 object_type *q_ptr = &forge;
79 q_ptr->prep(player_ptr, k_idx);
81 q_ptr->ident = IDENT_STORE;
82 describe_flavor(player_ptr, fullname, q_ptr, OD_NAME_ONLY);
83 } else if (strcmp(zz[0], "MONSTER") == 0) {
86 MONRACE_IDX r_idx = rumor_num(zz[1], max_r_idx);
87 r_ptr = &r_info[r_idx];
88 if (!r_ptr->name.empty())
92 strcpy(fullname, r_ptr->name.c_str());
94 if (!r_ptr->r_sights) {
97 } else if (strcmp(zz[0], "DUNGEON") == 0) {
101 d_idx = rumor_num(zz[1], current_world_ptr->max_d_idx);
102 d_ptr = &d_info[d_idx];
103 if (!d_ptr->name.empty())
107 strcpy(fullname, d_ptr->name.c_str());
109 if (!max_dlv[d_idx]) {
110 max_dlv[d_idx] = d_ptr->mindepth;
111 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
113 } else if (strcmp(zz[0], "TOWN") == 0) {
116 t_idx = rumor_num(zz[1], NO_TOWN);
117 if (town_info[t_idx].name[0] != '\0')
121 strcpy(fullname, town_info[t_idx].name);
123 s32b visit = (1UL << (t_idx - 1));
124 if ((t_idx != SECRET_TOWN) && !(player_ptr->visit & visit)) {
125 player_ptr->visit |= visit;
126 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
130 concptr rumor_msg = rumor_bind_name(zz[2], fullname);
131 msg_print(rumor_msg);
132 if (rumor_eff_format) {
134 msg_format(rumor_eff_format, fullname);