OSDN Git Service

[Refactor] #40477 Separated input-options.c/h from cmd-gameoption.c/h
[hengbandforosx/hengbandosx.git] / src / realm / realm-trump.c
1 #include "realm/realm-trump.h"
2 #include "cmd-action/cmd-spell.h"
3 #include "effect/spells-effect-util.h"
4 #include "game-option/input-options.h"
5 #include "io/targeting.h"
6 #include "monster-floor/place-monster-types.h"
7 #include "mutation/mutation.h"
8 #include "player/player-class.h"
9 #include "player/player-effects.h"
10 #include "spell-kind/spells-detection.h"
11 #include "spell-kind/spells-launcher.h"
12 #include "spell/spells-object.h"
13 #include "spell-kind/spells-sight.h"
14 #include "spell/spells-status.h"
15 #include "spell/spells-summon.h"
16 #include "spell-kind/spells-floor.h"
17 #include "spell-realm/spells-trump.h"
18 #include "spell-kind/spells-teleport.h"
19 #include "spell/spells-type.h"
20 #include "spell/spells3.h"
21 #include "util/util.h"
22
23 /*!
24 * @brief トランプ領域魔法の各処理を行う
25 * @param caster_ptr プレーヤーへの参照ポインタ
26 * @param spell 魔法ID
27 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST)
28 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST時はNULL文字列を返す。
29 */
30 concptr do_trump_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
31 {
32         bool name = (mode == SPELL_NAME) ? TRUE : FALSE;
33         bool desc = (mode == SPELL_DESC) ? TRUE : FALSE;
34         bool info = (mode == SPELL_INFO) ? TRUE : FALSE;
35         bool cast = (mode == SPELL_CAST) ? TRUE : FALSE;
36         bool fail = (mode == SPELL_FAIL) ? TRUE : FALSE;
37
38         DIRECTION dir;
39         PLAYER_LEVEL plev = caster_ptr->lev;
40
41         switch (spell)
42         {
43         case 0:
44                 if (name) return _("ショート・テレポート", "Phase Door");
45                 if (desc) return _("近距離のテレポートをする。", "Teleports you a short distance.");
46
47                 {
48                         POSITION range = 10;
49
50                         if (info) return info_range(range);
51
52                         if (cast)
53                         {
54                                 teleport_player(caster_ptr, range, TELEPORT_SPONTANEOUS);
55                         }
56                 }
57                 break;
58
59         case 1:
60                 if (name) return _("蜘蛛のカード", "Trump Spiders");
61                 if (desc) return _("蜘蛛を召喚する。", "Summons spiders.");
62
63                 {
64                         if (cast || fail)
65                         {
66                                 msg_print(_("あなたは蜘蛛のカードに集中する...", "You concentrate on the trump of an spider..."));
67                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_SPIDER, PM_ALLOW_GROUP))
68                                 {
69                                         if (fail)
70                                         {
71                                                 msg_print(_("召喚された蜘蛛は怒っている!", "The summoned spiders get angry!"));
72                                         }
73                                 }
74                         }
75                 }
76                 break;
77
78         case 2:
79                 if (name) return _("シャッフル", "Shuffle");
80                 if (desc) return _("カードの占いをする。", "Causes random effects.");
81
82                 {
83                         if (info) return KWD_RANDOM;
84
85                         if (cast)
86                         {
87                                 cast_shuffle(caster_ptr);
88                         }
89                 }
90                 break;
91
92         case 3:
93                 if (name) return _("フロア・リセット", "Reset Recall");
94                 if (desc) return _("最深階を変更する。", "Resets the 'deepest' level for recall spell.");
95
96                 {
97                         if (cast)
98                         {
99                                 if (!reset_recall(caster_ptr)) return NULL;
100                         }
101                 }
102                 break;
103
104         case 4:
105                 if (name) return _("テレポート", "Teleport");
106                 if (desc) return _("遠距離のテレポートをする。", "Teleports you a long distance.");
107
108                 {
109                         POSITION range = plev * 4;
110
111                         if (info) return info_range(range);
112
113                         if (cast)
114                         {
115                                 teleport_player(caster_ptr, range, TELEPORT_SPONTANEOUS);
116                         }
117                 }
118                 break;
119
120         case 5:
121                 if (name) return _("感知のカード", "Trump Spying");
122                 if (desc) return _("一定時間、テレパシー能力を得る。", "Gives telepathy for a while.");
123
124                 {
125                         int base = 25;
126                         DICE_SID sides = 30;
127
128                         if (info) return info_duration(base, sides);
129
130                         if (cast)
131                         {
132                                 set_tim_esp(caster_ptr, randint1(sides) + base, FALSE);
133                         }
134                 }
135                 break;
136
137         case 6:
138                 if (name) return _("テレポート・モンスター", "Teleport Away");
139                 if (desc) return _("モンスターをテレポートさせるビームを放つ。抵抗されると無効。", "Teleports all monsters on the line away unless resisted.");
140
141                 {
142                         int power = plev;
143
144                         if (info) return info_power(power);
145
146                         if (cast)
147                         {
148                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
149
150                                 fire_beam(caster_ptr, GF_AWAY_ALL, dir, power);
151                         }
152                 }
153                 break;
154
155         case 7:
156                 if (name) return _("動物のカード", "Trump Animals");
157                 if (desc) return _("1体の動物を召喚する。", "Summons an animal.");
158
159                 {
160                         if (cast || fail)
161                         {
162                                 int type = (!fail ? SUMMON_ANIMAL_RANGER : SUMMON_ANIMAL);
163                                 msg_print(_("あなたは動物のカードに集中する...", "You concentrate on the trump of an animal..."));
164                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, type, 0L))
165                                 {
166                                         if (fail)
167                                         {
168                                                 msg_print(_("召喚された動物は怒っている!", "The summoned animal gets angry!"));
169                                         }
170                                 }
171                         }
172                 }
173                 break;
174
175         case 8:
176                 if (name) return _("移動のカード", "Trump Reach");
177                 if (desc) return _("アイテムを自分の足元へ移動させる。", "Pulls a distant item close to you.");
178
179                 {
180                         WEIGHT weight = plev * 15;
181
182                         if (info) return info_weight(weight);
183
184                         if (cast)
185                         {
186                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
187
188                                 fetch(caster_ptr, dir, weight, FALSE);
189                         }
190                 }
191                 break;
192
193         case 9:
194                 if (name) return _("カミカゼのカード", "Trump Kamikaze");
195                 if (desc) return _("複数の爆発するモンスターを召喚する。", "Summons monsters which explode by itself.");
196
197                 {
198                         if (cast || fail)
199                         {
200                                 POSITION x, y;
201                                 int type;
202
203                                 if (cast)
204                                 {
205                                         if (!target_set(caster_ptr, TARGET_KILL)) return NULL;
206                                         x = target_col;
207                                         y = target_row;
208                                 }
209                                 else
210                                 {
211                                         /* Summons near player when failed */
212                                         x = caster_ptr->x;
213                                         y = caster_ptr->y;
214                                 }
215
216                                 if (caster_ptr->pclass == CLASS_BEASTMASTER)
217                                         type = SUMMON_KAMIKAZE_LIVING;
218                                 else
219                                         type = SUMMON_KAMIKAZE;
220
221                                 msg_print(_("あなたはカミカゼのカードに集中する...", "You concentrate on several trumps at once..."));
222                                 if (trump_summoning(caster_ptr, 2 + randint0(plev / 7), !fail, y, x, 0, type, 0L))
223                                 {
224                                         if (fail)
225                                         {
226                                                 msg_print(_("召喚されたモンスターは怒っている!", "The summoned creatures get angry!"));
227                                         }
228                                 }
229                         }
230                 }
231                 break;
232
233         case 10:
234                 if (name) return _("幻霊召喚", "Phantasmal Servant");
235                 if (desc) return _("1体の幽霊を召喚する。", "Summons a ghost.");
236
237                 {
238                         /* Phantasmal Servant is not summoned as enemy when failed */
239                         if (cast)
240                         {
241                                 int summon_lev = plev * 2 / 3 + randint1(plev / 2);
242
243                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, (summon_lev * 3 / 2), SUMMON_PHANTOM, 0L))
244                                 {
245                                         msg_print(_("御用でございますか、御主人様?", "'Your wish, master?'"));
246                                 }
247                         }
248                 }
249                 break;
250
251         case 11:
252                 if (name) return _("スピード・モンスター", "Haste Monster");
253                 if (desc) return _("モンスター1体を加速させる。", "Hastes a monster.");
254
255                 {
256                         if (cast)
257                         {
258                                 bool result;
259
260                                 /* Temporary enable target_pet option */
261                                 bool old_target_pet = target_pet;
262                                 target_pet = TRUE;
263
264                                 result = get_aim_dir(caster_ptr, &dir);
265
266                                 /* Restore target_pet option */
267                                 target_pet = old_target_pet;
268
269                                 if (!result) return NULL;
270
271                                 speed_monster(caster_ptr, dir, plev);
272                         }
273                 }
274                 break;
275
276         case 12:
277                 if (name) return _("テレポート・レベル", "Teleport Level");
278                 if (desc) return _("瞬時に上か下の階にテレポートする。", "Instantly teleports you up or down a level.");
279
280                 {
281                         if (cast)
282                         {
283                                 if (!get_check(_("本当に他の階にテレポートしますか?", "Are you sure? (Teleport Level)"))) return NULL;
284                                 teleport_level(caster_ptr, 0);
285                         }
286                 }
287                 break;
288
289         case 13:
290                 if (name) return _("次元の扉", "Dimension Door");
291                 if (desc) return _("短距離内の指定した場所にテレポートする。", "Teleports you to a given location.");
292
293                 {
294                         POSITION range = plev / 2 + 10;
295
296                         if (info) return info_range(range);
297
298                         if (cast)
299                         {
300                                 msg_print(_("次元の扉が開いた。目的地を選んで下さい。", "You open a dimensional gate. Choose a destination."));
301                                 if (!dimension_door(caster_ptr)) return NULL;
302                         }
303                 }
304                 break;
305
306         case 14:
307                 if (name) return _("帰還の呪文", "Word of Recall");
308                 if (desc) return _("地上にいるときはダンジョンの最深階へ、ダンジョンにいるときは地上へと移動する。",
309                         "Recalls player from dungeon to town or from town to the deepest level of dungeon.");
310
311                 {
312                         int base = 15;
313                         DICE_SID sides = 20;
314
315                         if (info) return info_delay(base, sides);
316
317                         if (cast)
318                         {
319                                 if (!recall_player(caster_ptr, randint0(21) + 15)) return NULL;
320                         }
321                 }
322                 break;
323
324         case 15:
325                 if (name) return _("怪物追放", "Banish");
326                 if (desc) return _("視界内の全てのモンスターをテレポートさせる。抵抗されると無効。", "Teleports all monsters in sight away unless resisted.");
327
328                 {
329                         int power = plev * 4;
330
331                         if (info) return info_power(power);
332
333                         if (cast)
334                         {
335                                 banish_monsters(caster_ptr, power);
336                         }
337                 }
338                 break;
339
340         case 16:
341                 if (name) return _("位置交換のカード", "Swap Position");
342                 if (desc) return _("1体のモンスターと位置を交換する。", "Swap positions of you and a monster.");
343
344                 {
345                         if (cast)
346                         {
347                                 bool result;
348
349                                 /* HACK -- No range limit */
350                                 project_length = -1;
351
352                                 result = get_aim_dir(caster_ptr, &dir);
353
354                                 /* Restore range to default */
355                                 project_length = 0;
356
357                                 if (!result) return NULL;
358
359                                 teleport_swap(caster_ptr, dir);
360                         }
361                 }
362                 break;
363
364         case 17:
365                 if (name) return _("アンデッドのカード", "Trump Undead");
366                 if (desc) return _("1体のアンデッドを召喚する。", "Summons an undead monster.");
367
368                 {
369                         if (cast || fail)
370                         {
371                                 msg_print(_("あなたはアンデッドのカードに集中する...", "You concentrate on the trump of an undead creature..."));
372                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_UNDEAD, 0L))
373                                 {
374                                         if (fail)
375                                         {
376                                                 msg_print(_("召喚されたアンデッドは怒っている!", "The summoned undead creature gets angry!"));
377                                         }
378                                 }
379                         }
380                 }
381                 break;
382
383         case 18:
384                 if (name) return _("爬虫類のカード", "Trump Reptile");
385                 if (desc) return _("1体のヒドラを召喚する。", "Summons a hydra.");
386
387                 {
388                         if (cast || fail)
389                         {
390                                 msg_print(_("あなたは爬虫類のカードに集中する...", "You concentrate on the trump of a reptile..."));
391                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_HYDRA, 0L))
392                                 {
393                                         if (fail)
394                                         {
395                                                 msg_print(_("召喚された爬虫類は怒っている!", "The summoned reptile gets angry!"));
396                                         }
397                                 }
398                         }
399                 }
400                 break;
401
402         case 19:
403                 if (name) return _("モンスターのカード", "Trump Monsters");
404                 if (desc) return _("複数のモンスターを召喚する。", "Summons some monsters.");
405
406                 {
407                         if (cast || fail)
408                         {
409                                 int type;
410                                 msg_print(_("あなたはモンスターのカードに集中する...", "You concentrate on several trumps at once..."));
411                                 if (caster_ptr->pclass == CLASS_BEASTMASTER)
412                                         type = SUMMON_LIVING;
413                                 else
414                                         type = 0;
415
416                                 if (trump_summoning(caster_ptr, (1 + (plev - 15) / 10), !fail, caster_ptr->y, caster_ptr->x, 0, type, 0L))
417                                 {
418                                         if (fail)
419                                         {
420                                                 msg_print(_("召喚されたモンスターは怒っている!", "The summoned creatures get angry!"));
421                                         }
422                                 }
423
424                         }
425                 }
426                 break;
427
428         case 20:
429                 if (name) return _("ハウンドのカード", "Trump Hounds");
430                 if (desc) return _("1グループのハウンドを召喚する。", "Summons a group of hounds.");
431
432                 {
433                         if (cast || fail)
434                         {
435                                 msg_print(_("あなたはハウンドのカードに集中する...", "You concentrate on the trump of a hound..."));
436                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_HOUND, PM_ALLOW_GROUP))
437                                 {
438                                         if (fail)
439                                         {
440                                                 msg_print(_("召喚されたハウンドは怒っている!", "The summoned hounds get angry!"));
441                                         }
442                                 }
443                         }
444                 }
445                 break;
446
447         case 21:
448                 if (name) return _("トランプの刃", "Trump Branding");
449                 if (desc) return _("武器にトランプの属性をつける。", "Makes current weapon a Trump weapon.");
450
451                 {
452                         if (cast)
453                         {
454                                 brand_weapon(caster_ptr, 5);
455                         }
456                 }
457                 break;
458
459         case 22:
460                 if (name) return _("人間トランプ", "Living Trump");
461                 if (desc) return _("ランダムにテレポートする突然変異か、自分の意思でテレポートする突然変異が身につく。",
462                         "Gives mutation which makes you teleport randomly or makes you able to teleport at will.");
463                 if (cast) become_living_trump(caster_ptr);
464                 break;
465
466         case 23:
467                 if (name) return _("サイバーデーモンのカード", "Trump Cyberdemon");
468                 if (desc) return _("1体のサイバーデーモンを召喚する。", "Summons a cyber demon.");
469
470                 {
471                         if (cast || fail)
472                         {
473                                 msg_print(_("あなたはサイバーデーモンのカードに集中する...", "You concentrate on the trump of a Cyberdemon..."));
474                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_CYBER, 0L))
475                                 {
476                                         if (fail)
477                                         {
478                                                 msg_print(_("召喚されたサイバーデーモンは怒っている!", "The summoned Cyberdemon gets angry!"));
479                                         }
480                                 }
481                         }
482                 }
483                 break;
484
485         case 24:
486                 if (name) return _("予見のカード", "Trump Divination");
487                 if (desc) return _("近くの全てのモンスター、罠、扉、階段、財宝、そしてアイテムを感知する。",
488                         "Detects all monsters, traps, doors, stairs, treasures and items in your vicinity.");
489
490                 {
491                         POSITION rad = DETECT_RAD_DEFAULT;
492
493                         if (info) return info_radius(rad);
494
495                         if (cast)
496                         {
497                                 detect_all(caster_ptr, rad);
498                         }
499                 }
500                 break;
501
502         case 25:
503                 if (name) return _("知識のカード", "Trump Lore");
504                 if (desc) return _("アイテムの持つ能力を完全に知る。", "*Identifies* an item.");
505
506                 {
507                         if (cast)
508                         {
509                                 if (!identify_fully(caster_ptr, FALSE, 0)) return NULL;
510                         }
511                 }
512                 break;
513
514         case 26:
515                 if (name) return _("回復モンスター", "Heal Monster");
516                 if (desc) return _("モンスター1体の体力を回復させる。", "Heals a monster.");
517
518                 {
519                         int heal = plev * 10 + 200;
520
521                         if (info) return info_heal(0, 0, heal);
522
523                         if (cast)
524                         {
525                                 bool result;
526
527                                 /* Temporary enable target_pet option */
528                                 bool old_target_pet = target_pet;
529                                 target_pet = TRUE;
530
531                                 result = get_aim_dir(caster_ptr, &dir);
532
533                                 /* Restore target_pet option */
534                                 target_pet = old_target_pet;
535
536                                 if (!result) return NULL;
537
538                                 heal_monster(caster_ptr, dir, heal);
539                         }
540                 }
541                 break;
542
543         case 27:
544                 if (name) return _("ドラゴンのカード", "Trump Dragon");
545                 if (desc) return _("1体のドラゴンを召喚する。", "Summons a dragon.");
546
547                 {
548                         if (cast || fail)
549                         {
550                                 msg_print(_("あなたはドラゴンのカードに集中する...", "You concentrate on the trump of a dragon..."));
551                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_DRAGON, 0L))
552                                 {
553                                         if (fail)
554                                         {
555                                                 msg_print(_("召喚されたドラゴンは怒っている!", "The summoned dragon gets angry!"));
556                                         }
557                                 }
558                         }
559                 }
560                 break;
561
562         case 28:
563                 if (name) return _("隕石のカード", "Trump Meteor");
564                 if (desc) return _("自分の周辺に隕石を落とす。", "Causes meteorites to fall down on nearby random locations.");
565
566                 {
567                         HIT_POINT dam = plev * 2;
568                         POSITION rad = 2;
569
570                         if (info) return info_multi_damage(dam);
571
572                         if (cast)
573                         {
574                                 cast_meteor(caster_ptr, dam, rad);
575                         }
576                 }
577                 break;
578
579         case 29:
580                 if (name) return _("デーモンのカード", "Trump Demon");
581                 if (desc) return _("1体の悪魔を召喚する。", "Summons a demon.");
582
583                 {
584                         if (cast || fail)
585                         {
586                                 msg_print(_("あなたはデーモンのカードに集中する...", "You concentrate on the trump of a demon..."));
587                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_DEMON, 0L))
588                                 {
589                                         if (fail)
590                                         {
591                                                 msg_print(_("召喚されたデーモンは怒っている!", "The summoned demon gets angry!"));
592                                         }
593                                 }
594                         }
595                 }
596                 break;
597
598         case 30:
599                 if (name) return _("地獄のカード", "Trump Greater Undead");
600                 if (desc) return _("1体の上級アンデッドを召喚する。", "Summons a greater undead.");
601
602                 {
603                         if (cast || fail)
604                         {
605                                 msg_print(_("あなたは強力なアンデッドのカードに集中する...", "You concentrate on the trump of a greater undead being..."));
606                                 /* May allow unique depend on level and dice roll */
607                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, SUMMON_HI_UNDEAD, PM_ALLOW_UNIQUE))
608                                 {
609                                         if (fail)
610                                         {
611                                                 msg_print(_("召喚された上級アンデッドは怒っている!", "The summoned greater undead creature gets angry!"));
612                                         }
613                                 }
614                         }
615                 }
616                 break;
617
618         case 31:
619                 if (name) return _("古代ドラゴンのカード", "Trump Ancient Dragon");
620                 if (desc) return _("1体の古代ドラゴンを召喚する。", "Summons an ancient dragon.");
621
622                 {
623                         if (cast)
624                         {
625                                 int type;
626
627                                 if (caster_ptr->pclass == CLASS_BEASTMASTER)
628                                         type = SUMMON_HI_DRAGON_LIVING;
629                                 else
630                                         type = SUMMON_HI_DRAGON;
631
632                                 msg_print(_("あなたは古代ドラゴンのカードに集中する...", "You concentrate on the trump of an ancient dragon..."));
633                                 /* May allow unique depend on level and dice roll */
634                                 if (trump_summoning(caster_ptr, 1, !fail, caster_ptr->y, caster_ptr->x, 0, type, PM_ALLOW_UNIQUE))
635                                 {
636                                         if (fail)
637                                         {
638                                                 msg_print(_("召喚された古代ドラゴンは怒っている!", "The summoned ancient dragon gets angry!"));
639                                         }
640                                 }
641                         }
642                 }
643                 break;
644         }
645
646         return "";
647 }