OSDN Git Service

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