OSDN Git Service

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