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 creature_ptr プレーヤーへの参照ポインタ
22 * @param sval オブジェクトのsval
23 * @param dir 発動目標の方向ID
24 * @param use_charge チャージを消費したかどうかを返す参照ポインタ
25 * @param powerful 強力発動上の処理ならばTRUE
26 * @param magic 魔道具術上の処理ならばTRUE
27 * @return 発動により効果内容が確定したならばTRUEを返す
29 int rod_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
32 PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
33 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
34 POSITION rad = powerful ? 3 : 2;
42 case SV_ROD_DETECT_TRAP:
44 if (detect_traps(creature_ptr, detect_rad, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
48 case SV_ROD_DETECT_DOOR:
50 if (detect_doors(creature_ptr, detect_rad)) ident = TRUE;
51 if (detect_stairs(creature_ptr, detect_rad)) ident = TRUE;
58 if (!identify_fully(FALSE)) *use_charge = FALSE;
61 if (!ident_spell(creature_ptr, FALSE)) *use_charge = FALSE;
69 if (!recall_player(creature_ptr, randint0(21) + 15)) *use_charge = FALSE;
74 case SV_ROD_ILLUMINATION:
76 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
82 map_area(creature_ptr, powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
87 case SV_ROD_DETECTION:
89 detect_all(creature_ptr, detect_rad);
96 probing(creature_ptr);
103 if (true_healing(creature_ptr, 0)) ident = TRUE;
104 if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
110 if(cure_critical_wounds(creature_ptr, powerful ? 750 : 500)) ident = TRUE;
114 case SV_ROD_RESTORATION:
116 if(restore_level(creature_ptr)) ident = TRUE;
117 if(restore_all_status(creature_ptr)) ident = TRUE;
123 if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
127 case SV_ROD_PESTICIDE:
129 if (dispel_monsters(powerful ? 8 : 4)) ident = TRUE;
133 case SV_ROD_TELEPORT_AWAY:
135 int distance = MAX_SIGHT * (powerful ? 8 : 5);
136 if (teleport_monster(dir, distance)) ident = TRUE;
140 case SV_ROD_DISARMING:
142 if (disarm_trap(dir)) ident = TRUE;
143 if (powerful && disarm_traps_touch()) ident = TRUE;
149 HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
150 msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
151 (void)lite_line(dir, dam);
156 case SV_ROD_SLEEP_MONSTER:
158 if (sleep_monster(dir, lev)) ident = TRUE;
162 case SV_ROD_SLOW_MONSTER:
164 if (slow_monster(dir, lev)) ident = TRUE;
168 case SV_ROD_HYPODYNAMIA:
170 if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
174 case SV_ROD_POLYMORPH:
176 if (poly_monster(dir, lev)) ident = TRUE;
180 case SV_ROD_ACID_BOLT:
182 fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + lev / 7, 8));
187 case SV_ROD_ELEC_BOLT:
189 fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
194 case SV_ROD_FIRE_BOLT:
196 fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
201 case SV_ROD_COLD_BOLT:
203 fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + lev / 8, 8));
208 case SV_ROD_ACID_BALL:
210 fire_ball(creature_ptr, GF_ACID, dir, 60 + lev, rad);
215 case SV_ROD_ELEC_BALL:
217 fire_ball(creature_ptr, GF_ELEC, dir, 40 + lev, rad);
222 case SV_ROD_FIRE_BALL:
224 fire_ball(creature_ptr, GF_FIRE, dir, 70 + lev, rad);
229 case SV_ROD_COLD_BALL:
231 fire_ball(creature_ptr, GF_COLD, dir, 50 + lev, rad);
238 call_chaos(creature_ptr);
243 case SV_ROD_STONE_TO_MUD:
245 HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
246 if (wall_to_mud(dir, dam)) ident = TRUE;
250 case SV_ROD_AGGRAVATE:
252 aggravate_monsters(0);
261 * @brief ロッドを使うコマンドのサブルーチン /
262 * Activate (zap) a Rod
263 * @param item 使うオブジェクトの所持品ID
267 * Unstack fully charged rods as needed.
268 * Hack -- rods of perception/genocide can be "cancelled"
269 * All rods can be cancelled at the "Direction?" prompt
270 * pvals are defined for each rod in k_info. -LM-
273 void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
275 int ident, chance, lev, fail;
280 /* Hack -- let perception get aborted */
281 bool use_charge = TRUE;
285 o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
287 /* Mega-Hack -- refuse to zap a pile from the ground */
288 if ((item < 0) && (o_ptr->number > 1))
290 msg_print(_("まずはロッドを拾わなければ。", "You must first pick up the rods."));
295 /* Get a direction (unless KNOWN not to need it) */
296 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)) ||
297 !object_is_aware(o_ptr))
299 /* Get a direction, allow cancel */
300 if (!get_aim_dir(&dir)) return;
304 take_turn(creature_ptr, 100);
306 lev = k_info[o_ptr->k_idx].level;
308 /* Base chance of success */
309 chance = creature_ptr->skill_dev;
311 /* Confusion hurts skill */
312 if (creature_ptr->confused) chance = chance / 2;
315 if (chance > fail) fail -= (chance - fail) * 2;
316 else chance -= (fail - chance) * 2;
317 if (fail < USE_DEVICE) fail = USE_DEVICE;
318 if (chance < USE_DEVICE) chance = USE_DEVICE;
320 if (cmd_limit_time_walk(creature_ptr)) return;
322 if (creature_ptr->pclass == CLASS_BERSERKER) success = FALSE;
323 else if (chance > fail)
325 if (randint0(chance * 2) < fail) success = FALSE;
330 if (randint0(fail * 2) < chance) success = TRUE;
331 else success = FALSE;
337 if (flush_failure) flush();
338 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
343 k_ptr = &k_info[o_ptr->k_idx];
345 /* A single rod is still charging */
346 if ((o_ptr->number == 1) && (o_ptr->timeout))
348 if (flush_failure) flush();
349 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
352 /* A stack of rods lacks enough energy. */
353 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
355 if (flush_failure) flush();
356 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
362 ident = rod_effect(creature_ptr, o_ptr->sval, dir, &use_charge, FALSE, FALSE);
364 /* Increase the timeout by the rod kind's pval. -LM- */
365 if (use_charge) o_ptr->timeout += k_ptr->pval;
366 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
368 if (!(object_is_aware(o_ptr)))
370 chg_virtue(creature_ptr, V_PATIENCE, -1);
371 chg_virtue(creature_ptr, V_CHANCE, 1);
372 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
375 /* Tried the object */
378 /* Successfully determined the object function */
379 if (ident && !object_is_aware(o_ptr))
382 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
385 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
389 * @brief ロッドを使うコマンドのメインルーチン /
392 void do_cmd_zap_rod(player_type *creature_ptr)
397 if (creature_ptr->wild_mode)
402 if (cmd_limit_arena(creature_ptr)) return;
404 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
406 set_action(creature_ptr, ACTION_NONE);
409 q = _("どのロッドを振りますか? ", "Zap which rod? ");
410 s = _("使えるロッドがない。", "You have no rod to zap.");
412 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
415 exe_zap_rod(creature_ptr, item);