3 #include "spells-status.h"
4 #include "player-status.h"
8 * @param sval オブジェクトのsval
10 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
11 * @param powerful 強力発動上の処理ならばTRUE
12 * @param magic 魔道具術上の処理ならばTRUE
13 * @return 発動により効果内容が確定したならばTRUEを返す
15 int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
18 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
19 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
20 POSITION rad = powerful ? 3 : 2;
28 case SV_ROD_DETECT_TRAP:
30 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
34 case SV_ROD_DETECT_DOOR:
36 if (detect_doors(detect_rad)) ident = TRUE;
37 if (detect_stairs(detect_rad)) ident = TRUE;
44 if (!identify_fully(FALSE)) *use_charge = FALSE;
47 if (!ident_spell(FALSE)) *use_charge = FALSE;
55 if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
60 case SV_ROD_ILLUMINATION:
62 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
68 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
73 case SV_ROD_DETECTION:
75 detect_all(detect_rad);
89 if (true_healing(0)) ident = TRUE;
90 if (set_shero(0, TRUE)) ident = TRUE;
96 if(cure_critical_wounds(powerful ? 750 : 500)) ident = TRUE;
100 case SV_ROD_RESTORATION:
102 if(restore_level()) ident = TRUE;
103 if(restore_all_status()) ident = TRUE;
109 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
113 case SV_ROD_PESTICIDE:
115 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
119 case SV_ROD_TELEPORT_AWAY:
121 int distance = MAX_SIGHT * (powerful ? 8 : 5);
122 if (teleport_monster(dir, distance)) ident = TRUE;
126 case SV_ROD_DISARMING:
128 if (disarm_trap(dir)) ident = TRUE;
129 if (powerful && disarm_traps_touch()) ident = TRUE;
135 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
136 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
137 (void)lite_line(dir, dam);
142 case SV_ROD_SLEEP_MONSTER:
144 if (sleep_monster(dir, lev)) ident = TRUE;
148 case SV_ROD_SLOW_MONSTER:
150 if (slow_monster(dir, lev)) ident = TRUE;
154 case SV_ROD_HYPODYNAMIA:
156 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
160 case SV_ROD_POLYMORPH:
162 if (poly_monster(dir, lev)) ident = TRUE;
166 case SV_ROD_ACID_BOLT:
168 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
173 case SV_ROD_ELEC_BOLT:
175 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
180 case SV_ROD_FIRE_BOLT:
182 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
187 case SV_ROD_COLD_BOLT:
189 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
194 case SV_ROD_ACID_BALL:
196 fire_ball(GF_ACID, dir, 60 + lev, rad);
201 case SV_ROD_ELEC_BALL:
203 fire_ball(GF_ELEC, dir, 40 + lev, rad);
208 case SV_ROD_FIRE_BALL:
210 fire_ball(GF_FIRE, dir, 70 + lev, rad);
215 case SV_ROD_COLD_BALL:
217 fire_ball(GF_COLD, dir, 50 + lev, rad);
229 case SV_ROD_STONE_TO_MUD:
231 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
232 if (wall_to_mud(dir, dam)) ident = TRUE;
236 case SV_ROD_AGGRAVATE:
238 aggravate_monsters(0);
247 * @brief ロッドを使うコマンドのサブルーチン /
248 * Activate (zap) a Rod
249 * @param item 使うオブジェクトの所持品ID
253 * Unstack fully charged rods as needed.
254 * Hack -- rods of perception/genocide can be "cancelled"
255 * All rods can be cancelled at the "Direction?" prompt
256 * pvals are defined for each rod in k_info. -LM-
259 void do_cmd_zap_rod_aux(INVENTORY_IDX item)
261 int ident, chance, lev, fail;
266 /* Hack -- let perception get aborted */
267 bool use_charge = TRUE;
271 /* Get the item (in the pack) */
274 o_ptr = &inventory[item];
277 /* Get the item (on the floor) */
280 o_ptr = ¤t_floor_ptr->o_list[0 - item];
284 /* Mega-Hack -- refuse to zap a pile from the ground */
285 if ((item < 0) && (o_ptr->number > 1))
287 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
292 /* Get a direction (unless KNOWN not to need it) */
293 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)) ||
294 !object_is_aware(o_ptr))
296 /* Get a direction, allow cancel */
297 if (!get_aim_dir(&dir)) return;
301 take_turn(p_ptr, 100);
303 /* Extract the item level */
304 lev = k_info[o_ptr->k_idx].level;
306 /* Base chance of success */
307 chance = p_ptr->skill_dev;
309 /* Confusion hurts skill */
310 if (p_ptr->confused) chance = chance / 2;
313 if (chance > fail) fail -= (chance - fail) * 2;
314 else chance -= (fail - chance) * 2;
315 if (fail < USE_DEVICE) fail = USE_DEVICE;
316 if (chance < USE_DEVICE) chance = USE_DEVICE;
318 if (cmd_limit_time_walk(p_ptr)) return;
320 if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
321 else if (chance > fail)
323 if (randint0(chance * 2) < fail) success = FALSE;
328 if (randint0(fail * 2) < chance) success = TRUE;
329 else success = FALSE;
335 if (flush_failure) flush();
336 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
341 k_ptr = &k_info[o_ptr->k_idx];
343 /* A single rod is still charging */
344 if ((o_ptr->number == 1) && (o_ptr->timeout))
346 if (flush_failure) flush();
347 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
350 /* A stack of rods lacks enough energy. */
351 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
353 if (flush_failure) flush();
354 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
360 ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
362 /* Increase the timeout by the rod kind's pval. -LM- */
363 if (use_charge) o_ptr->timeout += k_ptr->pval;
364 p_ptr->update |= (PU_COMBINE | PU_REORDER);
366 if (!(object_is_aware(o_ptr)))
368 chg_virtue(V_PATIENCE, -1);
369 chg_virtue(V_CHANCE, 1);
370 chg_virtue(V_KNOWLEDGE, -1);
373 /* Tried the object */
376 /* Successfully determined the object function */
377 if (ident && !object_is_aware(o_ptr))
380 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
383 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
387 * @brief ロッドを使うコマンドのメインルーチン /
390 void do_cmd_zap_rod(void)
395 if (p_ptr->wild_mode)
400 if (cmd_limit_arena(p_ptr)) return;
402 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
404 set_action(ACTION_NONE);
407 /* Restrict choices to rods */
408 item_tester_tval = TV_ROD;
410 q = _("どのロッドを振りますか? ", "Zap which rod? ");
411 s = _("使えるロッドがない。", "You have no rod to zap.");
413 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
416 do_cmd_zap_rod_aux(item);