1 #include "spell/spells-genocide.h"
2 #include "core/stuff-handler.h"
3 #include "dungeon/quest.h"
4 #include "floor/floor.h"
5 #include "io/write-diary.h"
6 #include "monster/monster-status.h"
7 #include "player/avatar.h"
8 #include "player/player-damage.h"
9 #include "view/display-main-window.h"
12 * @brief モンスターへの単体抹殺処理サブルーチン / Delete a non-unique/non-quest monster
13 * @param m_idx 抹殺するモンスターID
15 * @param player_cast プレイヤーの魔法によるものならば TRUE
16 * @param dam_side プレイヤーへの負担ダメージ量(1d(dam_side))
17 * @param spell_name 抹殺効果を起こした魔法の名前
18 * @return 効力があった場合TRUEを返す
20 bool genocide_aux(player_type *caster_ptr, MONSTER_IDX m_idx, int power, bool player_cast, int dam_side, concptr spell_name)
22 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
23 monster_race *r_ptr = &r_info[m_ptr->r_idx];
24 if (is_pet(m_ptr) && !player_cast)
28 if (r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR))
30 else if (r_ptr->flags7 & RF7_UNIQUE2)
32 else if (m_idx == caster_ptr->riding)
34 else if ((caster_ptr->current_floor_ptr->inside_quest && !random_quest_number(caster_ptr, caster_ptr->current_floor_ptr->dun_level))
35 || caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out)
37 else if (player_cast && (r_ptr->level > randint0(power)))
39 else if (player_cast && (m_ptr->mflag2 & MFLAG2_NOGENO))
42 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
43 GAME_TEXT m_name[MAX_NLEN];
44 monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
45 exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
48 delete_monster_idx(caster_ptr, m_idx);
51 if (resist && player_cast) {
52 bool see_m = is_seen(m_ptr);
53 GAME_TEXT m_name[MAX_NLEN];
54 monster_desc(caster_ptr, m_name, m_ptr, 0);
56 msg_format(_("%^sには効果がなかった。", "%^s is unaffected."), m_name);
59 if (MON_CSLEEP(m_ptr)) {
60 (void)set_monster_csleep(caster_ptr, m_idx, 0);
62 msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
66 if (is_friendly(m_ptr) && !is_pet(m_ptr)) {
68 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
71 set_hostile(caster_ptr, m_ptr);
75 m_ptr->mflag2 |= MFLAG2_NOGENO;
79 take_hit(caster_ptr, DAMAGE_GENO, randint1(dam_side), format(_("%^sの呪文を唱えた疲労", "the strain of casting %^s"), spell_name), -1);
82 move_cursor_relative(caster_ptr->y, caster_ptr->x);
83 caster_ptr->redraw |= (PR_HP);
84 caster_ptr->window |= (PW_PLAYER);
85 handle_stuff(caster_ptr);
88 int msec = delay_factor * delay_factor * delay_factor;
89 Term_xtra(TERM_XTRA_DELAY, msec);
95 * @brief モンスターへのシンボル抹殺処理ルーチン / Delete all non-unique/non-quest monsters of a given "type" from the level
97 * @param player_cast プレイヤーの魔法によるものならば TRUE
98 * @return 効力があった場合TRUEを返す
100 bool symbol_genocide(player_type *caster_ptr, int power, bool player_cast)
102 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
103 bool is_special_floor = floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level);
104 is_special_floor |= caster_ptr->current_floor_ptr->inside_arena;
105 is_special_floor |= caster_ptr->phase_out;
106 if (is_special_floor) {
107 msg_print(_("何も起きないようだ……", "It seems nothing happen here..."));
112 while (!get_com(_("どの種類(文字)のモンスターを抹殺しますか: ", "Choose a monster race (by symbol) to genocide: "), &typ, FALSE))
115 for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
116 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
117 monster_race *r_ptr = &r_info[m_ptr->r_idx];
118 if (!monster_is_valid(m_ptr))
120 if (r_ptr->d_char != typ)
123 result |= genocide_aux(caster_ptr, i, power, player_cast, 4, _("抹殺", "Genocide"));
127 chg_virtue(caster_ptr, V_VITALITY, -2);
128 chg_virtue(caster_ptr, V_CHANCE, -1);
135 * @brief モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) monsters
137 * @param player_cast プレイヤーの魔法によるものならば TRUE
138 * @return 効力があった場合TRUEを返す
140 bool mass_genocide(player_type *caster_ptr, int power, bool player_cast)
142 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
143 bool is_special_floor = floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level);
144 is_special_floor |= caster_ptr->current_floor_ptr->inside_arena;
145 is_special_floor |= caster_ptr->phase_out;
146 if (is_special_floor) {
151 for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
152 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
153 if (!monster_is_valid(m_ptr))
155 if (m_ptr->cdis > MAX_SIGHT)
158 result |= genocide_aux(caster_ptr, i, power, player_cast, 3, _("周辺抹殺", "Mass Genocide"));
162 chg_virtue(caster_ptr, V_VITALITY, -2);
163 chg_virtue(caster_ptr, V_CHANCE, -1);
170 * @brief アンデッド・モンスターへの周辺抹殺処理ルーチン / Delete all nearby (non-unique) undead
172 * @param player_cast プレイヤーの魔法によるものならば TRUE
173 * @return 効力があった場合TRUEを返す
175 bool mass_genocide_undead(player_type *caster_ptr, int power, bool player_cast)
177 floor_type *floor_ptr = caster_ptr->current_floor_ptr;
178 bool is_special_floor = floor_ptr->inside_quest && !random_quest_number(caster_ptr, floor_ptr->dun_level);
179 is_special_floor |= caster_ptr->current_floor_ptr->inside_arena;
180 is_special_floor |= caster_ptr->phase_out;
181 if (is_special_floor) {
186 for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) {
187 monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i];
188 monster_race *r_ptr = &r_info[m_ptr->r_idx];
189 if (!monster_is_valid(m_ptr))
191 if (!(r_ptr->flags3 & RF3_UNDEAD))
193 if (m_ptr->cdis > MAX_SIGHT)
196 result |= genocide_aux(caster_ptr, i, power, player_cast, 3, _("アンデッド消滅", "Annihilate Undead"));
200 chg_virtue(caster_ptr, V_UNLIFE, -2);
201 chg_virtue(caster_ptr, V_CHANCE, -1);