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(creature_ptr, 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(creature_ptr, 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(creature_ptr, powerful ? 8 : 4)) ident = TRUE;
133 case SV_ROD_TELEPORT_AWAY:
135 int distance = MAX_SIGHT * (powerful ? 8 : 5);
136 if (teleport_monster(creature_ptr, dir, distance)) ident = TRUE;
140 case SV_ROD_DISARMING:
142 if (disarm_trap(creature_ptr, dir)) ident = TRUE;
143 if (powerful && disarm_traps_touch(creature_ptr)) 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(creature_ptr, 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(creature_ptr, 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(creature_ptr, 10, GF_ACID, dir, damroll(6 + lev / 7, 8));
187 case SV_ROD_ELEC_BOLT:
189 fire_bolt_or_beam(creature_ptr, 10, GF_ELEC, dir, damroll(4 + lev / 9, 8));
194 case SV_ROD_FIRE_BOLT:
196 fire_bolt_or_beam(creature_ptr, 10, GF_FIRE, dir, damroll(7 + lev / 6, 8));
201 case SV_ROD_COLD_BOLT:
203 fire_bolt_or_beam(creature_ptr, 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(creature_ptr, dir, dam)) ident = TRUE;
250 case SV_ROD_AGGRAVATE:
252 aggravate_monsters(creature_ptr, 0);
262 * @brief ロッドを使うコマンドのサブルーチン /
263 * Activate (zap) a Rod
264 * @param creature_ptr プレーヤーへの参照ポインタ
265 * @param item 使うオブジェクトの所持品ID
269 * Unstack fully charged rods as needed.
270 * Hack -- rods of perception/genocide can be "cancelled"
271 * All rods can be cancelled at the "Direction?" prompt
272 * pvals are defined for each rod in k_info. -LM-
275 void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
277 int ident, chance, lev, fail;
282 /* Hack -- let perception get aborted */
283 bool use_charge = TRUE;
287 o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, 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(creature_ptr, 100);
308 lev = k_info[o_ptr->k_idx].level;
310 /* Base chance of success */
311 chance = creature_ptr->skill_dev;
313 /* Confusion hurts skill */
314 if (creature_ptr->confused) chance = chance / 2;
317 if (chance > fail) fail -= (chance - fail) * 2;
318 else chance -= (fail - chance) * 2;
319 if (fail < USE_DEVICE) fail = USE_DEVICE;
320 if (chance < USE_DEVICE) chance = USE_DEVICE;
322 if (cmd_limit_time_walk(creature_ptr)) return;
324 if (creature_ptr->pclass == CLASS_BERSERKER) success = FALSE;
325 else if (chance > fail)
327 if (randint0(chance * 2) < fail) success = FALSE;
332 if (randint0(fail * 2) < chance) success = TRUE;
333 else success = FALSE;
339 if (flush_failure) flush();
340 msg_print(_("うまくロッドを使えなかった。", "You failed to use the rod properly."));
345 k_ptr = &k_info[o_ptr->k_idx];
347 /* A single rod is still charging */
348 if ((o_ptr->number == 1) && (o_ptr->timeout))
350 if (flush_failure) flush();
351 msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
354 /* A stack of rods lacks enough energy. */
355 else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
357 if (flush_failure) flush();
358 msg_print(_("そのロッドはまだ充填中です。", "The rods are all still charging."));
364 ident = rod_effect(creature_ptr, o_ptr->sval, dir, &use_charge, FALSE, FALSE);
366 /* Increase the timeout by the rod kind's pval. -LM- */
367 if (use_charge) o_ptr->timeout += k_ptr->pval;
368 creature_ptr->update |= (PU_COMBINE | PU_REORDER);
370 if (!(object_is_aware(o_ptr)))
372 chg_virtue(creature_ptr, V_PATIENCE, -1);
373 chg_virtue(creature_ptr, V_CHANCE, 1);
374 chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
377 /* Tried the object */
380 /* Successfully determined the object function */
381 if (ident && !object_is_aware(o_ptr))
384 gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
387 creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
392 * @brief ロッドを使うコマンドのメインルーチン /
393 * @param creature_ptr プレーヤーへの参照ポインタ
396 void do_cmd_zap_rod(player_type *creature_ptr)
401 if (creature_ptr->wild_mode)
406 if (cmd_limit_arena(creature_ptr)) return;
408 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
410 set_action(creature_ptr, ACTION_NONE);
413 q = _("どのロッドを振りますか? ", "Zap which rod? ");
414 s = _("使えるロッドがない。", "You have no rod to zap.");
416 if (!choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
419 exe_zap_rod(creature_ptr, item);