3 #include "main/sound-definitions-table.h"
6 #include "player-status.h"
7 #include "player-effects.h"
8 #include "player-class.h"
9 #include "player-inventory.h"
10 #include "object/object-kind.h"
11 #include "object-hook.h"
13 #include "spells-status.h"
14 #include "spells-floor.h"
15 #include "cmd-basic.h"
17 #include "targeting.h"
18 #include "view-mainwindow.h"
22 * @param creature_ptr プレーヤーへの参照ポインタ
23 * @param sval オブジェクトのsval
24 * @param dir 発動目標の方向ID
25 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
26 * @param powerful 強力発動上の処理ならばTRUE
27 * @param magic 魔道具術上の処理ならばTRUE
28 * @return 発動により効果内容が確定したならばTRUEを返す
30 int rod_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
33 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
34 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
35 POSITION rad = powerful ? 3 : 2;
43 case SV_ROD_DETECT_TRAP:
45 if (detect_traps(creature_ptr, detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
49 case SV_ROD_DETECT_DOOR:
51 if (detect_doors(creature_ptr, detect_rad)) ident = TRUE;
52 if (detect_stairs(creature_ptr, detect_rad)) ident = TRUE;
59 if (!identify_fully(creature_ptr, FALSE)) *use_charge = FALSE;
62 if (!ident_spell(creature_ptr, FALSE)) *use_charge = FALSE;
70 if (!recall_player(creature_ptr, randint0(21) + 15)) *use_charge = FALSE;
75 case SV_ROD_ILLUMINATION:
77 if (lite_area(creature_ptr, damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
83 map_area(creature_ptr, powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
88 case SV_ROD_DETECTION:
90 detect_all(creature_ptr, detect_rad);
97 probing(creature_ptr);
104 if (true_healing(creature_ptr, 0)) ident = TRUE;
105 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
111 if(cure_critical_wounds(creature_ptr, powerful ? 750 : 500)) ident = TRUE;
115 case SV_ROD_RESTORATION:
117 if(restore_level(creature_ptr)) ident = TRUE;
118 if(restore_all_status(creature_ptr)) ident = TRUE;
124 if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
128 case SV_ROD_PESTICIDE:
130 if (dispel_monsters(creature_ptr, powerful ? 8 : 4)) ident = TRUE;
134 case SV_ROD_TELEPORT_AWAY:
136 int distance = MAX_SIGHT * (powerful ? 8 : 5);
137 if (teleport_monster(creature_ptr, dir, distance)) ident = TRUE;
141 case SV_ROD_DISARMING:
143 if (disarm_trap(creature_ptr, dir)) ident = TRUE;
144 if (powerful && disarm_traps_touch(creature_ptr)) ident = TRUE;
150 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
151 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
152 (void)lite_line(creature_ptr, dir, dam);
157 case SV_ROD_SLEEP_MONSTER:
159 if (sleep_monster(creature_ptr, dir, lev)) ident = TRUE;
163 case SV_ROD_SLOW_MONSTER:
165 if (slow_monster(creature_ptr, dir, lev)) ident = TRUE;
169 case SV_ROD_HYPODYNAMIA:
171 if (hypodynamic_bolt(creature_ptr, dir, 70 + 3 * lev / 2)) ident = TRUE;
175 case SV_ROD_POLYMORPH:
177 if (poly_monster(creature_ptr, dir, lev)) ident = TRUE;
181 case SV_ROD_ACID_BOLT:
183 fire_bolt_or_beam(creature_ptr, 10, GF_ACID, dir, damroll(6 + lev / 7, 8));
188 case SV_ROD_ELEC_BOLT:
190 fire_bolt_or_beam(creature_ptr, 10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
195 case SV_ROD_FIRE_BOLT:
197 fire_bolt_or_beam(creature_ptr, 10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
202 case SV_ROD_COLD_BOLT:
204 fire_bolt_or_beam(creature_ptr, 10, GF_COLD, dir, damroll(5 + lev / 8, 8));
209 case SV_ROD_ACID_BALL:
211 fire_ball(creature_ptr, GF_ACID, dir, 60 + lev, rad);
216 case SV_ROD_ELEC_BALL:
218 fire_ball(creature_ptr, GF_ELEC, dir, 40 + lev, rad);
223 case SV_ROD_FIRE_BALL:
225 fire_ball(creature_ptr, GF_FIRE, dir, 70 + lev, rad);
230 case SV_ROD_COLD_BALL:
232 fire_ball(creature_ptr, GF_COLD, dir, 50 + lev, rad);
239 call_chaos(creature_ptr);
244 case SV_ROD_STONE_TO_MUD:
246 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
247 if (wall_to_mud(creature_ptr, dir, dam)) ident = TRUE;
251 case SV_ROD_AGGRAVATE:
253 aggravate_monsters(creature_ptr, 0);
263 * @brief ロッドを使うコマンドのサブルーチン /
264 * Activate (zap) a Rod
265 * @param creature_ptr プレーヤーへの参照ポインタ
266 * @param item 使うオブジェクトの所持品ID
270 * Unstack fully charged rods as needed.
271 * Hack -- rods of perception/genocide can be "cancelled"
272 * All rods can be cancelled at the "Direction?" prompt
273 * pvals are defined for each rod in k_info. -LM-
276 void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
278 int ident, chance, lev, fail;
283 /* Hack -- let perception get aborted */
284 bool use_charge = TRUE;
288 o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
290 /* Mega-Hack -- refuse to zap a pile from the ground */
291 if ((item < 0) && (o_ptr->number > 1))
293 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
298 /* Get a direction (unless KNOWN not to need it) */
299 if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE) && (o_ptr->sval != SV_ROD_PESTICIDE)) ||
300 !object_is_aware(o_ptr))
302 /* Get a direction, allow cancel */
303 if (!get_aim_dir(creature_ptr, &dir)) return;
307 take_turn(creature_ptr, 100);
309 lev = k_info[o_ptr->k_idx].level;
311 /* Base chance of success */
312 chance = creature_ptr->skill_dev;
314 /* Confusion hurts skill */
315 if (creature_ptr->confused) chance = chance / 2;
318 if (chance > fail) fail -= (chance - fail) * 2;
319 else chance -= (fail - chance) * 2;
320 if (fail < USE_DEVICE) fail = USE_DEVICE;
321 if (chance < USE_DEVICE) chance = USE_DEVICE;
323 if (cmd_limit_time_walk(creature_ptr)) return;
325 if (creature_ptr->pclass == CLASS_BERSERKER) success = FALSE;
326 else if (chance > fail)
328 if (randint0(chance * 2) < fail) success = FALSE;
333 if (randint0(fail * 2) < chance) success = TRUE;
334 else success = FALSE;
340 if (flush_failure) flush();
341 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
346 k_ptr = &k_info[o_ptr->k_idx];
348 /* A single rod is still charging */
349 if ((o_ptr->number == 1) && (o_ptr->timeout))
351 if (flush_failure) flush();
352 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
355 /* A stack of rods lacks enough energy. */
356 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
358 if (flush_failure) flush();
359 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
365 ident = rod_effect(creature_ptr, o_ptr->sval, dir, &use_charge, FALSE, FALSE);
367 /* Increase the timeout by the rod kind's pval. -LM- */
368 if (use_charge) o_ptr->timeout += k_ptr->pval;
369 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
371 if (!(object_is_aware(o_ptr)))
373 chg_virtue(creature_ptr, V_PATIENCE, -1);
374 chg_virtue(creature_ptr, V_CHANCE, 1);
375 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
378 /* Tried the object */
381 /* Successfully determined the object function */
382 if (ident && !object_is_aware(o_ptr))
384 object_aware(creature_ptr, o_ptr);
385 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
388 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
393 * @brief ロッドを使うコマンドのメインルーチン /
394 * @param creature_ptr プレーヤーへの参照ポインタ
397 void do_cmd_zap_rod(player_type *creature_ptr)
402 if (creature_ptr->wild_mode)
407 if (cmd_limit_arena(creature_ptr)) return;
409 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
411 set_action(creature_ptr, ACTION_NONE);
414 q = _("どのロッドを振りますか? ", "Zap which rod? ");
415 s = _("使えるロッドがない。", "You have no rod to zap.");
417 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
420 exe_zap_rod(creature_ptr, item);