OSDN Git Service

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