5 #include "player-status.h"
6 #include "player-effects.h"
7 #include "player-class.h"
8 #include "player-inventory.h"
9 #include "objectkind.h"
10 #include "object-hook.h"
12 #include "spells-status.h"
13 #include "spells-floor.h"
14 #include "cmd-basic.h"
16 #include "targeting.h"
17 #include "view-mainwindow.h"
21 * @param sval オブジェクトのsval
22 * @param dir 発動目標の方向ID
23 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
24 * @param powerful 強力発動上の処理ならばTRUE
25 * @param magic 魔道具術上の処理ならばTRUE
26 * @return 発動により効果内容が確定したならばTRUEを返す
28 int rod_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
31 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
32 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
33 POSITION rad = powerful ? 3 : 2;
41 case SV_ROD_DETECT_TRAP:
43 if (detect_traps(detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
47 case SV_ROD_DETECT_DOOR:
49 if (detect_doors(detect_rad)) ident = TRUE;
50 if (detect_stairs(detect_rad)) ident = TRUE;
57 if (!identify_fully(FALSE)) *use_charge = FALSE;
60 if (!ident_spell(FALSE)) *use_charge = FALSE;
68 if (!recall_player(creature_ptr, randint0(21) + 15)) *use_charge = FALSE;
73 case SV_ROD_ILLUMINATION:
75 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
81 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
86 case SV_ROD_DETECTION:
88 detect_all(detect_rad);
102 if (true_healing(0)) ident = TRUE;
103 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
109 if(cure_critical_wounds(powerful ? 750 : 500)) ident = TRUE;
113 case SV_ROD_RESTORATION:
115 if(restore_level(creature_ptr)) ident = TRUE;
116 if(restore_all_status()) ident = TRUE;
122 if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
126 case SV_ROD_PESTICIDE:
128 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
132 case SV_ROD_TELEPORT_AWAY:
134 int distance = MAX_SIGHT * (powerful ? 8 : 5);
135 if (teleport_monster(dir, distance)) ident = TRUE;
139 case SV_ROD_DISARMING:
141 if (disarm_trap(dir)) ident = TRUE;
142 if (powerful && disarm_traps_touch()) ident = TRUE;
148 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
149 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
150 (void)lite_line(dir, dam);
155 case SV_ROD_SLEEP_MONSTER:
157 if (sleep_monster(dir, lev)) ident = TRUE;
161 case SV_ROD_SLOW_MONSTER:
163 if (slow_monster(dir, lev)) ident = TRUE;
167 case SV_ROD_HYPODYNAMIA:
169 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
173 case SV_ROD_POLYMORPH:
175 if (poly_monster(dir, lev)) ident = TRUE;
179 case SV_ROD_ACID_BOLT:
181 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
186 case SV_ROD_ELEC_BOLT:
188 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
193 case SV_ROD_FIRE_BOLT:
195 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
200 case SV_ROD_COLD_BOLT:
202 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
207 case SV_ROD_ACID_BALL:
209 fire_ball(GF_ACID, dir, 60 + lev, rad);
214 case SV_ROD_ELEC_BALL:
216 fire_ball(GF_ELEC, dir, 40 + lev, rad);
221 case SV_ROD_FIRE_BALL:
223 fire_ball(GF_FIRE, dir, 70 + lev, rad);
228 case SV_ROD_COLD_BALL:
230 fire_ball(GF_COLD, dir, 50 + lev, rad);
242 case SV_ROD_STONE_TO_MUD:
244 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
245 if (wall_to_mud(dir, dam)) ident = TRUE;
249 case SV_ROD_AGGRAVATE:
251 aggravate_monsters(0);
260 * @brief ロッドを使うコマンドのサブルーチン /
261 * Activate (zap) a Rod
262 * @param item 使うオブジェクトの所持品ID
266 * Unstack fully charged rods as needed.
267 * Hack -- rods of perception/genocide can be "cancelled"
268 * All rods can be cancelled at the "Direction?" prompt
269 * pvals are defined for each rod in k_info. -LM-
272 void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
274 int ident, chance, lev, fail;
279 /* Hack -- let perception get aborted */
280 bool use_charge = TRUE;
284 o_ptr = REF_ITEM(creature_ptr, current_floor_ptr, item);
286 /* Mega-Hack -- refuse to zap a pile from the ground */
287 if ((item < 0) && (o_ptr->number > 1))
289 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
294 /* Get a direction (unless KNOWN not to need it) */
295 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)) ||
296 !object_is_aware(o_ptr))
298 /* Get a direction, allow cancel */
299 if (!get_aim_dir(&dir)) return;
303 take_turn(creature_ptr, 100);
305 lev = k_info[o_ptr->k_idx].level;
307 /* Base chance of success */
308 chance = creature_ptr->skill_dev;
310 /* Confusion hurts skill */
311 if (creature_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(creature_ptr)) return;
321 if (creature_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(creature_ptr, 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 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
367 if (!(object_is_aware(o_ptr)))
369 chg_virtue(creature_ptr, V_PATIENCE, -1);
370 chg_virtue(creature_ptr, V_CHANCE, 1);
371 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
374 /* Tried the object */
377 /* Successfully determined the object function */
378 if (ident && !object_is_aware(o_ptr))
381 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
384 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
388 * @brief ロッドを使うコマンドのメインルーチン /
391 void do_cmd_zap_rod(player_type *creature_ptr)
396 if (creature_ptr->wild_mode)
401 if (cmd_limit_arena(creature_ptr)) return;
403 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
405 set_action(creature_ptr, ACTION_NONE);
408 q = _("どのロッドを振りますか? ", "Zap which rod? ");
409 s = _("使えるロッドがない。", "You have no rod to zap.");
411 if (!choose_object(p_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
414 exe_zap_rod(creature_ptr, item);