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);
31 concptr rumor_bind_name(char *base, concptr fullname)
34 s = strstr(base, "{Name}");
37 v = format("%s%s%s", base, fullname, (s + 6));
45 void display_rumor(PlayerType *player_ptr, bool ex)
48 int section = (ex && (randint0(3) == 0)) ? 1 : 0;
49 errr err = _(get_rnd_line_jonly("rumors_j.txt", section, rumor, 10), get_rnd_line("rumors.txt", section, rumor));
51 strcpy(rumor, _("嘘の噂もある。", "Some rumors are wrong."));
54 if (strncmp(rumor, "R:", 2) != 0) {
55 msg_format("%s", rumor);
60 if (tokenize(rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) != 3) {
61 msg_print(_("この情報は間違っている。", "This information is wrong."));
65 concptr rumor_eff_format = nullptr;
66 char fullname[1024] = "";
67 if (strcmp(zz[0], "ARTIFACT") == 0) {
71 a_idx = rumor_num(zz[1], static_cast<IDX>(a_info.size()));
73 a_ptr = &a_info[a_idx];
74 if (!a_ptr->name.empty()) {
79 KIND_OBJECT_IDX k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
83 q_ptr->fixed_artifact_idx = a_idx;
84 q_ptr->ident = IDENT_STORE;
85 describe_flavor(player_ptr, fullname, q_ptr, OD_NAME_ONLY);
86 } else if (strcmp(zz[0], "MONSTER") == 0) {
89 auto r_idx = i2enum<MonsterRaceId>(rumor_num(zz[1], static_cast<IDX>(r_info.size())));
90 r_ptr = &r_info[r_idx];
91 if (!r_ptr->name.empty()) {
96 strcpy(fullname, r_ptr->name.c_str());
98 if (!r_ptr->r_sights) {
101 } else if (strcmp(zz[0], "DUNGEON") == 0) {
105 d_idx = rumor_num(zz[1], static_cast<IDX>(d_info.size()));
106 d_ptr = &d_info[d_idx];
107 if (!d_ptr->name.empty()) {
112 strcpy(fullname, d_ptr->name.c_str());
114 if (!max_dlv[d_idx]) {
115 max_dlv[d_idx] = d_ptr->mindepth;
116 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
118 } else if (strcmp(zz[0], "TOWN") == 0) {
121 t_idx = rumor_num(zz[1], NO_TOWN);
122 if (town_info[t_idx].name[0] != '\0') {
127 strcpy(fullname, town_info[t_idx].name);
129 int32_t visit = (1UL << (t_idx - 1));
130 if ((t_idx != SECRET_TOWN) && !(player_ptr->visit & visit)) {
131 player_ptr->visit |= visit;
132 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
136 concptr rumor_msg = rumor_bind_name(zz[2], fullname);
137 msg_print(rumor_msg);
138 if (rumor_eff_format) {
140 msg_format(rumor_eff_format, fullname);