OSDN Git Service

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