OSDN Git Service

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