OSDN Git Service

[Refactor] #2355 Moved remove_mirror() remove_all_mirros() from mind-mirror-master...
[hengbandforosx/hengbandosx.git] / src / racial / racial-switcher.cpp
1 /*!
2  * @brief レイシャルと突然変異の技能処理 / Racial powers (and mutations)
3  * @date 2014/01/08
4  * @author
5  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
6  * This software may be copied and distributed for educational, research,\n
7  * and not for profit purposes provided that this copyright and statement\n
8  * are included in all such copies.  Other copyrights may also apply.\n
9  * 2014 Deskull rearranged comment for Doxygen. \n
10  */
11
12 #include "racial/racial-switcher.h"
13 #include "action/action-limited.h"
14 #include "action/mutation-execution.h"
15 #include "cmd-action/cmd-mane.h"
16 #include "cmd-action/cmd-spell.h"
17 #include "cmd-item/cmd-magiceat.h"
18 #include "cmd-item/cmd-zapwand.h"
19 #include "core/player-redraw-types.h"
20 #include "core/player-update-types.h"
21 #include "core/stuff-handler.h"
22 #include "core/window-redrawer.h"
23 #include "effect/spells-effect-util.h"
24 #include "game-option/text-display-options.h"
25 #include "inventory/inventory-slot-types.h"
26 #include "io/command-repeater.h"
27 #include "io/input-key-acceptor.h"
28 #include "io/input-key-requester.h"
29 #include "main/sound-of-music.h"
30 #include "melee/melee-postprocess.h"
31 #include "mind/mind-archer.h"
32 #include "mind/mind-cavalry.h"
33 #include "mind/mind-elementalist.h"
34 #include "mind/mind-force-trainer.h"
35 #include "mind/mind-hobbit.h"
36 #include "mind/mind-mage.h"
37 #include "mind/mind-magic-eater.h"
38 #include "mind/mind-mirror-master.h"
39 #include "mind/mind-monk.h"
40 #include "mind/mind-ninja.h"
41 #include "mind/mind-priest.h"
42 #include "mind/mind-samurai.h"
43 #include "mind/mind-warrior-mage.h"
44 #include "mind/mind-warrior.h"
45 #include "mind/monk-attack.h"
46 #include "mind/stances-table.h"
47 #include "mutation/mutation-flag-types.h"
48 #include "object/item-tester-hooker.h"
49 #include "player-info/class-info.h"
50 #include "player-info/equipment-info.h"
51 #include "player-info/race-info.h"
52 #include "player-info/race-types.h"
53 #include "player-status/player-energy.h"
54 #include "player-status/player-hand-types.h"
55 #include "player/attack-defense-types.h"
56 #include "player/player-damage.h"
57 #include "player/player-status.h"
58 #include "racial/racial-android.h"
59 #include "racial/racial-balrog.h"
60 #include "racial/racial-draconian.h"
61 #include "racial/racial-kutar.h"
62 #include "racial/racial-vampire.h"
63 #include "realm/realm-names-table.h"
64 #include "spell-class/spells-mirror-master.h"
65 #include "spell-kind/spells-beam.h"
66 #include "spell-kind/spells-detection.h"
67 #include "spell-kind/spells-grid.h"
68 #include "spell-kind/spells-launcher.h"
69 #include "spell-kind/spells-neighbor.h"
70 #include "spell-kind/spells-perception.h"
71 #include "spell-kind/spells-sight.h"
72 #include "spell-kind/spells-teleport.h"
73 #include "spell-kind/spells-world.h"
74 #include "spell-realm/spells-hex.h"
75 #include "spell-realm/spells-song.h"
76 #include "spell/spells-status.h"
77 #include "status/action-setter.h"
78 #include "status/bad-status-setter.h"
79 #include "status/buff-setter.h"
80 #include "status/experience.h"
81 #include "system/player-type-definition.h"
82 #include "target/target-getter.h"
83 #include "timed-effect/player-paralysis.h"
84 #include "timed-effect/timed-effects.h"
85 #include "util/bit-flags-calculator.h"
86 #include "util/int-char-converter.h"
87 #include "view/display-messages.h"
88
89 bool switch_class_racial_execution(PlayerType *player_ptr, const int32_t command)
90 {
91     DIRECTION dir = 0;
92     switch (player_ptr->pclass) {
93     case PlayerClassType::WARRIOR:
94         return sword_dancing(player_ptr);
95     case PlayerClassType::HIGH_MAGE:
96         if (player_ptr->realm1 == REALM_HEX) {
97             auto retval = SpellHex(player_ptr).stop_spells_with_selection();
98             if (retval) {
99                 PlayerEnergy(player_ptr).set_player_turn_energy(10);
100             }
101
102             return retval;
103         }
104
105         /* Fall through */
106     case PlayerClassType::MAGE:
107     case PlayerClassType::SORCERER:
108         return eat_magic(player_ptr, player_ptr->lev * 2);
109     case PlayerClassType::PRIEST:
110         if (!is_good_realm(player_ptr->realm1)) {
111             (void)dispel_monsters(player_ptr, player_ptr->lev * 4);
112             turn_monsters(player_ptr, player_ptr->lev * 4);
113             banish_monsters(player_ptr, player_ptr->lev * 4);
114             return true;
115         }
116
117         return bless_weapon(player_ptr);
118     case PlayerClassType::ROGUE:
119         return hit_and_away(player_ptr);
120     case PlayerClassType::RANGER:
121     case PlayerClassType::SNIPER:
122         msg_print(_("敵を調査した...", "You examine your foes..."));
123         probing(player_ptr);
124         return true;
125     case PlayerClassType::PALADIN:
126         if (!get_aim_dir(player_ptr, &dir)) {
127             return false;
128         }
129
130         fire_beam(player_ptr, is_good_realm(player_ptr->realm1) ? AttributeType::HOLY_FIRE : AttributeType::HELL_FIRE, dir, player_ptr->lev * 3);
131         return true;
132     case PlayerClassType::WARRIOR_MAGE:
133         if (command == -3) {
134             return comvert_hp_to_mp(player_ptr);
135         } else if (command == -4) {
136             return comvert_mp_to_hp(player_ptr);
137         }
138
139         return true;
140     case PlayerClassType::CHAOS_WARRIOR:
141         return confusing_light(player_ptr);
142     case PlayerClassType::MONK:
143         if (none_bits(empty_hands(player_ptr, true), EMPTY_HAND_MAIN)) {
144             msg_print(_("素手じゃないとできません。", "You need to be barehanded."));
145             return false;
146         }
147
148         if (player_ptr->riding) {
149             msg_print(_("乗馬中はできません。", "You need to get off a pet."));
150             return false;
151         }
152
153         if (command == -3) {
154             if (!choose_monk_stance(player_ptr)) {
155                 return false;
156             }
157
158             set_bits(player_ptr->update, PU_BONUS);
159             return true;
160         }
161
162         if (command == -4) {
163             return double_attack(player_ptr);
164         }
165
166         return true;
167     case PlayerClassType::MINDCRAFTER:
168     case PlayerClassType::FORCETRAINER:
169         return clear_mind(player_ptr);
170     case PlayerClassType::TOURIST:
171         if (command == -3) {
172             if (!get_aim_dir(player_ptr, &dir)) {
173                 return false;
174             }
175
176             project_length = 1;
177             fire_beam(player_ptr, AttributeType::PHOTO, dir, 1);
178             return true;
179         }
180
181         return (command != -4) || identify_fully(player_ptr, false);
182     case PlayerClassType::IMITATOR:
183         handle_stuff(player_ptr);
184         return do_cmd_mane(player_ptr, true);
185     case PlayerClassType::BEASTMASTER:
186         if (command == -3) {
187             if (!get_aim_dir(player_ptr, &dir)) {
188                 return false;
189             }
190
191             (void)fire_ball_hide(player_ptr, AttributeType::CHARM_LIVING, dir, player_ptr->lev, 0);
192             return true;
193         }
194
195         if (command == -4) {
196             project_all_los(player_ptr, AttributeType::CHARM_LIVING, player_ptr->lev);
197         }
198
199         return true;
200     case PlayerClassType::ARCHER:
201         return create_ammo(player_ptr);
202     case PlayerClassType::MAGIC_EATER:
203         if (command == -3) {
204             return import_magic_device(player_ptr);
205         }
206
207         return (command != -4) || (!cmd_limit_cast(player_ptr) && do_cmd_magic_eater(player_ptr, false, true));
208     case PlayerClassType::BARD:
209         if ((get_singing_song_effect(player_ptr) == 0) && (get_interrupting_song_effect(player_ptr) == 0)) {
210             return false;
211         }
212
213         stop_singing(player_ptr);
214         PlayerEnergy(player_ptr).set_player_turn_energy(10);
215         return true;
216     case PlayerClassType::RED_MAGE:
217         if (cmd_limit_cast(player_ptr)) {
218             return false;
219         }
220
221         handle_stuff(player_ptr);
222         if (!do_cmd_cast(player_ptr)) {
223             return false;
224         }
225
226         if (!player_ptr->effects()->paralysis()->is_paralyzed() && !cmd_limit_cast(player_ptr)) {
227             handle_stuff(player_ptr);
228             command_dir = 0;
229             (void)do_cmd_cast(player_ptr);
230         }
231         return true;
232     case PlayerClassType::SAMURAI:
233         if (command == -3) {
234             concentration(player_ptr);
235             return true;
236         }
237
238         if (command != -4) {
239             return true;
240         }
241
242         if (!has_melee_weapon(player_ptr, INVEN_MAIN_HAND) && !has_melee_weapon(player_ptr, INVEN_SUB_HAND)) {
243             msg_print(_("武器を持たないといけません。", "You need to wield a weapon."));
244             return false;
245         }
246
247         if (!choose_samurai_stance(player_ptr)) {
248             return false;
249         }
250
251         set_bits(player_ptr->update, PU_BONUS);
252         return true;
253     case PlayerClassType::BLUE_MAGE:
254         set_action(player_ptr, player_ptr->action == ACTION_LEARN ? ACTION_NONE : ACTION_LEARN);
255         PlayerEnergy(player_ptr).reset_player_turn();
256         return true;
257     case PlayerClassType::CAVALRY:
258         return rodeo(player_ptr);
259     case PlayerClassType::BERSERKER:
260         return recall_player(player_ptr, randint0(21) + 15);
261     case PlayerClassType::SMITH:
262         if (player_ptr->lev <= 29) {
263             return ident_spell(player_ptr, true);
264         }
265
266         return identify_fully(player_ptr, true);
267     case PlayerClassType::MIRROR_MASTER:
268         if (command == -3) {
269             SpellsMirrorMaster(player_ptr).remove_all_mirrors(true);
270             return true;
271         }
272
273         if (command == -4) {
274             return mirror_concentration(player_ptr);
275         }
276
277         return true;
278     case PlayerClassType::NINJA:
279         return hayagake(player_ptr);
280     case PlayerClassType::ELEMENTALIST:
281         if (command == -3) {
282             return clear_mind(player_ptr);
283         }
284         if (command == -4) {
285             return switch_element_execution(player_ptr);
286         }
287         return true;
288     default:
289         return true;
290     }
291 }
292
293 bool switch_mimic_racial_execution(PlayerType *player_ptr)
294 {
295     switch (player_ptr->mimic_form) {
296     case MimicKindType::DEMON:
297     case MimicKindType::DEMON_LORD: {
298         return demonic_breath(player_ptr);
299     }
300     case MimicKindType::VAMPIRE:
301         vampirism(player_ptr);
302         return true;
303     default:
304         return true;
305     }
306 }
307
308 bool switch_race_racial_execution(PlayerType *player_ptr, const int32_t command)
309 {
310     DIRECTION dir = 0;
311     switch (player_ptr->prace) {
312     case PlayerRaceType::DWARF:
313         msg_print(_("周囲を調べた。", "You examine your surroundings."));
314         (void)detect_traps(player_ptr, DETECT_RAD_DEFAULT, true);
315         (void)detect_doors(player_ptr, DETECT_RAD_DEFAULT);
316         (void)detect_stairs(player_ptr, DETECT_RAD_DEFAULT);
317         return true;
318     case PlayerRaceType::HOBBIT:
319         return create_ration(player_ptr);
320     case PlayerRaceType::GNOME:
321         msg_print(_("パッ!", "Blink!"));
322         teleport_player(player_ptr, 10, TELEPORT_SPONTANEOUS);
323         return true;
324     case PlayerRaceType::HALF_ORC:
325         msg_print(_("勇気を出した。", "You play tough."));
326         (void)BadStatusSetter(player_ptr).fear(0);
327         return true;
328     case PlayerRaceType::HALF_TROLL:
329         msg_print(_("うがぁぁ!", "RAAAGH!"));
330         (void)berserk(player_ptr, 10 + randint1(player_ptr->lev));
331         return true;
332     case PlayerRaceType::AMBERITE:
333         if (command == -1) {
334             msg_print(_("あなたは歩き周り始めた。", "You start walking around. "));
335             reserve_alter_reality(player_ptr, randint0(21) + 15);
336             return true;
337         }
338
339         if (command != -2) {
340             return true;
341         }
342
343         msg_print(_("あなたは「パターン」を心に描いてその上を歩いた...", "You picture the Pattern in your mind and walk it..."));
344         (void)true_healing(player_ptr, 0);
345         (void)restore_all_status(player_ptr);
346         (void)restore_level(player_ptr);
347         return true;
348     case PlayerRaceType::BARBARIAN:
349         msg_print(_("うぉぉおお!", "Raaagh!"));
350         (void)berserk(player_ptr, 10 + randint1(player_ptr->lev));
351         return true;
352     case PlayerRaceType::HALF_OGRE:
353         msg_print(_("爆発のルーンを慎重に仕掛けた...", "You carefully set an explosive rune..."));
354         (void)create_rune_explosion(player_ptr, player_ptr->y, player_ptr->x);
355         return true;
356     case PlayerRaceType::HALF_GIANT:
357         if (!get_aim_dir(player_ptr, &dir)) {
358             return false;
359         }
360
361         (void)wall_to_mud(player_ptr, dir, 20 + randint1(30));
362         return true;
363     case PlayerRaceType::HALF_TITAN:
364         msg_print(_("敵を調査した...", "You examine your foes..."));
365         (void)probing(player_ptr);
366         return true;
367     case PlayerRaceType::CYCLOPS:
368         if (!get_aim_dir(player_ptr, &dir)) {
369             return false;
370         }
371
372         msg_print(_("巨大な岩を投げた。", "You throw a huge boulder."));
373         (void)fire_bolt(player_ptr, AttributeType::MISSILE, dir, (3 * player_ptr->lev) / 2);
374         return true;
375     case PlayerRaceType::YEEK:
376         if (!get_aim_dir(player_ptr, &dir)) {
377             return false;
378         }
379
380         stop_mouth(player_ptr);
381         msg_print(_("身の毛もよだつ叫び声を上げた!", "You make a horrible scream!"));
382         (void)fear_monster(player_ptr, dir, player_ptr->lev);
383         return true;
384     case PlayerRaceType::KLACKON:
385         if (!get_aim_dir(player_ptr, &dir)) {
386             return false;
387         }
388
389         stop_mouth(player_ptr);
390         msg_print(_("酸を吐いた。", "You spit acid."));
391         if (player_ptr->lev < 25) {
392             (void)fire_bolt(player_ptr, AttributeType::ACID, dir, player_ptr->lev);
393         } else {
394             (void)fire_ball(player_ptr, AttributeType::ACID, dir, player_ptr->lev, 2);
395         }
396
397         return true;
398     case PlayerRaceType::KOBOLD:
399         if (!get_aim_dir(player_ptr, &dir)) {
400             return false;
401         }
402
403         msg_print(_("毒のダーツを投げた。", "You throw a poisoned dart."));
404         (void)fire_bolt(player_ptr, AttributeType::POIS, dir, player_ptr->lev);
405         return true;
406     case PlayerRaceType::NIBELUNG:
407         msg_print(_("周囲を調査した。", "You examine your surroundings."));
408         (void)detect_traps(player_ptr, DETECT_RAD_DEFAULT, true);
409         (void)detect_doors(player_ptr, DETECT_RAD_DEFAULT);
410         (void)detect_stairs(player_ptr, DETECT_RAD_DEFAULT);
411         return true;
412     case PlayerRaceType::DARK_ELF:
413         if (!get_aim_dir(player_ptr, &dir)) {
414             return false;
415         }
416
417         msg_print(_("マジック・ミサイルを放った。", "You cast a magic missile."));
418         (void)fire_bolt_or_beam(player_ptr, 10, AttributeType::MISSILE, dir, damroll(3 + ((player_ptr->lev - 1) / 5), 4));
419         return true;
420     case PlayerRaceType::DRACONIAN:
421         return draconian_breath(player_ptr);
422     case PlayerRaceType::MIND_FLAYER:
423         if (!get_aim_dir(player_ptr, &dir)) {
424             return false;
425         }
426
427         msg_print(_("あなたは集中し、目が赤く輝いた...", "You concentrate and your eyes glow red..."));
428         (void)fire_bolt(player_ptr, AttributeType::PSI, dir, player_ptr->lev);
429         return true;
430     case PlayerRaceType::IMP:
431         if (!get_aim_dir(player_ptr, &dir)) {
432             return false;
433         }
434
435         if (player_ptr->lev >= 30) {
436             msg_print(_("ファイア・ボールを放った。", "You cast a ball of fire."));
437             (void)fire_ball(player_ptr, AttributeType::FIRE, dir, player_ptr->lev, 2);
438         } else {
439             msg_print(_("ファイア・ボルトを放った。", "You cast a bolt of fire."));
440             (void)fire_bolt(player_ptr, AttributeType::FIRE, dir, player_ptr->lev);
441         }
442
443         return true;
444     case PlayerRaceType::GOLEM:
445         (void)set_shield(player_ptr, randint1(20) + 30, false);
446         return true;
447     case PlayerRaceType::SKELETON:
448     case PlayerRaceType::ZOMBIE:
449         msg_print(_("あなたは失ったエネルギーを取り戻そうと試みた。", "You attempt to restore your lost energies."));
450         (void)restore_level(player_ptr);
451         return true;
452     case PlayerRaceType::VAMPIRE:
453         (void)vampirism(player_ptr);
454         return true;
455     case PlayerRaceType::SPECTRE:
456         if (!get_aim_dir(player_ptr, &dir)) {
457             return false;
458         }
459
460         stop_mouth(player_ptr);
461         msg_print(_("あなたはおどろおどろしい叫び声をあげた!", "You emit an eldritch howl!"));
462         (void)fear_monster(player_ptr, dir, player_ptr->lev);
463         return true;
464     case PlayerRaceType::SPRITE:
465         msg_print(_("あなたは魔法の粉を投げつけた...", "You throw some magic dust..."));
466         if (player_ptr->lev < 25) {
467             (void)sleep_monsters_touch(player_ptr);
468         } else {
469             (void)sleep_monsters(player_ptr, player_ptr->lev);
470         }
471
472         return true;
473     case PlayerRaceType::BALROG:
474         return demonic_breath(player_ptr);
475     case PlayerRaceType::KUTAR:
476         (void)set_leveling(player_ptr, randint1(20) + 30, false);
477         return true;
478     case PlayerRaceType::ANDROID:
479         return android_inside_weapon(player_ptr);
480     default:
481         msg_print(_("この種族は特殊な能力を持っていません。", "This race has no bonus power."));
482         PlayerEnergy(player_ptr).reset_player_turn();
483         return true;
484     }
485 }