3 #include "player-status.h"
4 #include "player-effects.h"
5 #include "object-hook.h"
7 #include "spells-status.h"
8 #include "spells-floor.h"
13 * @param sval オブジェクトのsval
14 * @param dir 発動目標の方向ID
15 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
16 * @param powerful 強力発動上の処理ならばTRUE
17 * @param magic 魔道具術上の処理ならばTRUE
18 * @return 発動により効果内容が確定したならばTRUEを返す
20 int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
23 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
24 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
25 POSITION rad = powerful ? 3 : 2;
33 case SV_ROD_DETECT_TRAP:
35 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
39 case SV_ROD_DETECT_DOOR:
41 if (detect_doors(detect_rad)) ident = TRUE;
42 if (detect_stairs(detect_rad)) ident = TRUE;
49 if (!identify_fully(FALSE)) *use_charge = FALSE;
52 if (!ident_spell(FALSE)) *use_charge = FALSE;
60 if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
65 case SV_ROD_ILLUMINATION:
67 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
73 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
78 case SV_ROD_DETECTION:
80 detect_all(detect_rad);
94 if (true_healing(0)) ident = TRUE;
95 if (set_shero(0, TRUE)) ident = TRUE;
101 if(cure_critical_wounds(powerful ? 750 : 500)) ident = TRUE;
105 case SV_ROD_RESTORATION:
107 if(restore_level()) ident = TRUE;
108 if(restore_all_status()) ident = TRUE;
114 if (set_fast(randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
118 case SV_ROD_PESTICIDE:
120 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
124 case SV_ROD_TELEPORT_AWAY:
126 int distance = MAX_SIGHT * (powerful ? 8 : 5);
127 if (teleport_monster(dir, distance)) ident = TRUE;
131 case SV_ROD_DISARMING:
133 if (disarm_trap(dir)) ident = TRUE;
134 if (powerful && disarm_traps_touch()) ident = TRUE;
140 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
141 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
142 (void)lite_line(dir, dam);
147 case SV_ROD_SLEEP_MONSTER:
149 if (sleep_monster(dir, lev)) ident = TRUE;
153 case SV_ROD_SLOW_MONSTER:
155 if (slow_monster(dir, lev)) ident = TRUE;
159 case SV_ROD_HYPODYNAMIA:
161 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
165 case SV_ROD_POLYMORPH:
167 if (poly_monster(dir, lev)) ident = TRUE;
171 case SV_ROD_ACID_BOLT:
173 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
178 case SV_ROD_ELEC_BOLT:
180 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
185 case SV_ROD_FIRE_BOLT:
187 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
192 case SV_ROD_COLD_BOLT:
194 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
199 case SV_ROD_ACID_BALL:
201 fire_ball(GF_ACID, dir, 60 + lev, rad);
206 case SV_ROD_ELEC_BALL:
208 fire_ball(GF_ELEC, dir, 40 + lev, rad);
213 case SV_ROD_FIRE_BALL:
215 fire_ball(GF_FIRE, dir, 70 + lev, rad);
220 case SV_ROD_COLD_BALL:
222 fire_ball(GF_COLD, dir, 50 + lev, rad);
234 case SV_ROD_STONE_TO_MUD:
236 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
237 if (wall_to_mud(dir, dam)) ident = TRUE;
241 case SV_ROD_AGGRAVATE:
243 aggravate_monsters(0);
252 * @brief ロッドを使うコマンドのサブルーチン /
253 * Activate (zap) a Rod
254 * @param item 使うオブジェクトの所持品ID
258 * Unstack fully charged rods as needed.
259 * Hack -- rods of perception/genocide can be "cancelled"
260 * All rods can be cancelled at the "Direction?" prompt
261 * pvals are defined for each rod in k_info. -LM-
264 void do_cmd_zap_rod_aux(INVENTORY_IDX item)
266 int ident, chance, lev, fail;
271 /* Hack -- let perception get aborted */
272 bool use_charge = TRUE;
276 /* Get the item (in the pack) */
279 o_ptr = &inventory[item];
282 /* Get the item (on the floor) */
285 o_ptr = ¤t_floor_ptr->o_list[0 - item];
289 /* Mega-Hack -- refuse to zap a pile from the ground */
290 if ((item < 0) && (o_ptr->number > 1))
292 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
297 /* Get a direction (unless KNOWN not to need it) */
298 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)) ||
299 !object_is_aware(o_ptr))
301 /* Get a direction, allow cancel */
302 if (!get_aim_dir(&dir)) return;
306 take_turn(p_ptr, 100);
308 /* Extract the item level */
309 lev = k_info[o_ptr->k_idx].level;
311 /* Base chance of success */
312 chance = p_ptr->skill_dev;
314 /* Confusion hurts skill */
315 if (p_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(p_ptr)) return;
325 if (p_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(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 p_ptr->update |= (PU_COMBINE | PU_REORDER);
371 if (!(object_is_aware(o_ptr)))
373 chg_virtue(V_PATIENCE, -1);
374 chg_virtue(V_CHANCE, 1);
375 chg_virtue(V_KNOWLEDGE, -1);
378 /* Tried the object */
381 /* Successfully determined the object function */
382 if (ident && !object_is_aware(o_ptr))
385 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
388 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
392 * @brief ロッドを使うコマンドのメインルーチン /
395 void do_cmd_zap_rod(void)
400 if (p_ptr->wild_mode)
405 if (cmd_limit_arena(p_ptr)) return;
407 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
409 set_action(ACTION_NONE);
412 /* Restrict choices to rods */
413 item_tester_tval = TV_ROD;
415 q = _("どのロッドを振りますか? ", "Zap which rod? ");
416 s = _("使えるロッドがない。", "You have no rod to zap.");
418 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
421 do_cmd_zap_rod_aux(item);