2 * @file mutation-execution.cpp
3 * @brief プレイヤーの変異能力実行定義
6 #include "action/mutation-execution.h"
7 #include "cmd-item/cmd-throw.h"
8 #include "core/asking-player.h"
9 #include "effect/attribute-types.h"
10 #include "effect/spells-effect-util.h"
11 #include "floor/geometry.h"
12 #include "game-option/play-record-options.h"
13 #include "inventory/inventory-slot-types.h"
14 #include "io/write-diary.h"
15 #include "mind/mind-mage.h"
16 #include "mind/mind-warrior.h"
17 #include "monster-floor/monster-remover.h"
18 #include "monster-floor/monster-summon.h"
19 #include "monster-floor/place-monster-types.h"
20 #include "monster-race/monster-race.h"
21 #include "monster-race/race-flags1.h"
22 #include "monster-race/race-flags3.h"
23 #include "monster/monster-describer.h"
24 #include "monster/monster-description-types.h"
25 #include "monster/monster-flag-types.h"
26 #include "monster/monster-info.h"
27 #include "mutation/mutation-flag-types.h"
28 #include "mutation/mutation-techniques.h"
29 #include "object-enchant/item-feeling.h"
30 #include "player-info/self-info.h"
31 #include "player-status/player-energy.h"
32 #include "player/player-damage.h"
33 #include "player/player-status.h"
34 #include "racial/racial-vampire.h"
35 #include "spell-kind/earthquake.h"
36 #include "spell-kind/spells-charm.h"
37 #include "spell-kind/spells-detection.h"
38 #include "spell-kind/spells-fetcher.h"
39 #include "spell-kind/spells-launcher.h"
40 #include "spell-kind/spells-lite.h"
41 #include "spell-kind/spells-sight.h"
42 #include "spell-kind/spells-teleport.h"
43 #include "spell-kind/spells-world.h"
44 #include "spell-realm/spells-sorcery.h"
45 #include "spell/spells-status.h"
46 #include "spell/summon-types.h"
47 #include "status/element-resistance.h"
48 #include "status/shape-changer.h"
49 #include "system/floor-type-definition.h"
50 #include "system/grid-type-definition.h"
51 #include "system/item-entity.h"
52 #include "system/monster-entity.h"
53 #include "system/monster-race-info.h"
54 #include "system/player-type-definition.h"
55 #include "target/target-getter.h"
56 #include "util/bit-flags-calculator.h"
57 #include "view/display-messages.h"
60 * @brief 突然変異のレイシャル効果実装
61 * @param player_ptr プレイヤーへの参照ポインタ
62 * @param power 発動させる突然変異レイシャルのID
63 * @return レイシャルを実行した場合TRUE、キャンセルした場合FALSEを返す
65 bool exe_mutation_power(PlayerType *player_ptr, PlayerMutationType power)
68 PLAYER_LEVEL lvl = player_ptr->lev;
69 auto &floor = *player_ptr->current_floor_ptr;
71 case PlayerMutationType::SPIT_ACID:
72 if (!get_aim_dir(player_ptr, &dir)) {
76 stop_mouth(player_ptr);
77 msg_print(_("酸を吐きかけた...", "You spit acid..."));
78 fire_ball(player_ptr, AttributeType::ACID, dir, lvl, 1 + (lvl / 30));
80 case PlayerMutationType::BR_FIRE:
81 if (!get_aim_dir(player_ptr, &dir)) {
85 stop_mouth(player_ptr);
86 msg_print(_("あなたは火炎のブレスを吐いた...", "You breathe fire..."));
87 fire_breath(player_ptr, AttributeType::FIRE, dir, lvl * 2, 1 + (lvl / 20));
89 case PlayerMutationType::HYPN_GAZE:
90 if (!get_aim_dir(player_ptr, &dir)) {
94 msg_print(_("あなたの目は幻惑的になった...", "Your eyes look mesmerizing..."));
95 (void)charm_monster(player_ptr, dir, lvl);
97 case PlayerMutationType::TELEKINES:
98 if (!get_aim_dir(player_ptr, &dir)) {
102 msg_print(_("集中している...", "You concentrate..."));
103 fetch_item(player_ptr, dir, lvl * 10, true);
105 case PlayerMutationType::VTELEPORT:
106 msg_print(_("集中している...", "You concentrate..."));
107 teleport_player(player_ptr, 10 + 4 * lvl, TELEPORT_SPONTANEOUS);
109 case PlayerMutationType::MIND_BLST:
110 if (!get_aim_dir(player_ptr, &dir)) {
114 msg_print(_("集中している...", "You concentrate..."));
115 fire_bolt(player_ptr, AttributeType::PSI, dir, damroll(3 + ((lvl - 1) / 5), 3));
117 case PlayerMutationType::RADIATION:
118 msg_print(_("体から放射能が発生した!", "Radiation flows from your body!"));
119 fire_ball(player_ptr, AttributeType::NUKE, 0, (lvl * 2), 3 + (lvl / 20));
121 case PlayerMutationType::VAMPIRISM:
122 vampirism(player_ptr);
124 case PlayerMutationType::SMELL_MET:
125 stop_mouth(player_ptr);
126 (void)detect_treasure(player_ptr, DETECT_RAD_DEFAULT);
128 case PlayerMutationType::SMELL_MON:
129 stop_mouth(player_ptr);
130 (void)detect_monsters_normal(player_ptr, DETECT_RAD_DEFAULT);
132 case PlayerMutationType::BLINK:
133 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
135 case PlayerMutationType::EAT_ROCK:
136 return eat_rock(player_ptr);
137 case PlayerMutationType::SWAP_POS:
139 if (!get_aim_dir(player_ptr, &dir)) {
144 (void)teleport_swap(player_ptr, dir);
147 case PlayerMutationType::SHRIEK:
148 stop_mouth(player_ptr);
149 (void)fire_ball(player_ptr, AttributeType::SOUND, 0, 2 * lvl, 8);
150 (void)aggravate_monsters(player_ptr, 0);
152 case PlayerMutationType::ILLUMINE:
153 (void)lite_area(player_ptr, damroll(2, (lvl / 2)), (lvl / 10) + 1);
155 case PlayerMutationType::DET_CURSE:
156 for (int i = 0; i < INVEN_TOTAL; i++) {
157 auto *o_ptr = &player_ptr->inventory_list[i];
158 if (!o_ptr->is_valid() || !o_ptr->is_cursed()) {
162 o_ptr->feeling = FEEL_CURSED;
166 case PlayerMutationType::BERSERK:
167 (void)berserk(player_ptr, randint1(25) + 25);
169 case PlayerMutationType::POLYMORPH:
170 if (!input_check(_("変身します。よろしいですか?", "You will polymorph your self. Are you sure? "))) {
174 do_poly_self(player_ptr);
176 case PlayerMutationType::MIDAS_TCH:
177 return alchemy(player_ptr);
178 case PlayerMutationType::GROW_MOLD:
179 for (DIRECTION i = 0; i < 8; i++) {
180 summon_specific(player_ptr, -1, player_ptr->y, player_ptr->x, lvl, SUMMON_MOLD, PM_FORCE_PET);
184 case PlayerMutationType::RESIST: {
186 TIME_EFFECT dur = randint1(20) + 20;
187 if (randint0(5) < num) {
188 (void)set_oppose_acid(player_ptr, dur, false);
192 if (randint0(4) < num) {
193 (void)set_oppose_elec(player_ptr, dur, false);
197 if (randint0(3) < num) {
198 (void)set_oppose_fire(player_ptr, dur, false);
202 if (randint0(2) < num) {
203 (void)set_oppose_cold(player_ptr, dur, false);
208 (void)set_oppose_pois(player_ptr, dur, false);
214 case PlayerMutationType::EARTHQUAKE:
215 (void)earthquake(player_ptr, player_ptr->y, player_ptr->x, 10, 0);
217 case PlayerMutationType::EAT_MAGIC:
218 return eat_magic(player_ptr, player_ptr->lev * 2);
219 case PlayerMutationType::WEIGH_MAG:
220 report_magics(player_ptr);
222 case PlayerMutationType::STERILITY:
223 msg_print(_("突然頭が痛くなった!", "You suddenly have a headache!"));
224 take_hit(player_ptr, DAMAGE_LOSELIFE, randint1(17) + 17, _("禁欲を強いた疲労", "the strain of forcing abstinence"));
225 floor.num_repro += MAX_REPRODUCTION;
227 case PlayerMutationType::HIT_AND_AWAY:
228 return hit_and_away(player_ptr);
229 case PlayerMutationType::DAZZLE:
230 stun_monsters(player_ptr, lvl * 4);
231 confuse_monsters(player_ptr, lvl * 4);
232 turn_monsters(player_ptr, lvl * 4);
234 case PlayerMutationType::LASER_EYE:
235 if (!get_aim_dir(player_ptr, &dir)) {
239 fire_beam(player_ptr, AttributeType::LITE, dir, 2 * lvl);
241 case PlayerMutationType::RECALL:
242 return recall_player(player_ptr, randint0(21) + 15);
243 case PlayerMutationType::BANISH: {
244 if (!get_direction(player_ptr, &dir)) {
248 const auto y = player_ptr->y + ddy[dir];
249 const auto x = player_ptr->x + ddx[dir];
250 const auto &grid = floor.grid_array[y][x];
252 msg_print(_("邪悪な存在を感じとれません!", "You sense no evil there!"));
256 auto &monster = floor.m_list[grid.m_idx];
257 const auto &monrace = monraces_info[monster.r_idx];
258 auto can_banish = monrace.kind_flags.has(MonsterKindType::EVIL);
259 can_banish &= none_bits(monrace.flags1, RF1_QUESTOR);
260 can_banish &= monrace.kind_flags.has_not(MonsterKindType::UNIQUE);
261 can_banish &= !floor.inside_arena;
262 can_banish &= !inside_quest(floor.quest_number);
263 can_banish &= (monrace.level < randint1(player_ptr->lev + 50));
264 can_banish &= monster.mflag2.has_not(MonsterConstantFlagType::NOGENO);
266 if (record_named_pet && monster.is_named_pet()) {
267 const auto m_name = monster_desc(player_ptr, &monster, MD_INDEF_VISIBLE);
268 exe_write_diary(player_ptr, DiaryKind::NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
271 delete_monster_idx(player_ptr, grid.m_idx);
272 msg_print(_("その邪悪なモンスターは硫黄臭い煙とともに消え去った!", "The evil creature vanishes in a puff of sulfurous smoke!"));
276 msg_print(_("祈りは効果がなかった!", "Your invocation is ineffectual!"));
278 monster.mflag2.set(MonsterConstantFlagType::NOGENO);
283 case PlayerMutationType::COLD_TOUCH: {
284 if (!get_direction(player_ptr, &dir)) {
288 const auto y = player_ptr->y + ddy[dir];
289 const auto x = player_ptr->x + ddx[dir];
290 auto &grid = floor.grid_array[y][x];
292 msg_print(_("あなたは何もない場所で手を振った。", "You wave your hands in the air."));
296 fire_bolt(player_ptr, AttributeType::COLD, dir, 2 * lvl);
299 case PlayerMutationType::LAUNCHER:
300 return ThrowCommand(player_ptr).do_cmd_throw(2 + lvl / 40, false, -1);
302 PlayerEnergy(player_ptr).reset_player_turn();
303 msg_format(_("能力 PlayerMutationType::%d は実装されていません。", "Power PlayerMutationType::%d not implemented. Oops."), enum2i(power));