OSDN Git Service

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