OSDN Git Service

[Refactor] #40414 Separated spells-launcher.c/h from spells2.c/h
[hengband/hengband.git] / src / realm / realm-arcane.c
1 #include "realm/realm-arcane.h"
2 #include "cmd-action/cmd-spell.h"
3 #include "io/targeting.h"
4 #include "player/avatar.h"
5 #include "player/player-effects.h"
6 #include "player/player-status.h"
7 #include "spell/spells-detection.h"
8 #include "spell/spells-diceroll.h"
9 #include "spell/spells-floor.h"
10 #include "spell/spells-launcher.h"
11 #include "spell/spells-object.h"
12 #include "spell/spells-status.h"
13 #include "spell/spells-summon.h"
14 #include "spell/spells-teleport.h"
15 #include "spell/spells-type.h"
16 #include "spell/spells2.h"
17 #include "spell/spells3.h"
18 #include "util/util.h"
19
20 /*!
21 * @brief 秘術領域魔法の各処理を行う
22 * @param caster_ptr プレーヤーへの参照ポインタ
23 * @param spell 魔法ID
24 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST)
25 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST時はNULL文字列を返す。
26 */
27 concptr do_arcane_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
28 {
29         bool name = (mode == SPELL_NAME) ? TRUE : FALSE;
30         bool desc = (mode == SPELL_DESC) ? TRUE : FALSE;
31         bool info = (mode == SPELL_INFO) ? TRUE : FALSE;
32         bool cast = (mode == SPELL_CAST) ? TRUE : FALSE;
33
34         DIRECTION dir;
35         PLAYER_LEVEL plev = caster_ptr->lev;
36
37         switch (spell)
38         {
39         case 0:
40                 if (name) return _("電撃", "Zap");
41                 if (desc) return _("電撃のボルトもしくはビームを放つ。", "Fires a bolt or beam of lightning.");
42
43                 {
44                         DICE_NUMBER dice = 3 + (plev - 1) / 5;
45                         DICE_SID sides = 3;
46
47                         if (info) return info_damage(dice, sides, 0);
48
49                         if (cast)
50                         {
51                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
52
53                                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_ELEC, dir, damroll(dice, sides));
54                         }
55                 }
56                 break;
57
58         case 1:
59                 if (name) return _("魔法の施錠", "Wizard Lock");
60                 if (desc) return _("扉に鍵をかける。", "Locks a door.");
61
62                 {
63                         if (cast)
64                         {
65                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
66
67                                 wizard_lock(caster_ptr, dir);
68                         }
69                 }
70                 break;
71
72         case 2:
73                 if (name) return _("透明体感知", "Detect Invisibility");
74                 if (desc) return _("近くの透明なモンスターを感知する。", "Detects all invisible monsters in your vicinity.");
75
76                 {
77                         POSITION rad = DETECT_RAD_DEFAULT;
78
79                         if (info) return info_radius(rad);
80
81                         if (cast)
82                         {
83                                 detect_monsters_invis(caster_ptr, rad);
84                         }
85                 }
86                 break;
87
88         case 3:
89                 if (name) return _("モンスター感知", "Detect Monsters");
90                 if (desc) return _("近くの全ての見えるモンスターを感知する。", "Detects all monsters in your vicinity unless invisible.");
91
92                 {
93                         POSITION rad = DETECT_RAD_DEFAULT;
94
95                         if (info) return info_radius(rad);
96
97                         if (cast)
98                         {
99                                 detect_monsters_normal(caster_ptr, rad);
100                         }
101                 }
102                 break;
103
104         case 4:
105                 if (name) return _("ショート・テレポート", "Blink");
106                 if (desc) return _("近距離のテレポートをする。", "Teleports you a short distance.");
107
108                 {
109                         POSITION range = 10;
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 _("ライト・エリア", "Light Area");
122                 if (desc) return _("光源が照らしている範囲か部屋全体を永久に明るくする。", "Lights up nearby area and the inside of a room permanently.");
123
124                 {
125                         DICE_NUMBER dice = 2;
126                         DICE_SID sides = plev / 2;
127                         POSITION rad = plev / 10 + 1;
128
129                         if (info) return info_damage(dice, sides, 0);
130
131                         if (cast)
132                         {
133                                 lite_area(caster_ptr, damroll(dice, sides), rad);
134                         }
135                 }
136                 break;
137
138         case 6:
139                 if (name) return _("罠と扉 破壊", "Trap & Door Destruction");
140                 if (desc) return _("一直線上の全ての罠と扉を破壊する。", "Fires a beam which destroy traps and doors.");
141
142                 {
143                         if (cast)
144                         {
145                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
146
147                                 destroy_door(caster_ptr, dir);
148                         }
149                 }
150                 break;
151
152         case 7:
153                 if (name) return _("軽傷の治癒", "Cure Light Wounds");
154                 if (desc) return _("怪我と体力を少し回復させる。", "Heals cuts and HP a little.");
155
156                 {
157                         DICE_NUMBER dice = 2;
158                         DICE_SID sides = 8;
159
160                         if (info) return info_heal(dice, sides, 0);
161                         if (cast) (void)cure_light_wounds(caster_ptr, dice, sides);
162                 }
163                 break;
164
165         case 8:
166                 if (name) return _("罠と扉 感知", "Detect Doors & Traps");
167                 if (desc) return _("近くの全ての罠と扉と階段を感知する。", "Detects traps, doors, and stairs in your vicinity.");
168
169                 {
170                         POSITION rad = DETECT_RAD_DEFAULT;
171
172                         if (info) return info_radius(rad);
173
174                         if (cast)
175                         {
176                                 detect_traps(caster_ptr, rad, TRUE);
177                                 detect_doors(caster_ptr, rad);
178                                 detect_stairs(caster_ptr, rad);
179                         }
180                 }
181                 break;
182
183         case 9:
184                 if (name) return _("燃素", "Phlogiston");
185                 if (desc) return _("光源に燃料を補給する。", "Adds more turns of light to a lantern or torch.");
186
187                 {
188                         if (cast)
189                         {
190                                 phlogiston(caster_ptr);
191                         }
192                 }
193                 break;
194
195         case 10:
196                 if (name) return _("財宝感知", "Detect Treasure");
197                 if (desc) return _("近くの財宝を感知する。", "Detects all treasures in your vicinity.");
198
199                 {
200                         POSITION rad = DETECT_RAD_DEFAULT;
201
202                         if (info) return info_radius(rad);
203
204                         if (cast)
205                         {
206                                 detect_treasure(caster_ptr, rad);
207                                 detect_objects_gold(caster_ptr, rad);
208                         }
209                 }
210                 break;
211
212         case 11:
213                 if (name) return _("魔法 感知", "Detect Enchantment");
214                 if (desc) return _("近くの魔法がかかったアイテムを感知する。", "Detects all magical items in your vicinity.");
215
216                 {
217                         POSITION rad = DETECT_RAD_DEFAULT;
218
219                         if (info) return info_radius(rad);
220
221                         if (cast)
222                         {
223                                 detect_objects_magic(caster_ptr, rad);
224                         }
225                 }
226                 break;
227
228         case 12:
229                 if (name) return _("アイテム感知", "Detect Objects");
230                 if (desc) return _("近くの全てのアイテムを感知する。", "Detects all items in your vicinity.");
231
232                 {
233                         POSITION rad = DETECT_RAD_DEFAULT;
234
235                         if (info) return info_radius(rad);
236
237                         if (cast)
238                         {
239                                 detect_objects_normal(caster_ptr, rad);
240                         }
241                 }
242                 break;
243
244         case 13:
245                 if (name) return _("解毒", "Cure Poison");
246                 if (desc) return _("毒を体内から完全に取り除く。", "Cures poison status.");
247
248                 {
249                         if (cast)
250                         {
251                                 set_poisoned(caster_ptr, 0);
252                         }
253                 }
254                 break;
255
256         case 14:
257                 if (name) return _("耐冷", "Resist Cold");
258                 if (desc) return _("一定時間、冷気への耐性を得る。装備による耐性に累積する。", "Gives resistance to cold. This resistance can be added to that from equipment for more powerful resistance.");
259
260                 {
261                         int base = 20;
262
263                         if (info) return info_duration(base, base);
264
265                         if (cast)
266                         {
267                                 set_oppose_cold(caster_ptr, randint1(base) + base, FALSE);
268                         }
269                 }
270                 break;
271
272         case 15:
273                 if (name) return _("耐火", "Resist Fire");
274                 if (desc) return _("一定時間、炎への耐性を得る。装備による耐性に累積する。",
275                         "Gives resistance to fire. This resistance can be added to that from equipment for more powerful resistance.");
276
277                 {
278                         int base = 20;
279
280                         if (info) return info_duration(base, base);
281
282                         if (cast)
283                         {
284                                 set_oppose_fire(caster_ptr, randint1(base) + base, FALSE);
285                         }
286                 }
287                 break;
288
289         case 16:
290                 if (name) return _("耐電", "Resist Lightning");
291                 if (desc) return _("一定時間、電撃への耐性を得る。装備による耐性に累積する。",
292                         "Gives resistance to electricity. This resistance can be added to that from equipment for more powerful resistance.");
293
294                 {
295                         int base = 20;
296
297                         if (info) return info_duration(base, base);
298
299                         if (cast)
300                         {
301                                 set_oppose_elec(caster_ptr, randint1(base) + base, FALSE);
302                         }
303                 }
304                 break;
305
306         case 17:
307                 if (name) return _("耐酸", "Resist Acid");
308                 if (desc) return _("一定時間、酸への耐性を得る。装備による耐性に累積する。",
309                         "Gives resistance to acid. This resistance can be added to that from equipment for more powerful resistance.");
310
311                 {
312                         int base = 20;
313
314                         if (info) return info_duration(base, base);
315
316                         if (cast)
317                         {
318                                 set_oppose_acid(caster_ptr, randint1(base) + base, FALSE);
319                         }
320                 }
321                 break;
322
323         case 18:
324                 if (name) return _("重傷の治癒", "Cure Medium Wounds");
325                 if (desc) return _("怪我と体力を中程度回復させる。", "Heals cuts and HP.");
326
327                 {
328                         DICE_NUMBER dice = 4;
329                         DICE_SID sides = 8;
330
331                         if (info) return info_heal(dice, sides, 0);
332                         if (cast) (void)cure_serious_wounds(caster_ptr, 4, 8);
333                 }
334                 break;
335
336         case 19:
337                 if (name) return _("テレポート", "Teleport");
338                 if (desc) return _("遠距離のテレポートをする。", "Teleports you a long distance.");
339
340                 {
341                         POSITION range = plev * 5;
342
343                         if (info) return info_range(range);
344
345                         if (cast)
346                         {
347                                 teleport_player(caster_ptr, range, TELEPORT_SPONTANEOUS);
348                         }
349                 }
350                 break;
351
352         case 20:
353                 if (name) return _("鑑定", "Identify");
354                 if (desc) return _("アイテムを識別する。", "Identifies an item.");
355
356                 {
357                         if (cast)
358                         {
359                                 if (!ident_spell(caster_ptr, FALSE, 0)) return NULL;
360                         }
361                 }
362                 break;
363
364         case 21:
365                 if (name) return _("岩石溶解", "Stone to Mud");
366                 if (desc) return _("壁を溶かして床にする。", "Turns one rock square to mud.");
367
368                 {
369                         DICE_NUMBER dice = 1;
370                         DICE_SID sides = 30;
371                         int base = 20;
372
373                         if (info) return info_damage(dice, sides, base);
374
375                         if (cast)
376                         {
377                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
378
379                                 wall_to_mud(caster_ptr, dir, 20 + randint1(30));
380                         }
381                 }
382                 break;
383
384         case 22:
385                 if (name) return _("閃光", "Ray of Light");
386                 if (desc) return _("光線を放つ。光りを嫌うモンスターに効果がある。", "Fires a beam of light which damages to light-sensitive monsters.");
387
388                 {
389                         DICE_NUMBER dice = 6;
390                         DICE_SID sides = 8;
391
392                         if (info) return info_damage(dice, sides, 0);
393
394                         if (cast)
395                         {
396                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
397
398                                 msg_print(_("光線が放たれた。", "A line of light appears."));
399                                 lite_line(caster_ptr, dir, damroll(6, 8));
400                         }
401                 }
402                 break;
403
404         case 23:
405                 if (name) return _("空腹充足", "Satisfy Hunger");
406                 if (desc) return _("満腹にする。", "Satisfies hunger.");
407
408                 {
409                         if (cast)
410                         {
411                                 set_food(caster_ptr, PY_FOOD_MAX - 1);
412                         }
413                 }
414                 break;
415
416         case 24:
417                 if (name) return _("透明視認", "See Invisible");
418                 if (desc) return _("一定時間、透明なものが見えるようになる。", "Gives see invisible for a while.");
419
420                 {
421                         int base = 24;
422
423                         if (info) return info_duration(base, base);
424
425                         if (cast)
426                         {
427                                 set_tim_invis(caster_ptr, randint1(base) + base, FALSE);
428                         }
429                 }
430                 break;
431
432         case 25:
433                 if (name) return _("エレメンタル召喚", "Conjure Elemental");
434                 if (desc) return _("1体のエレメンタルを召喚する。", "Summons an elemental.");
435                 {
436                         if (cast)
437                         {
438                                 if (!summon_specific(caster_ptr, -1, caster_ptr->y, caster_ptr->x, plev, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_FORCE_PET)))
439                                 {
440                                         msg_print(_("エレメンタルは現れなかった。", "No Elementals arrive."));
441                                 }
442                         }
443                 }
444                 break;
445
446         case 26:
447                 if (name) return _("テレポート・レベル", "Teleport Level");
448                 if (desc) return _("瞬時に上か下の階にテレポートする。", "Instantly teleports you up or down a level.");
449
450                 {
451                         if (cast)
452                         {
453                                 if (!get_check(_("本当に他の階にテレポートしますか?", "Are you sure? (Teleport Level)"))) return NULL;
454                                 teleport_level(caster_ptr, 0);
455                         }
456                 }
457                 break;
458
459         case 27:
460                 if (name) return _("テレポート・モンスター", "Teleport Away");
461                 if (desc) return _("モンスターをテレポートさせるビームを放つ。抵抗されると無効。", "Teleports all monsters on the line away unless resisted.");
462
463                 {
464                         int power = plev;
465
466                         if (info) return info_power(power);
467
468                         if (cast)
469                         {
470                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
471
472                                 fire_beam(caster_ptr, GF_AWAY_ALL, dir, power);
473                         }
474                 }
475                 break;
476
477         case 28:
478                 if (name) return _("元素の球", "Elemental Ball");
479                 if (desc) return _("炎、電撃、冷気、酸のどれかの球を放つ。", "Fires a ball of some elements.");
480
481                 {
482                         HIT_POINT dam = 75 + plev;
483                         POSITION rad = 2;
484
485                         if (info) return info_damage(0, 0, dam);
486
487                         if (cast)
488                         {
489                                 int type;
490
491                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
492
493                                 switch (randint1(4))
494                                 {
495                                 case 1:  type = GF_FIRE; break;
496                                 case 2:  type = GF_ELEC; break;
497                                 case 3:  type = GF_COLD; break;
498                                 default: type = GF_ACID; break;
499                                 }
500
501                                 fire_ball(caster_ptr, type, dir, dam, rad);
502                         }
503                 }
504                 break;
505
506         case 29:
507                 if (name) return _("全感知", "Detection");
508                 if (desc) return _("近くの全てのモンスター、罠、扉、階段、財宝、そしてアイテムを感知する。",
509                         "Detects all monsters, traps, doors, stairs, treasures and items in your vicinity.");
510
511                 {
512                         POSITION rad = DETECT_RAD_DEFAULT;
513
514                         if (info) return info_radius(rad);
515
516                         if (cast)
517                         {
518                                 detect_all(caster_ptr, rad);
519                         }
520                 }
521                 break;
522
523         case 30:
524                 if (name) return _("帰還の呪文", "Word of Recall");
525                 if (desc) return _("地上にいるときはダンジョンの最深階へ、ダンジョンにいるときは地上へと移動する。",
526                         "Recalls player from dungeon to town or from town to the deepest level of dungeon.");
527
528                 {
529                         int base = 15;
530                         DICE_SID sides = 20;
531
532                         if (info) return info_delay(base, sides);
533
534                         if (cast)
535                         {
536                                 if (!recall_player(caster_ptr, randint0(21) + 15)) return NULL;
537                         }
538                 }
539                 break;
540
541         case 31:
542                 if (name) return _("千里眼", "Clairvoyance");
543                 if (desc) return _("その階全体を永久に照らし、ダンジョン内すべてのアイテムを感知する。さらに、一定時間テレパシー能力を得る。",
544                         "Maps and lights whole dungeon level. Reveals locations of all objects. Gives telepathy for a while.");
545
546                 {
547                         int base = 25;
548                         DICE_SID sides = 30;
549
550                         if (info) return info_duration(base, sides);
551
552                         if (cast)
553                         {
554                                 chg_virtue(caster_ptr, V_KNOWLEDGE, 1);
555                                 chg_virtue(caster_ptr, V_ENLIGHTEN, 1);
556
557                                 wiz_lite(caster_ptr, FALSE);
558
559                                 if (!caster_ptr->telepathy)
560                                 {
561                                         set_tim_esp(caster_ptr, randint1(sides) + base, FALSE);
562                                 }
563                         }
564                 }
565                 break;
566         }
567
568         return "";
569 }