OSDN Git Service

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