OSDN Git Service

[Refactor] #2628 Renamed object-type-definition.cpp/h to item-entity.cpp/h
[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 (!MonsterRace(m_ptr->r_idx).is_valid() || !m_ptr->is_pet()) {
30             continue;
31         }
32         if (m_ptr->nickname) {
33             okay = false;
34         }
35     }
36
37     if (!okay || player_ptr->riding) {
38         if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? "))) {
39             return;
40         }
41     }
42
43     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
44         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
45         if (!MonsterRace(m_ptr->r_idx).is_valid() || !m_ptr->is_pet()) {
46             continue;
47         }
48
49         MonsterRaceInfo *r_ptr;
50         r_ptr = &monraces_info[m_ptr->r_idx];
51         if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
52             GAME_TEXT m_name[MAX_NLEN];
53             monster_desc(player_ptr, m_name, m_ptr, 0x00);
54             msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists being blasted and runs away."), m_name);
55             delete_monster_idx(player_ptr, i);
56             continue;
57         }
58
59         int dam = m_ptr->maxhp / 2;
60         if (dam > 100) {
61             dam = (dam - 100) / 2 + 100;
62         }
63         if (dam > 400) {
64             dam = (dam - 400) / 2 + 400;
65         }
66         if (dam > 800) {
67             dam = 800;
68         }
69         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);
70
71         if (record_named_pet && m_ptr->nickname) {
72             GAME_TEXT m_name[MAX_NLEN];
73
74             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
75             exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name);
76         }
77
78         delete_monster_idx(player_ptr, i);
79     }
80 }