OSDN Git Service

03b725216590574c0404a14926d8083258f9bfc5
[hengbandforosx/hengbandosx.git] / src / spell-kind / spells-pet.cpp
1 #include "spell-kind/spells-pet.h"
2 #include "core/asking-player.h"
3 #include "effect/attribute-types.h"
4 #include "effect/effect-characteristics.h"
5 #include "effect/effect-processor.h"
6 #include "game-option/play-record-options.h"
7 #include "io/write-diary.h"
8 #include "monster-floor/monster-remover.h"
9 #include "monster-race/monster-race.h"
10 #include "monster-race/race-flags1.h"
11 #include "monster/monster-describer.h"
12 #include "monster/monster-description-types.h"
13 #include "monster/monster-info.h"
14 #include "monster/smart-learn-types.h"
15 #include "system/floor-type-definition.h"
16 #include "system/monster-race-definition.h"
17 #include "system/monster-type-definition.h"
18 #include "system/player-type-definition.h"
19 #include "view/display-messages.h"
20
21 /*!
22  * @brief ペット爆破処理 /
23  */
24 void discharge_minion(PlayerType *player_ptr)
25 {
26     bool okay = true;
27     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
28         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
29         if (!m_ptr->r_idx || !is_pet(m_ptr))
30             continue;
31         if (m_ptr->nickname)
32             okay = false;
33     }
34
35     if (!okay || player_ptr->riding) {
36         if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? ")))
37             return;
38     }
39
40     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
41         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
42         if (!m_ptr->r_idx || !is_pet(m_ptr))
43             continue;
44
45         monster_race *r_ptr;
46         r_ptr = &r_info[m_ptr->r_idx];
47         if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
48             GAME_TEXT m_name[MAX_NLEN];
49             monster_desc(player_ptr, m_name, m_ptr, 0x00);
50             msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists being blasted and runs away."), m_name);
51             delete_monster_idx(player_ptr, i);
52             continue;
53         }
54
55         HIT_POINT dam = m_ptr->maxhp / 2;
56         if (dam > 100)
57             dam = (dam - 100) / 2 + 100;
58         if (dam > 400)
59             dam = (dam - 400) / 2 + 400;
60         if (dam > 800)
61             dam = 800;
62         project(player_ptr, i, 2 + (r_ptr->level / 20), m_ptr->fy, m_ptr->fx, dam, AttributeType::PLASMA, PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL);
63
64         if (record_named_pet && m_ptr->nickname) {
65             GAME_TEXT m_name[MAX_NLEN];
66
67             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
68             exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name);
69         }
70
71         delete_monster_idx(player_ptr, i);
72     }
73 }