3 #include "spells-status.h"
4 #include "player-status.h"
5 #include "object-hook.h"
9 * @param sval オブジェクトのsval
10 * @param dir 発動目標の方向ID
11 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
12 * @param powerful 強力発動上の処理ならばTRUE
13 * @param magic 魔道具術上の処理ならばTRUE
14 * @return 発動により効果内容が確定したならばTRUEを返す
16 int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
19 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
20 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
21 POSITION rad = powerful ? 3 : 2;
29 case SV_ROD_DETECT_TRAP:
31 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
35 case SV_ROD_DETECT_DOOR:
37 if (detect_doors(detect_rad)) ident = TRUE;
38 if (detect_stairs(detect_rad)) ident = TRUE;
45 if (!identify_fully(FALSE)) *use_charge = FALSE;
48 if (!ident_spell(FALSE)) *use_charge = FALSE;
56 if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
61 case SV_ROD_ILLUMINATION:
63 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
69 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
74 case SV_ROD_DETECTION:
76 detect_all(detect_rad);
90 if (true_healing(0)) ident = TRUE;
91 if (set_shero(0, TRUE)) ident = TRUE;
97 if(cure_critical_wounds(powerful ? 750 : 500)) ident = TRUE;
101 case SV_ROD_RESTORATION:
103 if(restore_level()) ident = TRUE;
104 if(restore_all_status()) ident = TRUE;
110 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
114 case SV_ROD_PESTICIDE:
116 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
120 case SV_ROD_TELEPORT_AWAY:
122 int distance = MAX_SIGHT * (powerful ? 8 : 5);
123 if (teleport_monster(dir, distance)) ident = TRUE;
127 case SV_ROD_DISARMING:
129 if (disarm_trap(dir)) ident = TRUE;
130 if (powerful && disarm_traps_touch()) ident = TRUE;
136 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
137 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
138 (void)lite_line(dir, dam);
143 case SV_ROD_SLEEP_MONSTER:
145 if (sleep_monster(dir, lev)) ident = TRUE;
149 case SV_ROD_SLOW_MONSTER:
151 if (slow_monster(dir, lev)) ident = TRUE;
155 case SV_ROD_HYPODYNAMIA:
157 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
161 case SV_ROD_POLYMORPH:
163 if (poly_monster(dir, lev)) ident = TRUE;
167 case SV_ROD_ACID_BOLT:
169 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
174 case SV_ROD_ELEC_BOLT:
176 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
181 case SV_ROD_FIRE_BOLT:
183 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
188 case SV_ROD_COLD_BOLT:
190 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
195 case SV_ROD_ACID_BALL:
197 fire_ball(GF_ACID, dir, 60 + lev, rad);
202 case SV_ROD_ELEC_BALL:
204 fire_ball(GF_ELEC, dir, 40 + lev, rad);
209 case SV_ROD_FIRE_BALL:
211 fire_ball(GF_FIRE, dir, 70 + lev, rad);
216 case SV_ROD_COLD_BALL:
218 fire_ball(GF_COLD, dir, 50 + lev, rad);
230 case SV_ROD_STONE_TO_MUD:
232 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
233 if (wall_to_mud(dir, dam)) ident = TRUE;
237 case SV_ROD_AGGRAVATE:
239 aggravate_monsters(0);
248 * @brief ロッドを使うコマンドのサブルーチン /
249 * Activate (zap) a Rod
250 * @param item 使うオブジェクトの所持品ID
254 * Unstack fully charged rods as needed.
255 * Hack -- rods of perception/genocide can be "cancelled"
256 * All rods can be cancelled at the "Direction?" prompt
257 * pvals are defined for each rod in k_info. -LM-
260 void do_cmd_zap_rod_aux(INVENTORY_IDX item)
262 int ident, chance, lev, fail;
267 /* Hack -- let perception get aborted */
268 bool use_charge = TRUE;
272 /* Get the item (in the pack) */
275 o_ptr = &inventory[item];
278 /* Get the item (on the floor) */
281 o_ptr = ¤t_floor_ptr->o_list[0 - item];
285 /* Mega-Hack -- refuse to zap a pile from the ground */
286 if ((item < 0) && (o_ptr->number > 1))
288 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
293 /* Get a direction (unless KNOWN not to need it) */
294 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)) ||
295 !object_is_aware(o_ptr))
297 /* Get a direction, allow cancel */
298 if (!get_aim_dir(&dir)) return;
302 take_turn(p_ptr, 100);
304 /* Extract the item level */
305 lev = k_info[o_ptr->k_idx].level;
307 /* Base chance of success */
308 chance = p_ptr->skill_dev;
310 /* Confusion hurts skill */
311 if (p_ptr->confused) chance = chance / 2;
314 if (chance > fail) fail -= (chance - fail) * 2;
315 else chance -= (fail - chance) * 2;
316 if (fail < USE_DEVICE) fail = USE_DEVICE;
317 if (chance < USE_DEVICE) chance = USE_DEVICE;
319 if (cmd_limit_time_walk(p_ptr)) return;
321 if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
322 else if (chance > fail)
324 if (randint0(chance * 2) < fail) success = FALSE;
329 if (randint0(fail * 2) < chance) success = TRUE;
330 else success = FALSE;
336 if (flush_failure) flush();
337 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
342 k_ptr = &k_info[o_ptr->k_idx];
344 /* A single rod is still charging */
345 if ((o_ptr->number == 1) && (o_ptr->timeout))
347 if (flush_failure) flush();
348 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
351 /* A stack of rods lacks enough energy. */
352 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
354 if (flush_failure) flush();
355 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
361 ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
363 /* Increase the timeout by the rod kind's pval. -LM- */
364 if (use_charge) o_ptr->timeout += k_ptr->pval;
365 p_ptr->update |= (PU_COMBINE | PU_REORDER);
367 if (!(object_is_aware(o_ptr)))
369 chg_virtue(V_PATIENCE, -1);
370 chg_virtue(V_CHANCE, 1);
371 chg_virtue(V_KNOWLEDGE, -1);
374 /* Tried the object */
377 /* Successfully determined the object function */
378 if (ident && !object_is_aware(o_ptr))
381 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
384 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
388 * @brief ロッドを使うコマンドのメインルーチン /
391 void do_cmd_zap_rod(void)
396 if (p_ptr->wild_mode)
401 if (cmd_limit_arena(p_ptr)) return;
403 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
405 set_action(ACTION_NONE);
408 /* Restrict choices to rods */
409 item_tester_tval = TV_ROD;
411 q = _("どのロッドを振りますか? ", "Zap which rod? ");
412 s = _("使えるロッドがない。", "You have no rod to zap.");
414 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
417 do_cmd_zap_rod_aux(item);