OSDN Git Service

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