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 "dungeon/quest.h"
10 #include "effect/attribute-types.h"
11 #include "effect/spells-effect-util.h"
12 #include "floor/geometry.h"
13 #include "game-option/play-record-options.h"
14 #include "inventory/inventory-slot-types.h"
15 #include "io/write-diary.h"
16 #include "mind/mind-mage.h"
17 #include "mind/mind-warrior.h"
18 #include "monster-floor/monster-remover.h"
19 #include "monster-floor/monster-summon.h"
20 #include "monster-floor/place-monster-types.h"
21 #include "monster-race/monster-race.h"
22 #include "monster-race/race-flags1.h"
23 #include "monster-race/race-flags3.h"
24 #include "monster/monster-describer.h"
25 #include "monster/monster-description-types.h"
26 #include "monster/monster-flag-types.h"
27 #include "monster/monster-info.h"
28 #include "mutation/mutation-flag-types.h"
29 #include "mutation/mutation-techniques.h"
30 #include "object-enchant/item-feeling.h"
31 #include "player-info/self-info.h"
32 #include "player-status/player-energy.h"
33 #include "player/player-damage.h"
34 #include "player/player-status.h"
35 #include "racial/racial-vampire.h"
36 #include "spell-kind/earthquake.h"
37 #include "spell-kind/spells-charm.h"
38 #include "spell-kind/spells-detection.h"
39 #include "spell-kind/spells-fetcher.h"
40 #include "spell-kind/spells-launcher.h"
41 #include "spell-kind/spells-lite.h"
42 #include "spell-kind/spells-sight.h"
43 #include "spell-kind/spells-teleport.h"
44 #include "spell-kind/spells-world.h"
45 #include "spell-realm/spells-sorcery.h"
46 #include "spell/spells-status.h"
47 #include "spell/summon-types.h"
48 #include "status/element-resistance.h"
49 #include "status/shape-changer.h"
50 #include "system/floor-type-definition.h"
51 #include "system/grid-type-definition.h"
52 #include "system/item-entity.h"
53 #include "system/monster-entity.h"
54 #include "system/monster-race-info.h"
55 #include "system/player-type-definition.h"
56 #include "target/target-getter.h"
57 #include "util/bit-flags-calculator.h"
58 #include "view/display-messages.h"
61 * @brief 突然変異のレイシャル効果実装
62 * @param player_ptr プレイヤーへの参照ポインタ
63 * @param power 発動させる突然変異レイシャルのID
64 * @return レイシャルを実行した場合TRUE、キャンセルした場合FALSEを返す
66 bool exe_mutation_power(PlayerType *player_ptr, PlayerMutationType power)
69 PLAYER_LEVEL lvl = player_ptr->lev;
70 auto &floor = *player_ptr->current_floor_ptr;
72 case PlayerMutationType::SPIT_ACID:
73 if (!get_aim_dir(player_ptr, &dir)) {
77 stop_mouth(player_ptr);
78 msg_print(_("酸を吐きかけた...", "You spit acid..."));
79 fire_ball(player_ptr, AttributeType::ACID, dir, lvl, 1 + (lvl / 30));
81 case PlayerMutationType::BR_FIRE:
82 if (!get_aim_dir(player_ptr, &dir)) {
86 stop_mouth(player_ptr);
87 msg_print(_("あなたは火炎のブレスを吐いた...", "You breathe fire..."));
88 fire_breath(player_ptr, AttributeType::FIRE, dir, lvl * 2, 1 + (lvl / 20));
90 case PlayerMutationType::HYPN_GAZE:
91 if (!get_aim_dir(player_ptr, &dir)) {
95 msg_print(_("あなたの目は幻惑的になった...", "Your eyes look mesmerizing..."));
96 (void)charm_monster(player_ptr, dir, lvl);
98 case PlayerMutationType::TELEKINES:
99 if (!get_aim_dir(player_ptr, &dir)) {
103 msg_print(_("集中している...", "You concentrate..."));
104 fetch_item(player_ptr, dir, lvl * 10, true);
106 case PlayerMutationType::VTELEPORT:
107 msg_print(_("集中している...", "You concentrate..."));
108 teleport_player(player_ptr, 10 + 4 * lvl, TELEPORT_SPONTANEOUS);
110 case PlayerMutationType::MIND_BLST:
111 if (!get_aim_dir(player_ptr, &dir)) {
115 msg_print(_("集中している...", "You concentrate..."));
116 fire_bolt(player_ptr, AttributeType::PSI, dir, damroll(3 + ((lvl - 1) / 5), 3));
118 case PlayerMutationType::RADIATION:
119 msg_print(_("体から放射能が発生した!", "Radiation flows from your body!"));
120 fire_ball(player_ptr, AttributeType::NUKE, 0, (lvl * 2), 3 + (lvl / 20));
122 case PlayerMutationType::VAMPIRISM:
123 vampirism(player_ptr);
125 case PlayerMutationType::SMELL_MET:
126 stop_mouth(player_ptr);
127 (void)detect_treasure(player_ptr, DETECT_RAD_DEFAULT);
129 case PlayerMutationType::SMELL_MON:
130 stop_mouth(player_ptr);
131 (void)detect_monsters_normal(player_ptr, DETECT_RAD_DEFAULT);
133 case PlayerMutationType::BLINK:
134 teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
136 case PlayerMutationType::EAT_ROCK:
137 return eat_rock(player_ptr);
138 case PlayerMutationType::SWAP_POS:
140 if (!get_aim_dir(player_ptr, &dir)) {
145 (void)teleport_swap(player_ptr, dir);
148 case PlayerMutationType::SHRIEK:
149 stop_mouth(player_ptr);
150 (void)fire_ball(player_ptr, AttributeType::SOUND, 0, 2 * lvl, 8);
151 (void)aggravate_monsters(player_ptr, 0);
153 case PlayerMutationType::ILLUMINE:
154 (void)lite_area(player_ptr, damroll(2, (lvl / 2)), (lvl / 10) + 1);
156 case PlayerMutationType::DET_CURSE:
157 for (int i = 0; i < INVEN_TOTAL; i++) {
158 auto *o_ptr = &player_ptr->inventory_list[i];
159 if (!o_ptr->is_valid() || !o_ptr->is_cursed()) {
163 o_ptr->feeling = FEEL_CURSED;
167 case PlayerMutationType::BERSERK:
168 (void)berserk(player_ptr, randint1(25) + 25);
170 case PlayerMutationType::POLYMORPH:
171 if (!input_check(_("変身します。よろしいですか?", "You will polymorph your self. Are you sure? "))) {
175 do_poly_self(player_ptr);
177 case PlayerMutationType::MIDAS_TCH:
178 return alchemy(player_ptr);
179 case PlayerMutationType::GROW_MOLD:
180 for (DIRECTION i = 0; i < 8; i++) {
181 summon_specific(player_ptr, -1, player_ptr->y, player_ptr->x, lvl, SUMMON_MOLD, PM_FORCE_PET);
185 case PlayerMutationType::RESIST: {
187 TIME_EFFECT dur = randint1(20) + 20;
188 if (randint0(5) < num) {
189 (void)set_oppose_acid(player_ptr, dur, false);
193 if (randint0(4) < num) {
194 (void)set_oppose_elec(player_ptr, dur, false);
198 if (randint0(3) < num) {
199 (void)set_oppose_fire(player_ptr, dur, false);
203 if (randint0(2) < num) {
204 (void)set_oppose_cold(player_ptr, dur, false);
209 (void)set_oppose_pois(player_ptr, dur, false);
215 case PlayerMutationType::EARTHQUAKE:
216 (void)earthquake(player_ptr, player_ptr->y, player_ptr->x, 10, 0);
218 case PlayerMutationType::EAT_MAGIC:
219 return eat_magic(player_ptr, player_ptr->lev * 2);
220 case PlayerMutationType::WEIGH_MAG:
221 report_magics(player_ptr);
223 case PlayerMutationType::STERILITY:
224 msg_print(_("突然頭が痛くなった!", "You suddenly have a headache!"));
225 take_hit(player_ptr, DAMAGE_LOSELIFE, randint1(17) + 17, _("禁欲を強いた疲労", "the strain of forcing abstinence"));
226 floor.num_repro += MAX_REPRODUCTION;
228 case PlayerMutationType::HIT_AND_AWAY:
229 return hit_and_away(player_ptr);
230 case PlayerMutationType::DAZZLE:
231 stun_monsters(player_ptr, lvl * 4);
232 confuse_monsters(player_ptr, lvl * 4);
233 turn_monsters(player_ptr, lvl * 4);
235 case PlayerMutationType::LASER_EYE:
236 if (!get_aim_dir(player_ptr, &dir)) {
240 fire_beam(player_ptr, AttributeType::LITE, dir, 2 * lvl);
242 case PlayerMutationType::RECALL:
243 return recall_player(player_ptr, randint0(21) + 15);
244 case PlayerMutationType::BANISH: {
245 if (!get_direction(player_ptr, &dir)) {
249 const auto y = player_ptr->y + ddy[dir];
250 const auto x = player_ptr->x + ddx[dir];
251 const auto &grid = floor.grid_array[y][x];
253 msg_print(_("邪悪な存在を感じとれません!", "You sense no evil there!"));
257 auto &monster = floor.m_list[grid.m_idx];
258 const auto &monrace = monster.get_monrace();
259 auto can_banish = monrace.kind_flags.has(MonsterKindType::EVIL);
260 can_banish &= monrace.misc_flags.has_not(MonsterMiscType::QUESTOR);
261 can_banish &= monrace.kind_flags.has_not(MonsterKindType::UNIQUE);
262 can_banish &= !floor.inside_arena;
263 can_banish &= !floor.is_in_quest();
264 can_banish &= (monrace.level < randint1(player_ptr->lev + 50));
265 can_banish &= monster.mflag2.has_not(MonsterConstantFlagType::NOGENO);
267 if (record_named_pet && monster.is_named_pet()) {
268 const auto m_name = monster_desc(player_ptr, &monster, MD_INDEF_VISIBLE);
269 exe_write_diary(player_ptr, DiaryKind::NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
272 delete_monster_idx(player_ptr, grid.m_idx);
273 msg_print(_("その邪悪なモンスターは硫黄臭い煙とともに消え去った!", "The evil creature vanishes in a puff of sulfurous smoke!"));
277 msg_print(_("祈りは効果がなかった!", "Your invocation is ineffectual!"));
279 monster.mflag2.set(MonsterConstantFlagType::NOGENO);
284 case PlayerMutationType::COLD_TOUCH: {
285 if (!get_direction(player_ptr, &dir)) {
289 const auto y = player_ptr->y + ddy[dir];
290 const auto x = player_ptr->x + ddx[dir];
291 auto &grid = floor.grid_array[y][x];
293 msg_print(_("あなたは何もない場所で手を振った。", "You wave your hands in the air."));
297 fire_bolt(player_ptr, AttributeType::COLD, dir, 2 * lvl);
300 case PlayerMutationType::LAUNCHER:
301 return ThrowCommand(player_ptr).do_cmd_throw(2 + lvl / 40, false, -1);
303 PlayerEnergy(player_ptr).reset_player_turn();
304 msg_format(_("能力 PlayerMutationType::%d は実装されていません。", "Power PlayerMutationType::%d not implemented. Oops."), enum2i(power));