5 #include "player-status.h"
6 #include "player-effects.h"
7 #include "objectkind.h"
8 #include "object-hook.h"
10 #include "spells-status.h"
11 #include "spells-floor.h"
12 #include "cmd-basic.h"
17 * @param sval オブジェクトのsval
18 * @param dir 発動目標の方向ID
19 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
20 * @param powerful 強力発動上の処理ならばTRUE
21 * @param magic 魔道具術上の処理ならばTRUE
22 * @return 発動により効果内容が確定したならばTRUEを返す
24 int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
27 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
28 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
29 POSITION rad = powerful ? 3 : 2;
37 case SV_ROD_DETECT_TRAP:
39 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
43 case SV_ROD_DETECT_DOOR:
45 if (detect_doors(detect_rad)) ident = TRUE;
46 if (detect_stairs(detect_rad)) ident = TRUE;
53 if (!identify_fully(FALSE)) *use_charge = FALSE;
56 if (!ident_spell(FALSE)) *use_charge = FALSE;
64 if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
69 case SV_ROD_ILLUMINATION:
71 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
77 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
82 case SV_ROD_DETECTION:
84 detect_all(detect_rad);
98 if (true_healing(0)) ident = TRUE;
99 if (set_shero(0, TRUE)) ident = TRUE;
105 if(cure_critical_wounds(powerful ? 750 : 500)) ident = TRUE;
109 case SV_ROD_RESTORATION:
111 if(restore_level()) ident = TRUE;
112 if(restore_all_status()) ident = TRUE;
118 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
122 case SV_ROD_PESTICIDE:
124 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
128 case SV_ROD_TELEPORT_AWAY:
130 int distance = MAX_SIGHT * (powerful ? 8 : 5);
131 if (teleport_monster(dir, distance)) ident = TRUE;
135 case SV_ROD_DISARMING:
137 if (disarm_trap(dir)) ident = TRUE;
138 if (powerful && disarm_traps_touch()) ident = TRUE;
144 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
145 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
146 (void)lite_line(dir, dam);
151 case SV_ROD_SLEEP_MONSTER:
153 if (sleep_monster(dir, lev)) ident = TRUE;
157 case SV_ROD_SLOW_MONSTER:
159 if (slow_monster(dir, lev)) ident = TRUE;
163 case SV_ROD_HYPODYNAMIA:
165 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
169 case SV_ROD_POLYMORPH:
171 if (poly_monster(dir, lev)) ident = TRUE;
175 case SV_ROD_ACID_BOLT:
177 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
182 case SV_ROD_ELEC_BOLT:
184 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
189 case SV_ROD_FIRE_BOLT:
191 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
196 case SV_ROD_COLD_BOLT:
198 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
203 case SV_ROD_ACID_BALL:
205 fire_ball(GF_ACID, dir, 60 + lev, rad);
210 case SV_ROD_ELEC_BALL:
212 fire_ball(GF_ELEC, dir, 40 + lev, rad);
217 case SV_ROD_FIRE_BALL:
219 fire_ball(GF_FIRE, dir, 70 + lev, rad);
224 case SV_ROD_COLD_BALL:
226 fire_ball(GF_COLD, dir, 50 + lev, rad);
238 case SV_ROD_STONE_TO_MUD:
240 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
241 if (wall_to_mud(dir, dam)) ident = TRUE;
245 case SV_ROD_AGGRAVATE:
247 aggravate_monsters(0);
256 * @brief ロッドを使うコマンドのサブルーチン /
257 * Activate (zap) a Rod
258 * @param item 使うオブジェクトの所持品ID
262 * Unstack fully charged rods as needed.
263 * Hack -- rods of perception/genocide can be "cancelled"
264 * All rods can be cancelled at the "Direction?" prompt
265 * pvals are defined for each rod in k_info. -LM-
268 void do_cmd_zap_rod_aux(INVENTORY_IDX item)
270 int ident, chance, lev, fail;
275 /* Hack -- let perception get aborted */
276 bool use_charge = TRUE;
280 /* Get the item (in the pack) */
283 o_ptr = &p_ptr->inventory_list[item];
286 /* Get the item (on the floor) */
289 o_ptr = ¤t_floor_ptr->o_list[0 - item];
293 /* Mega-Hack -- refuse to zap a pile from the ground */
294 if ((item < 0) && (o_ptr->number > 1))
296 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
301 /* Get a direction (unless KNOWN not to need it) */
302 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)) ||
303 !object_is_aware(o_ptr))
305 /* Get a direction, allow cancel */
306 if (!get_aim_dir(&dir)) return;
310 take_turn(p_ptr, 100);
312 /* Extract the item level */
313 lev = k_info[o_ptr->k_idx].level;
315 /* Base chance of success */
316 chance = p_ptr->skill_dev;
318 /* Confusion hurts skill */
319 if (p_ptr->confused) chance = chance / 2;
322 if (chance > fail) fail -= (chance - fail) * 2;
323 else chance -= (fail - chance) * 2;
324 if (fail < USE_DEVICE) fail = USE_DEVICE;
325 if (chance < USE_DEVICE) chance = USE_DEVICE;
327 if (cmd_limit_time_walk(p_ptr)) return;
329 if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
330 else if (chance > fail)
332 if (randint0(chance * 2) < fail) success = FALSE;
337 if (randint0(fail * 2) < chance) success = TRUE;
338 else success = FALSE;
344 if (flush_failure) flush();
345 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
350 k_ptr = &k_info[o_ptr->k_idx];
352 /* A single rod is still charging */
353 if ((o_ptr->number == 1) && (o_ptr->timeout))
355 if (flush_failure) flush();
356 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
359 /* A stack of rods lacks enough energy. */
360 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
362 if (flush_failure) flush();
363 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
369 ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
371 /* Increase the timeout by the rod kind's pval. -LM- */
372 if (use_charge) o_ptr->timeout += k_ptr->pval;
373 p_ptr->update |= (PU_COMBINE | PU_REORDER);
375 if (!(object_is_aware(o_ptr)))
377 chg_virtue(V_PATIENCE, -1);
378 chg_virtue(V_CHANCE, 1);
379 chg_virtue(V_KNOWLEDGE, -1);
382 /* Tried the object */
385 /* Successfully determined the object function */
386 if (ident && !object_is_aware(o_ptr))
389 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
392 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
396 * @brief ロッドを使うコマンドのメインルーチン /
399 void do_cmd_zap_rod(void)
404 if (p_ptr->wild_mode)
409 if (cmd_limit_arena(p_ptr)) return;
411 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
413 set_action(ACTION_NONE);
416 /* Restrict choices to rods */
417 item_tester_tval = TV_ROD;
419 q = _("どのロッドを振りますか? ", "Zap which rod? ");
420 s = _("使えるロッドがない。", "You have no rod to zap.");
422 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
425 do_cmd_zap_rod_aux(item);