1 #include "spell-kind/spells-genocide.h"
2 #include "avatar/avatar.h"
3 #include "core/asking-player.h"
4 #include "core/player-redraw-types.h"
5 #include "core/stuff-handler.h"
6 #include "core/window-redrawer.h"
7 #include "dungeon/quest.h"
8 #include "floor/geometry.h"
9 #include "game-option/map-screen-options.h"
10 #include "game-option/play-record-options.h"
11 #include "game-option/special-options.h"
12 #include "grid/grid.h"
13 #include "io/cursor.h"
14 #include "io/write-diary.h"
15 #include "monster-floor/monster-remover.h"
16 #include "monster-race/monster-race.h"
17 #include "monster-race/race-flags1.h"
18 #include "monster-race/race-flags3.h"
19 #include "monster-race/race-flags7.h"
20 #include "monster/monster-describer.h"
21 #include "monster/monster-description-types.h"
22 #include "monster/monster-flag-types.h"
23 #include "monster/monster-info.h"
24 #include "monster/monster-status-setter.h"
25 #include "monster/monster-status.h"
26 #include "player/player-damage.h"
27 #include "system/floor-type-definition.h"
28 #include "system/monster-entity.h"
29 #include "system/monster-race-info.h"
30 #include "system/player-type-definition.h"
31 #include "util/bit-flags-calculator.h"
32 #include "view/display-messages.h"
35 * @brief モンスターへの単体抹殺処理サブルーチン / Delete a non-unique/non-quest monster
36 * @param m_idx 抹殺するモンスターID
38 * @param player_cast プレイヤーの魔法によるものならば TRUE
39 * @param dam_side プレイヤーへの負担ダメージ量(1d(dam_side))
40 * @param spell_name 抹殺効果を起こした魔法の名前
41 * @return 効力があった場合TRUEを返す
43 bool genocide_aux(PlayerType *player_ptr, MONSTER_IDX m_idx, int power, bool player_cast, int dam_side, concptr spell_name)
45 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
46 auto *r_ptr = &monraces_info[m_ptr->r_idx];
47 if (m_ptr->is_pet() && !player_cast) {
52 if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || any_bits(r_ptr->flags1, RF1_QUESTOR)) {
54 } else if (r_ptr->flags7 & RF7_UNIQUE2) {
56 } else if (m_idx == player_ptr->riding) {
58 } else if ((inside_quest(player_ptr->current_floor_ptr->quest_number) && !inside_quest(random_quest_number(player_ptr, player_ptr->current_floor_ptr->dun_level))) || player_ptr->current_floor_ptr->inside_arena || player_ptr->phase_out) {
60 } else if (player_cast && (r_ptr->level > randint0(power))) {
62 } else if (player_cast && m_ptr->mflag2.has(MonsterConstantFlagType::NOGENO)) {
65 if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
66 GAME_TEXT m_name[MAX_NLEN];
67 monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
68 exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
71 delete_monster_idx(player_ptr, m_idx);
74 if (resist && player_cast) {
75 bool see_m = is_seen(player_ptr, m_ptr);
76 GAME_TEXT m_name[MAX_NLEN];
77 monster_desc(player_ptr, m_name, m_ptr, 0);
79 msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
82 if (m_ptr->is_asleep()) {
83 (void)set_monster_csleep(player_ptr, m_idx, 0);
85 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
89 if (m_ptr->is_friendly() && !m_ptr->is_pet()) {
91 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
94 set_hostile(player_ptr, m_ptr);
98 m_ptr->mflag2.set(MonsterConstantFlagType::NOGENO);
103 take_hit(player_ptr, DAMAGE_GENO, randint1(dam_side), format(_("%^sの呪文を唱えた疲労", "the strain of casting %^s"), spell_name).data());
106 move_cursor_relative(player_ptr->y, player_ptr->x);
107 player_ptr->redraw |= (PR_HP);
108 player_ptr->window_flags |= (PW_PLAYER);
109 handle_stuff(player_ptr);
112 term_xtra(TERM_XTRA_DELAY, delay_factor);
118 * @brief モンスターへのシンボル抹殺処理ルーチン / Delete all non-unique/non-quest monsters of a given "type" from the level
120 * @param player_cast プレイヤーの魔法によるものならば TRUE
121 * @return 効力があった場合TRUEを返す
123 bool symbol_genocide(PlayerType *player_ptr, int power, bool player_cast)
125 auto *floor_ptr = player_ptr->current_floor_ptr;
126 bool is_special_floor = inside_quest(floor_ptr->quest_number) && !inside_quest(random_quest_number(player_ptr, floor_ptr->dun_level));
127 is_special_floor |= player_ptr->current_floor_ptr->inside_arena;
128 is_special_floor |= player_ptr->phase_out;
129 if (is_special_floor) {
130 msg_print(_("何も起きないようだ……", "Nothing seems to happen..."));
135 while (!get_com(_("どの種類(文字)のモンスターを抹殺しますか: ", "Choose a monster race (by symbol) to genocide: "), &typ, false)) {
139 for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
140 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
141 auto *r_ptr = &monraces_info[m_ptr->r_idx];
142 if (!m_ptr->is_valid()) {
145 if (r_ptr->d_char != typ) {
149 result |= genocide_aux(player_ptr, i, power, player_cast, 4, _("抹殺", "Genocide"));
153 chg_virtue(player_ptr, V_VITALITY, -2);
154 chg_virtue(player_ptr, V_CHANCE, -1);
161 * @brief モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) monsters
163 * @param player_cast プレイヤーの魔法によるものならば TRUE
164 * @return 効力があった場合TRUEを返す
166 bool mass_genocide(PlayerType *player_ptr, int power, bool player_cast)
168 auto *floor_ptr = player_ptr->current_floor_ptr;
169 bool is_special_floor = inside_quest(floor_ptr->quest_number) && !inside_quest(random_quest_number(player_ptr, floor_ptr->dun_level));
170 is_special_floor |= player_ptr->current_floor_ptr->inside_arena;
171 is_special_floor |= player_ptr->phase_out;
172 if (is_special_floor) {
177 for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
178 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
179 if (!m_ptr->is_valid()) {
182 if (m_ptr->cdis > MAX_PLAYER_SIGHT) {
186 result |= genocide_aux(player_ptr, i, power, player_cast, 3, _("周辺抹殺", "Mass Genocide"));
190 chg_virtue(player_ptr, V_VITALITY, -2);
191 chg_virtue(player_ptr, V_CHANCE, -1);
198 * @brief アンデッド・モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) undead
200 * @param player_cast プレイヤーの魔法によるものならば TRUE
201 * @return 効力があった場合TRUEを返す
203 bool mass_genocide_undead(PlayerType *player_ptr, int power, bool player_cast)
205 auto *floor_ptr = player_ptr->current_floor_ptr;
206 bool is_special_floor = inside_quest(floor_ptr->quest_number) && !inside_quest(random_quest_number(player_ptr, floor_ptr->dun_level));
207 is_special_floor |= player_ptr->current_floor_ptr->inside_arena;
208 is_special_floor |= player_ptr->phase_out;
209 if (is_special_floor) {
214 for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
215 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
216 auto *r_ptr = &monraces_info[m_ptr->r_idx];
217 if (!m_ptr->is_valid()) {
220 if (r_ptr->kind_flags.has_not(MonsterKindType::UNDEAD)) {
223 if (m_ptr->cdis > MAX_PLAYER_SIGHT) {
227 result |= genocide_aux(player_ptr, i, power, player_cast, 3, _("アンデッド消滅", "Annihilate Undead"));
231 chg_virtue(player_ptr, V_UNLIFE, -2);
232 chg_virtue(player_ptr, V_CHANCE, -1);