OSDN Git Service

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