2 * @brief モンスター死亡時の特殊処理switch (一般的な処理もdefaultで実施)
7 #include "monster-floor/special-death-switcher.h"
8 #include "artifact/fixed-art-generator.h"
9 #include "artifact/fixed-art-types.h"
10 #include "artifact/random-art-generator.h"
11 #include "effect/effect-characteristics.h"
12 #include "effect/effect-processor.h"
13 #include "floor/cave.h"
14 #include "floor/floor-object.h"
15 #include "floor/floor-util.h"
16 #include "floor/geometry.h"
17 #include "game-option/birth-options.h"
18 #include "grid/grid.h"
19 #include "main/sound-definitions-table.h"
20 #include "main/sound-of-music.h"
21 #include "monster-floor/monster-death-util.h"
22 #include "monster-floor/monster-summon.h"
23 #include "monster-floor/place-monster-types.h"
24 #include "monster-race/monster-race.h"
25 #include "monster-race/race-indice-types.h"
26 #include "monster/monster-describer.h"
27 #include "monster/monster-description-types.h"
28 #include "monster/monster-info.h"
29 #include "object-enchant/apply-magic.h"
30 #include "object-enchant/item-apply-magic.h"
31 #include "object-hook/hook-checker.h"
32 #include "object/object-generator.h"
33 #include "object/object-kind-hook.h"
34 #include "spell/spell-types.h"
35 #include "spell/summon-types.h"
36 #include "sv-definition/sv-other-types.h"
37 #include "sv-definition/sv-protector-types.h"
38 #include "sv-definition/sv-weapon-types.h"
39 #include "system/artifact-type-definition.h"
40 #include "system/floor-type-definition.h"
41 #include "system/monster-race-definition.h"
42 #include "system/monster-type-definition.h"
43 #include "system/object-type-definition.h"
44 #include "system/player-type-definition.h"
45 #include "view/display-messages.h"
46 #include "world/world.h"
49 * @brief 死亡時召喚処理 (今のところ自分自身のみ)
50 * @param player_ptr プレーヤーへの参照ポインタ
51 * @param md_ptr モンスター撃破構造体への参照ポインタ
53 * @param probability 召喚確率 (計算式:1 - 1/probability)
54 * @param radius 召喚半径 (モンスターが死亡した座標から半径何マス以内に召喚させるか)
55 * @param message 召喚時のメッセージ
57 static void summon_self(player_type *player_ptr, monster_death_type *md_ptr, summon_type type, int probability, POSITION radius, concptr message)
59 floor_type *floor_ptr = player_ptr->current_floor_ptr;
60 if (floor_ptr->inside_arena || player_ptr->phase_out || one_in_(probability))
63 POSITION wy = md_ptr->md_y;
64 POSITION wx = md_ptr->md_x;
66 bool pet = is_pet(md_ptr->m_ptr);
68 scatter(player_ptr, &wy, &wx, md_ptr->md_y, md_ptr->md_x, radius, PROJECT_NONE);
69 } while (!(in_bounds(floor_ptr, wy, wx) && is_cave_empty_bold2(player_ptr, wy, wx)) && --attempts);
74 BIT_FLAGS mode = pet ? PM_FORCE_PET : PM_NONE;
75 if (summon_specific(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, 100, type, mode) && player_can_see_bold(player_ptr, wy, wx))
79 static void on_dead_pink_horror(player_type *player_ptr, monster_death_type *md_ptr)
81 if (player_ptr->current_floor_ptr->inside_arena || player_ptr->phase_out)
85 const int blue_horrors = 2;
86 for (int i = 0; i < blue_horrors; i++) {
87 POSITION wy = md_ptr->md_y;
88 POSITION wx = md_ptr->md_x;
89 bool pet = is_pet(md_ptr->m_ptr);
90 BIT_FLAGS mode = pet ? PM_FORCE_PET : PM_NONE;
91 if (summon_specific(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode) && player_can_see_bold(player_ptr, wy, wx))
96 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
99 static void on_dead_bloodletter(player_type *player_ptr, monster_death_type *md_ptr)
101 if (!md_ptr->drop_chosen_item || (randint1(100) >= 15))
105 object_type *q_ptr = &forge;
106 object_prep(player_ptr, q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
107 apply_magic_to_object(player_ptr, q_ptr, player_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART | md_ptr->mo_mode);
108 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
111 static void on_dead_raal(player_type *player_ptr, monster_death_type *md_ptr)
113 floor_type *floor_ptr = player_ptr->current_floor_ptr;
114 if (!md_ptr->drop_chosen_item || (floor_ptr->dun_level <= 9))
118 object_type *q_ptr = &forge;
120 if ((floor_ptr->dun_level > 49) && one_in_(5))
121 get_obj_num_hook = kind_is_good_book;
123 get_obj_num_hook = kind_is_book;
125 make_object(player_ptr, q_ptr, md_ptr->mo_mode);
126 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
130 * @brief 6/7の確率で、20マス以内に暁の戦士自身を召喚する
131 * @param player_ptr プレーヤーへの参照ポインタ
132 * @param md_ptr モンスター撃破構造体への参照ポインタ
134 static void on_dead_dawn(player_type *player_ptr, monster_death_type *md_ptr)
136 summon_self(player_ptr, md_ptr, SUMMON_DAWN, 7, 20, _("新たな戦士が現れた!", "A new warrior steps forth!"));
139 static void on_dead_unmaker(player_type *player_ptr, monster_death_type *md_ptr)
141 if (is_seen(player_ptr, md_ptr->m_ptr)) {
142 GAME_TEXT m_name[MAX_NLEN];
143 monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_NONE);
144 msg_format(_("%sは辺りにログルスの残り香を撒き散らした!", "%^s sprinkled the remaining incense from Logrus!"), m_name);
147 (void)project(player_ptr, md_ptr->m_idx, 6, md_ptr->md_y, md_ptr->md_x, 100, GF_CHAOS, PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL);
150 static void on_dead_sacred_treasures(player_type *player_ptr, monster_death_type *md_ptr)
152 if ((player_ptr->pseikaku != PERSONALITY_LAZY) || !md_ptr->drop_chosen_item)
155 ARTIFACT_IDX a_idx = 0;
156 artifact_type *a_ptr = NULL;
158 switch (randint0(3)) {
160 a_idx = ART_NAMAKE_HAMMER;
163 a_idx = ART_NAMAKE_BOW;
166 a_idx = ART_NAMAKE_ARMOR;
170 a_ptr = &a_info[a_idx];
171 } while (a_ptr->cur_num == 1);
173 if (create_named_art(player_ptr, a_idx, md_ptr->md_y, md_ptr->md_x)) {
175 if (current_world_ptr->character_dungeon)
176 a_ptr->floor_id = player_ptr->floor_id;
185 static void on_dead_serpent(player_type *player_ptr, monster_death_type *md_ptr)
187 if (!md_ptr->drop_chosen_item)
191 object_type *q_ptr = &forge;
192 object_prep(player_ptr, q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
193 q_ptr->name1 = ART_GROND;
194 apply_magic_to_object(player_ptr, q_ptr, -1, AM_GOOD | AM_GREAT);
195 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
197 object_prep(player_ptr, q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
198 q_ptr->name1 = ART_CHAOS;
199 apply_magic_to_object(player_ptr, q_ptr, -1, AM_GOOD | AM_GREAT);
200 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
203 static void on_dead_death_sword(player_type *player_ptr, monster_death_type *md_ptr)
205 if (!md_ptr->drop_chosen_item)
209 object_type *q_ptr = &forge;
210 object_prep(player_ptr, q_ptr, lookup_kind(TV_SWORD, randint1(2)));
211 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
214 static void on_dead_can_angel(player_type *player_ptr, monster_death_type *md_ptr)
216 bool is_drop_can = md_ptr->drop_chosen_item;
217 bool is_silver = md_ptr->m_ptr->r_idx == MON_A_SILVER;
218 is_silver &= md_ptr->r_ptr->r_akills % 5 == 0;
219 is_drop_can &= (md_ptr->m_ptr->r_idx == MON_A_GOLD) || is_silver;
224 object_type *q_ptr = &forge;
225 object_prep(player_ptr, q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
226 apply_magic_to_object(player_ptr, q_ptr, player_ptr->current_floor_ptr->object_level, AM_NO_FIXED_ART);
227 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
230 static void on_dead_rolento(player_type *player_ptr, monster_death_type *md_ptr)
232 if (is_seen(player_ptr, md_ptr->m_ptr)) {
233 GAME_TEXT m_name[MAX_NLEN];
234 monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_NONE);
235 msg_format(_("%sは手榴弾を抱えて自爆した!", "%^s blew himself up with grenades!"), m_name);
238 (void)project(player_ptr, md_ptr->m_idx, 3, md_ptr->md_y, md_ptr->md_x, damroll(20, 10), GF_FIRE, PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL);
241 static void on_dead_aqua_illusion(player_type *player_ptr, monster_death_type *md_ptr)
243 if (player_ptr->current_floor_ptr->inside_arena || player_ptr->phase_out)
247 const int popped_bubbles = 4;
248 for (int i = 0; i < popped_bubbles; i++) {
249 POSITION wy = md_ptr->md_y;
250 POSITION wx = md_ptr->md_x;
251 bool pet = is_pet(md_ptr->m_ptr);
252 BIT_FLAGS mode = pet ? PM_FORCE_PET : PM_NONE;
253 MONSTER_IDX smaller_bubble = md_ptr->m_ptr->r_idx - 1;
254 if (summon_named_creature(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, smaller_bubble, mode) && player_can_see_bold(player_ptr, wy, wx))
259 msg_print(_("泡が弾けた!", "The bubble pops!"));
265 * @brief 7/8の確率で、5マス以内にトーテムモアイ自身を召喚する
266 * @param player_ptr プレーヤーへの参照ポインタ
267 * @param md_ptr モンスター撃破構造体への参照ポインタ
269 static void on_dead_totem_moai(player_type *player_ptr, monster_death_type *md_ptr)
271 summon_self(player_ptr, md_ptr, SUMMON_TOTEM_MOAI, 8, 5, _("新たなモアイが現れた!", "A new moai steps forth!"));
274 static void on_dead_demon_slayer_senior(player_type *player_ptr, monster_death_type *md_ptr)
276 if (!is_seen(player_ptr, md_ptr->m_ptr))
279 GAME_TEXT m_name[MAX_NLEN];
280 monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_NONE);
281 msg_format(_("あなたの闘気が%sの身体をサイコロ状に切り刻んだ!", "Your fighting spirit chopped %^s's body into dice!"), m_name);
284 static void on_dead_mirmulnir(player_type *player_ptr, monster_death_type *md_ptr)
286 if (!is_seen(player_ptr, md_ptr->m_ptr))
289 GAME_TEXT m_name[MAX_NLEN];
290 monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_NONE);
291 msg_format(_("%s「ドヴ@ーキン、やめろぉ!」", "%^s says, 'Dov@hkiin! No!!'"), m_name);
294 static void on_dead_dragon_centipede(player_type *player_ptr, monster_death_type *md_ptr)
296 if (player_ptr->current_floor_ptr->inside_arena || player_ptr->phase_out)
300 const int reproduced_centipede = 2;
301 for (int i = 0; i < reproduced_centipede; i++) {
302 POSITION wy = md_ptr->md_y;
303 POSITION wx = md_ptr->md_x;
304 bool pet = is_pet(md_ptr->m_ptr);
305 BIT_FLAGS mode = pet ? PM_FORCE_PET : PM_NONE;
306 MONSTER_IDX smaller_centipede = md_ptr->m_ptr->r_idx - 1;
307 if (summon_named_creature(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, smaller_centipede, mode) && player_can_see_bold(player_ptr, wy, wx))
311 GAME_TEXT m_name[MAX_NLEN];
312 monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_NONE);
314 msg_format(_("%sが再生した!", "The %s reproduced!"), m_name);
320 * @brief ビッグキューちゃん撃破時メッセージ
321 * @todo 死亡時の特殊メッセージを表示するだけの処理を複数作るなら、switch/case文に分けられるように汎用化すること
323 static void on_dead_big_raven(player_type *player_ptr, monster_death_type *md_ptr)
325 if (!is_seen(player_ptr, md_ptr->m_ptr))
328 GAME_TEXT m_name[MAX_NLEN];
329 monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_NONE);
330 msg_format(_("%sはお星さまになった!", "%^s became a constellation!"), m_name);
335 * @param player_ptr プレーヤーへの参照ポインタ
336 * @param q_ptr 生成中アイテムへの参照ポインタ
337 * @param drop_mode ドロップ品の質
338 * @param is_object_hook_null アイテム種別が何でもありならtrue、指定されていればfalse
339 * @return 生成したアイテムが装備品ならtrue、それ以外ならfalse
340 * @todo 汎用的に使えそうだがどこかにいいファイルはないか?
342 static bool make_equipment(player_type *player_ptr, object_type *q_ptr, const BIT_FLAGS drop_mode, const bool is_object_hook_null)
345 (void)make_object(player_ptr, q_ptr, drop_mode);
346 if (!is_object_hook_null) {
350 auto tval = q_ptr->tval;
376 * @brief 死亡時ドロップとしてランダムアーティファクトのみを生成する
377 * @param player_ptr プレーヤーへの参照ポインタ
378 * @param md_ptr モンスター撃破構造体への参照ポインタ
379 * @param object_hook_pf アイテム種別指定、特になければNULLで良い
382 * 最初のアイテム生成でいきなり☆が生成された場合を除き、中途半端な☆ (例:呪われている)は生成しない.
383 * このルーチンで★は生成されないので、★生成フラグのキャンセルも不要
385 static void on_dead_random_artifact(player_type *player_ptr, monster_death_type *md_ptr, bool (*object_hook_pf)(KIND_OBJECT_IDX k_idx))
388 object_type *q_ptr = &forge;
389 auto is_object_hook_null = object_hook_pf == NULL;
390 auto drop_mode = md_ptr->mo_mode | AM_NO_FIXED_ART;
392 // make_object() の中でアイテム種別をキャンセルしている
393 // よってこのwhileループ中へ入れないと、引数で指定していない種別のアイテムが選ばれる可能性がある
394 get_obj_num_hook = object_hook_pf;
395 if (!make_equipment(player_ptr, q_ptr, drop_mode, is_object_hook_null)) {
399 if (q_ptr->art_name > 0) {
403 if ((q_ptr->name1 != 0) && q_ptr->name2 != 0) {
407 (void)become_random_artifact(player_ptr, q_ptr, false);
408 auto is_good_random_art = !object_is_cursed(q_ptr);
409 is_good_random_art &= q_ptr->to_h > 0;
410 is_good_random_art &= q_ptr->to_d > 0;
411 is_good_random_art &= q_ptr->to_a > 0;
412 is_good_random_art &= q_ptr->pval > 0;
413 if (is_good_random_art) {
418 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
422 * @brief マニマニのあくま撃破時メッセージ
423 * @todo 死亡時の特殊メッセージを表示するだけの処理を複数作るなら、switch/case文に分けられるように汎用化すること
425 static void on_dead_manimani(player_type *player_ptr, monster_death_type *md_ptr)
427 if (!is_seen(player_ptr, md_ptr->m_ptr))
430 msg_print(_("どこからか声が聞こえる…「ハロー! そして…グッドバイ!」", "Heard a voice from somewhere... 'Hello! And... good bye!'"));
433 static void drop_specific_item_on_dead(player_type *player_ptr, monster_death_type *md_ptr, bool (*object_hook_pf)(KIND_OBJECT_IDX k_idx))
436 object_type *q_ptr = &forge;
438 get_obj_num_hook = object_hook_pf;
439 (void)make_object(player_ptr, q_ptr, md_ptr->mo_mode);
440 (void)drop_near(player_ptr, q_ptr, -1, md_ptr->md_y, md_ptr->md_x);
443 static void on_dead_mimics(player_type *player_ptr, monster_death_type *md_ptr)
445 if (!md_ptr->drop_chosen_item)
448 switch (md_ptr->r_ptr->d_char) {
450 if (player_ptr->current_floor_ptr->dun_level <= 0)
453 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_cloak);
456 if (player_ptr->current_floor_ptr->dun_level <= 4)
459 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_polearm);
462 if (player_ptr->current_floor_ptr->dun_level <= 19)
465 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_armor);
468 if (player_ptr->current_floor_ptr->dun_level <= 4)
471 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_hafted);
474 if (md_ptr->m_ptr->r_idx == MON_STORMBRINGER)
477 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_sword);
480 if (player_ptr->current_floor_ptr->dun_level <= 19)
483 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_boots);
490 void switch_special_death(player_type *player_ptr, monster_death_type *md_ptr)
492 switch (md_ptr->m_ptr->r_idx) {
493 case MON_PINK_HORROR:
494 on_dead_pink_horror(player_ptr, md_ptr);
496 case MON_BLOODLETTER:
497 on_dead_bloodletter(player_ptr, md_ptr);
500 on_dead_raal(player_ptr, md_ptr);
503 on_dead_dawn(player_ptr, md_ptr);
506 on_dead_unmaker(player_ptr, md_ptr);
508 case MON_UNICORN_ORD:
511 on_dead_sacred_treasures(player_ptr, md_ptr);
514 on_dead_serpent(player_ptr, md_ptr);
516 case MON_B_DEATH_SWORD:
517 on_dead_death_sword(player_ptr, md_ptr);
521 on_dead_can_angel(player_ptr, md_ptr);
524 on_dead_rolento(player_ptr, md_ptr);
526 case MON_MIDDLE_AQUA_FIRST:
527 case MON_LARGE_AQUA_FIRST:
528 case MON_EXTRA_LARGE_AQUA_FIRST:
529 case MON_MIDDLE_AQUA_SECOND:
530 case MON_LARGE_AQUA_SECOND:
531 case MON_EXTRA_LARGE_AQUA_SECOND:
532 on_dead_aqua_illusion(player_ptr, md_ptr);
535 on_dead_totem_moai(player_ptr, md_ptr);
537 case MON_DEMON_SLAYER_SENIOR:
538 on_dead_demon_slayer_senior(player_ptr, md_ptr);
541 on_dead_mirmulnir(player_ptr, md_ptr);
543 case MON_DRAGON_CENTIPEDE:
544 case MON_DRAGON_WORM:
545 on_dead_dragon_centipede(player_ptr, md_ptr);
548 drop_specific_item_on_dead(player_ptr, md_ptr, kind_is_boots);
551 on_dead_big_raven(player_ptr, md_ptr);
553 case MON_YENDOR_WIZARD_1:
554 case MON_YENDOR_WIZARD_2:
555 on_dead_random_artifact(player_ptr, md_ptr, kind_is_amulet);
558 on_dead_manimani(player_ptr, md_ptr);
561 on_dead_random_artifact(player_ptr, md_ptr, kind_is_sword);
564 on_dead_mimics(player_ptr, md_ptr);