OSDN Git Service

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