4 #include "player-race.h"
5 #include "spells-summon.h"
7 #include "player-status.h"
8 #include "player-effects.h"
9 #include "player-class.h"
11 #include "spells-status.h"
12 #include "spells-floor.h"
13 #include "object-hook.h"
14 #include "cmd-basic.h"
16 #include "objectkind.h"
17 #include "view-mainwindow.h"
23 * @param sval オブジェクトのsval
24 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
25 * @param powerful 強力発動上の処理ならばTRUE
26 * @param magic 魔道具術上の処理ならばTRUE
27 * @param known 判明済ならばTRUE
28 * @return 発動により効果内容が確定したならばTRUEを返す
30 int staff_effect(OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
34 PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
35 POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
37 /* Analyze the staff */
40 case SV_STAFF_DARKNESS:
42 if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
44 if (set_blind(p_ptr, p_ptr->blind + 3 + randint1(5))) ident = TRUE;
46 if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
50 case SV_STAFF_SLOWNESS:
52 if (set_slow(p_ptr, p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
56 case SV_STAFF_HASTE_MONSTERS:
58 if (speed_monsters()) ident = TRUE;
62 case SV_STAFF_SUMMONING:
64 const int times = randint1(powerful ? 8 : 4);
65 for (k = 0; k < times; k++)
67 if (summon_specific(0, p_ptr->y, p_ptr->x, current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
75 case SV_STAFF_TELEPORTATION:
77 teleport_player((powerful ? 150 : 100), 0L);
82 case SV_STAFF_IDENTIFY:
85 if (!identify_fully(FALSE)) *use_charge = FALSE;
88 if (!ident_spell(FALSE)) *use_charge = FALSE;
94 case SV_STAFF_REMOVE_CURSE:
96 bool result = powerful ? remove_all_curse() : remove_curse();
104 case SV_STAFF_STARLITE:
105 ident = starlight(magic);
110 if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
114 case SV_STAFF_MAPPING:
116 map_area(powerful ? DETECT_RAD_MAP * 3 / 2 : DETECT_RAD_MAP);
121 case SV_STAFF_DETECT_GOLD:
123 if (detect_treasure(detect_rad)) ident = TRUE;
124 if (detect_objects_gold(detect_rad)) ident = TRUE;
128 case SV_STAFF_DETECT_ITEM:
130 if (detect_objects_normal(detect_rad)) ident = TRUE;
134 case SV_STAFF_DETECT_TRAP:
136 if (detect_traps(detect_rad, known)) ident = TRUE;
140 case SV_STAFF_DETECT_DOOR:
142 if (detect_doors(detect_rad)) ident = TRUE;
143 if (detect_stairs(detect_rad)) ident = TRUE;
147 case SV_STAFF_DETECT_INVIS:
149 if (detect_monsters_invis(detect_rad)) ident = TRUE;
153 case SV_STAFF_DETECT_EVIL:
155 if (detect_monsters_evil(detect_rad)) ident = TRUE;
159 case SV_STAFF_CURE_LIGHT:
161 ident = cure_light_wounds((powerful ? 4 : 2), 8);
165 case SV_STAFF_CURING:
167 ident = true_healing(0);
168 if (set_shero(p_ptr, 0, TRUE)) ident = TRUE;
172 case SV_STAFF_HEALING:
174 if (cure_critical_wounds(powerful ? 500 : 300)) ident = TRUE;
178 case SV_STAFF_THE_MAGI:
180 if (do_res_stat(p_ptr, A_INT)) ident = TRUE;
181 ident |= restore_mana(FALSE);
182 if (set_shero(p_ptr, 0, TRUE)) ident = TRUE;
186 case SV_STAFF_SLEEP_MONSTERS:
188 if (sleep_monsters(lev)) ident = TRUE;
192 case SV_STAFF_SLOW_MONSTERS:
194 if (slow_monsters(lev)) ident = TRUE;
200 if (set_fast(p_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
204 case SV_STAFF_PROBING:
210 case SV_STAFF_DISPEL_EVIL:
212 ident = dispel_evil(powerful ? 120 : 80);
218 ident = dispel_monsters(powerful ? 225 : 150) ;
222 case SV_STAFF_HOLINESS:
224 ident = cleansing_nova(p_ptr, magic, powerful);
228 case SV_STAFF_GENOCIDE:
230 ident = symbol_genocide((magic ? lev + 50 : 200), TRUE);
234 case SV_STAFF_EARTHQUAKES:
236 if (earthquake(p_ptr->y, p_ptr->x, (powerful ? 15 : 10), 0))
239 msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
244 case SV_STAFF_DESTRUCTION:
246 ident = destroy_area(p_ptr->y, p_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
250 case SV_STAFF_ANIMATE_DEAD:
252 ident = animate_dead(0, p_ptr->y, p_ptr->x);
256 case SV_STAFF_MSTORM:
258 ident = unleash_mana_storm(p_ptr, powerful);
262 case SV_STAFF_NOTHING:
264 msg_print(_("何も起らなかった。", "Nothing happen."));
265 if (PRACE_IS_(p_ptr, RACE_SKELETON) || PRACE_IS_(p_ptr, RACE_GOLEM) ||
266 PRACE_IS_(p_ptr, RACE_ZOMBIE) || PRACE_IS_(p_ptr, RACE_SPECTRE))
267 msg_print(_("もったいない事をしたような気がする。食べ物は大切にしなくては。", "What a waste. It's your food!"));
275 * @brief 杖を使うコマンドのサブルーチン /
277 * @param item 使うオブジェクトの所持品ID
280 * One charge of one staff disappears.
281 * Hack -- staffs of identify can be "cancelled".
283 void exe_use_staff(INVENTORY_IDX item)
285 int ident, chance, lev;
289 /* Hack -- let staffs of identify get aborted */
290 bool use_charge = TRUE;
293 /* Get the item (in the pack) */
296 o_ptr = &p_ptr->inventory_list[item];
299 /* Get the item (on the floor) */
302 o_ptr = ¤t_floor_ptr->o_list[0 - item];
306 /* Mega-Hack -- refuse to use a pile from the ground */
307 if ((item < 0) && (o_ptr->number > 1))
309 msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
314 take_turn(p_ptr, 100);
316 lev = k_info[o_ptr->k_idx].level;
317 if (lev > 50) lev = 50 + (lev - 50) / 2;
319 /* Base chance of success */
320 chance = p_ptr->skill_dev;
322 /* Confusion hurts skill */
323 if (p_ptr->confused) chance = chance / 2;
325 /* Hight level objects are harder */
326 chance = chance - lev;
328 /* Give everyone a (slight) chance */
329 if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
334 if (cmd_limit_time_walk(p_ptr)) return;
337 if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
339 if (flush_failure) flush();
340 msg_print(_("杖をうまく使えなかった。", "You failed to use the staff properly."));
345 /* Notice empty staffs */
346 if (o_ptr->pval <= 0)
348 if (flush_failure) flush();
349 msg_print(_("この杖にはもう魔力が残っていない。", "The staff has no charges left."));
350 o_ptr->ident |= (IDENT_EMPTY);
351 p_ptr->update |= (PU_COMBINE | PU_REORDER);
352 p_ptr->window |= (PW_INVEN);
360 ident = staff_effect(o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
362 if (!(object_is_aware(o_ptr)))
364 chg_virtue(V_PATIENCE, -1);
365 chg_virtue(V_CHANCE, 1);
366 chg_virtue(V_KNOWLEDGE, -1);
368 p_ptr->update |= (PU_COMBINE | PU_REORDER);
373 /* An identification was made */
374 if (ident && !object_is_aware(o_ptr))
377 gain_exp(p_ptr, (lev + (p_ptr->lev >> 1)) / p_ptr->lev);
380 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
383 /* Hack -- some uses are "free" */
384 if (!use_charge) return;
387 /* Use a single charge */
390 /* XXX Hack -- unstack if necessary */
391 if ((item >= 0) && (o_ptr->number > 1))
396 object_copy(q_ptr, o_ptr);
398 /* Modify quantity */
401 /* Restore the charges */
404 /* Unstack the used item */
406 p_ptr->total_weight -= q_ptr->weight;
407 item = inven_carry(q_ptr);
409 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
412 /* Describe charges in the pack */
415 inven_item_charges(item);
418 /* Describe charges on the floor */
421 floor_item_charges(0 - item);
426 * @brief 杖を使うコマンドのメインルーチン /
429 void do_cmd_use_staff(void)
434 if (p_ptr->wild_mode)
439 if (cmd_limit_arena(p_ptr)) return;
441 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
443 set_action(ACTION_NONE);
446 q = _("どの杖を使いますか? ", "Use which staff? ");
447 s = _("使える杖がない。", "You have no staff to use.");
448 if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), TV_STAFF)) return;