OSDN Git Service

[Refactor] #929 Added combat-killing messages (English version only)
[hengbandforosx/hengbandosx.git] / src / monster / monster-damage.cpp
1 /*
2  * @brief モンスターがダメージを受けた時の処理と経験値の加算処理
3  * @date 2021/08/04
4  * @author Hourier
5  */
6
7 #include "monster/monster-damage.h"
8 #include "core/player-redraw-types.h"
9 #include "core/speed-table.h"
10 #include "core/stuff-handler.h"
11 #include "dungeon/dungeon.h"
12 #include "game-option/birth-options.h"
13 #include "game-option/play-record-options.h"
14 #include "io/files-util.h"
15 #include "io/report.h"
16 #include "io/write-diary.h"
17 #include "main/sound-definitions-table.h"
18 #include "main/sound-of-music.h"
19 #include "mind/mind-ninja.h"
20 #include "monster-floor/monster-death.h"
21 #include "monster-floor/monster-remover.h"
22 #include "monster-floor/monster-summon.h"
23 #include "monster-floor/place-monster-types.h"
24 #include "monster-race/monster-race-hook.h"
25 #include "monster-race/monster-race.h"
26 #include "monster-race/race-ability-mask.h"
27 #include "monster-race/race-flags1.h"
28 #include "monster-race/race-flags2.h"
29 #include "monster-race/race-flags3.h"
30 #include "monster-race/race-flags7.h"
31 #include "monster-race/race-flags8.h"
32 #include "monster/monster-describer.h"
33 #include "monster/monster-description-types.h"
34 #include "monster/monster-info.h"
35 #include "monster/monster-status-setter.h"
36 #include "monster/monster-status.h"
37 #include "object-enchant/object-curse.h"
38 #include "player-info/avatar.h"
39 #include "player/player-status.h"
40 #include "player/special-defense-types.h"
41 #include "spell-kind/spells-random.h"
42 #include "status/experience.h"
43 #include "system/floor-type-definition.h"
44 #include "system/monster-race-definition.h"
45 #include "system/monster-type-definition.h"
46 #include "system/player-type-definition.h"
47 #include "util/bit-flags-calculator.h"
48 #include "view/display-messages.h"
49 #include "world/world.h"
50 #include <algorithm>
51
52 /*
53  * @brief コンストラクタ
54  * @param target_ptr プレーヤーへの参照ポインタ
55  * @param m_idx ダメージを与えたモンスターのID
56  * @param dam 与えたダメージ量
57  * @param fear ダメージによってモンスターが恐慌状態に陥ったならばtrue
58  * @param note モンスターが倒された際の特別なメッセージ述語
59  */
60 MonsterDamageProcessor::MonsterDamageProcessor(player_type *target_ptr, MONSTER_IDX m_idx, HIT_POINT dam, bool *fear)
61     : target_ptr(target_ptr)
62     , m_idx(m_idx)
63     , dam(dam)
64     , fear(fear)
65 {
66 }
67
68 /*!
69  * @brief モンスターのHPをダメージに応じて減算する /
70  * @return モンスターが生きていればfalse、死んだらtrue
71  */
72 bool MonsterDamageProcessor::mon_take_hit(concptr note)
73 {
74     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
75     auto innocent = true;
76     auto thief = false;
77
78     monster_type exp_mon;
79     (void)COPY(&exp_mon, m_ptr, monster_type);
80
81     auto exp_dam = (m_ptr->hp > this->dam) ? this->dam : m_ptr->hp;
82
83     this->get_exp_from_mon(&exp_mon, exp_dam);
84     if (this->genocide_chaos_patron()) {
85         return true;
86     }
87
88     m_ptr->hp -= this->dam;
89     m_ptr->dealt_damage += this->dam;
90     if (m_ptr->dealt_damage > m_ptr->max_maxhp * 100) {
91         m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
92     }
93
94     if (current_world_ptr->wizard) {
95         msg_format(_("合計%d/%dのダメージを与えた。", "You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
96     }
97
98     auto *r_ptr = &r_info[m_ptr->r_idx];
99     if (m_ptr->hp < 0) {
100         this->death_special_flag_monster();
101         if (r_ptr->r_akills < MAX_SHORT) {
102             r_ptr->r_akills++;
103         }
104
105         this->increase_kill_numbers();
106         GAME_TEXT m_name[MAX_NLEN];
107         monster_desc(this->target_ptr, m_name, m_ptr, MD_TRUE_NAME);
108         this->death_amberites(m_name);
109         this->dying_scream(m_name);
110         this->change_virtue_non_beginner();
111         if (r_ptr->flags1 & RF1_UNIQUE) {
112             if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
113                 chg_virtue(this->target_ptr, V_HARMONY, 2);
114
115             if (r_ptr->flags3 & RF3_GOOD) {
116                 chg_virtue(this->target_ptr, V_UNLIFE, 2);
117                 chg_virtue(this->target_ptr, V_VITALITY, -2);
118             }
119
120             if (one_in_(3))
121                 chg_virtue(this->target_ptr, V_INDIVIDUALISM, -1);
122         }
123
124         if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER) {
125             chg_virtue(this->target_ptr, V_COMPASSION, -1);
126         }
127
128         auto *floor_ptr = this->target_ptr->current_floor_ptr;
129         if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * floor_ptr->dun_level) >= randint1(100)))
130             chg_virtue(this->target_ptr, V_UNLIFE, 1);
131
132         if (any_bits(r_ptr->flags3, RF3_ANGEL)) {
133             if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
134                 chg_virtue(this->target_ptr, V_FAITH, -2);
135             } else if ((r_ptr->level) / 10 + (3 * floor_ptr->dun_level) >= randint1(100)) {
136                 auto change_value = any_bits(r_ptr->flags3, RF3_GOOD) ? -1 : 1;
137                 chg_virtue(this->target_ptr, V_FAITH, change_value);
138             }
139         } else if (any_bits(r_ptr->flags3, RF3_DEMON)) {
140             if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
141                 chg_virtue(this->target_ptr, V_FAITH, 2);
142             } else if ((r_ptr->level) / 10 + (3 * floor_ptr->dun_level) >= randint1(100)) {
143                 chg_virtue(this->target_ptr, V_FAITH, 1);
144             }
145         }
146
147         if (any_bits(r_ptr->flags3, RF3_UNDEAD) && any_bits(r_ptr->flags1, RF1_UNIQUE)) {
148             chg_virtue(this->target_ptr, V_VITALITY, 2);
149         }
150
151         if (r_ptr->r_deaths > 0) {
152             if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
153                 chg_virtue(this->target_ptr, V_HONOUR, 10);
154             } else if ((r_ptr->level) / 10 + (2 * this->target_ptr->current_floor_ptr->dun_level) >= randint1(100)) {
155                 chg_virtue(this->target_ptr, V_HONOUR, 1);
156             }
157         }
158
159         if (any_bits(r_ptr->flags2, RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10)) {
160             chg_virtue(this->target_ptr, V_VALOUR, -1);
161         }
162
163         for (auto i = 0; i < MAX_NUM_BLOWS; i++) {
164             if (r_ptr->blow[i].d_dice != 0) {
165                 innocent = false;
166             }
167             
168             if ((r_ptr->blow[i].effect == RBE_EAT_ITEM) || (r_ptr->blow[i].effect == RBE_EAT_GOLD)) {
169                 thief = true;
170             }
171         }
172
173         if (r_ptr->level > 0) {
174             innocent = false;
175         }
176
177         if (thief) {
178             if (any_bits(r_ptr->flags1, RF1_UNIQUE)) {
179                 chg_virtue(this->target_ptr, V_JUSTICE, 3);
180             } else if (1 + ((r_ptr->level) / 10 + (2 * this->target_ptr->current_floor_ptr->dun_level)) >= randint1(100)) {
181                 chg_virtue(this->target_ptr, V_JUSTICE, 1);
182             }
183         } else if (innocent) {
184             chg_virtue(this->target_ptr, V_JUSTICE, -1);
185         }
186
187         auto magic_ability_flags = r_ptr->ability_flags;
188         magic_ability_flags.reset(RF_ABILITY_NOMAGIC_MASK);
189         if (any_bits(r_ptr->flags3, RF3_ANIMAL) && none_bits(r_ptr->flags3, RF3_EVIL) && magic_ability_flags.none()) {
190             if (one_in_(4)) {
191                 chg_virtue(this->target_ptr, V_NATURE, -1);
192             }
193         }
194
195         if (any_bits(r_ptr->flags1, RF1_UNIQUE) && record_destroy_uniq) {
196             char note_buf[160];
197             sprintf(note_buf, "%s%s", r_ptr->name.c_str(), m_ptr->mflag2.has(MFLAG2::CLONED) ? _("(クローン)", "(Clone)") : "");
198             exe_write_diary(this->target_ptr, DIARY_UNIQUE, 0, note_buf);
199         }
200
201         sound(SOUND_KILL);
202         if (note != nullptr) {
203             msg_format("%^s%s", m_name, note);
204         } else if (!m_ptr->ml) {
205             auto mes = is_echizen(this->target_ptr) ? _("せっかくだから%sを殺した。", "Because it's time, you have killed %s.")
206                                                     : _("%sを殺した。", "You have killed %s.");
207             msg_format(mes, m_name);
208         } else if (!monster_living(m_ptr->r_idx)) {
209             bool explode = false;
210             for (auto i = 0; i < 4; i++) {
211                 if (r_ptr->blow[i].method == RBM_EXPLODE) {
212                     explode = true;
213                 }
214             }
215
216             if (explode) {
217                 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
218             } else {
219                 auto mes = is_echizen(this->target_ptr) ? _("せっかくだから%sを殺した。", "Because it's time, you have destroyed %s.")
220                                                         : _("%sを殺した。", "You have destoryed %s.");
221                 msg_format(mes, m_name);
222             }
223         } else {
224             auto mes = is_echizen(this->target_ptr) ? _("せっかくだから%sを殺した。", "Because it's time, you have slained %s.")
225                                                     : _("%sを殺した。", "You have slained %s.");
226             msg_format(mes, m_name);
227         }
228
229         if (any_bits(r_ptr->flags1, RF1_UNIQUE) && m_ptr->mflag2.has_not(MFLAG2::CLONED) && !vanilla_town) {
230             for (auto i = 0; i < MAX_BOUNTY; i++) {
231                 if ((current_world_ptr->bounty_r_idx[i] == m_ptr->r_idx) && m_ptr->mflag2.has_not(MFLAG2::CHAMELEON)) {
232                     msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
233                     break;
234                 }
235             }
236         }
237
238         monster_death(this->target_ptr, this->m_idx, true);
239         this->summon_special_unique();
240         this->get_exp_from_mon(&exp_mon, exp_mon.max_maxhp * 2);
241         *this->fear = false;
242         return true;
243     }
244
245     if (monster_fear_remaining(m_ptr) && (this->dam > 0)) {
246         auto fear_remining = monster_fear_remaining(m_ptr) - randint1(this->dam);
247         if (set_monster_monfear(this->target_ptr, this->m_idx, fear_remining)) {
248             *this->fear = false;
249         }
250     }
251
252     // 恐怖の更なる加算.
253     if (!monster_fear_remaining(m_ptr) && none_bits(r_ptr->flags3, RF3_NO_FEAR)) {
254         int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
255         if ((randint1(10) >= percentage) || ((this->dam >= m_ptr->hp) && (randint0(100) < 80))) {
256             *this->fear = true;
257             (void)set_monster_monfear(
258                 this->target_ptr, this->m_idx, (randint1(10) + (((this->dam >= m_ptr->hp) && (percentage > 7)) ? 20 : ((11 - percentage) * 5))));
259         }
260     }
261
262     return false;
263 }
264
265 bool MonsterDamageProcessor::genocide_chaos_patron()
266 {
267     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
268     if (!monster_is_valid(m_ptr)) {
269         this->m_idx = 0;
270     }
271
272     this->set_redraw();
273     (void)set_monster_csleep(this->target_ptr, this->m_idx, 0);
274     if (this->target_ptr->special_defense & NINJA_S_STEALTH) {
275         set_superstealth(this->target_ptr, false);
276     }
277
278     return this->m_idx == 0;
279 }
280
281 /*
282  * @brief たぬき、カメレオン、ナズグル、ユニークの死亡時処理
283  * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
284  */
285 void MonsterDamageProcessor::death_special_flag_monster()
286 {
287     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
288     auto r_idx = m_ptr->r_idx;
289     auto *r_ptr = &r_info[r_idx];
290     if (any_bits(r_info[r_idx].flags7, RF7_TANUKI)) {
291         r_ptr = &r_info[r_idx];
292         m_ptr->ap_r_idx = r_idx;
293         if (r_ptr->r_sights < MAX_SHORT) {
294             r_ptr->r_sights++;
295         }
296     }
297
298     if (m_ptr->mflag2.has(MFLAG2::CHAMELEON)) {
299         r_ptr = real_r_ptr(m_ptr);
300         if (r_ptr->r_sights < MAX_SHORT) {
301             r_ptr->r_sights++;
302         }
303     }
304
305     if (m_ptr->mflag2.has(MFLAG2::CLONED)) {
306         return;
307     }
308
309     if (any_bits(r_ptr->flags7, RF7_NAZGUL)) {
310         r_ptr->max_num--;
311         return;
312     }
313
314     if (none_bits(r_ptr->flags1, RF1_UNIQUE)) {
315         return;
316     }
317
318     this->death_unique_monster((monster_race_type)r_idx);
319 }
320
321 /*
322  * @brief ユニークの死亡処理
323  * @param r_idx 死亡したユニークの種族番号
324  */
325 void MonsterDamageProcessor::death_unique_monster(monster_race_type r_idx)
326 {
327     r_info[r_idx].max_num = 0;
328     std::vector<monster_race_type> combined_uniques;
329     if (!check_combined_unique(r_idx, &combined_uniques)) {
330         return;
331     }
332
333     std::vector<std::tuple<monster_race_type, monster_race_type, monster_race_type>> uniques;
334     const int one_unit = 3;
335     for (auto i = 0U; i < combined_uniques.size(); i += one_unit) {
336         auto unique = std::make_tuple(combined_uniques[i], combined_uniques[i + 1], combined_uniques[i + 2]);
337         uniques.push_back(unique);
338     }
339
340     this->death_combined_uniques(r_idx, &uniques);
341 }
342
343 /*
344  * @brief 死亡したモンスターが分裂/合体を行う特殊ユニークか否かの判定処理
345  * @param r_idx 死亡したモンスターの種族番号
346  * @param united_uniques 分裂/合体を行う特殊ユニーク
347  * @details 合体後、合体前1、合体前2 の順にpush_backすること
348  */
349 bool MonsterDamageProcessor::check_combined_unique(const monster_race_type r_idx, std::vector<monster_race_type> *combined_uniques)
350 {
351     combined_uniques->push_back(MON_BANORLUPART);
352     combined_uniques->push_back(MON_BANOR);
353     combined_uniques->push_back(MON_LUPART);
354
355     for (const auto &unique : *combined_uniques) {
356         if (r_idx == unique) {
357             return true;
358         }
359     }
360
361     return false;
362 }
363
364 /*
365  * @brief 分裂/合体を行う特殊ユニークの死亡処理
366  * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
367  * @uniques 分裂/合体を行う特殊ユニークのリスト
368  */
369 void MonsterDamageProcessor::death_combined_uniques(
370     const monster_race_type r_idx, std::vector<std::tuple<monster_race_type, monster_race_type, monster_race_type>> *combined_uniques)
371 {
372     for (const auto &unique : *combined_uniques) {
373         auto united = (monster_race_type)0;
374         auto split1 = (monster_race_type)0;
375         auto split2 = (monster_race_type)0;
376         std::tie(united, split1, split2) = unique;
377         if ((r_idx == split1) || (r_idx == split2)) {
378             r_info[united].max_num = 0;
379             r_info[united].r_pkills++;
380             r_info[united].r_akills++;
381             if (r_info[united].r_tkills < MAX_SHORT) {
382                 r_info[united].r_tkills++;
383             }
384
385             continue;
386         }
387
388         if (r_idx != united) {
389             continue;
390         }
391
392         r_info[split1].max_num = 0;
393         r_info[split1].r_pkills++;
394         r_info[split1].r_akills++;
395         if (r_info[split1].r_tkills < MAX_SHORT) {
396             r_info[split1].r_tkills++;
397         }
398
399         r_info[split2].max_num = 0;
400         r_info[split2].r_pkills++;
401         r_info[split2].r_akills++;
402         if (r_info[split2].r_tkills < MAX_SHORT) {
403             r_info[split2].r_tkills++;
404         }
405     }
406 }
407
408 void MonsterDamageProcessor::increase_kill_numbers()
409 {
410     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
411     auto *r_ptr = &r_info[m_ptr->r_idx];
412     if (((m_ptr->ml == 0) || this->target_ptr->image) && none_bits(r_ptr->flags1, RF1_UNIQUE)) {
413         return;
414     }
415
416     if (m_ptr->mflag2.has(MFLAG2::KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) {
417         r_info[MON_KAGE].r_pkills++;
418     } else if (r_ptr->r_pkills < MAX_SHORT) {
419         r_ptr->r_pkills++;
420     }
421
422     if (m_ptr->mflag2.has(MFLAG2::KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) {
423         r_info[MON_KAGE].r_tkills++;
424     } else if (r_ptr->r_tkills < MAX_SHORT) {
425         r_ptr->r_tkills++;
426     }
427
428     monster_race_track(this->target_ptr, m_ptr->ap_r_idx);
429 }
430
431 void MonsterDamageProcessor::death_amberites(GAME_TEXT *m_name)
432 {
433     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
434     auto *r_ptr = &r_info[m_ptr->r_idx];
435     if (none_bits(r_ptr->flags3, RF3_AMBERITE) || one_in_(2)) {
436         return;
437     }
438
439     auto curses = 1 + randint1(3);
440     auto stop_ty = false;
441     auto count = 0;
442     msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
443     curse_equipment(this->target_ptr, 100, 50);
444     do {
445         stop_ty = activate_ty_curse(this->target_ptr, stop_ty, &count);
446     } while (--curses);
447 }
448
449 void MonsterDamageProcessor::dying_scream(GAME_TEXT *m_name)
450 {
451     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
452     auto *r_ptr = &r_info[m_ptr->r_idx];
453     if (none_bits(r_ptr->flags2, RF2_CAN_SPEAK)) {
454         return;
455     }
456
457     char line_got[1024];
458     if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got)) {
459         msg_format("%^s %s", m_name, line_got);
460     }
461
462 #ifdef WORLD_SCORE
463     if (m_ptr->r_idx == MON_SERPENT) {
464         screen_dump = make_screen_dump(this->target_ptr);
465     }
466 #endif
467 }
468
469 void MonsterDamageProcessor::change_virtue_non_beginner()
470 {
471     auto *floor_ptr = this->target_ptr->current_floor_ptr;
472     auto *m_ptr = &floor_ptr->m_list[this->m_idx];
473     auto *r_ptr = &r_info[m_ptr->r_idx];
474     if (d_info[this->target_ptr->dungeon_idx].flags.has(DF::BEGINNER)) {
475         return;
476     }
477
478     if ((floor_ptr->dun_level == 0) && !this->target_ptr->ambush_flag && !floor_ptr->inside_arena) {
479         chg_virtue(this->target_ptr, V_VALOUR, -1);
480     } else if (r_ptr->level > floor_ptr->dun_level) {
481         if (randint1(10) <= (r_ptr->level - floor_ptr->dun_level)) {
482             chg_virtue(this->target_ptr, V_VALOUR, 1);
483         }
484     }
485
486     if (r_ptr->level > 60) {
487         chg_virtue(this->target_ptr, V_VALOUR, 1);
488     }
489
490     if (r_ptr->level >= 2 * (this->target_ptr->lev + 1)) {
491         chg_virtue(this->target_ptr, V_VALOUR, 2);
492     }
493 }
494
495 /*!
496  * @brief モンスターに与えたダメージを元に経験値を加算する /
497  * Calculate experience point to be get
498  * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
499  * @details
500  * <pre>
501  * Even the 64 bit operation is not big enough to avoid overflaw
502  * unless we carefully choose orders of ENERGY_MULTIPLICATION and ENERGY_DIVISION.
503  * Get the coefficient first, and multiply (potentially huge) base
504  * experience point of a monster later.
505  * </pre>
506  */
507 void MonsterDamageProcessor::get_exp_from_mon(monster_type *m_ptr, HIT_POINT exp_dam)
508 {
509     auto *r_ptr = &r_info[m_ptr->r_idx];
510     if (!monster_is_valid(m_ptr) || is_pet(m_ptr) || this->target_ptr->phase_out) {
511         return;
512     }
513
514     /*
515      * - Ratio of monster's level to player's level effects
516      * - Varying speed effects
517      * - Get a fraction in proportion of damage point
518      */
519     auto new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * exp_dam;
520     auto new_exp_frac = 0U;
521     auto div_h = 0;
522     auto div_l = (uint)((this->target_ptr->max_plv + 2) * SPEED_TO_ENERGY(r_ptr->speed));
523
524     /* Use (average maxhp * 2) as a denominator */
525     auto compensation = any_bits(r_ptr->flags1, RF1_FORCE_MAXHP) ? r_ptr->hside * 2 : r_ptr->hside + 1;
526     s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * compensation);
527
528     /* Special penalty in the wilderness */
529     if (!this->target_ptr->current_floor_ptr->dun_level && (none_bits(r_ptr->flags8, RF8_WILD_ONLY) || none_bits(r_ptr->flags1, RF1_UNIQUE))) {
530         s64b_mul(&div_h, &div_l, 0, 5);
531     }
532
533     /* Do ENERGY_DIVISION first to prevent overflaw */
534     s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
535
536     /* Special penalty for mutiply-monster */
537     if (any_bits(r_ptr->flags2, RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN)) {
538         int monnum_penarty = r_ptr->r_akills / 400;
539         if (monnum_penarty > 8) {
540             monnum_penarty = 8;
541         }
542
543         while (monnum_penarty--) {
544             /* Divide by 4 */
545             s64b_rshift(&new_exp, &new_exp_frac, 2);
546         }
547     }
548
549     /* Special penalty for rest_and_shoot exp scum */
550     if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0)) {
551         int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
552         if (over_damage > 32) {
553             over_damage = 32;
554         }
555
556         while (over_damage--) {
557             /* 9/10 for once */
558             s64b_mul(&new_exp, &new_exp_frac, 0, 9);
559             s64b_div(&new_exp, &new_exp_frac, 0, 10);
560         }
561     }
562
563     s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
564     gain_exp_64(this->target_ptr, new_exp, new_exp_frac);
565 }
566
567 void MonsterDamageProcessor::set_redraw()
568 {
569     if (this->target_ptr->health_who == this->m_idx) {
570         this->target_ptr->redraw |= PR_HEALTH;
571     }
572
573     if (this->target_ptr->riding == this->m_idx) {
574         this->target_ptr->redraw |= PR_UHEALTH;
575     }
576 }
577
578 /*
579  * @brief 特定ユニークを倒した時に更にユニークを特殊召喚する処理
580  * @param m_ptr ダメージを与えた特定ユニークの構造体参照ポインタ
581  */
582 void MonsterDamageProcessor::summon_special_unique()
583 {
584     auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx];
585     auto *r_ptr = &r_info[m_ptr->r_idx];
586     bool is_special_summon = m_ptr->r_idx == MON_IKETA;
587     is_special_summon |= m_ptr->r_idx == MON_DOPPIO;
588     if (!is_special_summon || this->target_ptr->current_floor_ptr->inside_arena || this->target_ptr->phase_out) {
589         delete_monster_idx(this->target_ptr, this->m_idx);
590         return;
591     }
592
593     auto dummy_y = m_ptr->fy;
594     auto dummy_x = m_ptr->fx;
595     auto mode = (BIT_FLAGS)0;
596     if (is_pet(m_ptr)) {
597         mode |= PM_FORCE_PET;
598     }
599
600     MONRACE_IDX new_unique_idx;
601     concptr mes;
602     switch (m_ptr->r_idx) {
603     case MON_IKETA:
604         new_unique_idx = MON_BIKETAL;
605         mes = _("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha!  *I* am Biketal!");
606         break;
607     case MON_DOPPIO:
608         new_unique_idx = MON_DIAVOLO;
609         mes = _("「これは『試練』だ 過去に打ち勝てという『試練』とオレは受けとった」", "This is a 'trial'. I took it as a 'trial' to overcome in the past.");
610         break;
611     default: // バグでなければ入らない.
612         new_unique_idx = 0;
613         mes = "";
614         break;
615     }
616
617     delete_monster_idx(this->target_ptr, this->m_idx);
618     if (summon_named_creature(this->target_ptr, 0, dummy_y, dummy_x, new_unique_idx, mode)) {
619         msg_print(mes);
620     }
621 }