OSDN Git Service

Changed to match the For2.2.2-Refactoring-Cocoa2 branch. Put se_maoudamashii_voice_m...
[hengbandforosx/hengbandosx.git] / src / cmd-zapwand.c
1 #include "angband.h"
2 #include "avatar.h"
3 #include "spells-status.h"
4 #include "player-status.h"
5
6
7 /*!
8 * @brief 魔法棒の効果を発動する
9 * @param sval オブジェクトのsval
10 * @param dir 発動の方向ID
11 * @param powerful 強力発動上の処理ならばTRUE
12 * @param magic 魔道具術上の処理ならばTRUE
13 * @return 発動により効果内容が確定したならばTRUEを返す
14 */
15 bool wand_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool powerful, bool magic)
16 {
17         bool ident = FALSE;
18         PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
19         POSITION rad = powerful ? 3 : 2;
20
21         /* XXX Hack -- Wand of wonder can do anything before it */
22         if (sval == SV_WAND_WONDER)
23         {
24                 int vir = virtue_number(V_CHANCE);
25                 sval = (OBJECT_SUBTYPE_VALUE)randint0(SV_WAND_WONDER);
26
27                 if (vir)
28                 {
29                         if (p_ptr->virtues[vir - 1] > 0)
30                         {
31                                 while (randint1(300) < p_ptr->virtues[vir - 1]) sval++;
32                                 if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
33                         }
34                         else
35                         {
36                                 while (randint1(300) < (0 - p_ptr->virtues[vir - 1])) sval--;
37                                 if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
38                         }
39                 }
40                 if (sval < SV_WAND_TELEPORT_AWAY)
41                         chg_virtue(V_CHANCE, 1);
42         }
43
44         /* Analyze the wand */
45         switch (sval)
46         {
47                 case SV_WAND_HEAL_MONSTER:
48                 {
49                         HIT_POINT dam = damroll((powerful ? 20 : 10), 10);
50                         if (heal_monster(dir, dam)) ident = TRUE;
51                         break;
52                 }
53
54                 case SV_WAND_HASTE_MONSTER:
55                 {
56                         if (speed_monster(dir, lev)) ident = TRUE;
57                         break;
58                 }
59
60                 case SV_WAND_CLONE_MONSTER:
61                 {
62                         if (clone_monster(dir)) ident = TRUE;
63                         break;
64                 }
65
66                 case SV_WAND_TELEPORT_AWAY:
67                 {
68                         int distance = MAX_SIGHT * (powerful ? 8 : 5);
69                         if (teleport_monster(dir, distance)) ident = TRUE;
70                         break;
71                 }
72
73                 case SV_WAND_DISARMING:
74                 {
75                         if (disarm_trap(dir)) ident = TRUE;
76                         if (powerful && disarm_traps_touch()) ident = TRUE;
77                         break;
78                 }
79
80                 case SV_WAND_TRAP_DOOR_DEST:
81                 {
82                         if (destroy_door(dir)) ident = TRUE;
83                         if (powerful && destroy_doors_touch()) ident = TRUE;
84                         break;
85                 }
86
87                 case SV_WAND_STONE_TO_MUD:
88                 {
89                         HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
90                         if (wall_to_mud(dir, dam)) ident = TRUE;
91                         break;
92                 }
93
94                 case SV_WAND_LITE:
95                 {
96                         HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
97                         msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
98                         (void)lite_line(dir, dam);
99                         ident = TRUE;
100                         break;
101                 }
102
103                 case SV_WAND_SLEEP_MONSTER:
104                 {
105                         if (sleep_monster(dir, lev)) ident = TRUE;
106                         break;
107                 }
108
109                 case SV_WAND_SLOW_MONSTER:
110                 {
111                         if (slow_monster(dir, lev)) ident = TRUE;
112                         break;
113                 }
114
115                 case SV_WAND_CONFUSE_MONSTER:
116                 {
117                         if (confuse_monster(dir, lev)) ident = TRUE;
118                         break;
119                 }
120
121                 case SV_WAND_FEAR_MONSTER:
122                 {
123                         if (fear_monster(dir, lev)) ident = TRUE;
124                         break;
125                 }
126
127                 case SV_WAND_HYPODYNAMIA:
128                 {
129                         if (hypodynamic_bolt(dir, 80 + lev)) ident = TRUE;
130                         break;
131                 }
132
133                 case SV_WAND_POLYMORPH:
134                 {
135                         if (poly_monster(dir, lev)) ident = TRUE;
136                         break;
137                 }
138
139                 case SV_WAND_STINKING_CLOUD:
140                 {
141                         fire_ball(GF_POIS, dir, 12 + lev / 4, rad);
142                         ident = TRUE;
143                         break;
144                 }
145
146                 case SV_WAND_MAGIC_MISSILE:
147                 {
148                         fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(2 + lev / 10, 6));
149                         ident = TRUE;
150                         break;
151                 }
152
153                 case SV_WAND_ACID_BOLT:
154                 {
155                         fire_bolt_or_beam(20, GF_ACID, dir, damroll(6 + lev / 7, 8));
156                         ident = TRUE;
157                         break;
158                 }
159
160                 case SV_WAND_CHARM_MONSTER:
161                 {
162                         if (charm_monster(dir, MAX(20, lev)))
163                                 ident = TRUE;
164                         break;
165                 }
166
167                 case SV_WAND_FIRE_BOLT:
168                 {
169                         fire_bolt_or_beam(20, GF_FIRE, dir, damroll(7 + lev / 6, 8));
170                         ident = TRUE;
171                         break;
172                 }
173
174                 case SV_WAND_COLD_BOLT:
175                 {
176                         fire_bolt_or_beam(20, GF_COLD, dir, damroll(5 + lev / 8, 8));
177                         ident = TRUE;
178                         break;
179                 }
180
181                 case SV_WAND_ACID_BALL:
182                 {
183                         fire_ball(GF_ACID, dir, 60 + 3 * lev / 4, rad);
184                         ident = TRUE;
185                         break;
186                 }
187
188                 case SV_WAND_ELEC_BALL:
189                 {
190                         fire_ball(GF_ELEC, dir, 40 + 3 * lev / 4, rad);
191                         ident = TRUE;
192                         break;
193                 }
194
195                 case SV_WAND_FIRE_BALL:
196                 {
197                         fire_ball(GF_FIRE, dir, 70 + 3 * lev / 4, rad);
198                         ident = TRUE;
199                         break;
200                 }
201
202                 case SV_WAND_COLD_BALL:
203                 {
204                         fire_ball(GF_COLD, dir, 50 + 3 * lev / 4, rad);
205                         ident = TRUE;
206                         break;
207                 }
208
209                 case SV_WAND_WONDER:
210                 {
211                         msg_print(_("おっと、謎の魔法棒を始動させた。", "Oops.  Wand of wonder activated."));
212                         break;
213                 }
214
215                 case SV_WAND_DRAGON_FIRE:
216                 {
217                         fire_breath(GF_FIRE, dir, (powerful ? 300 : 200), 3);
218                         ident = TRUE;
219                         break;
220                 }
221
222                 case SV_WAND_DRAGON_COLD:
223                 {
224                         fire_breath(GF_COLD, dir, (powerful ? 270 : 180), 3);
225                         ident = TRUE;
226                         break;
227                 }
228
229                 case SV_WAND_DRAGON_BREATH:
230                 {
231                         HIT_POINT dam;
232                         EFFECT_ID typ;
233
234                         switch (randint1(5))
235                         {
236                         case 1:
237                                 dam = 240;
238                                 typ = GF_ACID;
239                                 break;
240                         case 2:
241                                 dam = 210;
242                                 typ = GF_ELEC;
243                                 break;
244                         case 3:
245                                 dam = 240;
246                                 typ = GF_FIRE;
247                                 break;
248                         case 4:
249                                 dam = 210;
250                                 typ = GF_COLD;
251                                 break;
252                         default:
253                                 dam = 180;
254                                 typ = GF_POIS;
255                                 break;
256                         }
257
258                         if (powerful) dam = (dam * 3) / 2;
259
260                         fire_breath(typ, dir, dam, 3);
261
262                         ident = TRUE;
263                         break;
264                 }
265
266                 case SV_WAND_DISINTEGRATE:
267                 {
268                         fire_ball(GF_DISINTEGRATE, dir, 200 + randint1(lev * 2), rad);
269                         ident = TRUE;
270                         break;
271                 }
272
273                 case SV_WAND_ROCKETS:
274                 {
275                         msg_print(_("ロケットを発射した!", "You launch a rocket!"));
276                         fire_rocket(GF_ROCKET, dir, 250 + lev * 3, rad);
277                         ident = TRUE;
278                         break;
279                 }
280
281                 case SV_WAND_STRIKING:
282                 {
283                         fire_bolt(GF_METEOR, dir, damroll(15 + lev / 3, 13));
284                         ident = TRUE;
285                         break;
286                 }
287
288                 case SV_WAND_GENOCIDE:
289                 {
290                         fire_ball_hide(GF_GENOCIDE, dir, magic ? lev + 50 : 250, 0);
291                         ident = TRUE;
292                         break;
293                 }
294         }
295         return ident;
296 }
297
298 /*!
299 * @brief 魔法棒を使うコマンドのサブルーチン /
300 * Aim a wand (from the pack or floor).
301 * @param item 使うオブジェクトの所持品ID
302 * @return なし
303 * @details
304 * <pre>
305 * Use a single charge from a single item.
306 * Handle "unstacking" in a logical manner.
307 * For simplicity, you cannot use a stack of items from the
308 * ground.  This would require too much nasty code.
309 * There are no wands which can "destroy" themselves, in the inventory
310 * or on the ground, so we can ignore this possibility.  Note that this
311 * required giving "wand of wonder" the ability to ignore destruction
312 * by electric balls.
313 * All wands can be "cancelled" at the "Direction?" prompt for free.
314 * Note that the basic "bolt" wands do slightly less damage than the
315 * basic "bolt" rods, but the basic "ball" wands do the same damage
316 * as the basic "ball" rods.
317 * </pre>
318 */
319 void do_cmd_aim_wand_aux(INVENTORY_IDX item)
320 {
321         DEPTH lev;
322         int ident, chance;
323         DIRECTION dir;
324         BIT_FLAGS inventory_flags;
325         object_type *o_ptr;
326         bool old_target_pet = target_pet;
327
328         /* Get the item (in the pack) */
329         if (item >= 0)
330         {
331                 o_ptr = &inventory[item];
332         }
333
334         /* Get the item (on the floor) */
335         else
336         {
337                 o_ptr = &current_floor_ptr->o_list[0 - item];
338         }
339
340         /* Mega-Hack -- refuse to aim a pile from the ground */
341         if ((item < 0) && (o_ptr->number > 1))
342         {
343                 msg_print(_("まずは魔法棒を拾わなければ。", "You must first pick up the wands."));
344                 return;
345         }
346
347
348         /* Allow direction to be cancelled for free */
349         if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
350                 || o_ptr->sval == SV_WAND_HASTE_MONSTER))
351                 target_pet = TRUE;
352         if (!get_aim_dir(&dir))
353         {
354                 target_pet = old_target_pet;
355                 return;
356         }
357         target_pet = old_target_pet;
358
359         take_turn(p_ptr, 100);
360
361         /* Get the level */
362         lev = k_info[o_ptr->k_idx].level;
363         if (lev > 50) lev = 50 + (lev - 50) / 2;
364
365         /* Base chance of success */
366         chance = p_ptr->skill_dev;
367
368         /* Confusion hurts skill */
369         if (p_ptr->confused) chance = chance / 2;
370
371         /* Hight level objects are harder */
372         chance = chance - lev;
373
374         /* Give everyone a (slight) chance */
375         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
376         {
377                 chance = USE_DEVICE;
378         }
379
380         if (cmd_limit_time_walk(p_ptr)) return;
381
382         /* Roll for usage */
383         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
384         {
385                 if (flush_failure) flush();
386                 msg_print(_("魔法棒をうまく使えなかった。", "You failed to use the wand properly."));
387                 sound(SOUND_FAIL);
388                 return;
389         }
390
391         /* The wand is already empty! */
392         if (o_ptr->pval <= 0)
393         {
394                 if (flush_failure) flush();
395                 msg_print(_("この魔法棒にはもう魔力が残っていない。", "The wand has no charges left."));
396                 o_ptr->ident |= (IDENT_EMPTY);
397                 p_ptr->update |= (PU_COMBINE | PU_REORDER);
398                 p_ptr->window |= (PW_INVEN);
399
400                 return;
401         }
402
403         sound(SOUND_ZAP);
404
405         ident = wand_effect(o_ptr->sval, dir, FALSE, FALSE);
406         /*
407          * Temporarily remove the flags for updating the inventory so
408          * gain_exp() does not reorder the inventory before the charge
409          * is deducted from the wand.
410          */
411         inventory_flags = (PU_COMBINE | PU_REORDER |
412                            (p_ptr->update & PU_AUTODESTROY));
413         p_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
414
415         if (!(object_is_aware(o_ptr)))
416         {
417                 chg_virtue(V_PATIENCE, -1);
418                 chg_virtue(V_CHANCE, 1);
419                 chg_virtue(V_KNOWLEDGE, -1);
420         }
421
422         /* Mark it as tried */
423         object_tried(o_ptr);
424
425         /* Apply identification */
426         if (ident && !object_is_aware(o_ptr))
427         {
428                 object_aware(o_ptr);
429                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
430         }
431
432         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
433         p_ptr->update |= inventory_flags;
434
435         /* Use a single charge */
436         o_ptr->pval--;
437
438         /* Describe the charges in the pack */
439         if (item >= 0)
440         {
441                 inven_item_charges(item);
442         }
443
444         /* Describe the charges on the floor */
445         else
446         {
447                 floor_item_charges(0 - item);
448         }
449 }
450
451 /*!
452 * @brief 魔法棒を使うコマンドのメインルーチン /
453 * @return なし
454 */
455 void do_cmd_aim_wand(void)
456 {
457         OBJECT_IDX item;
458         concptr q, s;
459
460         if (p_ptr->wild_mode) return;
461         if (cmd_limit_arena(p_ptr)) return;
462
463         /* Restrict choices to wands */
464         item_tester_tval = TV_WAND;
465
466         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
467         {
468                 set_action(ACTION_NONE);
469         }
470
471         q = _("どの魔法棒で狙いますか? ", "Aim which wand? ");
472         s = _("使える魔法棒がない。", "You have no wand to aim.");
473         if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
474
475         do_cmd_aim_wand_aux(item);
476 }