OSDN Git Service

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