1 #include "cmd-item/cmd-zapwand.h"
2 #include "action/action-limited.h"
3 #include "avatar/avatar.h"
4 #include "core/player-update-types.h"
5 #include "core/window-redrawer.h"
6 #include "floor/floor-object.h"
7 #include "game-option/disturbance-options.h"
8 #include "game-option/input-options.h"
9 #include "inventory/player-inventory.h"
10 #include "main/sound-definitions-table.h"
11 #include "main/sound-of-music.h"
12 #include "object-enchant/special-object-flags.h"
13 #include "object-use/zapwand-execution.h"
14 #include "object/item-tester-hooker.h"
15 #include "object/item-use-flags.h"
16 #include "object/object-info.h"
17 #include "object/object-kind.h"
18 #include "perception/object-perception.h"
19 #include "player-base/player-class.h"
20 #include "player-info/class-info.h"
21 #include "player-info/samurai-data-type.h"
22 #include "player-status/player-energy.h"
23 #include "player/attack-defense-types.h"
24 #include "player/special-defense-types.h"
25 #include "spell-kind/spells-beam.h"
26 #include "spell-kind/spells-charm.h"
27 #include "spell-kind/spells-launcher.h"
28 #include "spell-kind/spells-lite.h"
29 #include "spell-kind/spells-neighbor.h"
30 #include "spell-kind/spells-specific-bolt.h"
31 #include "spell-kind/spells-teleport.h"
32 #include "effect/attribute-types.h"
33 #include "spell/spells-status.h"
34 #include "status/action-setter.h"
35 #include "status/experience.h"
36 #include "sv-definition/sv-wand-types.h"
37 #include "system/object-type-definition.h"
38 #include "system/player-type-definition.h"
39 #include "target/target-getter.h"
40 #include "term/screen-processor.h"
41 #include "util/bit-flags-calculator.h"
42 #include "view/display-messages.h"
43 #include "view/object-describer.h"
47 * @param player_ptr プレイヤーへの参照ポインタ
48 * @param sval オブジェクトのsval
50 * @param powerful 強力発動上の処理ならばTRUE
51 * @param magic 魔道具術上の処理ならばTRUE
52 * @return 発動により効果内容が確定したならばTRUEを返す
54 bool wand_effect(player_type *player_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool powerful, bool magic)
57 PLAYER_LEVEL lev = powerful ? player_ptr->lev * 2 : player_ptr->lev;
58 POSITION rad = powerful ? 3 : 2;
60 /* XXX Hack -- Wand of wonder can do anything before it */
61 if (sval == SV_WAND_WONDER) {
62 int vir = virtue_number(player_ptr, V_CHANCE);
63 sval = (OBJECT_SUBTYPE_VALUE)randint0(SV_WAND_WONDER);
66 if (player_ptr->virtues[vir - 1] > 0) {
67 while (randint1(300) < player_ptr->virtues[vir - 1])
69 if (sval > SV_WAND_COLD_BALL)
70 sval = randint0(4) + SV_WAND_ACID_BALL;
72 while (randint1(300) < (0 - player_ptr->virtues[vir - 1]))
74 if (sval < SV_WAND_HEAL_MONSTER)
75 sval = randint0(3) + SV_WAND_HEAL_MONSTER;
78 if (sval < SV_WAND_TELEPORT_AWAY)
79 chg_virtue(player_ptr, V_CHANCE, 1);
82 /* Analyze the wand */
84 case SV_WAND_HEAL_MONSTER: {
85 HIT_POINT dam = damroll((powerful ? 20 : 10), 10);
86 if (heal_monster(player_ptr, dir, dam))
91 case SV_WAND_HASTE_MONSTER: {
92 if (speed_monster(player_ptr, dir, lev))
97 case SV_WAND_CLONE_MONSTER: {
98 if (clone_monster(player_ptr, dir))
103 case SV_WAND_TELEPORT_AWAY: {
104 int distance = MAX_SIGHT * (powerful ? 8 : 5);
105 if (teleport_monster(player_ptr, dir, distance))
110 case SV_WAND_DISARMING: {
111 if (disarm_trap(player_ptr, dir))
113 if (powerful && disarm_traps_touch(player_ptr))
118 case SV_WAND_TRAP_DOOR_DEST: {
119 if (destroy_door(player_ptr, dir))
121 if (powerful && destroy_doors_touch(player_ptr))
126 case SV_WAND_STONE_TO_MUD: {
127 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
128 if (wall_to_mud(player_ptr, dir, dam))
134 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
135 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
136 (void)lite_line(player_ptr, dir, dam);
141 case SV_WAND_SLEEP_MONSTER: {
142 if (sleep_monster(player_ptr, dir, lev))
147 case SV_WAND_SLOW_MONSTER: {
148 if (slow_monster(player_ptr, dir, lev))
153 case SV_WAND_CONFUSE_MONSTER: {
154 if (confuse_monster(player_ptr, dir, lev))
159 case SV_WAND_FEAR_MONSTER: {
160 if (fear_monster(player_ptr, dir, lev))
165 case SV_WAND_HYPODYNAMIA: {
166 if (hypodynamic_bolt(player_ptr, dir, 80 + lev))
171 case SV_WAND_POLYMORPH: {
172 if (poly_monster(player_ptr, dir, lev))
177 case SV_WAND_STINKING_CLOUD: {
178 fire_ball(player_ptr, AttributeType::POIS, dir, 12 + lev / 4, rad);
183 case SV_WAND_MAGIC_MISSILE: {
184 fire_bolt_or_beam(player_ptr, 20, AttributeType::MISSILE, dir, damroll(2 + lev / 10, 6));
189 case SV_WAND_ACID_BOLT: {
190 fire_bolt_or_beam(player_ptr, 20, AttributeType::ACID, dir, damroll(6 + lev / 7, 8));
195 case SV_WAND_CHARM_MONSTER: {
196 if (charm_monster(player_ptr, dir, std::max<short>(20, lev)))
201 case SV_WAND_FIRE_BOLT: {
202 fire_bolt_or_beam(player_ptr, 20, AttributeType::FIRE, dir, damroll(7 + lev / 6, 8));
207 case SV_WAND_COLD_BOLT: {
208 fire_bolt_or_beam(player_ptr, 20, AttributeType::COLD, dir, damroll(5 + lev / 8, 8));
213 case SV_WAND_ACID_BALL: {
214 fire_ball(player_ptr, AttributeType::ACID, dir, 60 + 3 * lev / 4, rad);
219 case SV_WAND_ELEC_BALL: {
220 fire_ball(player_ptr, AttributeType::ELEC, dir, 40 + 3 * lev / 4, rad);
225 case SV_WAND_FIRE_BALL: {
226 fire_ball(player_ptr, AttributeType::FIRE, dir, 70 + 3 * lev / 4, rad);
231 case SV_WAND_COLD_BALL: {
232 fire_ball(player_ptr, AttributeType::COLD, dir, 50 + 3 * lev / 4, rad);
237 case SV_WAND_WONDER: {
238 msg_print(_("おっと、謎の魔法棒を始動させた。", "Oops. Wand of wonder activated."));
242 case SV_WAND_DRAGON_FIRE: {
243 fire_breath(player_ptr, AttributeType::FIRE, dir, (powerful ? 300 : 200), 3);
248 case SV_WAND_DRAGON_COLD: {
249 fire_breath(player_ptr, AttributeType::COLD, dir, (powerful ? 270 : 180), 3);
254 case SV_WAND_DRAGON_BREATH: {
258 switch (randint1(5)) {
261 typ = AttributeType::ACID;
265 typ = AttributeType::ELEC;
269 typ = AttributeType::FIRE;
273 typ = AttributeType::COLD;
277 typ = AttributeType::POIS;
284 fire_breath(player_ptr, typ, dir, dam, 3);
290 case SV_WAND_DISINTEGRATE: {
291 fire_ball(player_ptr, AttributeType::DISINTEGRATE, dir, 200 + randint1(lev * 2), rad);
296 case SV_WAND_ROCKETS: {
297 msg_print(_("ロケットを発射した!", "You launch a rocket!"));
298 fire_rocket(player_ptr, AttributeType::ROCKET, dir, 250 + lev * 3, rad);
303 case SV_WAND_STRIKING: {
304 fire_bolt(player_ptr, AttributeType::METEOR, dir, damroll(15 + lev / 3, 13));
309 case SV_WAND_GENOCIDE: {
310 fire_ball_hide(player_ptr, AttributeType::GENOCIDE, dir, magic ? lev + 50 : 250, 0);
319 * @brief 魔法棒を使うコマンドのメインルーチン /
321 void do_cmd_aim_wand(player_type *player_ptr)
326 if (player_ptr->wild_mode)
328 if (cmd_limit_arena(player_ptr))
330 PlayerClass(player_ptr).break_samurai_stance({ SamuraiStance::MUSOU, SamuraiStance::KOUKIJIN });
332 q = _("どの魔法棒で狙いますか? ", "Aim which wand? ");
333 s = _("使える魔法棒がない。", "You have no wand to aim.");
334 if (!choose_object(player_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TvalItemTester(ItemKindType::WAND)))
337 ObjectZapWandEntity(player_ptr).execute(item);