OSDN Git Service

[Refactor] #40577 Separated line-of-sight.c/h from floor.c/h
[hengband/hengband.git] / src / monster-floor / monster-death.c
1 #include "monster-floor/monster-death.h"
2 #include "art-definition/art-armor-types.h"
3 #include "art-definition/art-bow-types.h"
4 #include "art-definition/art-protector-types.h"
5 #include "art-definition/art-weapon-types.h"
6 #include "art-definition/random-art-effects.h"
7 #include "artifact/fixed-art-generator.h"
8 #include "core/player-redraw-types.h"
9 #include "core/player-update-types.h"
10 #include "dungeon/dungeon.h"
11 #include "dungeon/quest-completion-checker.h"
12 #include "effect/effect-characteristics.h"
13 #include "effect/effect-processor.h"
14 #include "floor/cave.h"
15 #include "floor/floor-object.h"
16 #include "floor/floor.h"
17 #include "game-option/birth-options.h"
18 #include "game-option/play-record-options.h"
19 #include "grid/grid.h"
20 #include "io/write-diary.h"
21 #include "lore/lore-store.h"
22 #include "main/music-definitions-table.h"
23 #include "main/sound-of-music.h"
24 #include "market/arena-info-table.h"
25 #include "monster-floor/monster-object.h"
26 #include "monster-floor/monster-summon.h"
27 #include "monster-floor/place-monster-types.h"
28 #include "monster-race/monster-race-hook.h"
29 #include "monster-race/monster-race.h"
30 #include "monster-race/race-flags1.h"
31 #include "monster-race/race-flags2.h"
32 #include "monster-race/race-flags7.h"
33 #include "monster-race/race-flags9.h"
34 #include "monster-race/race-indice-types.h"
35 #include "monster/monster-describer.h"
36 #include "monster/monster-description-types.h"
37 #include "monster/monster-flag-types.h"
38 #include "monster/monster-info.h"
39 #include "monster/monster-list.h"
40 #include "monster/smart-learn-types.h"
41 #include "object-enchant/apply-magic.h"
42 #include "object-enchant/item-apply-magic.h"
43 #include "object/object-generator.h"
44 #include "object/object-kind-hook.h"
45 #include "pet/pet-fall-off.h"
46 #include "player/patron.h"
47 #include "spell/spell-types.h"
48 #include "spell/spells-summon.h"
49 #include "sv-definition/sv-other-types.h"
50 #include "sv-definition/sv-protector-types.h"
51 #include "sv-definition/sv-scroll-types.h"
52 #include "sv-definition/sv-weapon-types.h"
53 #include "system/artifact-type-definition.h"
54 #include "system/floor-type-definition.h"
55 #include "system/monster-type-definition.h"
56 #include "system/system-variables.h"
57 #include "view/display-messages.h"
58 #include "world/world.h"
59
60 /*!
61  * @brief モンスターを倒した際の財宝svalを返す
62  * @param r_idx 倒したモンスターの種族ID
63  * @return 財宝のsval
64  * @details
65  * Hack -- Return the "automatic coin type" of a monster race
66  * Used to allocate proper treasure when "Creeping coins" die
67  * Note the use of actual "monster names"
68  */
69 static OBJECT_SUBTYPE_VALUE get_coin_type(MONRACE_IDX r_idx)
70 {
71     switch (r_idx) {
72     case MON_COPPER_COINS:
73         return 2;
74     case MON_SILVER_COINS:
75         return 5;
76     case MON_GOLD_COINS:
77         return 10;
78     case MON_MITHRIL_COINS:
79     case MON_MITHRIL_GOLEM:
80         return 16;
81     case MON_ADAMANT_COINS:
82         return 17;
83     }
84
85     return 0;
86 }
87
88 /*!
89  * @brief モンスターが死亡した時の処理 /
90  * Handle the "death" of a monster.
91  * @param m_idx 死亡したモンスターのID
92  * @param drop_item TRUEならばモンスターのドロップ処理を行う
93  * @return 撃破されたモンスターの述語
94  * @details
95  * <pre>
96  * Disperse treasures centered at the monster location based on the
97  * various flags contained in the monster flags fields.
98  * Check for "Quest" completion when a quest monster is killed.
99  * Note that only the player can induce "monster_death()" on Uniques.
100  * Thus (for now) all Quest monsters should be Uniques.
101  * Note that monsters can now carry objects, and when a monster dies,
102  * it drops all of its objects, which may disappear in crowded rooms.
103  * </pre>
104  */
105 void monster_death(player_type *player_ptr, MONSTER_IDX m_idx, bool drop_item)
106 {
107     floor_type *floor_ptr = player_ptr->current_floor_ptr;
108     monster_type *m_ptr = &floor_ptr->m_list[m_idx];
109     monster_race *r_ptr = &r_info[m_ptr->r_idx];
110
111     bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
112     bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
113     bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
114     int force_coin = get_coin_type(m_ptr->r_idx);
115
116     bool drop_chosen_item = drop_item && !cloned && !floor_ptr->inside_arena && !player_ptr->phase_out && !is_pet(m_ptr);
117
118     if (current_world_ptr->timewalk_m_idx && current_world_ptr->timewalk_m_idx == m_idx) {
119         current_world_ptr->timewalk_m_idx = 0;
120     }
121
122     if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) {
123         player_ptr->update |= (PU_MON_LITE);
124     }
125
126     POSITION y = m_ptr->fy;
127     POSITION x = m_ptr->fx;
128
129     if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
130         GAME_TEXT m_name[MAX_NLEN];
131
132         monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
133         exe_write_diary(player_ptr, DIARY_NAMED_PET, 3, m_name);
134     }
135
136     for (int i = 0; i < 4; i++) {
137         if (r_ptr->blow[i].method != RBM_EXPLODE)
138             continue;
139
140         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
141         EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
142         DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
143         DICE_SID d_side = r_ptr->blow[i].d_side;
144         HIT_POINT damage = damroll(d_dice, d_side);
145
146         project(player_ptr, m_idx, 3, y, x, damage, typ, flg, -1);
147         break;
148     }
149
150     if (m_ptr->mflag2 & MFLAG2_CHAMELEON) {
151         choose_new_monster(player_ptr, m_idx, TRUE, MON_CHAMELEON);
152         r_ptr = &r_info[m_ptr->r_idx];
153     }
154
155     check_quest_completion(player_ptr, m_ptr);
156
157     object_type forge;
158     object_type *q_ptr;
159     if (floor_ptr->inside_arena && !is_pet(m_ptr)) {
160         player_ptr->exit_bldg = TRUE;
161         if (player_ptr->arena_number > MAX_ARENA_MONS) {
162             msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
163         } else {
164             msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
165         }
166
167         if (arena_info[player_ptr->arena_number].tval) {
168             q_ptr = &forge;
169             object_prep(player_ptr, q_ptr, lookup_kind(arena_info[player_ptr->arena_number].tval, arena_info[player_ptr->arena_number].sval));
170             apply_magic(player_ptr, q_ptr, floor_ptr->object_level, AM_NO_FIXED_ART);
171             (void)drop_near(player_ptr, q_ptr, -1, y, x);
172         }
173
174         if (player_ptr->arena_number > MAX_ARENA_MONS)
175             player_ptr->arena_number++;
176         player_ptr->arena_number++;
177         if (record_arena) {
178             GAME_TEXT m_name[MAX_NLEN];
179             monster_desc(player_ptr, m_name, m_ptr, MD_WRONGDOER_NAME);
180             exe_write_diary(player_ptr, DIARY_ARENA, player_ptr->arena_number, m_name);
181         }
182     }
183
184     if (m_idx == player_ptr->riding && process_fall_off_horse(player_ptr, -1, FALSE)) {
185         msg_print(_("地面に落とされた。", "You have fallen from the pet you were riding."));
186     }
187
188     bool is_drop_corpse = one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4);
189     is_drop_corpse &= (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != 0;
190     is_drop_corpse &= !(floor_ptr->inside_arena || player_ptr->phase_out || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr)));
191     if (is_drop_corpse) {
192         bool corpse = FALSE;
193
194         if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
195             corpse = TRUE;
196         else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
197             corpse = TRUE;
198         else if (r_ptr->flags9 & RF9_DROP_CORPSE) {
199             if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp) {
200                 if (one_in_(5))
201                     corpse = TRUE;
202             } else {
203                 if (!one_in_(5))
204                     corpse = TRUE;
205             }
206         }
207
208         q_ptr = &forge;
209         object_prep(player_ptr, q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
210         apply_magic(player_ptr, q_ptr, floor_ptr->object_level, AM_NO_FIXED_ART);
211         q_ptr->pval = m_ptr->r_idx;
212         (void)drop_near(player_ptr, q_ptr, -1, y, x);
213     }
214
215     monster_drop_carried_objects(player_ptr, m_ptr);
216
217     u32b mo_mode = 0L;
218     if (r_ptr->flags1 & RF1_DROP_GOOD)
219         mo_mode |= AM_GOOD;
220     if (r_ptr->flags1 & RF1_DROP_GREAT)
221         mo_mode |= AM_GREAT;
222
223     switch (m_ptr->r_idx) {
224     case MON_PINK_HORROR: {
225         if (floor_ptr->inside_arena || player_ptr->phase_out)
226             break;
227
228         bool notice = FALSE;
229         for (int i = 0; i < 2; i++) {
230             POSITION wy = y, wx = x;
231             bool pet = is_pet(m_ptr);
232             BIT_FLAGS mode = 0L;
233
234             if (pet) {
235                 mode |= PM_FORCE_PET;
236             }
237
238             if (summon_specific(player_ptr, (pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode)) {
239                 if (player_can_see_bold(player_ptr, wy, wx))
240                     notice = TRUE;
241             }
242         }
243
244         if (notice) {
245             msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
246         }
247
248         break;
249     }
250     case MON_BLOODLETTER: {
251         if (!drop_chosen_item || (randint1(100) >= 15))
252             break;
253
254         q_ptr = &forge;
255         object_prep(player_ptr, q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
256         apply_magic(player_ptr, q_ptr, floor_ptr->object_level, AM_NO_FIXED_ART | mo_mode);
257         (void)drop_near(player_ptr, q_ptr, -1, y, x);
258         break;
259     }
260     case MON_RAAL: {
261         if (!drop_chosen_item || (floor_ptr->dun_level <= 9))
262             break;
263
264         q_ptr = &forge;
265         object_wipe(q_ptr);
266         if ((floor_ptr->dun_level > 49) && one_in_(5))
267             get_obj_num_hook = kind_is_good_book;
268         else
269             get_obj_num_hook = kind_is_book;
270
271         make_object(player_ptr, q_ptr, mo_mode);
272         (void)drop_near(player_ptr, q_ptr, -1, y, x);
273         break;
274     }
275     case MON_DAWN: {
276         if (floor_ptr->inside_arena || player_ptr->phase_out)
277             break;
278         if (one_in_(7))
279             break;
280
281         POSITION wy = y, wx = x;
282         int attempts = 100;
283         bool pet = is_pet(m_ptr);
284         do {
285             scatter(player_ptr, &wy, &wx, y, x, 20, 0);
286         } while (!(in_bounds(floor_ptr, wy, wx) && is_cave_empty_bold2(player_ptr, wy, wx)) && --attempts);
287
288         if (attempts <= 0)
289             break;
290
291         BIT_FLAGS mode = 0L;
292         if (pet)
293             mode |= PM_FORCE_PET;
294
295         if (summon_specific(player_ptr, (pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode)) {
296             if (player_can_see_bold(player_ptr, wy, wx))
297                 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
298         }
299
300         break;
301     }
302     case MON_UNMAKER: {
303         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
304         (void)project(player_ptr, m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
305         break;
306     }
307     case MON_UNICORN_ORD:
308     case MON_MORGOTH:
309     case MON_ONE_RING: {
310         if (player_ptr->pseikaku != PERSONALITY_LAZY)
311             break;
312         if (!drop_chosen_item)
313             break;
314
315         ARTIFACT_IDX a_idx = 0;
316         artifact_type *a_ptr = NULL;
317         do {
318             switch (randint0(3)) {
319             case 0:
320                 a_idx = ART_NAMAKE_HAMMER;
321                 break;
322             case 1:
323                 a_idx = ART_NAMAKE_BOW;
324                 break;
325             case 2:
326                 a_idx = ART_NAMAKE_ARMOR;
327                 break;
328             }
329
330             a_ptr = &a_info[a_idx];
331         } while (a_ptr->cur_num);
332
333         if (create_named_art(player_ptr, a_idx, y, x)) {
334             a_ptr->cur_num = 1;
335             if (current_world_ptr->character_dungeon)
336                 a_ptr->floor_id = player_ptr->floor_id;
337         } else if (!preserve_mode)
338             a_ptr->cur_num = 1;
339
340         break;
341     }
342     case MON_SERPENT: {
343         if (!drop_chosen_item)
344             break;
345
346         q_ptr = &forge;
347         object_prep(player_ptr, q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
348         q_ptr->name1 = ART_GROND;
349         apply_magic(player_ptr, q_ptr, -1, AM_GOOD | AM_GREAT);
350         (void)drop_near(player_ptr, q_ptr, -1, y, x);
351         q_ptr = &forge;
352         object_prep(player_ptr, q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
353         q_ptr->name1 = ART_CHAOS;
354         apply_magic(player_ptr, q_ptr, -1, AM_GOOD | AM_GREAT);
355         (void)drop_near(player_ptr, q_ptr, -1, y, x);
356         break;
357     }
358     case MON_B_DEATH_SWORD: {
359         if (!drop_chosen_item)
360             break;
361
362         q_ptr = &forge;
363         object_prep(player_ptr, q_ptr, lookup_kind(TV_SWORD, randint1(2)));
364         (void)drop_near(player_ptr, q_ptr, -1, y, x);
365         break;
366     }
367     case MON_A_GOLD:
368     case MON_A_SILVER: {
369         bool is_drop_can = drop_chosen_item;
370         bool is_silver = m_ptr->r_idx == MON_A_SILVER;
371         is_silver &= r_ptr->r_akills % 5 == 0;
372         is_drop_can &= (m_ptr->r_idx == MON_A_GOLD) || is_silver;
373         if (!is_drop_can)
374             break;
375
376         q_ptr = &forge;
377         object_prep(player_ptr, q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
378         apply_magic(player_ptr, q_ptr, floor_ptr->object_level, AM_NO_FIXED_ART);
379         (void)drop_near(player_ptr, q_ptr, -1, y, x);
380         break;
381     }
382     case MON_ROLENTO: {
383         BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
384         (void)project(player_ptr, m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
385         break;
386     }
387     case MON_MIDDLE_AQUA_FIRST:
388     case MON_LARGE_AQUA_FIRST:
389     case MON_EXTRA_LARGE_AQUA_FIRST:
390     case MON_MIDDLE_AQUA_SECOND:
391     case MON_LARGE_AQUA_SECOND:
392     case MON_EXTRA_LARGE_AQUA_SECOND: {
393         if (floor_ptr->inside_arena || player_ptr->phase_out)
394             break;
395
396         bool notice = FALSE;
397         const int popped_bubbles = 4;
398         for (int i = 0; i < popped_bubbles; i++) {
399             POSITION wy = y, wx = x;
400             bool pet = is_pet(m_ptr);
401             BIT_FLAGS mode = PM_NONE;
402
403             if (pet)
404                 mode |= PM_FORCE_PET;
405
406             MONSTER_IDX smaller_bubblle = m_ptr->r_idx - 1;
407             if (summon_named_creature(player_ptr, (pet ? -1 : m_idx), wy, wx, smaller_bubblle, mode) && player_can_see_bold(player_ptr, wy, wx))
408                 notice = TRUE;
409         }
410
411         if (notice)
412             msg_print(_("泡が弾けた!", "The bubble pops!"));
413
414         break;
415     }
416     case MON_TOTEM_MOAI: {
417         if (floor_ptr->inside_arena || player_ptr->phase_out || one_in_(8))
418             break;
419
420         POSITION wy = y, wx = x;
421         int attempts = 100;
422         bool pet = is_pet(m_ptr);
423         do {
424             scatter(player_ptr, &wy, &wx, y, x, 20, 0);
425         } while (!(in_bounds(floor_ptr, wy, wx) && is_cave_empty_bold2(player_ptr, wy, wx)) && --attempts);
426
427         if (attempts <= 0)
428             break;
429
430         BIT_FLAGS mode = PM_NONE;
431         if (pet)
432             mode |= PM_FORCE_PET;
433
434         if (summon_named_creature(player_ptr, (pet ? -1 : m_idx), wy, wx, MON_TOTEM_MOAI, mode) && player_can_see_bold(player_ptr, wy, wx))
435             msg_print(_("新たなモアイが現れた!", "A new moai steps forth!"));
436
437         break;
438     }
439     default: {
440         if (!drop_chosen_item)
441             break;
442
443         switch (r_ptr->d_char) {
444         case '(': {
445             if (floor_ptr->dun_level <= 0)
446                 break;
447
448             q_ptr = &forge;
449             object_wipe(q_ptr);
450             get_obj_num_hook = kind_is_cloak;
451             make_object(player_ptr, q_ptr, mo_mode);
452             (void)drop_near(player_ptr, q_ptr, -1, y, x);
453             break;
454         }
455         case '/': {
456             if (floor_ptr->dun_level <= 4)
457                 break;
458
459             q_ptr = &forge;
460             object_wipe(q_ptr);
461             get_obj_num_hook = kind_is_polearm;
462             make_object(player_ptr, q_ptr, mo_mode);
463             (void)drop_near(player_ptr, q_ptr, -1, y, x);
464             break;
465         }
466         case '[': {
467             if (floor_ptr->dun_level <= 19)
468                 break;
469
470             q_ptr = &forge;
471             object_wipe(q_ptr);
472             get_obj_num_hook = kind_is_armor;
473             make_object(player_ptr, q_ptr, mo_mode);
474             (void)drop_near(player_ptr, q_ptr, -1, y, x);
475             break;
476         }
477         case '\\': {
478             if (floor_ptr->dun_level <= 4)
479                 break;
480             q_ptr = &forge;
481             object_wipe(q_ptr);
482             get_obj_num_hook = kind_is_hafted;
483             make_object(player_ptr, q_ptr, mo_mode);
484             (void)drop_near(player_ptr, q_ptr, -1, y, x);
485             break;
486         }
487         case '|': {
488             if (m_ptr->r_idx == MON_STORMBRINGER)
489                 break;
490
491             q_ptr = &forge;
492             object_wipe(q_ptr);
493             get_obj_num_hook = kind_is_sword;
494             make_object(player_ptr, q_ptr, mo_mode);
495             (void)drop_near(player_ptr, q_ptr, -1, y, x);
496             break;
497         }
498         }
499     }
500     }
501
502     if (drop_chosen_item) {
503         ARTIFACT_IDX a_idx = 0;
504         PERCENTAGE chance = 0;
505         for (int i = 0; i < 4; i++) {
506             if (!r_ptr->artifact_id[i])
507                 break;
508             a_idx = r_ptr->artifact_id[i];
509             chance = r_ptr->artifact_percent[i];
510             if (randint0(100) < chance || current_world_ptr->wizard) {
511                 artifact_type *a_ptr = &a_info[a_idx];
512                 if (!a_ptr->cur_num) {
513                     if (create_named_art(player_ptr, a_idx, y, x)) {
514                         a_ptr->cur_num = 1;
515                         if (current_world_ptr->character_dungeon)
516                             a_ptr->floor_id = player_ptr->floor_id;
517                     } else if (!preserve_mode) {
518                         a_ptr->cur_num = 1;
519                     }
520                 }
521             }
522         }
523
524         if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[player_ptr->dungeon_idx].final_guardian == m_ptr->r_idx)) {
525             KIND_OBJECT_IDX k_idx = d_info[player_ptr->dungeon_idx].final_object != 0 ? d_info[player_ptr->dungeon_idx].final_object
526                                                                                       : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
527
528             if (d_info[player_ptr->dungeon_idx].final_artifact != 0) {
529                 a_idx = d_info[player_ptr->dungeon_idx].final_artifact;
530                 artifact_type *a_ptr = &a_info[a_idx];
531                 if (!a_ptr->cur_num) {
532                     if (create_named_art(player_ptr, a_idx, y, x)) {
533                         a_ptr->cur_num = 1;
534                         if (current_world_ptr->character_dungeon)
535                             a_ptr->floor_id = player_ptr->floor_id;
536                     } else if (!preserve_mode) {
537                         a_ptr->cur_num = 1;
538                     }
539
540                     if (!d_info[player_ptr->dungeon_idx].final_object)
541                         k_idx = 0;
542                 }
543             }
544
545             if (k_idx != 0) {
546                 q_ptr = &forge;
547                 object_prep(player_ptr, q_ptr, k_idx);
548                 apply_magic(player_ptr, q_ptr, floor_ptr->object_level, AM_NO_FIXED_ART | AM_GOOD);
549                 (void)drop_near(player_ptr, q_ptr, -1, y, x);
550             }
551
552             msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"), d_name + d_info[player_ptr->dungeon_idx].name);
553         }
554     }
555
556     int number = 0;
557     if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60))
558         number++;
559     if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90))
560         number++;
561     if (r_ptr->flags1 & RF1_DROP_1D2)
562         number += damroll(1, 2);
563     if (r_ptr->flags1 & RF1_DROP_2D2)
564         number += damroll(2, 2);
565     if (r_ptr->flags1 & RF1_DROP_3D2)
566         number += damroll(3, 2);
567     if (r_ptr->flags1 & RF1_DROP_4D2)
568         number += damroll(4, 2);
569
570     if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
571         number = 0;
572
573     if (is_pet(m_ptr) || player_ptr->phase_out || floor_ptr->inside_arena)
574         number = 0;
575
576     if (!drop_item && (r_ptr->d_char != '$'))
577         number = 0;
578
579     if ((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
580         number = 0;
581
582     coin_type = force_coin;
583     floor_ptr->object_level = (floor_ptr->dun_level + r_ptr->level) / 2;
584
585     int dump_item = 0;
586     int dump_gold = 0;
587     for (int i = 0; i < number; i++) {
588         q_ptr = &forge;
589         object_wipe(q_ptr);
590
591         if (do_gold && (!do_item || (randint0(100) < 50))) {
592             if (!make_gold(player_ptr, q_ptr))
593                 continue;
594             dump_gold++;
595         } else {
596             if (!make_object(player_ptr, q_ptr, mo_mode))
597                 continue;
598             dump_item++;
599         }
600
601         (void)drop_near(player_ptr, q_ptr, -1, y, x);
602     }
603
604     floor_ptr->object_level = floor_ptr->base_level;
605     coin_type = 0;
606     bool visible = (m_ptr->ml && !player_ptr->image) || ((r_ptr->flags1 & RF1_UNIQUE) != 0);
607     if (visible && (dump_item || dump_gold)) {
608         lore_treasure(player_ptr, m_idx, dump_item, dump_gold);
609     }
610
611     if (!(r_ptr->flags1 & RF1_QUESTOR))
612         return;
613     if (player_ptr->phase_out)
614         return;
615     if ((m_ptr->r_idx != MON_SERPENT) || cloned)
616         return;
617
618     current_world_ptr->total_winner = TRUE;
619     player_ptr->redraw |= (PR_TITLE);
620     play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
621     exe_write_diary(player_ptr, DIARY_DESCRIPTION, 0, _("見事に変愚蛮怒の勝利者となった!", "finally became *WINNER* of Hengband!"));
622     admire_from_patron(player_ptr);
623     msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
624     msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
625     msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
626 }
627
628 /*!
629  * @brief モンスターを撃破した際の述語メッセージを返す /
630  * Return monster death string
631  * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
632  * @return 撃破されたモンスターの述語
633  */
634 concptr extract_note_dies(MONRACE_IDX r_idx)
635 {
636     monster_race *r_ptr = &r_info[r_idx];
637     if (monster_living(r_idx))
638         return _("は死んだ。", " dies.");
639
640     for (int i = 0; i < 4; i++) {
641         if (r_ptr->blow[i].method == RBM_EXPLODE) {
642             return _("は爆発して粉々になった。", " explodes into tiny shreds.");
643         }
644     }
645
646     return _("を倒した。", " is destroyed.");
647 }