OSDN Git Service

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