3 #include "main/sound-definitions-table.h"
6 #include "spell/spells-type.h"
7 #include "spells-status.h"
8 #include "player-status.h"
9 #include "player-effects.h"
10 #include "player-class.h"
11 #include "player-inventory.h"
12 #include "object/object-kind.h"
13 #include "object-hook.h"
14 #include "cmd-basic.h"
16 #include "targeting.h"
17 #include "view/display-main-window.h"
18 #include "spell/spells2.h"
22 * @param creature_ptr プレーヤーへの参照ポインタ
23 * @param sval オブジェクトのsval
25 * @param powerful 強力発動上の処理ならばTRUE
26 * @param magic 魔道具術上の処理ならばTRUE
27 * @return 発動により効果内容が確定したならばTRUEを返す
29 bool wand_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool powerful, bool magic)
32 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
33 POSITION rad = powerful ? 3 : 2;
35 /* XXX Hack -- Wand of wonder can do anything before it */
36 if (sval == SV_WAND_WONDER)
38 int vir = virtue_number(creature_ptr, V_CHANCE);
39 sval = (OBJECT_SUBTYPE_VALUE)randint0(SV_WAND_WONDER);
43 if (creature_ptr->virtues[vir - 1] > 0)
45 while (randint1(300) < creature_ptr->virtues[vir - 1]) sval++;
46 if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
50 while (randint1(300) < (0 - creature_ptr->virtues[vir - 1])) sval--;
51 if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
54 if (sval < SV_WAND_TELEPORT_AWAY)
55 chg_virtue(creature_ptr, V_CHANCE, 1);
58 /* Analyze the wand */
61 case SV_WAND_HEAL_MONSTER:
63 HIT_POINT dam = damroll((powerful ? 20 : 10), 10);
64 if (heal_monster(creature_ptr, dir, dam)) ident = TRUE;
68 case SV_WAND_HASTE_MONSTER:
70 if (speed_monster(creature_ptr, dir, lev)) ident = TRUE;
74 case SV_WAND_CLONE_MONSTER:
76 if (clone_monster(creature_ptr, dir)) ident = TRUE;
80 case SV_WAND_TELEPORT_AWAY:
82 int distance = MAX_SIGHT * (powerful ? 8 : 5);
83 if (teleport_monster(creature_ptr, dir, distance)) ident = TRUE;
87 case SV_WAND_DISARMING:
89 if (disarm_trap(creature_ptr, dir)) ident = TRUE;
90 if (powerful && disarm_traps_touch(creature_ptr)) ident = TRUE;
94 case SV_WAND_TRAP_DOOR_DEST:
96 if (destroy_door(creature_ptr, dir)) ident = TRUE;
97 if (powerful && destroy_doors_touch(creature_ptr)) ident = TRUE;
101 case SV_WAND_STONE_TO_MUD:
103 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
104 if (wall_to_mud(creature_ptr, dir, dam)) ident = TRUE;
110 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
111 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
112 (void)lite_line(creature_ptr, dir, dam);
117 case SV_WAND_SLEEP_MONSTER:
119 if (sleep_monster(creature_ptr, dir, lev)) ident = TRUE;
123 case SV_WAND_SLOW_MONSTER:
125 if (slow_monster(creature_ptr, dir, lev)) ident = TRUE;
129 case SV_WAND_CONFUSE_MONSTER:
131 if (confuse_monster(creature_ptr, dir, lev)) ident = TRUE;
135 case SV_WAND_FEAR_MONSTER:
137 if (fear_monster(creature_ptr, dir, lev)) ident = TRUE;
141 case SV_WAND_HYPODYNAMIA:
143 if (hypodynamic_bolt(creature_ptr, dir, 80 + lev)) ident = TRUE;
147 case SV_WAND_POLYMORPH:
149 if (poly_monster(creature_ptr, dir, lev)) ident = TRUE;
153 case SV_WAND_STINKING_CLOUD:
155 fire_ball(creature_ptr, GF_POIS, dir, 12 + lev / 4, rad);
160 case SV_WAND_MAGIC_MISSILE:
162 fire_bolt_or_beam(creature_ptr, 20, GF_MISSILE, dir, damroll(2 + lev / 10, 6));
167 case SV_WAND_ACID_BOLT:
169 fire_bolt_or_beam(creature_ptr, 20, GF_ACID, dir, damroll(6 + lev / 7, 8));
174 case SV_WAND_CHARM_MONSTER:
176 if (charm_monster(creature_ptr, dir, MAX(20, lev)))
181 case SV_WAND_FIRE_BOLT:
183 fire_bolt_or_beam(creature_ptr, 20, GF_FIRE, dir, damroll(7 + lev / 6, 8));
188 case SV_WAND_COLD_BOLT:
190 fire_bolt_or_beam(creature_ptr, 20, GF_COLD, dir, damroll(5 + lev / 8, 8));
195 case SV_WAND_ACID_BALL:
197 fire_ball(creature_ptr, GF_ACID, dir, 60 + 3 * lev / 4, rad);
202 case SV_WAND_ELEC_BALL:
204 fire_ball(creature_ptr, GF_ELEC, dir, 40 + 3 * lev / 4, rad);
209 case SV_WAND_FIRE_BALL:
211 fire_ball(creature_ptr, GF_FIRE, dir, 70 + 3 * lev / 4, rad);
216 case SV_WAND_COLD_BALL:
218 fire_ball(creature_ptr, GF_COLD, dir, 50 + 3 * lev / 4, rad);
225 msg_print(_("おっと、謎の魔法棒を始動させた。", "Oops. Wand of wonder activated."));
229 case SV_WAND_DRAGON_FIRE:
231 fire_breath(creature_ptr, GF_FIRE, dir, (powerful ? 300 : 200), 3);
236 case SV_WAND_DRAGON_COLD:
238 fire_breath(creature_ptr, GF_COLD, dir, (powerful ? 270 : 180), 3);
243 case SV_WAND_DRAGON_BREATH:
272 if (powerful) dam = (dam * 3) / 2;
274 fire_breath(creature_ptr, typ, dir, dam, 3);
280 case SV_WAND_DISINTEGRATE:
282 fire_ball(creature_ptr, GF_DISINTEGRATE, dir, 200 + randint1(lev * 2), rad);
287 case SV_WAND_ROCKETS:
289 msg_print(_("ロケットを発射した!", "You launch a rocket!"));
290 fire_rocket(creature_ptr, GF_ROCKET, dir, 250 + lev * 3, rad);
295 case SV_WAND_STRIKING:
297 fire_bolt(creature_ptr, GF_METEOR, dir, damroll(15 + lev / 3, 13));
302 case SV_WAND_GENOCIDE:
304 fire_ball_hide(creature_ptr, GF_GENOCIDE, dir, magic ? lev + 50 : 250, 0);
313 * @brief 魔法棒を使うコマンドのサブルーチン /
314 * Aim a wand (from the pack or floor).
315 * @param item 使うオブジェクトの所持品ID
319 * Use a single charge from a single item.
320 * Handle "unstacking" in a logical manner.
321 * For simplicity, you cannot use a stack of items from the
322 * ground. This would require too much nasty code.
323 * There are no wands which can "destroy" themselves, in the inventory
324 * or on the ground, so we can ignore this possibility. Note that this
325 * required giving "wand of wonder" the ability to ignore destruction
327 * All wands can be "cancelled" at the "Direction?" prompt for free.
328 * Note that the basic "bolt" wands do slightly less damage than the
329 * basic "bolt" rods, but the basic "ball" wands do the same damage
330 * as the basic "ball" rods.
333 void exe_aim_wand(player_type *creature_ptr, INVENTORY_IDX item)
339 bool old_target_pet = target_pet;
341 o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
343 /* Mega-Hack -- refuse to aim a pile from the ground */
344 if ((item < 0) && (o_ptr->number > 1))
346 msg_print(_("まずは魔法棒を拾わなければ。", "You must first pick up the wands."));
351 /* Allow direction to be cancelled for free */
352 if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
353 || o_ptr->sval == SV_WAND_HASTE_MONSTER))
355 if (!get_aim_dir(creature_ptr, &dir))
357 target_pet = old_target_pet;
360 target_pet = old_target_pet;
362 take_turn(creature_ptr, 100);
365 lev = k_info[o_ptr->k_idx].level;
366 if (lev > 50) lev = 50 + (lev - 50) / 2;
368 /* Base chance of success */
369 chance = creature_ptr->skill_dev;
371 /* Confusion hurts skill */
372 if (creature_ptr->confused) chance = chance / 2;
374 /* Hight level objects are harder */
375 chance = chance - lev;
377 /* Give everyone a (slight) chance */
378 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
383 if (cmd_limit_time_walk(creature_ptr)) return;
386 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (creature_ptr->pclass == CLASS_BERSERKER))
388 if (flush_failure) flush();
389 msg_print(_("魔法棒をうまく使えなかった。", "You failed to use the wand properly."));
394 /* The wand is already empty! */
395 if (o_ptr->pval <= 0)
397 if (flush_failure) flush();
398 msg_print(_("この魔法棒にはもう魔力が残っていない。", "The wand has no charges left."));
399 o_ptr->ident |= (IDENT_EMPTY);
400 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
401 creature_ptr->window |= (PW_INVEN);
408 ident = wand_effect(creature_ptr, o_ptr->sval, dir, FALSE, FALSE);
411 * Temporarily remove the flags for updating the inventory so
412 * gain_exp() does not reorder the inventory before the charge
413 * is deducted from the wand.
415 BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
416 creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
418 if (!(object_is_aware(o_ptr)))
420 chg_virtue(creature_ptr, V_PATIENCE, -1);
421 chg_virtue(creature_ptr, V_CHANCE, 1);
422 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
425 /* Mark it as tried */
428 /* Apply identification */
429 if (ident && !object_is_aware(o_ptr))
431 object_aware(creature_ptr, o_ptr);
432 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
435 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
436 creature_ptr->update |= inventory_flags;
438 /* Use a single charge */
443 inven_item_charges(creature_ptr, item);
447 floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
451 * @brief 魔法棒を使うコマンドのメインルーチン /
454 void do_cmd_aim_wand(player_type *creature_ptr)
459 if (creature_ptr->wild_mode) return;
460 if (cmd_limit_arena(creature_ptr)) return;
461 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
463 set_action(creature_ptr, ACTION_NONE);
466 q = _("どの魔法棒で狙いますか? ", "Aim which wand? ");
467 s = _("使える魔法棒がない。", "You have no wand to aim.");
468 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_WAND)) return;
470 exe_aim_wand(creature_ptr, item);