OSDN Git Service

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