5 #include "player-status.h"
6 #include "player-effects.h"
7 #include "object-hook.h"
9 #include "spells-status.h"
10 #include "spells-floor.h"
11 #include "cmd-basic.h"
16 * @param sval オブジェクトのsval
17 * @param dir 発動目標の方向ID
18 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
19 * @param powerful 強力発動上の処理ならばTRUE
20 * @param magic 魔道具術上の処理ならばTRUE
21 * @return 発動により効果内容が確定したならばTRUEを返す
23 int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
26 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
27 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
28 POSITION rad = powerful ? 3 : 2;
36 case SV_ROD_DETECT_TRAP:
38 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
42 case SV_ROD_DETECT_DOOR:
44 if (detect_doors(detect_rad)) ident = TRUE;
45 if (detect_stairs(detect_rad)) ident = TRUE;
52 if (!identify_fully(FALSE)) *use_charge = FALSE;
55 if (!ident_spell(FALSE)) *use_charge = FALSE;
63 if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
68 case SV_ROD_ILLUMINATION:
70 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
76 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
81 case SV_ROD_DETECTION:
83 detect_all(detect_rad);
97 if (true_healing(0)) ident = TRUE;
98 if (set_shero(0, TRUE)) ident = TRUE;
104 if(cure_critical_wounds(powerful ? 750 : 500)) ident = TRUE;
108 case SV_ROD_RESTORATION:
110 if(restore_level()) ident = TRUE;
111 if(restore_all_status()) ident = TRUE;
117 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
121 case SV_ROD_PESTICIDE:
123 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
127 case SV_ROD_TELEPORT_AWAY:
129 int distance = MAX_SIGHT * (powerful ? 8 : 5);
130 if (teleport_monster(dir, distance)) ident = TRUE;
134 case SV_ROD_DISARMING:
136 if (disarm_trap(dir)) ident = TRUE;
137 if (powerful && disarm_traps_touch()) ident = TRUE;
143 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
144 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
145 (void)lite_line(dir, dam);
150 case SV_ROD_SLEEP_MONSTER:
152 if (sleep_monster(dir, lev)) ident = TRUE;
156 case SV_ROD_SLOW_MONSTER:
158 if (slow_monster(dir, lev)) ident = TRUE;
162 case SV_ROD_HYPODYNAMIA:
164 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
168 case SV_ROD_POLYMORPH:
170 if (poly_monster(dir, lev)) ident = TRUE;
174 case SV_ROD_ACID_BOLT:
176 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
181 case SV_ROD_ELEC_BOLT:
183 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
188 case SV_ROD_FIRE_BOLT:
190 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
195 case SV_ROD_COLD_BOLT:
197 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
202 case SV_ROD_ACID_BALL:
204 fire_ball(GF_ACID, dir, 60 + lev, rad);
209 case SV_ROD_ELEC_BALL:
211 fire_ball(GF_ELEC, dir, 40 + lev, rad);
216 case SV_ROD_FIRE_BALL:
218 fire_ball(GF_FIRE, dir, 70 + lev, rad);
223 case SV_ROD_COLD_BALL:
225 fire_ball(GF_COLD, dir, 50 + lev, rad);
237 case SV_ROD_STONE_TO_MUD:
239 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
240 if (wall_to_mud(dir, dam)) ident = TRUE;
244 case SV_ROD_AGGRAVATE:
246 aggravate_monsters(0);
255 * @brief ロッドを使うコマンドのサブルーチン /
256 * Activate (zap) a Rod
257 * @param item 使うオブジェクトの所持品ID
261 * Unstack fully charged rods as needed.
262 * Hack -- rods of perception/genocide can be "cancelled"
263 * All rods can be cancelled at the "Direction?" prompt
264 * pvals are defined for each rod in k_info. -LM-
267 void do_cmd_zap_rod_aux(INVENTORY_IDX item)
269 int ident, chance, lev, fail;
274 /* Hack -- let perception get aborted */
275 bool use_charge = TRUE;
279 /* Get the item (in the pack) */
282 o_ptr = &inventory[item];
285 /* Get the item (on the floor) */
288 o_ptr = ¤t_floor_ptr->o_list[0 - item];
292 /* Mega-Hack -- refuse to zap a pile from the ground */
293 if ((item < 0) && (o_ptr->number > 1))
295 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
300 /* Get a direction (unless KNOWN not to need it) */
301 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)) ||
302 !object_is_aware(o_ptr))
304 /* Get a direction, allow cancel */
305 if (!get_aim_dir(&dir)) return;
309 take_turn(p_ptr, 100);
311 /* Extract the item level */
312 lev = k_info[o_ptr->k_idx].level;
314 /* Base chance of success */
315 chance = p_ptr->skill_dev;
317 /* Confusion hurts skill */
318 if (p_ptr->confused) chance = chance / 2;
321 if (chance > fail) fail -= (chance - fail) * 2;
322 else chance -= (fail - chance) * 2;
323 if (fail < USE_DEVICE) fail = USE_DEVICE;
324 if (chance < USE_DEVICE) chance = USE_DEVICE;
326 if (cmd_limit_time_walk(p_ptr)) return;
328 if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
329 else if (chance > fail)
331 if (randint0(chance * 2) < fail) success = FALSE;
336 if (randint0(fail * 2) < chance) success = TRUE;
337 else success = FALSE;
343 if (flush_failure) flush();
344 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
349 k_ptr = &k_info[o_ptr->k_idx];
351 /* A single rod is still charging */
352 if ((o_ptr->number == 1) && (o_ptr->timeout))
354 if (flush_failure) flush();
355 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
358 /* A stack of rods lacks enough energy. */
359 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
361 if (flush_failure) flush();
362 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
368 ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
370 /* Increase the timeout by the rod kind's pval. -LM- */
371 if (use_charge) o_ptr->timeout += k_ptr->pval;
372 p_ptr->update |= (PU_COMBINE | PU_REORDER);
374 if (!(object_is_aware(o_ptr)))
376 chg_virtue(V_PATIENCE, -1);
377 chg_virtue(V_CHANCE, 1);
378 chg_virtue(V_KNOWLEDGE, -1);
381 /* Tried the object */
384 /* Successfully determined the object function */
385 if (ident && !object_is_aware(o_ptr))
388 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
391 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
395 * @brief ロッドを使うコマンドのメインルーチン /
398 void do_cmd_zap_rod(void)
403 if (p_ptr->wild_mode)
408 if (cmd_limit_arena(p_ptr)) return;
410 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
412 set_action(ACTION_NONE);
415 /* Restrict choices to rods */
416 item_tester_tval = TV_ROD;
418 q = _("どのロッドを振りますか? ", "Zap which rod? ");
419 s = _("使えるロッドがない。", "You have no rod to zap.");
421 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
424 do_cmd_zap_rod_aux(item);