OSDN Git Service

Merge branch 'For2.2.2-Refactoring' into For2.2.2-Fix-Hourier
[hengband/hengband.git] / src / realm / realm-nature.c
1 #include "angband.h"
2 #include "util.h"
3
4 #include "cmd-spell.h"
5 #include "spells-summon.h"
6 #include "spells-status.h"
7 #include "spells-object.h"
8 #include "spells-diceroll.h"
9 #include "avatar.h"
10 #include "spells-floor.h"
11 #include "player-race.h"
12 #include "player-effects.h"
13 #include "player-damage.h"
14 #include "targeting.h"
15 #include "effect/spells-effect-util.h"
16 #include "realm/realm-nature.h"
17 #include "spell/spells-type.h"
18 #include "spell/process-effect.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_nature_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 _("モンスター感知", "Detect Creatures");
41                 if (desc) return _("近くの全ての見えるモンスターを感知する。", "Detects all monsters in your vicinity unless invisible.");
42
43                 {
44                         POSITION rad = DETECT_RAD_DEFAULT;
45
46                         if (info) return info_radius(rad);
47
48                         if (cast)
49                         {
50                                 detect_monsters_normal(caster_ptr, rad);
51                         }
52                 }
53                 break;
54
55         case 1:
56                 if (name) return _("稲妻", "Lightning");
57                 if (desc) return _("電撃の短いビームを放つ。", "Fires a short beam of lightning.");
58
59                 {
60                         DICE_NUMBER dice = 3 + (plev - 1) / 5;
61                         DICE_SID sides = 4;
62                         POSITION range = plev / 6 + 2;
63
64                         if (info) return format("%s%dd%d %s%d", KWD_DAM, dice, sides, KWD_RANGE, range);
65
66                         if (cast)
67                         {
68                                 project_length = range;
69
70                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
71
72                                 fire_beam(caster_ptr, GF_ELEC, dir, damroll(dice, sides));
73                         }
74                 }
75                 break;
76
77         case 2:
78                 if (name) return _("罠と扉感知", "Detect Doors and Traps");
79                 if (desc) return _("近くの全ての罠と扉を感知する。", "Detects traps, doors, and stairs in your vicinity.");
80
81                 {
82                         POSITION rad = DETECT_RAD_DEFAULT;
83
84                         if (info) return info_radius(rad);
85
86                         if (cast)
87                         {
88                                 detect_traps(caster_ptr, rad, TRUE);
89                                 detect_doors(caster_ptr, rad);
90                                 detect_stairs(caster_ptr, rad);
91                         }
92                 }
93                 break;
94
95         case 3:
96                 if (name) return _("食糧生成", "Produce Food");
97                 if (desc) return _("食料を一つ作り出す。", "Produces a Ration of Food.");
98
99                 {
100                         if (cast)
101                         {
102                                 object_type forge, *q_ptr = &forge;
103                                 msg_print(_("食料を生成した。", "A food ration is produced."));
104
105                                 /* Create the food ration */
106                                 object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
107
108                                 /* Drop the object from heaven */
109                                 (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
110                         }
111                 }
112                 break;
113
114         case 4:
115                 if (name) return _("日の光", "Daylight");
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(caster_ptr, damroll(dice, sides), rad);
128
129                                 if ((PRACE_IS_(caster_ptr, RACE_VAMPIRE) || (caster_ptr->mimic_form == MIMIC_VAMPIRE)) && !caster_ptr->resist_lite)
130                                 {
131                                         msg_print(_("日の光があなたの肉体を焦がした!", "The daylight scorches your flesh!"));
132                                         take_hit(caster_ptr, DAMAGE_NOESCAPE, damroll(2, 2), _("日の光", "daylight"), -1);
133                                 }
134                         }
135                 }
136                 break;
137
138         case 5:
139                 if (name) return _("動物習し", "Animal Taming");
140                 if (desc) return _("動物1体を魅了する。抵抗されると無効。", "Attempts to charm an animal.");
141
142                 {
143                         int power = plev;
144
145                         if (info) return info_power(power);
146
147                         if (cast)
148                         {
149                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
150
151                                 charm_animal(caster_ptr, dir, plev);
152                         }
153                 }
154                 break;
155
156         case 6:
157                 if (name) return _("環境への耐性", "Resist Environment");
158                 if (desc) return _("一定時間、冷気、炎、電撃に対する耐性を得る。装備による耐性に累積する。",
159                         "Gives resistance to fire, cold and electricity for a while. These resistances can be added to those from equipment for more powerful resistances.");
160
161                 {
162                         int base = 20;
163
164                         if (info) return info_duration(base, base);
165
166                         if (cast)
167                         {
168                                 set_oppose_cold(caster_ptr, randint1(base) + base, FALSE);
169                                 set_oppose_fire(caster_ptr, randint1(base) + base, FALSE);
170                                 set_oppose_elec(caster_ptr, randint1(base) + base, FALSE);
171                         }
172                 }
173                 break;
174
175         case 7:
176                 if (name) return _("傷と毒治療", "Cure Wounds & Poison");
177                 if (desc) return _("怪我を全快させ、毒を体から完全に取り除き、体力を少し回復させる。", "Heals all cuts and poisons. Heals HP a little.");
178
179                 {
180                         DICE_NUMBER dice = 2;
181                         DICE_SID sides = 8;
182
183                         if (info) return info_heal(dice, sides, 0);
184
185                         if (cast)
186                         {
187                                 hp_player(caster_ptr, damroll(dice, sides));
188                                 set_cut(caster_ptr,0);
189                                 set_poisoned(caster_ptr, 0);
190                         }
191                 }
192                 break;
193
194         case 8:
195                 if (name) return _("岩石溶解", "Stone to Mud");
196                 if (desc) return _("壁を溶かして床にする。", "Turns one rock square to mud.");
197
198                 {
199                         DICE_NUMBER dice = 1;
200                         DICE_SID sides = 30;
201                         int base = 20;
202
203                         if (info) return info_damage(dice, sides, base);
204
205                         if (cast)
206                         {
207                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
208
209                                 wall_to_mud(caster_ptr, dir, 20 + randint1(30));
210                         }
211                 }
212                 break;
213
214         case 9:
215                 if (name) return _("アイス・ボルト", "Frost Bolt");
216                 if (desc) return _("冷気のボルトもしくはビームを放つ。", "Fires a bolt or beam of cold.");
217
218                 {
219                         DICE_NUMBER dice = 3 + (plev - 5) / 4;
220                         DICE_SID sides = 8;
221
222                         if (info) return info_damage(dice, sides, 0);
223
224                         if (cast)
225                         {
226                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
227                                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_COLD, dir, damroll(dice, sides));
228                         }
229                 }
230                 break;
231
232         case 10:
233                 if (name) return _("自然の覚醒", "Nature Awareness");
234                 if (desc) return _("周辺の地形を感知し、近くの罠、扉、階段、全てのモンスターを感知する。",
235                         "Maps nearby area. Detects all monsters, traps, doors and stairs.");
236
237                 {
238                         int rad1 = DETECT_RAD_MAP;
239                         int rad2 = DETECT_RAD_DEFAULT;
240
241                         if (info) return info_radius(MAX(rad1, rad2));
242
243                         if (cast)
244                         {
245                                 map_area(caster_ptr, rad1);
246                                 detect_traps(caster_ptr, rad2, TRUE);
247                                 detect_doors(caster_ptr, rad2);
248                                 detect_stairs(caster_ptr, rad2);
249                                 detect_monsters_normal(caster_ptr, rad2);
250                         }
251                 }
252                 break;
253
254         case 11:
255                 if (name) return _("ファイア・ボルト", "Fire Bolt");
256                 if (desc) return _("火炎のボルトもしくはビームを放つ。", "Fires a bolt or beam of fire.");
257
258                 {
259                         DICE_NUMBER dice = 5 + (plev - 5) / 4;
260                         DICE_SID sides = 8;
261
262                         if (info) return info_damage(dice, sides, 0);
263
264                         if (cast)
265                         {
266                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
267                                 fire_bolt_or_beam(caster_ptr, beam_chance(caster_ptr) - 10, GF_FIRE, dir, damroll(dice, sides));
268                         }
269                 }
270                 break;
271
272         case 12:
273                 if (name) return _("太陽光線", "Ray of Sunlight");
274                 if (desc) return _("光線を放つ。光りを嫌うモンスターに効果がある。", "Fires a beam of light which damages light-sensitive monsters.");
275
276                 {
277                         DICE_NUMBER dice = 6;
278                         DICE_SID sides = 8;
279
280                         if (info) return info_damage(dice, sides, 0);
281
282                         if (cast)
283                         {
284                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
285                                 msg_print(_("太陽光線が現れた。", "A line of sunlight appears."));
286                                 lite_line(caster_ptr, dir, damroll(6, 8));
287                         }
288                 }
289                 break;
290
291         case 13:
292                 if (name) return _("足かせ", "Entangle");
293                 if (desc) return _("視界内の全てのモンスターを減速させる。抵抗されると無効。", "Attempts to slow all monsters in sight.");
294                 {
295                         int power = plev;
296                         if (info) return info_power(power);
297                         if (cast) slow_monsters(caster_ptr, plev);
298                 }
299                 break;
300
301         case 14:
302                 if (name) return _("動物召喚", "Summon Animal");
303                 if (desc) return _("動物を1体召喚する。", "Summons an animal.");
304
305                 {
306                         if (cast)
307                         {
308                                 if (!(summon_specific(caster_ptr, -1, caster_ptr->y, caster_ptr->x, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET))))
309                                 {
310                                         msg_print(_("動物は現れなかった。", "No animals arrive."));
311                                 }
312                                 break;
313                         }
314                 }
315                 break;
316
317         case 15:
318                 if (name) return _("薬草治療", "Herbal Healing");
319                 if (desc) return _("体力を大幅に回復させ、負傷、朦朧状態、毒から全快する。", "Heals HP greatly. Completely cures cuts, poisons and being stunned.");
320                 {
321                         int heal = 500;
322                         if (info) return info_heal(0, 0, heal);
323                         if (cast) (void)cure_critical_wounds(caster_ptr, heal);
324                 }
325                 break;
326
327         case 16:
328                 if (name) return _("階段生成", "Stair Building");
329                 if (desc) return _("自分のいる位置に階段を作る。", "Creates a staircase which goes down or up.");
330
331                 {
332                         if (cast)
333                         {
334                                 stair_creation(caster_ptr);
335                         }
336                 }
337                 break;
338
339         case 17:
340                 if (name) return _("肌石化", "Stone Skin");
341                 if (desc) return _("一定時間、ACを上昇させる。", "Gives a bonus to AC for a while.");
342
343                 {
344                         int base = 20;
345                         DICE_SID sides = 30;
346
347                         if (info) return info_duration(base, sides);
348
349                         if (cast)
350                         {
351                                 set_shield(caster_ptr, randint1(sides) + base, FALSE);
352                         }
353                 }
354                 break;
355
356         case 18:
357                 if (name) return _("真・耐性", "Resistance True");
358                 if (desc) return _("一定時間、酸、電撃、炎、冷気、毒に対する耐性を得る。装備による耐性に累積する。",
359                         "Gives resistance to fire, cold, electricity, acid and poison for a while. These resistances can be added to those from equipment for more powerful resistances.");
360
361                 {
362                         int base = 20;
363
364                         if (info) return info_duration(base, base);
365
366                         if (cast)
367                         {
368                                 set_oppose_acid(caster_ptr, randint1(base) + base, FALSE);
369                                 set_oppose_elec(caster_ptr, randint1(base) + base, FALSE);
370                                 set_oppose_fire(caster_ptr, randint1(base) + base, FALSE);
371                                 set_oppose_cold(caster_ptr, randint1(base) + base, FALSE);
372                                 set_oppose_pois(caster_ptr, randint1(base) + base, FALSE);
373                         }
374                 }
375                 break;
376
377         case 19:
378                 if (name) return _("森林創造", "Forest Creation");
379                 if (desc) return _("周囲に木を作り出す。", "Creates trees in all adjacent squares.");
380
381                 {
382                         if (cast)
383                         {
384                                 tree_creation(caster_ptr, caster_ptr->y, caster_ptr->x);
385                         }
386                 }
387                 break;
388
389         case 20:
390                 if (name) return _("動物友和", "Animal Friendship");
391                 if (desc) return _("視界内の全ての動物を魅了する。抵抗されると無効。", "Attempts to charm all animals in sight.");
392
393                 {
394                         int power = plev * 2;
395                         if (info) return info_power(power);
396                         if (cast) charm_animals(caster_ptr, power);
397                 }
398                 break;
399
400         case 21:
401                 if (name) return _("試金石", "Stone Tell");
402                 if (desc) return _("アイテムの持つ能力を完全に知る。", "*Identifies* an item.");
403
404                 {
405                         if (cast)
406                         {
407                                 if (!identify_fully(caster_ptr, FALSE, 0)) return NULL;
408                         }
409                 }
410                 break;
411
412         case 22:
413                 if (name) return _("石の壁", "Wall of Stone");
414                 if (desc) return _("自分の周囲に花崗岩の壁を作る。", "Creates granite walls in all adjacent squares.");
415
416                 {
417                         if (cast)
418                         {
419                                 wall_stone(caster_ptr);
420                         }
421                 }
422                 break;
423
424         case 23:
425                 if (name) return _("腐食防止", "Protect from Corrosion");
426                 if (desc) return _("アイテムを酸で傷つかないよう加工する。", "Makes a piece of equipment acid-proof.");
427
428                 {
429                         if (cast)
430                         {
431                                 if (!rustproof(caster_ptr)) return NULL;
432                         }
433                 }
434                 break;
435
436         case 24:
437                 if (name) return _("地震", "Earthquake");
438                 if (desc) return _("周囲のダンジョンを揺らし、壁と床をランダムに入れ変える。",
439                         "Shakes dungeon structure, and results in random swapping of floors and walls.");
440
441                 {
442                         POSITION rad = 10;
443
444                         if (info) return info_radius(rad);
445
446                         if (cast)
447                         {
448                                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, rad, 0);
449                         }
450                 }
451                 break;
452
453         case 25:
454                 if (name) return _("カマイタチ", "Whirlwind");
455                 if (desc) return _("全方向に向かって攻撃する。", "Attacks all adjacent monsters.");
456                 if (cast) massacre(caster_ptr);
457                 break;
458
459         case 26:
460                 if (name) return _("ブリザード", "Blizzard");
461                 if (desc) return _("巨大な冷気の球を放つ。", "Fires a huge ball of cold.");
462
463                 {
464                         HIT_POINT dam = 70 + plev * 3 / 2;
465                         POSITION rad = plev / 12 + 1;
466
467                         if (info) return info_damage(0, 0, dam);
468
469                         if (cast)
470                         {
471                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
472
473                                 fire_ball(caster_ptr, GF_COLD, dir, dam, rad);
474                         }
475                 }
476                 break;
477
478         case 27:
479                 if (name) return _("稲妻嵐", "Lightning Storm");
480                 if (desc) return _("巨大な電撃の球を放つ。", "Fires a huge electric ball.");
481
482                 {
483                         HIT_POINT dam = 90 + plev * 3 / 2;
484                         POSITION rad = plev / 12 + 1;
485
486                         if (info) return info_damage(0, 0, dam);
487
488                         if (cast)
489                         {
490                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
491                                 fire_ball(caster_ptr, GF_ELEC, dir, dam, rad);
492                                 break;
493                         }
494                 }
495                 break;
496
497         case 28:
498                 if (name) return _("渦潮", "Whirlpool");
499                 if (desc) return _("巨大な水の球を放つ。", "Fires a huge ball of water.");
500
501                 {
502                         HIT_POINT dam = 100 + plev * 3 / 2;
503                         POSITION rad = plev / 12 + 1;
504
505                         if (info) return info_damage(0, 0, dam);
506
507                         if (cast)
508                         {
509                                 if (!get_aim_dir(caster_ptr, &dir)) return NULL;
510                                 fire_ball(caster_ptr, GF_WATER, dir, dam, rad);
511                         }
512                 }
513                 break;
514
515         case 29:
516                 if (name) return _("陽光召喚", "Call Sunlight");
517                 if (desc) return _("自分を中心とした光の球を発生させる。さらに、その階全体を永久に照らし、ダンジョン内すべてのアイテムを感知する。",
518                         "Generates ball of light centered on you. Maps and lights whole dungeon level. Knows all objects location.");
519
520                 {
521                         HIT_POINT dam = 150;
522                         POSITION rad = 8;
523
524                         if (info) return info_damage(0, 0, dam / 2);
525
526                         if (cast)
527                         {
528                                 fire_ball(caster_ptr, GF_LITE, 0, dam, rad);
529                                 chg_virtue(caster_ptr, V_KNOWLEDGE, 1);
530                                 chg_virtue(caster_ptr, V_ENLIGHTEN, 1);
531                                 wiz_lite(caster_ptr, FALSE);
532
533                                 if ((PRACE_IS_(caster_ptr, RACE_VAMPIRE) || (caster_ptr->mimic_form == MIMIC_VAMPIRE)) && !caster_ptr->resist_lite)
534                                 {
535                                         msg_print(_("日光があなたの肉体を焦がした!", "The sunlight scorches your flesh!"));
536                                         take_hit(caster_ptr, DAMAGE_NOESCAPE, 50, _("日光", "sunlight"), -1);
537                                 }
538                         }
539                 }
540                 break;
541
542         case 30:
543                 if (name) return _("精霊の刃", "Elemental Branding");
544                 if (desc) return _("武器に炎か冷気の属性をつける。", "Brands current weapon with fire or frost.");
545
546                 {
547                         if (cast)
548                         {
549                                 brand_weapon(caster_ptr, randint0(2));
550                         }
551                 }
552                 break;
553
554         case 31:
555                 if (name) return _("自然の脅威", "Nature's Wrath");
556                 if (desc) return _("近くの全てのモンスターにダメージを与え、地震を起こし、自分を中心とした分解の球を発生させる。",
557                         "Damages all monsters in sight. Makes quake. Generates disintegration ball centered on you.");
558
559                 {
560                         int d_dam = 4 * plev;
561                         int b_dam = (100 + plev) * 2;
562                         POSITION b_rad = 1 + plev / 12;
563                         POSITION q_rad = 20 + plev / 2;
564
565                         if (info) return format("%s%d+%d", KWD_DAM, d_dam, b_dam / 2);
566
567                         if (cast)
568                         {
569                                 dispel_monsters(caster_ptr, d_dam);
570                                 earthquake(caster_ptr, caster_ptr->y, caster_ptr->x, q_rad, 0);
571                                 project(caster_ptr, 0, b_rad, caster_ptr->y, caster_ptr->x, b_dam, GF_DISINTEGRATE, PROJECT_KILL | PROJECT_ITEM, -1);
572                         }
573                 }
574                 break;
575         }
576
577         return "";
578 }
579